Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
texproject.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 : WW3D *
24 * *
25 * $Archive:: /Commando/Code/ww3d2/texproject.h $*
26 * *
27 * Original Author:: Greg Hjelstrom *
28 * *
29 * $Author:: Kenny Mitchell *
30 * *
31 * $Modtime:: 06/26/02 4:04p $*
32 * *
33 * $Revision:: 8 $*
34 * *
35 * 06/27/02 KM Render to shadow buffer texture support *
36 *---------------------------------------------------------------------------------------------*
37 * Functions: *
38 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
39
40#if defined(_MSC_VER)
41#pragma once
42#endif
43
44#ifndef TEXPROJECT_H
45#define TEXPROJECT_H
46
47#include "always.h"
48#include "matrix3d.h"
49#include "matrix4.h"
50#include "obbox.h"
51#include "matpass.h"
52#include "matrixmapper.h"
53#include "cullsys.h"
54#include "multilist.h"
55#include "projector.h"
56
57
59class RenderObjClass;
61class SurfaceClass;
62
63class TextureClass;
64class ZTextureClass;
65
66
105{
106public:
107
108 TexProjectClass(void);
109 virtual ~TexProjectClass(void);
110
111 /*
112 ** Material settings
113 */
114 void Set_Texture_Size(int size);
115 int Get_Texture_Size(void);
116 void Init_Multiplicative(void);
117 void Init_Additive(void);
118 void Set_Intensity(float intensity,bool immediate = false); // 1.0 = on 100%, 0.0 = 'off'
119 float Get_Intensity(void);
120 bool Is_Intensity_Zero(void);
121 void Set_Attenuation(float attenuation); // 1.0 = on, 0.0 = off
122 float Get_Attenuation(void);
123 void Enable_Attenuation(bool onoff);
124 bool Is_Attenuation_Enabled(void);
126
127 /*
128 ** Options
129 */
134 void Enable_Depth_Gradient(bool onoff);
135 bool Is_Depth_Gradient_Enabled(bool onoff);
136
137 /*
138 ** Manual initialization of a TexProjectClass
139 ** 1 - call ProjectorClass::Set_Transform
140 ** 2 - call Set_Projection_Perspective -or- Set_Projection_Ortho
141 ** 3 - call Set_Texture.
142 */
143 virtual void Set_Perspective_Projection(float hfov,float vfov,float znear,float zfar);
144 virtual void Set_Ortho_Projection(float xmin,float xmax,float ymin,float ymax,float znear,float zfar);
145
146 void Set_Texture(TextureClass * texture);
147 TextureClass * Get_Texture(void) const;
148 TextureClass * Peek_Texture(void) const;
149
150
154
155 /*
156 ** Automatic initialization of a TexProjectClass.
157 ** First set up your projection parameters, give the projector a render target, then call Compute_Texture
158 */
159 bool Compute_Perspective_Projection(RenderObjClass * obj,const Vector3 & lightpos,float znear=-1.0f,float zfar=-1.0f);
160 bool Compute_Perspective_Projection(const AABoxClass & obj_box,const Matrix3D & tm,const Vector3 & lightpos,float znear=-1.0f,float zfar=-1.0f);
161
162 bool Compute_Ortho_Projection(RenderObjClass * obj,const Vector3 & lightdir,float znear=-1.0f,float zfar=-1.0f);
163 bool Compute_Ortho_Projection(const AABoxClass & obj_box,const Matrix3D & tm,const Vector3 & lightdir,float znear=-1.0f,float zfar=-1.0f);
164
165 bool Needs_Render_Target(void);
166 void Set_Render_Target(TextureClass* render_target, ZTextureClass* ztarget=NULL);
168
170
171 /*
172 ** Prep for rendering, called by the scene prior to usage.
173 */
174 virtual void Pre_Render_Update(const Matrix3D & camera);
175
176 /*
177 ** virtual interface for getting the pointer of the object that generated this shadow.
178 ** defaults to returning NULL. This is implemented by some derived classes and used by
179 ** the system to prevent a projection from being applied to the object that generated
180 ** the projection...
181 ** (gth) feels kludgy, this got a little messy when I moved this code into WW3D from WWPhys
182 */
183 virtual void * Get_Projection_Object_ID(void) const { return NULL; }
184
185protected:
186
187 void Set_Flag(uint32 flag,bool onoff);
188 bool Get_Flag(uint32 flag) const;
189 virtual void Update_WS_Bounding_Volume(void);
190 void Configure_Camera(CameraClass & camera);
191
193 {
194 PERSPECTIVE = 0x00000001, // PERSPECTIVE or ORTHO
195 ADDITIVE = 0x00000002, // ADDITIVE or MULTIPLICATIVE
196 TEXTURE_DIRTY = 0x00000004, // used by derived DynTexProjectClass
197 VOLATILE = 0x00000008, // this is a volatile texture.
198 ATTENUATE = 0x00000010, // this projector should be attenuated based on distance to viewer
199 AFFECT_DYNAMIC_OBJS = 0x00000020, // this projector affects dynamic objects
200 AFFECT_STATIC_OBJS = 0x00000040, // this projector affects static objects
201 USE_DEPTH_GRADIENT = 0x00000080, // fade the projection as a function of depth
202 HAS_RENDER_TARGET = 0x00000100, // the texture we have can be a render target
203 SIZE_MASK = 0xFFF00000, // desired texture size stored in upper 3 nibbles
205
207 };
208
210
211 /*
212 ** Intensity Controls
213 */
214 float DesiredIntensity; // last input desired intensity.
215 float Intensity; // basic shadow intensity. value between 0 and 1
216 float Attenuation; // attenuation factor based on distance from camera. value between 0 and 1
217
218 /*
219 ** Material pass to be added to any object that intersects the volume
220 */
225
226 /*
227 ** I have to remember all of these values so that I can properly initialize a CameraClass
228 ** when we do render-to-texture. Some day we will merge CameraClass and ProjectorClass.
229 */
230 float HFov; // horizontal fov (for perspective mode)
231 float VFov; // vertical fov (for perspective mode)
232 float XMin; // left x clip plane (for ortho)
233 float XMax; // right x clip plane (for ortho)
234 float YMin; // bottom y clip plane (for ortho)
235 float YMax; // top y clip plane (for ortho)
236 float ZNear,ZFar; // z clip planes (for both modes)
237};
238
239
240/*
241** Texture Projector Lists
242*/
245
246
247#endif
248
#define NULL
Definition BaseType.h:92
unsigned long uint32
Definition bittype.h:46
CullableClass(void)
Definition cullsys.cpp:47
ProjectorClass(void)
Definition projector.cpp:64
virtual void * Get_Projection_Object_ID(void) const
Definition texproject.h:183
void Set_Render_Target(TextureClass *render_target, ZTextureClass *ztarget=NULL)
virtual void Set_Perspective_Projection(float hfov, float vfov, float znear, float zfar)
bool Needs_Render_Target(void)
void Configure_Camera(CameraClass &camera)
void Set_Attenuation(float attenuation)
bool Is_Affect_Dynamic_Objects_Enabled(void)
Definition texproject.h:131
bool Get_Flag(uint32 flag) const
void Set_Texture(TextureClass *texture)
bool Compute_Perspective_Projection(RenderObjClass *obj, const Vector3 &lightpos, float znear=-1.0f, float zfar=-1.0f)
bool Compute_Texture(RenderObjClass *model, SpecialRenderInfoClass *context)
virtual ~TexProjectClass(void)
float Get_Intensity(void)
virtual void Pre_Render_Update(const Matrix3D &camera)
ZTextureClass * Peek_DepthStencilBuffer() const
bool Compute_Ortho_Projection(RenderObjClass *obj, const Vector3 &lightdir, float znear=-1.0f, float zfar=-1.0f)
void Set_DepthStencilBuffer(ZTextureClass *ztex)
TextureClass * Peek_Texture(void) const
virtual void Update_WS_Bounding_Volume(void)
void Set_Flag(uint32 flag, bool onoff)
ZTextureClass * Get_DepthStencilBuffer() const
ZTextureClass * DepthStencilTarget
Definition texproject.h:224
virtual void Set_Ortho_Projection(float xmin, float xmax, float ymin, float ymax, float znear, float zfar)
void Set_Texture_Size(int size)
MaterialPassClass * Peek_Material_Pass(void)
bool Is_Affect_Static_Objects_Enabled(void)
Definition texproject.h:133
TextureClass * Get_Texture(void) const
bool Is_Intensity_Zero(void)
void Enable_Affect_Dynamic_Objects(bool onoff)
Definition texproject.h:130
float DesiredIntensity
Definition texproject.h:214
void Init_Additive(void)
TextureClass * Peek_Render_Target(TextureClass **rtarget=NULL, ZTextureClass **ztarget=NULL)
void Init_Multiplicative(void)
void Enable_Depth_Gradient(bool onoff)
int Get_Texture_Size(void)
bool Is_Depth_Gradient_Enabled(bool onoff)
bool Is_Attenuation_Enabled(void)
MaterialPassClass * MaterialPass
Definition texproject.h:221
MatrixMapperClass * Mapper1
Definition texproject.h:222
float Get_Attenuation(void)
void Enable_Affect_Static_Objects(bool onoff)
Definition texproject.h:132
void Enable_Attenuation(bool onoff)
TextureClass * RenderTarget
Definition texproject.h:223
void Set_Intensity(float intensity, bool immediate=false)
RefMultiListClass< TexProjectClass > TexProjListClass
Definition texproject.h:243
RefMultiListIterator< TexProjectClass > TexProjListIterator
Definition texproject.h:244
unsigned char flag
Definition vchannel.cpp:273