material.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // Filename: material.h
  2. // Created by: mike (09Jan97)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. #ifndef MATERIAL_H
  7. #define MATERIAL_H
  8. //
  9. ////////////////////////////////////////////////////////////////////
  10. // Includes
  11. ////////////////////////////////////////////////////////////////////
  12. #include <pandabase.h>
  13. #include <graphicsStateGuardianBase.h>
  14. #include <typedReferenceCount.h>
  15. #include <luse.h>
  16. ////////////////////////////////////////////////////////////////////
  17. // Defines
  18. ////////////////////////////////////////////////////////////////////
  19. ////////////////////////////////////////////////////////////////////
  20. // Class : Material
  21. // Description :
  22. ////////////////////////////////////////////////////////////////////
  23. class EXPCL_PANDA Material : public TypedReferenceCount
  24. {
  25. public:
  26. Material( void );
  27. ~Material( void );
  28. void apply( GraphicsStateGuardianBase *gsg ) {
  29. gsg->apply_material( this );
  30. }
  31. INLINE Colorf get_ambient( void ) const;
  32. INLINE void set_ambient( const Colorf& color );
  33. INLINE Colorf get_diffuse( void ) const;
  34. INLINE void set_diffuse( const Colorf& color );
  35. INLINE Colorf get_specular( void ) const;
  36. INLINE void set_specular( const Colorf& color );
  37. INLINE float get_shininess( void ) const;
  38. INLINE void set_shininess( float shininess );
  39. INLINE Colorf get_emission( void ) const;
  40. INLINE void set_emission( const Colorf& color );
  41. INLINE bool get_local( void ) const;
  42. INLINE void set_local( bool local );
  43. INLINE bool get_twoside( void ) const;
  44. INLINE void set_twoside( bool twoside );
  45. void output( ostream &out ) const;
  46. void write( ostream &out, int indent = 0 ) const;
  47. protected:
  48. Colorf _ambient;
  49. Colorf _diffuse;
  50. Colorf _specular;
  51. float _shininess;
  52. Colorf _emission;
  53. bool _local;
  54. bool _twoside;
  55. public:
  56. static TypeHandle get_class_type() {
  57. return _type_handle;
  58. }
  59. static void init_type() {
  60. TypedReferenceCount::init_type();
  61. register_type(_type_handle, "Material",
  62. TypedReferenceCount::get_class_type());
  63. }
  64. virtual TypeHandle get_type() const {
  65. return get_class_type();
  66. }
  67. virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
  68. private:
  69. static TypeHandle _type_handle;
  70. };
  71. INLINE ostream &operator << (ostream &out, const Material &m) {
  72. m.output(out);
  73. return out;
  74. }
  75. #include "material.I"
  76. #endif