Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
meshdam.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/meshdam.cpp $*
26 * *
27 * Author:: Greg_h *
28 * *
29 * $Modtime:: 1/08/01 10:04a $*
30 * *
31 * $Revision:: 1 $*
32 * *
33 *---------------------------------------------------------------------------------------------*
34 * Functions: *
35 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
36
37
38#if 0
39
40
41#include "meshdam.h"
42#include "w3d_file.h"
43#include "w3derr.h"
44#include "chunkio.h"
45//#include <sr.hpp>
46
47
48/***********************************************************************************************
49 * DamageClass::DamageClass -- constructor *
50 * *
51 * INPUT: *
52 * *
53 * OUTPUT: *
54 * *
55 * WARNINGS: *
56 * *
57 * HISTORY: *
58 * 10/28/1997 GH : Created. *
59 *=============================================================================================*/
60DamageClass::DamageClass(void):
61 DamageIndex(0),
62 NumMaterials(0),
63 NumVerts(0),
64 NumColors(0),
65 Verts(NULL),
66 Colors(NULL)
67{
68}
69
70
71/***********************************************************************************************
72 * DamageClass::~DamageClass -- destructor *
73 * *
74 * INPUT: *
75 * *
76 * OUTPUT: *
77 * *
78 * WARNINGS: *
79 * *
80 * HISTORY: *
81 * 10/28/1997 GH : Created. *
82 *=============================================================================================*/
83DamageClass::~DamageClass(void)
84{
85 if (Verts != NULL) {
86 delete [] Verts;
87 Verts = NULL;
88 }
89
90 if (Colors != NULL) {
91 delete[] Colors;
92 Colors = NULL;
93 }
94}
95
96/***********************************************************************************************
97 * DamageClass::Load -- load damage data from a W3D file *
98 * *
99 * INPUT: *
100 * *
101 * OUTPUT: *
102 * *
103 * WARNINGS: *
104 * *
105 * HISTORY: *
106 * 10/28/1997 GH : Created. *
107 *=============================================================================================*/
108WW3DErrorType DamageClass::Load(ChunkLoadClass & cload,MeshModelClass * basemesh)
109{
110#if 0
111 /*
112 ** Open the first chunk, it should be the damage header
113 */
114 cload.Open_Chunk();
115
116 if (cload.Cur_Chunk_ID() != W3D_CHUNK_DAMAGE_HEADER) {
118 }
119
120 W3dMeshDamageStruct header;
121 if (cload.Read(&header,sizeof(W3dMeshDamageStruct)) != sizeof(W3dMeshDamageStruct)) {
123 }
124
125 cload.Close_Chunk();
126
127 /*
128 ** allocate the arrays based on the info in the header
129 */
130 NumVerts = header.NumDamageVerts;
131 if (NumVerts > 0) {
132 Verts = W3DNEWARRAY DamageVertexStruct[NumVerts];
133 }
134
135 NumColors = header.NumDamageColors;
136 if (NumColors > 0) {
137 Colors = W3DNEWARRAY DamageColorStruct[NumColors];
138 }
139
140 // TODO: allocate materials
141
142 /*
143 ** Now read in the rest of the chunks
144 */
145 while (1) {
146
147 /*
148 ** Read in the chunk header
149 ** If there are no more chunks within the chunk, we are done.
150 */
151 if (!cload.Open_Chunk()) {
152 return WW3D_ERROR_OK;
153 }
154
155 /*
156 ** Process the chunk
157 */
158 int error = WW3D_ERROR_OK;
159
160 switch (cload.Cur_Chunk_ID()) {
161
162// case W3D_CHUNK_DAMAGE_MATERIALS:
163// //TODO: read new set of materials
164// break;
165
167 error = read_vertices(cload,basemesh);
168 break;
169
171 error = read_colors(cload,basemesh);
172 break;
173
174 default:
175 break;
176
177 }
178
179 cload.Close_Chunk();
180
181 if (error != WW3D_ERROR_OK) {
182 return error;
183 }
184 }
185#endif
186
187 return WW3D_ERROR_OK;
188}
189
190/***********************************************************************************************
191 * DamageClass::read_vertices -- read damage vertices from a W3D file *
192 * *
193 * INPUT: *
194 * *
195 * OUTPUT: *
196 * *
197 * WARNINGS: *
198 * *
199 * HISTORY: *
200 * 11/04/1997 GH : Created. *
201 *=============================================================================================*/
202WW3DErrorType DamageClass::read_vertices(ChunkLoadClass & cload,MeshModelClass * basemesh)
203{
204#if 0
206
207 for (int i=0; i<NumVerts; i++) {
208
209 if (cload.Read(&dv,sizeof(W3dMeshDamageVertexStruct)) != sizeof(W3dMeshDamageVertexStruct)) {
211 }
212
213 srVector3 * vert_array = basemesh->getVertexLoc();
214
215 srVector3 sr_v;
216 sr_v = vert_array[dv.VertexIndex];
217
218 Verts[i].VertexIdx = dv.VertexIndex;
219 Verts[i].Vertex0.Set(sr_v[0],sr_v[1],sr_v[2]);
220 Verts[i].Vertex1.Set(dv.NewVertex.X,dv.NewVertex.Y,dv.NewVertex.Z);
221 }
222#endif
223 return WW3D_ERROR_OK;
224}
225
226/***********************************************************************************************
227 * DamageClass::read_colors -- read damage colors from a w3d file *
228 * *
229 * INPUT: *
230 * *
231 * OUTPUT: *
232 * *
233 * WARNINGS: *
234 * *
235 * HISTORY: *
236 * 11/04/1997 GH : Created. *
237 *=============================================================================================*/
238WW3DErrorType DamageClass::read_colors(ChunkLoadClass & cload,MeshModelClass * basemesh)
239{
240#if 0
242
243 for (int i=0; i<NumColors; i++) {
244
245 if (cload.Read(&dc,sizeof(W3dMeshDamageColorStruct)) != sizeof(W3dMeshDamageColorStruct)) {
247 }
248
249
250 Colors[i].VertexIdx = dc.VertexIndex;
251
252 // TODO: check for existing vertex colors, store original here
253 Colors[i].Color0.R = 255;
254 Colors[i].Color0.G = 255;
255 Colors[i].Color0.B = 255;
256
257 Colors[i].Color1.R = dc.NewColor.R;
258 Colors[i].Color1.G = dc.NewColor.G;
259 Colors[i].Color1.B = dc.NewColor.B;
260 }
261#endif
262 return WW3D_ERROR_OK;
263}
264
265
266#endif //0
#define NULL
Definition BaseType.h:92
@ W3D_CHUNK_DAMAGE_VERTICES
@ W3D_CHUNK_DAMAGE_HEADER
@ W3D_CHUNK_DAMAGE_COLORS
#define W3DNEWARRAY
Definition always.h:110
bool Close_Chunk()
Definition chunkio.cpp:448
uint32 Cur_Chunk_ID()
Definition chunkio.cpp:484
uint32 Read(void *buf, uint32 nbytes)
Definition chunkio.cpp:692
bool Open_Chunk()
Definition chunkio.cpp:412
W3dVectorStruct NewVertex
WW3DErrorType
Definition w3derr.h:51
@ WW3D_ERROR_LOAD_FAILED
Definition w3derr.h:54
@ WW3D_ERROR_OK
Definition w3derr.h:52