Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
shdbumpdiff.cpp
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/shdbumpdiff.cpp $*
26 * *
27 * $Author:: Kenny_m
28 *
29 * $Modtime:: 6/03/02 8:12a $*
30 * *
31 * $Revision:: 1 $*
32 * *
33 *---------------------------------------------------------------------------------------------*
34 * Functions: *
35 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
36
37#include "dx8fvf.h"
38#include "dx8wrapper.h"
39#include "assetmgr.h"
40
41#include "shdbumpdiff.h"
42#include "shd6bumpdiff.h"
43#include "shd7bumpdiff.h"
44#include "shd8bumpdiff.h"
45
46#include "editable.h"
47#include "shdclassids.h"
48#include "shddeffactory.h"
49#include "shdinterface.h"
50
51#include "persistfactory.h"
52#include "wwhack.h"
53
54DECLARE_FORCE_LINK(BumpDiffShader);
56
57// static member
58ShdVersion ShdBumpDiffDefClass::Version;
59
60
61// Save-Load methods for ShdDefClass
62enum
63{
64 CHUNKID_VARIABLES = 0x16490450,
65
68
72};
73
76 Ambient(1,1,1),
77 Diffuse(1,1,1),
78 Diffuse_Bumpiness(1,0)
79{
80 NAMED_TEXTURE_FILENAME_PARAM(ShdBumpDiffDefClass, TextureName, "Base Map", "Targa Files", ".tga");
81 NAMED_TEXTURE_FILENAME_PARAM(ShdBumpDiffDefClass, BumpMapName, "Bump Map", "Targa Files", ".tga");
82
85
86 NAMED_EDITABLE_PARAM(ShdBumpDiffDefClass, ParameterClass::TYPE_FLOAT, Diffuse_Bumpiness.X, "Diffuse Bump Scale");
87 NAMED_EDITABLE_PARAM(ShdBumpDiffDefClass, ParameterClass::TYPE_FLOAT, Diffuse_Bumpiness.Y, "Diffuse Bump Bias");
88}
89
91: ShdDefClass(that),
92 Ambient(that.Ambient),
93 Diffuse(that.Diffuse),
94 Diffuse_Bumpiness(that.Diffuse_Bumpiness)
95{
96 TextureName=that.TextureName;
97 BumpMapName=that.BumpMapName;
98}
99
103
105{
106 return true;
107}
108
110{
111 ShdDefClass::Save(csave);
112
114
115 bool retval = true;
116
117 // only save the file name
118 char fname[_MAX_PATH];
119
120 _splitpath(TextureName,NULL,NULL,fname,NULL);
121 strcat(fname,".tga");
122 TextureName=fname;
123
125
126 _splitpath(BumpMapName,NULL,NULL,fname,NULL);
127 strcat(fname,".tga");
128 BumpMapName=fname;
129
131
132 WRITE_MICRO_CHUNK(csave, VARID_AMBIENT_COLOR, Ambient);
133 WRITE_MICRO_CHUNK(csave, VARID_DIFFUSE_COLOR, Diffuse);
134
135 WRITE_MICRO_CHUNK(csave, VARID_DIFFUSE_BUMPINESS, Diffuse_Bumpiness);
136
137 csave.End_Chunk();
138
139 return retval;
140}
141
143{
144 ShdDefClass::Load(cload);
145
146 // Loop through all the microchunks that define the variables
147 while (cload.Open_Chunk()) {
148 switch (cload.Cur_Chunk_ID())
149 {
151 while (cload.Open_Micro_Chunk())
152 {
153 switch (cload.Cur_Micro_Chunk_ID())
154 {
157
158 READ_MICRO_CHUNK(cload, VARID_AMBIENT_COLOR, Ambient);
159 READ_MICRO_CHUNK(cload, VARID_DIFFUSE_COLOR, Diffuse);
160
161 READ_MICRO_CHUNK(cload, VARID_DIFFUSE_BUMPINESS, Diffuse_Bumpiness);
162 }
163
164 cload.Close_Micro_Chunk();
165 }
166 break;
167
168 default:
169 break;
170 }
171
172 cload.Close_Chunk();
173 }
174
175 return true;
176}
177
178
180{
181 // select shader version
182 if ((DX8Wrapper::Get_Current_Caps()->Get_Pixel_Shader_Major_Version())==1 &&
183 (DX8Wrapper::Get_Current_Caps()->Get_Pixel_Shader_Minor_Version())>=1)
184 {
185 Version.Set(SHDVER_8);
186 }
187 else if (DX8Wrapper::Get_Current_Caps()->Support_Dot3())
188 {
189 Version.Set(SHDVER_7);
190 }
191 else
192 {
193 Version.Set(SHDVER_6);
194 }
195
196 switch (Version.Get())
197 {
198 case SHDVER_8 : Shd8BumpDiffClass::Init(); break;
199 case SHDVER_7 : Shd7BumpDiffClass::Init(); break;
200 case SHDVER_6 : Shd6BumpDiffClass::Init(); break;
201 }
202}
203
205{
206 switch (Version.Get())
207 {
211 }
212}
213
215{
216 switch (Version.Get())
217 {
218 case SHDVER_8 : return new Shd8BumpDiffClass(this); break;
219 case SHDVER_7 : return new Shd7BumpDiffClass(this); break;
220 case SHDVER_6 : return new Shd6BumpDiffClass(this); break;
221 }
222 return NULL;
223}
224
#define NULL
Definition BaseType.h:92
#define WRITE_MICRO_CHUNK_WWSTRING(csave, id, var)
Definition chunkio.h:309
#define WRITE_MICRO_CHUNK(csave, id, var)
Definition chunkio.h:293
#define READ_MICRO_CHUNK(cload, id, var)
Definition chunkio.h:334
#define READ_MICRO_CHUNK_WWSTRING(cload, id, var)
Definition chunkio.h:351
@ CHUNKID_VARIABLES
bool Close_Micro_Chunk()
Definition chunkio.cpp:585
bool Close_Chunk()
Definition chunkio.cpp:448
uint32 Cur_Chunk_ID()
Definition chunkio.cpp:484
uint32 Cur_Micro_Chunk_ID()
Definition chunkio.cpp:622
bool Open_Chunk()
Definition chunkio.cpp:412
bool Open_Micro_Chunk()
Definition chunkio.cpp:557
bool Begin_Chunk(uint32 id)
Definition chunkio.cpp:108
bool End_Chunk()
Definition chunkio.cpp:148
static const DX8Caps * Get_Current_Caps()
Definition dx8wrapper.h:536
static void Shutdown()
static void Init()
static void Init()
static void Shutdown()
static void Shutdown()
static void Init()
virtual bool Save(ChunkSaveClass &csave)
Serialize this ShdDef into a chunk saver.
virtual ~ShdBumpDiffDefClass()
virtual void Init()
virtual void Shutdown()
virtual bool Is_Valid_Config(StringClass &message)
virtual bool Load(ChunkLoadClass &cload)
Load this ShdDef from a chunk loader.
virtual ShdInterfaceClass * Create() const
ShdDefClass(uint32 class_id)
Definition shddef.cpp:45
virtual bool Load(ChunkLoadClass &cload)
Load this ShdDef from a chunk loader.
Definition shddef.cpp:160
virtual bool Save(ChunkSaveClass &csave)
Serialize this ShdDef into a chunk saver.
Definition shddef.cpp:140
#define NAMED_EDITABLE_PARAM(_class, type, data, name)
Definition editable.h:308
#define NAMED_TEXTURE_FILENAME_PARAM(_class, data, name, desc, extension)
Definition editable.h:326
@ VARID_DIFFUSE_COLOR
@ VARID_AMBIENT_COLOR
@ VARID_TEXTURE_NAME
@ VARID_DIFFUSE_BUMPINESS
@ VARID_BUMP_MAP_NAME
@ SHDDEF_CLASSID_BUMPDIFF
Definition shdclassids.h:52
@ SHDVER_6
Definition shddef.h:52
@ SHDVER_8
Definition shddef.h:54
@ SHDVER_7
Definition shddef.h:53
#define REGISTER_SHDDEF(T, ID, NAME)
#define DECLARE_FORCE_LINK(module)
Definition wwhack.h:48