Panda3D
mayaShader.h
1 // Filename: mayaShader.h
2 // Created by: drose (01Feb00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef MAYASHADER_H
16 #define MAYASHADER_H
17 
18 #include "pandatoolbase.h"
19 #include "mayaShaderColorDef.h"
20 
21 #include "luse.h"
22 #include "lmatrix.h"
23 #include "namable.h"
24 
25 class MObject;
26 
27 ////////////////////////////////////////////////////////////////////
28 // Class : MayaShader
29 // Description : Corresponds to a single "shader" in Maya. This
30 // extracts out all the parameters of a Maya shader that
31 // we might care about. There are many more parameters
32 // that we don't care about or don't know enough to
33 // extract.
34 ////////////////////////////////////////////////////////////////////
35 class MayaShader : public Namable {
36 public:
37  MayaShader(MObject engine, bool legacy_shader);
38  ~MayaShader();
39 
40  void output(ostream &out) const;
41  void write(ostream &out) const;
42 
43 private:
44  bool find_textures_modern(MObject shader);
45  bool find_textures_legacy(MObject shader);
46 
47 public:
48  void collect_maps();
49  bool _legacy_mode;
50 
51  MayaShaderColorList _all_maps;
52 
53 public: // relevant only to modern mode.
54 
55  LColord _flat_color;
56 
57  MayaShaderColorList _color_maps;
58  MayaShaderColorList _trans_maps;
59  MayaShaderColorList _normal_maps;
60  MayaShaderColorList _glow_maps;
61  MayaShaderColorList _gloss_maps;
62  MayaShaderColorList _height_maps;
63 
65 
66 private:
67  void calculate_pairings();
68  bool try_pair(MayaShaderColorDef *map1,
69  MayaShaderColorDef *map2,
70  bool perfect);
71  string get_file_prefix(const string &fn);
72  bool _legacy_shader;
73 public: // relevant only to legacy mode.
74  MayaShaderColorList _color;
75  MayaShaderColorDef _transparency;
76  LColor get_rgba(size_t idx=0) const;
77  MayaShaderColorDef *get_color_def(size_t idx=0) const;
78 };
79 
80 INLINE ostream &operator << (ostream &out, const MayaShader &shader) {
81  shader.output(out);
82  return out;
83 }
84 
85 #endif
86 
void collect_maps()
Recalculates the all_maps list.
Definition: mayaShader.cxx:172
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:1677
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:39
MayaShaderColorDef * get_color_def(size_t idx=0) const
This is part of the deprecated codepath.
Definition: mayaShader.cxx:123
A base class for all things which can have a name.
Definition: namable.h:29
This defines the various attributes that Maya may associate with the "color" channel for a particular...
LColor get_rgba(size_t idx=0) const
Returns the overall color of the shader as a single-precision rgba value, where the alpha component r...
Definition: mayaShader.cxx:143
Corresponds to a single "shader" in Maya.
Definition: mayaShader.h:35
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
MayaShader(MObject engine, bool legacy_shader)
Reads the Maya "shading engine" to determine the relevant shader properties.
Definition: mayaShader.cxx:43
void bind_uvsets(MayaFileToUVSetMap &map)
Assigns the uvset_name of each MayaShaderColorDef using the given file-to-uvset map.
Definition: mayaShader.cxx:274