metalmap.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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 : G *
  23. * *
  24. * $Archive:: /VSS_Sync/ww3d2/metalmap.h $*
  25. * *
  26. * $Author:: Vss_sync $*
  27. * *
  28. * $Modtime:: 10/26/01 2:56p $*
  29. * *
  30. * $Revision:: 3 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef METALMAP_H
  39. #define METALMAP_H
  40. #include <vector3.h>
  41. class TextureClass;
  42. class INIClass;
  43. /*
  44. ** MetalMapManagerClass: This class updates the procedural environment maps
  45. ** (aka metal maps) based on the global lighting environment.
  46. ** At the moment the metal maps are shaded using a simple Phong model - in
  47. ** future this may be extended to more complex and realistic shading
  48. ** (Cook-Torrance, etc.) which would require changing the metal parameters.
  49. ** Another possible extension would be to support a large dynamic range for
  50. ** the main light source (currently its color is treated as an RGB triple
  51. ** which is bound to 0,1).
  52. */
  53. // If this is increased too much the metal map updates will be too expensive
  54. #define METALMAP_SIZE 16
  55. #define METALMAP_SIZE_2 (METALMAP_SIZE * METALMAP_SIZE)
  56. class MetalMapManagerClass {
  57. public:
  58. // These parameters are for a simple Phong reflectance model
  59. struct MetalParams {
  60. Vector3 AmbientColor;
  61. Vector3 DiffuseColor;
  62. Vector3 SpecularColor;
  63. float Shininess;
  64. };
  65. // Create metal map manager with maps specified by INI file
  66. MetalMapManagerClass(INIClass &ini);
  67. ~MetalMapManagerClass(void);
  68. // Get the texture for a metal map by id number
  69. TextureClass * Get_Metal_Map(int id);
  70. // Get the number of metal maps in the manager
  71. int Metal_Map_Count(void);
  72. // Update the lighting parameters used for generating the maps
  73. void Update_Lighting(const Vector3& ambient, const Vector3& main_light_color,
  74. const Vector3& main_light_dir, const Vector3& camera_dir);
  75. // Update the metal map textures (should call once/frame before rendering)
  76. void Update_Textures(void);
  77. private:
  78. // 16 x 16 table of cameraspace normals for the environment maps
  79. static Vector3 * _NormalTable;
  80. void initialize_normal_table(void); // Utility function
  81. // Utility function - shared CTor code
  82. void initialize_metal_params(int map_count, MetalParams *metal_params);
  83. // Number of metal maps
  84. int MapCount;
  85. // Array of metal map texture pointers
  86. TextureClass ** Textures;
  87. // Array of metal parameters
  88. MetalParams * MetalParameters;
  89. // Current lighting parameters
  90. Vector3 CurrentAmbient;
  91. Vector3 CurrentMainLightColor;
  92. Vector3 CurrentMainLightDir;
  93. Vector3 CurrentCameraDir;
  94. // Use 16-bit metal maps or not
  95. bool Use16Bit;
  96. };
  97. #endif