Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
skindata.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/* $Header: /Commando/Code/Tools/max2w3d/skindata.cpp 7 5/28/98 12:15p Greg_h $ */
20/***********************************************************************************************
21 *** Confidential - Westwood Studios ***
22 ***********************************************************************************************
23 * *
24 * Project Name : Commando Tools - WWSkin *
25 * *
26 * $Archive:: /Commando/Code/Tools/max2w3d/skindata.cpp $*
27 * *
28 * $Author:: Greg_h $*
29 * *
30 * $Modtime:: 5/28/98 12:15p $*
31 * *
32 * $Revision:: 7 $*
33 * *
34 *---------------------------------------------------------------------------------------------*
35 * Functions: *
36 * SkinDataClass::Save -- save the skindata in the MAX file *
37 * SkinDataClass::Load -- load the skindata from a MAX file *
38 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
39
40
41#include "skindata.h"
42
43
44/***********************************************************************************************
45 * SkinDataClass::Save -- save the skindata in the MAX file *
46 * *
47 * INPUT: *
48 * *
49 * OUTPUT: *
50 * *
51 * WARNINGS: *
52 * *
53 * HISTORY: *
54 * 10/26/1997 GH : Created. *
55 *=============================================================================================*/
56IOResult SkinDataClass::Save(ISave *isave)
57{
58 ULONG nb;
59
60 /*
61 ** save the flags
62 */
63 short flags = 0;
64 if (Valid) flags |= 0x01;
65 if (Held) flags |= 0x02;
66
67 isave->BeginChunk(FLAGS_CHUNK);
68 isave->Write(&flags,sizeof(flags),&nb);
69 isave->EndChunk();
70
71 /*
72 ** Save the bit array of currently selected vertices
73 */
74 if (VertSel.NumberSet() > 0) {
75 isave->BeginChunk(VERT_SEL_CHUNK);
76 VertSel.Save(isave);
77 isave->EndChunk();
78 }
79
80 /*
81 ** Save the named selection sets of vertices
82 */
83#if 0
84 if (VertSelSets.Count() > 0) {
85 isave->BeginChunk(INFLUENCE_DATA_CHUNK);
86 VertSelSets.Save(isave);
87 isave->EndChunk();
88 }
89#endif
90
91 /*
92 ** Save the vertex influence data
93 */
94 if (VertData.Count() > 0) {
95 isave->BeginChunk(INFLUENCE_DATA_CHUNK);
96 isave->Write(VertData.Addr(0),VertData.Count() * sizeof(InfluenceStruct), &nb);
97 isave->EndChunk();
98 }
99
100 return IO_OK;
101}
102
103
104/***********************************************************************************************
105 * SkinDataClass::Load -- load the skindata from a MAX file *
106 * *
107 * INPUT: *
108 * *
109 * OUTPUT: *
110 * *
111 * WARNINGS: *
112 * *
113 * HISTORY: *
114 * 10/26/1997 GH : Created. *
115 *=============================================================================================*/
116IOResult SkinDataClass::Load(ILoad *iload)
117{
118 ULONG nb;
119 short flags;
120 int n;
121 IOResult res;
122
123 while (IO_OK == (res=iload->OpenChunk())) {
124
125 switch (iload->CurChunkID()) {
126
127 case FLAGS_CHUNK:
128 res = iload->Read(&flags,sizeof(flags),&nb);
129 Valid = (flags & 0x01);
130 Held = (flags & 0x02);
131 break;
132
133 case VERT_SEL_CHUNK:
134 res = VertSel.Load(iload);
135 break;
136
138 res = VertSelSets.Load(iload);
139 break;
140
142 n = iload->CurChunkLength() / sizeof(InfluenceStruct);
143 VertData.SetCount(n);
144 res = iload->Read(VertData.Addr(0),n*sizeof(InfluenceStruct),&nb);
145 break;
146 }
147
148 iload->CloseChunk();
149
150 if (res != IO_OK) {
151 return res;
152 }
153 }
154
155 /*
156 ** ensure that the arrays are sized correctly
157 */
158 Invalidate();
159
160 return IO_OK;
161}
162
unsigned long ULONG
Definition bittype.h:64
NamedSelSetList VertSelSets
Definition skindata.h:142
BitArray VertSel
Definition skindata.h:137
Tab< InfluenceStruct > VertData
Definition skindata.h:147
IOResult Load(ILoad *iload)
Definition skindata.cpp:116
IOResult Save(ISave *isave)
Definition skindata.cpp:56
void Invalidate()
Definition skindata.h:92
@ INFLUENCE_DATA_CHUNK
Definition skindata.h:156
@ NAMED_SEL_SETS_CHUNK
Definition skindata.h:155