00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef MAYASHADERCOLORDEF_H
00020 #define MAYASHADERCOLORDEF_H
00021
00022 #include "pandatoolbase.h"
00023
00024 #include "luse.h"
00025 #include "lmatrix.h"
00026
00027 class MObject;
00028
00029
00030
00031
00032
00033
00034
00035 class MayaShaderColorDef {
00036 public:
00037 MayaShaderColorDef();
00038 ~MayaShaderColorDef();
00039
00040 LMatrix3d compute_texture_matrix() const;
00041 bool has_projection() const;
00042 TexCoordd project_uv(const LPoint3d &pos, const LPoint3d &ref_point) const;
00043 bool reset_maya_texture(const Filename &texture);
00044
00045 void write(ostream &out) const;
00046
00047 enum ProjectionType {
00048 PT_off,
00049 PT_planar,
00050 PT_spherical,
00051 PT_cylindrical,
00052 PT_ball,
00053 PT_cubic,
00054 PT_triplanar,
00055 PT_concentric,
00056 PT_perspective,
00057 };
00058
00059 bool _has_texture;
00060 Filename _texture;
00061 RGBColorf _color_gain;
00062
00063 bool _has_flat_color;
00064 Colord _flat_color;
00065
00066 ProjectionType _projection_type;
00067 LMatrix4d _projection_matrix;
00068 double _u_angle;
00069 double _v_angle;
00070
00071 LVector2f _coverage;
00072 LVector2f _translate_frame;
00073 double _rotate_frame;
00074
00075 bool _mirror;
00076 bool _stagger;
00077 bool _wrap_u;
00078 bool _wrap_v;
00079
00080 LVector2f _repeat_uv;
00081 LVector2f _offset;
00082 double _rotate_uv;
00083
00084 private:
00085 void read_surface_color(MObject color);
00086 void set_projection_type(const string &type);
00087
00088 LPoint2d map_planar(const LPoint3d &pos, const LPoint3d ¢roid) const;
00089 LPoint2d map_spherical(const LPoint3d &pos, const LPoint3d ¢roid) const;
00090 LPoint2d map_cylindrical(const LPoint3d &pos, const LPoint3d ¢roid) const;
00091
00092
00093 LPoint2d (MayaShaderColorDef::*_map_uvs)(const LPoint3d &pos, const LPoint3d ¢roid) const;
00094
00095 MObject *_color_object;
00096
00097 friend class MayaShader;
00098 };
00099
00100 #endif
00101