matpass.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. ** Command & Conquer Generals(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. /// MW: Had to make this virtual so app can perform direct/custom D3D setup.
  74. virtual void Install_Materials(void) const;
  75. virtual void UnInstall_Materials(void) const { }; ///< reset/cleanup D3D states
  76. void Set_Texture(TextureClass * Texture,int stage = 0);
  77. void Set_Shader(ShaderClass shader);
  78. void Set_Material(VertexMaterialClass * mat);
  79. TextureClass * Get_Texture(int stage = 0) const;
  80. VertexMaterialClass * Get_Material(void) const;
  81. TextureClass * Peek_Texture(int stage = 0) const;
  82. ShaderClass Peek_Shader(void) const { return Shader; }
  83. VertexMaterialClass * Peek_Material(void) const { return Material; }
  84. void Set_Cull_Volume(OBBoxClass * volume) { CullVolume = volume; }
  85. OBBoxClass * Get_Cull_Volume(void) const { return CullVolume; }
  86. void Enable_On_Translucent_Meshes(bool onoff) { EnableOnTranslucentMeshes = onoff; }
  87. bool Is_Enabled_On_Translucent_Meshes(void) { return EnableOnTranslucentMeshes; }
  88. static void Enable_Per_Polygon_Culling(bool onoff) { EnablePerPolygonCulling = onoff; }
  89. static bool Is_Per_Polygon_Culling_Enabled(void) { return EnablePerPolygonCulling; }
  90. protected:
  91. enum { MAX_TEX_STAGES = 2 };
  92. TextureClass * Texture[MAX_TEX_STAGES];
  93. ShaderClass Shader;
  94. VertexMaterialClass * Material;
  95. bool EnableOnTranslucentMeshes;
  96. OBBoxClass * CullVolume;
  97. static bool EnablePerPolygonCulling;
  98. };
  99. inline TextureClass * MaterialPassClass::Peek_Texture(int stage) const
  100. {
  101. WWASSERT(stage >= 0);
  102. WWASSERT(stage < MAX_TEX_STAGES);
  103. return Texture[stage];
  104. }
  105. #endif // MATPASS_H