Richard Boegli's CnC_Generals_Zero_Hour Fork
WIP
This is documentation of Richard Boegil's Zero Hour Fork
Loading...
Searching...
No Matches
metalmap.h
Go to the documentation of this file.
1
/*
2
** Command & Conquer Generals Zero Hour(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
/***********************************************************************************************
20
*** 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 ***
21
***********************************************************************************************
22
* *
23
* Project Name : G *
24
* *
25
* $Archive:: /Commando/Code/ww3d2/metalmap.h $*
26
* *
27
* $Author:: Hector_y $*
28
* *
29
* $Modtime:: 6/27/01 4:30p $*
30
* *
31
* $Revision:: 2 $*
32
* *
33
*---------------------------------------------------------------------------------------------*
34
* Functions: *
35
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
36
37
#if defined(_MSC_VER)
38
#pragma once
39
#endif
40
41
#ifndef METALMAP_H
42
#define METALMAP_H
43
44
#include <vector3.h>
45
46
class
TextureClass
;
47
class
INIClass
;
48
49
/*
50
** MetalMapManagerClass: This class updates the procedural environment maps
51
** (aka metal maps) based on the global lighting environment.
52
** At the moment the metal maps are shaded using a simple Phong model - in
53
** future this may be extended to more complex and realistic shading
54
** (Cook-Torrance, etc.) which would require changing the metal parameters.
55
** Another possible extension would be to support a large dynamic range for
56
** the main light source (currently its color is treated as an RGB triple
57
** which is bound to 0,1).
58
*/
59
60
// If this is increased too much the metal map updates will be too expensive
61
#define METALMAP_SIZE 16
62
#define METALMAP_SIZE_2 (METALMAP_SIZE * METALMAP_SIZE)
63
64
class
MetalMapManagerClass
{
65
66
public
:
67
68
// These parameters are for a simple Phong reflectance model
69
struct
MetalParams
{
70
Vector3
AmbientColor
;
71
Vector3
DiffuseColor
;
72
Vector3
SpecularColor
;
73
float
Shininess
;
74
};
75
76
// Create metal map manager with maps specified by INI file
77
MetalMapManagerClass
(
INIClass
&ini);
78
~MetalMapManagerClass
(
void
);
79
80
// Get the texture for a metal map by id number
81
TextureClass
*
Get_Metal_Map
(
int
id
);
82
83
// Get the number of metal maps in the manager
84
int
Metal_Map_Count
(
void
);
85
86
// Update the lighting parameters used for generating the maps
87
void
Update_Lighting
(
const
Vector3
& ambient,
const
Vector3
& main_light_color,
88
const
Vector3
& main_light_dir,
const
Vector3
& camera_dir);
89
90
// Update the metal map textures (should call once/frame before rendering)
91
void
Update_Textures
(
void
);
92
93
private
:
94
95
// 16 x 16 table of cameraspace normals for the environment maps
96
static
Vector3
* _NormalTable;
97
void
initialize_normal_table(
void
);
// Utility function
98
99
// Utility function - shared CTor code
100
void
initialize_metal_params(
int
map_count,
MetalParams
*metal_params);
101
102
// Number of metal maps
103
int
MapCount;
104
105
// Array of metal map texture pointers
106
TextureClass
** Textures;
107
108
// Array of metal parameters
109
MetalParams
* MetalParameters;
110
111
// Current lighting parameters
112
Vector3
CurrentAmbient;
113
Vector3
CurrentMainLightColor;
114
Vector3
CurrentMainLightDir;
115
Vector3
CurrentCameraDir;
116
117
// Use 16-bit metal maps or not
118
bool
Use16Bit;
119
};
120
121
#endif
INIClass
Definition
INI.H:80
MetalMapManagerClass::Metal_Map_Count
int Metal_Map_Count(void)
Definition
metalmap.cpp:220
MetalMapManagerClass::~MetalMapManagerClass
~MetalMapManagerClass(void)
Definition
metalmap.cpp:170
MetalMapManagerClass::Update_Lighting
void Update_Lighting(const Vector3 &ambient, const Vector3 &main_light_color, const Vector3 &main_light_dir, const Vector3 &camera_dir)
Definition
metalmap.cpp:239
MetalMapManagerClass::Update_Textures
void Update_Textures(void)
Definition
metalmap.cpp:261
MetalMapManagerClass::MetalMapManagerClass
MetalMapManagerClass(INIClass &ini)
Definition
metalmap.cpp:79
MetalMapManagerClass::Get_Metal_Map
TextureClass * Get_Metal_Map(int id)
Definition
metalmap.cpp:199
TextureClass
Definition
texture.h:271
Vector3
Definition
vector3.h:85
MetalMapManagerClass::MetalParams
Definition
metalmap.h:69
MetalMapManagerClass::MetalParams::AmbientColor
Vector3 AmbientColor
Definition
metalmap.h:70
MetalMapManagerClass::MetalParams::DiffuseColor
Vector3 DiffuseColor
Definition
metalmap.h:71
MetalMapManagerClass::MetalParams::SpecularColor
Vector3 SpecularColor
Definition
metalmap.h:72
MetalMapManagerClass::MetalParams::Shininess
float Shininess
Definition
metalmap.h:73
Code
Libraries
Source
WWVegas
WW3D2
metalmap.h
Generated by
1.13.2