00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef MAYASHADERCOLORDEF_H
00016 #define MAYASHADERCOLORDEF_H
00017
00018 #include "pandatoolbase.h"
00019
00020 #include "luse.h"
00021 #include "lmatrix.h"
00022 #include "pmap.h"
00023 #include "pvector.h"
00024
00025 class MObject;
00026 class MPlug;
00027 class MayaShader;
00028 class MayaShaderColorDef;
00029 typedef pvector<MayaShaderColorDef *> MayaShaderColorList;
00030 typedef pmap<string, string> MayaFileToUVSetMap;
00031
00032
00033
00034
00035
00036
00037
00038 class MayaShaderColorDef {
00039 public:
00040 MayaShaderColorDef();
00041 MayaShaderColorDef (MayaShaderColorDef&);
00042 ~MayaShaderColorDef();
00043
00044 string strip_prefix(string full_name);
00045
00046 LMatrix3d compute_texture_matrix() const;
00047 bool has_projection() const;
00048 LTexCoordd project_uv(const LPoint3d &pos, const LPoint3d &ref_point) const;
00049 bool reset_maya_texture(const Filename &texture);
00050
00051 void write(ostream &out) const;
00052
00053 enum BlendType {
00054 BT_unspecified,
00055 BT_modulate,
00056 BT_decal,
00057 BT_blend,
00058 BT_replace,
00059 BT_add,
00060 BT_blend_color_scale,
00061 BT_modulate_glow,
00062 BT_modulate_gloss,
00063 BT_normal,
00064 BT_normal_height,
00065 BT_gloss,
00066 BT_glow,
00067 BT_height,
00068 BT_selector,
00069 };
00070
00071 enum ProjectionType {
00072 PT_off,
00073 PT_planar,
00074 PT_spherical,
00075 PT_cylindrical,
00076 PT_ball,
00077 PT_cubic,
00078 PT_triplanar,
00079 PT_concentric,
00080 PT_perspective,
00081 };
00082
00083 BlendType _blend_type;
00084 ProjectionType _projection_type;
00085 LMatrix4d _projection_matrix;
00086 double _u_angle;
00087 double _v_angle;
00088
00089 Filename _texture_filename;
00090 string _texture_name;
00091 LColor _color_gain;
00092
00093 LVector2 _coverage;
00094 LVector2 _translate_frame;
00095 double _rotate_frame;
00096
00097 bool _mirror;
00098 bool _stagger;
00099 bool _wrap_u;
00100 bool _wrap_v;
00101
00102 LVector2 _repeat_uv;
00103 LVector2 _offset;
00104 double _rotate_uv;
00105
00106 bool _is_alpha;
00107
00108 string _uvset_name;
00109 MayaShaderColorDef *_opposite;
00110
00111 string get_panda_uvset_name();
00112
00113 private:
00114 MObject *_color_object;
00115
00116 private:
00117 static void find_textures_modern(const string &shadername, MayaShaderColorList &list, MPlug inplug, bool is_alpha);
00118 void find_textures_legacy(MayaShader *shader, MObject color, bool trans=false);
00119
00120 void set_projection_type(const string &type);
00121
00122 LPoint2d map_planar(const LPoint3d &pos, const LPoint3d ¢roid) const;
00123 LPoint2d map_spherical(const LPoint3d &pos, const LPoint3d ¢roid) const;
00124 LPoint2d map_cylindrical(const LPoint3d &pos, const LPoint3d ¢roid) const;
00125
00126
00127 LPoint2d (MayaShaderColorDef::*_map_uvs)(const LPoint3d &pos, const LPoint3d ¢roid) const;
00128
00129 friend class MayaShader;
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150 public:
00151 bool _has_texture;
00152 bool _has_flat_color;
00153 LColord _flat_color;
00154 bool _has_alpha_channel;
00155 bool _keep_color;
00156 bool _keep_alpha;
00157 bool _interpolate;
00158
00159 };
00160
00161 #endif
00162