Panda3D
mayaShaderColorDef.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file mayaShaderColorDef.h
10  * @author drose
11  * @date 2003-04-12
12  */
13 
14 #ifndef MAYASHADERCOLORDEF_H
15 #define MAYASHADERCOLORDEF_H
16 
17 #include "pandatoolbase.h"
18 
19 #include "luse.h"
20 #include "lmatrix.h"
21 #include "pmap.h"
22 #include "pvector.h"
23 
24 class MayaShader;
25 class MayaShaderColorDef;
28 
29 /**
30  * This defines the various attributes that Maya may associate with the
31  * "color" channel for a particular shader (as well as on the "transparency"
32  * channel).
33  */
35 public:
39 
40  std::string strip_prefix(std::string full_name);
41 
42  LMatrix3d compute_texture_matrix() const;
43  bool has_projection() const;
44  LTexCoordd project_uv(const LPoint3d &pos, const LPoint3d &ref_point) const;
45  bool reset_maya_texture(const Filename &texture);
46 
47  void write(std::ostream &out) const;
48 
49  enum BlendType {
50  BT_unspecified,
51  BT_modulate,
52  BT_decal,
53  BT_blend,
54  BT_replace,
55  BT_add,
56  BT_blend_color_scale,
57  BT_modulate_glow,
58  BT_modulate_gloss,
59  BT_normal,
60  BT_normal_height,
61  BT_gloss,
62  BT_glow,
63  BT_height,
64  BT_selector,
65  };
66 
67  enum ProjectionType {
68  PT_off,
69  PT_planar,
70  PT_spherical,
71  PT_cylindrical,
72  PT_ball,
73  PT_cubic,
74  PT_triplanar,
75  PT_concentric,
76  PT_perspective,
77  };
78 
79  BlendType _blend_type;
80  ProjectionType _projection_type;
81  LMatrix4d _projection_matrix;
82  double _u_angle;
83  double _v_angle;
84 
85  Filename _texture_filename;
86  std::string _texture_name;
87  LColor _color_gain;
88 
89  LVector2 _coverage;
90  LVector2 _translate_frame;
91  double _rotate_frame;
92 
93  bool _mirror;
94  bool _stagger;
95  bool _wrap_u;
96  bool _wrap_v;
97 
98  LVector2 _repeat_uv;
99  LVector2 _offset;
100  double _rotate_uv;
101 
102  bool _is_alpha;
103 
104  std::string _uvset_name;
105  MayaShaderColorDef *_opposite;
106 
107  std::string get_panda_uvset_name();
108 
109 private:
110  MObject *_color_object;
111 
112 private:
113  static void find_textures_modern(const std::string &shadername, MayaShaderColorList &list, MPlug inplug, bool is_alpha);
114  void find_textures_legacy(MayaShader *shader, MObject color, bool trans=false);
115 
116  void set_projection_type(const std::string &type);
117 
118  LPoint2d map_planar(const LPoint3d &pos, const LPoint3d &centroid) const;
119  LPoint2d map_spherical(const LPoint3d &pos, const LPoint3d &centroid) const;
120  LPoint2d map_cylindrical(const LPoint3d &pos, const LPoint3d &centroid) const;
121 
122  // Define a pointer to one of the above member functions.
123  LPoint2d (MayaShaderColorDef::*_map_uvs)(const LPoint3d &pos, const LPoint3d &centroid) const;
124 
125  friend class MayaShader;
126 
127 
128 /*
129  * Legacy Fields - these fields are only used by the legacy codepath. These
130  * fields are deprecated for the following reasons: * has_texture is redundant
131  * --- if there's no texture, just don't allocate a MayaShaderColorDef. *
132  * has_flat_color and flat_color don't belong here, they belong in the shader.
133  * * has_alpha_channel is not needed - there are better ways to determine if a
134  * texture stage involves an alpha channel. * keep_color, keep_alpha, and
135  * interpolate are all adjuncts to blend_mode - it would make more sense just
136  * to add some more blend_modes.
137  */
138 
139 public:
140  bool _has_texture; // deprecated, see above.
141  bool _has_flat_color; // deprecated, see above.
142  LColord _flat_color; // deprecated, see above.
143  bool _has_alpha_channel; // deprecated, see above.
144  bool _keep_color; // deprecated, see above.
145  bool _keep_alpha; // deprecated, see above.
146  bool _interpolate; // deprecated, see above.
147 
148 };
149 
150 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
LTexCoordd project_uv(const LPoint3d &pos, const LPoint3d &ref_point) const
If the shader has a projection (has_projection() returns true), this computes the appropriate UV corr...
std::string get_panda_uvset_name()
Maya's default uvset name is "map1".
bool has_projection() const
Returns true if the shader has a projection in effect.
LMatrix3d compute_texture_matrix() const
Returns a texture matrix corresponding to the texture transforms indicated by the shader.
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
This defines the various attributes that Maya may associate with the "color" channel for a particular...
Corresponds to a single "shader" in Maya.
Definition: mayaShader.h:30
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool reset_maya_texture(const Filename &texture)
Changes the texture filename stored in the Maya file for this particular shader.