Panda3D

mayaShader.h

00001 // Filename: mayaShader.h
00002 // Created by:  drose (01Feb00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef MAYASHADER_H
00016 #define MAYASHADER_H
00017 
00018 #include "pandatoolbase.h"
00019 #include "mayaShaderColorDef.h"
00020 
00021 #include "luse.h"
00022 #include "lmatrix.h"
00023 #include "namable.h"
00024 
00025 class MObject;
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //       Class : MayaShader
00029 // Description : Corresponds to a single "shader" in Maya.  This
00030 //               extracts out all the parameters of a Maya shader that
00031 //               we might care about.  There are many more parameters
00032 //               that we don't care about or don't know enough to
00033 //               extract.
00034 ////////////////////////////////////////////////////////////////////
00035 class MayaShader : public Namable {
00036 public:
00037   MayaShader(MObject engine, bool legacy_shader);
00038   ~MayaShader();
00039 
00040   void output(ostream &out) const;
00041   void write(ostream &out) const;
00042   
00043 private:
00044   bool find_textures_modern(MObject shader);
00045   bool find_textures_legacy(MObject shader);
00046 
00047 public:
00048   void collect_maps();
00049   bool _legacy_mode;
00050   
00051   MayaShaderColorList _all_maps;
00052 
00053 public: // relevant only to modern mode.
00054 
00055   LColord _flat_color;
00056   
00057   MayaShaderColorList _color_maps;
00058   MayaShaderColorList _trans_maps;
00059   MayaShaderColorList _normal_maps;
00060   MayaShaderColorList _glow_maps;
00061   MayaShaderColorList _gloss_maps;
00062   MayaShaderColorList _height_maps;
00063   
00064   void bind_uvsets(MayaFileToUVSetMap &map);
00065   
00066 private:
00067   void calculate_pairings();
00068   bool try_pair(MayaShaderColorDef *map1,
00069                 MayaShaderColorDef *map2,
00070                 bool perfect);
00071   string get_file_prefix(const string &fn);
00072   bool _legacy_shader;
00073 public: // relevant only to legacy mode.
00074   MayaShaderColorList _color;
00075   MayaShaderColorDef  _transparency;
00076   LColor get_rgba(size_t idx=0) const;
00077   MayaShaderColorDef *get_color_def(size_t idx=0) const;
00078 };
00079 
00080 INLINE ostream &operator << (ostream &out, const MayaShader &shader) {
00081   shader.output(out);
00082   return out;
00083 }
00084 
00085 #endif
00086 
 All Classes Functions Variables Enumerations