matpass.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : ww3d *
  23. * *
  24. * $Archive:: /Commando/Code/ww3d2/matpass.h $*
  25. * *
  26. * Original Author:: Greg Hjelstrom *
  27. * *
  28. * $Author:: Greg_h $*
  29. * *
  30. * $Modtime:: 5/13/01 11:25a $*
  31. * *
  32. * $Revision:: 5 $*
  33. * *
  34. *---------------------------------------------------------------------------------------------*
  35. * Functions: *
  36. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  37. #if defined(_MSC_VER)
  38. #pragma once
  39. #endif
  40. #ifndef MATPASS_H
  41. #define MATPASS_H
  42. #ifndef REFCOUNT_H
  43. #include "refcount.h"
  44. #endif
  45. #ifndef SHADER_H
  46. #include "shader.h"
  47. #endif
  48. #ifndef WWDEBUG_H
  49. #include "wwdebug.h"
  50. #endif
  51. class TextureClass;
  52. class VertexMaterialClass;
  53. class MeshModelClass;
  54. class OBBoxClass;
  55. /**
  56. ** MaterialPassClass
  57. **
  58. ** This class wraps all of the data needed to describe an additional
  59. ** material pass for any object. The motivation for this class is to
  60. ** implement certain types of special effects. All data needed to
  61. ** apply the pass should be generated procedurally. Typically a
  62. ** vertex processor will be used to generate any needed u-v's or vertex
  63. ** colors. Alternatively, we could add the option to request to
  64. ** re-use the model's existing u-v's or vertex colors.
  65. **
  66. **
  67. */
  68. class MaterialPassClass : public RefCountClass
  69. {
  70. public:
  71. MaterialPassClass(void);
  72. ~MaterialPassClass(void);
  73. void Install_Materials(void) const;
  74. void Set_Texture(TextureClass * Texture,int stage = 0);
  75. void Set_Shader(ShaderClass shader);
  76. void Set_Material(VertexMaterialClass * mat);
  77. TextureClass * Get_Texture(int stage = 0) const;
  78. VertexMaterialClass * Get_Material(void) const;
  79. TextureClass * Peek_Texture(int stage = 0) const;
  80. ShaderClass Peek_Shader(void) const { return Shader; }
  81. VertexMaterialClass * Peek_Material(void) const { return Material; }
  82. void Set_Cull_Volume(OBBoxClass * volume) { CullVolume = volume; }
  83. OBBoxClass * Get_Cull_Volume(void) const { return CullVolume; }
  84. void Enable_On_Translucent_Meshes(bool onoff) { EnableOnTranslucentMeshes = onoff; }
  85. bool Is_Enabled_On_Translucent_Meshes(void) { return EnableOnTranslucentMeshes; }
  86. static void Enable_Per_Polygon_Culling(bool onoff) { EnablePerPolygonCulling = onoff; }
  87. static bool Is_Per_Polygon_Culling_Enabled(void) { return EnablePerPolygonCulling; }
  88. protected:
  89. enum { MAX_TEX_STAGES = 2 };
  90. TextureClass * Texture[MAX_TEX_STAGES];
  91. ShaderClass Shader;
  92. VertexMaterialClass * Material;
  93. bool EnableOnTranslucentMeshes;
  94. OBBoxClass * CullVolume;
  95. static bool EnablePerPolygonCulling;
  96. };
  97. inline TextureClass * MaterialPassClass::Peek_Texture(int stage) const
  98. {
  99. WWASSERT(stage >= 0);
  100. WWASSERT(stage < MAX_TEX_STAGES);
  101. return Texture[stage];
  102. }
  103. #endif // MATPASS_H