Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
skindata.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/* $Header: /Commando/Code/Tools/max2w3d/skindata.h 6 10/28/97 6:08p Greg_h $ */
20/***********************************************************************************************
21 *** Confidential - Westwood Studios ***
22 ***********************************************************************************************
23 * *
24 * Project Name : Commando Tools - WWSkin *
25 * *
26 * $Archive:: /Commando/Code/Tools/max2w3d/skindata.h $*
27 * *
28 * $Author:: Greg_h $*
29 * *
30 * $Modtime:: 10/21/97 2:04p $*
31 * *
32 * $Revision:: 6 $*
33 * *
34 *---------------------------------------------------------------------------------------------*
35 * Functions: *
36 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
37
38
39#ifndef SKINDATA_H
40#define SKINDATA_H
41
42#include "Max.h"
43#include "namedsel.h"
44
45/*
46** InfluenceStruct - structure which stores the bone
47** influence information for a single vertex.
48*/
50{
51 /*
52 ** vertices can be influenced by up to two bones.
53 */
54 int BoneIdx[2];
55 float BoneWeight[2];
56
57 InfluenceStruct(void) { BoneIdx[0] = -1; BoneIdx[1] = -1; BoneWeight[0] = 1.0f; BoneWeight[1] = 0.0f; }
58
59 void Set_Influence(int boneidx) {
60 // TODO: make this actually let you set two bones with
61 // weighting values. Need UI to furnish this info...
62 BoneIdx[0] = boneidx;
63 }
64};
65
66
67/*
68** SkinDataClass - a class which contains the bone influence data
69** for the modifier. One of these will be hung off of the
70** ModContext...
71*/
72class SkinDataClass : public LocalModData
73{
74
75public:
76
78
79 SkinDataClass(Mesh *mesh)
80 {
81 VertSel = mesh->vertSel;
82 VertData.SetCount(mesh->getNumVerts());
83 for (int i=0; i<VertData.Count(); i++) {
84 VertData[i].BoneIdx[0] = VertData[i].BoneIdx[1] = -1;
85 VertData[i].BoneWeight[0] = 1.0f;
86 VertData[i].BoneWeight[1] = 0.0f;
87 }
88 Valid = TRUE;
89 Held = FALSE;
90 }
91
92 void Invalidate() { Valid = FALSE; }
93
94 BOOL IsValid() { return Valid; }
95
96 void Validate(Mesh *mesh)
97 {
98 if (!Valid)
99 {
100 VertSel.SetSize(mesh->vertSel.GetSize(),1);
101 VertData.SetCount(mesh->getNumVerts());
102 Valid = TRUE;
103 }
104 }
105
106 virtual LocalModData * Clone(void)
107 {
108 SkinDataClass * newdata = new SkinDataClass();
109 newdata->VertSel = VertSel;
110 newdata->VertData = VertData;
111 return newdata;
112 }
113
114 void Add_Influence(int boneidx)
115 {
116 /*
117 ** Make this INode influence all currently selected vertices
118 */
119 for (int i=0; i<VertData.Count(); i++) {
120 if (VertSel[i]) {
121 VertData[i].Set_Influence(boneidx);
122 }
123 }
124 }
125
126 IOResult Save(ISave *isave);
127 IOResult Load(ILoad *iload);
128
129public:
130
133
134 /*
135 ** Current selection
136 */
137 BitArray VertSel;
138
139 /*
140 ** Named selection sets
141 */
143
144 /*
145 ** Vertex influence data
146 */
147 Tab<InfluenceStruct> VertData;
148
149 /*
150 ** Load/Save chunk ID's
151 */
152 enum {
153 FLAGS_CHUNK = 0x0000,
154 VERT_SEL_CHUNK = 0x0010,
157 };
158
159};
160
161
162#endif
#define TRUE
Definition BaseType.h:109
#define FALSE
Definition BaseType.h:113
#define BOOL
Definition Wnd_File.h:57
NamedSelSetList VertSelSets
Definition skindata.h:142
SkinDataClass(void)
Definition skindata.h:77
BitArray VertSel
Definition skindata.h:137
void Add_Influence(int boneidx)
Definition skindata.h:114
Tab< InfluenceStruct > VertData
Definition skindata.h:147
IOResult Load(ILoad *iload)
Definition skindata.cpp:116
IOResult Save(ISave *isave)
Definition skindata.cpp:56
void Validate(Mesh *mesh)
Definition skindata.h:96
void Invalidate()
Definition skindata.h:92
SkinDataClass(Mesh *mesh)
Definition skindata.h:79
@ INFLUENCE_DATA_CHUNK
Definition skindata.h:156
@ NAMED_SEL_SETS_CHUNK
Definition skindata.h:155
BOOL IsValid()
Definition skindata.h:94
virtual LocalModData * Clone(void)
Definition skindata.h:106
float BoneWeight[2]
Definition skindata.h:55
int BoneIdx[2]
Definition skindata.h:54
void Set_Influence(int boneidx)
Definition skindata.h:59
InfluenceStruct(void)
Definition skindata.h:57