mayaShaderColorDef.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // Filename: mayaShaderColorDef.h
  2. // Created by: drose (12Apr03)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://etc.cmu.edu/panda3d/docs/license/ .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #ifndef MAYASHADERCOLORDEF_H
  19. #define MAYASHADERCOLORDEF_H
  20. #include "pandatoolbase.h"
  21. #include "luse.h"
  22. #include "lmatrix.h"
  23. class MObject;
  24. class MayaShader;
  25. ////////////////////////////////////////////////////////////////////
  26. // Class : MayaShaderColorDef
  27. // Description : This defines the various attributes that Maya may
  28. // associate with the "color" channel for a particular
  29. // shader (as well as on the "transparency" channel).
  30. ////////////////////////////////////////////////////////////////////
  31. class MayaShaderColorDef {
  32. public:
  33. MayaShaderColorDef();
  34. MayaShaderColorDef(MayaShaderColorDef&);
  35. ~MayaShaderColorDef();
  36. LMatrix3d compute_texture_matrix() const;
  37. bool has_projection() const;
  38. TexCoordd project_uv(const LPoint3d &pos, const LPoint3d &ref_point) const;
  39. bool reset_maya_texture(const Filename &texture);
  40. void write(ostream &out) const;
  41. enum ProjectionType {
  42. PT_off,
  43. PT_planar,
  44. PT_spherical,
  45. PT_cylindrical,
  46. PT_ball,
  47. PT_cubic,
  48. PT_triplanar,
  49. PT_concentric,
  50. PT_perspective,
  51. };
  52. bool _has_texture;
  53. Filename _texture_filename;
  54. string _texture_name;
  55. string _uvset_name;
  56. Colorf _color_gain;
  57. bool _has_flat_color;
  58. Colord _flat_color;
  59. ProjectionType _projection_type;
  60. LMatrix4d _projection_matrix;
  61. double _u_angle;
  62. double _v_angle;
  63. LVector2f _coverage;
  64. LVector2f _translate_frame;
  65. double _rotate_frame;
  66. bool _mirror;
  67. bool _stagger;
  68. bool _wrap_u;
  69. bool _wrap_v;
  70. bool _alpha_is_luminance;
  71. LVector2f _repeat_uv;
  72. LVector2f _offset;
  73. double _rotate_uv;
  74. private:
  75. void read_surface_color(MayaShader *shader, MObject color, bool trans=false);
  76. void set_projection_type(const string &type);
  77. LPoint2d map_planar(const LPoint3d &pos, const LPoint3d &centroid) const;
  78. LPoint2d map_spherical(const LPoint3d &pos, const LPoint3d &centroid) const;
  79. LPoint2d map_cylindrical(const LPoint3d &pos, const LPoint3d &centroid) const;
  80. // Define a pointer to one of the above member functions.
  81. LPoint2d (MayaShaderColorDef::*_map_uvs)(const LPoint3d &pos, const LPoint3d &centroid) const;
  82. MObject *_color_object;
  83. friend class MayaShader;
  84. };
  85. #endif