Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
skin.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 : Commando Tools - WWSkin *
24 * *
25 * $Archive:: /Commando/Code/Tools/max2w3d/skin.h $*
26 * *
27 * $Author:: Moumine_ballo $*
28 * *
29 * $Modtime:: 4/18/01 11:31a $*
30 * *
31 * $Revision:: 8 $*
32 * *
33 *---------------------------------------------------------------------------------------------*
34 * Functions: *
35 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
36
37
38#ifndef SKIN_H
39#define SKIN_H
40
41#include <Max.h>
42#include "simpmod.h"
43#include "simpobj.h"
44#include "bpick.h"
45#include "namedsel.h"
46#include "w3d_file.h"
47
48
49#define SKIN_OBJ_CLASS_ID Class_ID(0x32b37e0c, 0x5a9612e4)
50#define SKIN_MOD_CLASS_ID Class_ID(0x6bad4898, 0x0d1d6ced)
51extern ClassDesc * Get_Skin_Obj_Desc();
52extern ClassDesc * Get_Skin_Mod_Desc();
53
54
55/*
56
57 Writing a space warp plug-in involves creating instances of two key classes.
58 One is derived from class WSMObject. (WSMObject stands for Word Space Modifier Object,
59 just another name for Space Warp Object). The other class is subclassed off Modifier.
60 These two classes work together. The space warp object handles the display and management
61 of its user interface parameters, the display of the space warp node in the scene, and
62 provides a world space orientation. The space warp modifier handles the actual deformation
63 of the geometry of nodes bound to the space warp. Each node bound to the space warp
64 will have a ModContext which we will store data in.
65
66 The following class is the WSMObject for the westwood skin modifier.
67
68*/
69class SkinWSMObjectClass : public SimpleWSMObject, BonePickerUserClass
70{
71public:
72
74 virtual ~SkinWSMObjectClass();
75
76 /*
77 ** From Animatable
78 */
79 void DeleteThis() { delete this; }
80 void BeginEditParams(IObjParam *ip, ULONG flags,Animatable *prev);
81 void EndEditParams(IObjParam *ip, ULONG flags,Animatable *next);
82 TCHAR * GetObjectName() { return _T("WWSkin"); }
83 Class_ID ClassID() { return SKIN_OBJ_CLASS_ID; }
84
85 /*
86 ** From ReferenceTarget
87 */
88 RefTargetHandle Clone(RemapDir& remap = NoRemap());
89
90 /*
91 ** From Reference Maker. These three functions give access to the "virtual array" of references.
92 ** For SkinWSMObjectClass, we have to remember that SimpleWSMObject already has a reference
93 ** so we are taking ours on after
94 */
95 virtual int NumRefs() { return SimpleWSMObject::NumRefs() + Num_Bones();}
96 virtual RefTargetHandle GetReference(int i);
97 virtual void SetReference(int i, RefTargetHandle rtarg);
98 RefResult NotifyRefChanged(Interval changeInt,RefTargetHandle hTarget,PartID& partID, RefMessage message);
99
100 /*
101 ** From Object
102 */
103 int DoOwnSelectHilite() { return TRUE; }
104 CreateMouseCallBack * GetCreateMouseCallBack();
105
106 /*
107 ** From WSMObject
108 */
109 Modifier *CreateWSMMod(INode *node);
110
111 /*
112 ** From SimpleWSMObject
113 */
114 void BuildMesh(TimeValue t);
115
116 /*
117 ** Setup a triangle
118 */
119 void Build_Tri(Face * f, int a, int b, int c);
120
121 /*
122 ** Dialog box message processing
123 */
124 BOOL SkinWSMObjectClass::Skeleton_Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam);
125
126 /*
127 ** Bone picking.
128 */
129 virtual void User_Picked_Bone(INode * node);
130 virtual void User_Picked_Bones(INodeTab & nodetab);
131 void Set_Bone_Selection_Mode(int mode);
132
133 int Add_Bone(INode * node);
134 void Add_Bones(INodeTab & nodetab);
135 void Remove_Bone(INode * node);
136 void Remove_Bones(INodeTab & nodetab);
137 void Update_Bone_List(void);
138
139 /*
140 ** Converting between bone indexes and reference indexes
141 ** The bone references are a variable number of references which are
142 ** added at the end of the reference array.
143 */
144 int To_Bone_Index(int refidx) { return refidx - SimpleWSMObject::NumRefs(); }
145 int To_Ref_Index(int boneidx) { return SimpleWSMObject::NumRefs() + boneidx; }
146
147 /*
148 ** External access to the bones
149 */
150 int Num_Bones(void) { return BoneTab.Count(); }
151 INode * Get_Bone(int idx) { return BoneTab[idx]; }
152 INodeTab & Get_Bone_List(void) { return BoneTab; }
153 int Find_Bone(INode * node);
154 int Get_Base_Pose_Frame(void) { return BasePoseFrame; }
155 int Get_Base_Pose_Time(void) { return BasePoseFrame * GetTicksPerFrame(); }
156 int Find_Closest_Bone(const Point3 & vertex);
157
158 /*
159 ** Saving and loading.
160 */
161 IOResult Save(ISave *isave);
162 IOResult Load(ILoad *iload);
163
164 /*
165 ** Static UI variables. These have to be static due to the strange way
166 ** that MAX behaves during creation of objects. If you create an object
167 ** then delete it, EndEditParams is not called and its destructor isn't called...
168 */
169 static HWND SotHWND;
170 static HWND SkeletonHWND;
171 static HWND BoneListHWND;
172 static IObjParam * InterfacePtr;
173 static ICustButton * AddBonesButton;
174 static ICustButton * RemoveBonesButton;
175 static ISpinnerControl * BasePoseSpin;
176
177 /*
178 ** flag for whether we need to build the bones mesh for this object
179 */
181
182 /*
183 ** Bone Selection!
184 */
185 enum {
191 };
192
194 INodeTab BoneTab;
195
196 /*
197 ** Dialog controls
198 */
200
201 /*
202 ** Chunk ID's
203 */
204 enum {
206 };
207
208 /*
209 ** Friend functions
210 */
211 friend BOOL CALLBACK _skeleton_dialog_thunk(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam);
212};
213
214/*
215** SkinModifierClass
216*/
218{
219
220public:
221
222 SkinModifierClass(void);
223 SkinModifierClass(INode * node,SkinWSMObjectClass * skin_obj);
224#if defined W3D_MAX4 //defined as in the project (.dsp)
225 ISubObjType *GetSubObjType(int i);
226 int NumSubObjTypes();
227#endif
228 void Default_Init(void);
229
230 /*
231 ** From Animatable
232 */
233 void DeleteThis() { delete this; }
234 void GetClassName(TSTR& s) { s = TSTR(_T("WWSkin")); }
235 TCHAR * GetObjectName() { return _T("WWSkin Binding"); }
236 SClass_ID SuperClassID() { return WSM_CLASS_ID; }
237 Class_ID ClassID() { return SKIN_MOD_CLASS_ID; }
238 RefTargetHandle Clone(RemapDir& remap = NoRemap());
239 RefResult NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message);
240 void BeginEditParams(IObjParam *ip, ULONG flags,Animatable *prev);
241 void EndEditParams(IObjParam *ip, ULONG flags,Animatable *next);
242 CreateMouseCallBack * GetCreateMouseCallBack() { return NULL; }
243
244 /*
245 ** From Reference Maker. These three functions give access to the "virtual array" of references.
246 */
247 int NumRefs() { return 2; }
248 RefTargetHandle GetReference(int i);
249 void SetReference(int i, RefTargetHandle rtarg);
250
251 /*
252 ** Tell MAX what channels we use and what channels we change:
253 ** Note that if we do not tell max that we use a channel, that channel is not
254 ** guaranteed to be valid.
255 */
256 virtual ChannelMask ChannelsUsed() { return SELECT_CHANNEL|SUBSEL_TYPE_CHANNEL|GEOM_CHANNEL; }
257 virtual ChannelMask ChannelsChanged() { return SELECT_CHANNEL|SUBSEL_TYPE_CHANNEL|GEOM_CHANNEL; }
258
259 /*
260 ** MAX tells us whenever an input changed. If we cache anything, we can use this
261 ** function to dump the cached data and regenerate it.
262 */
263 virtual void NotifyInputChanged(Interval changeInt, PartID partID, RefMessage message, ModContext *mc) {}
264
265 /*
266 ** This is where the modifier actually modifies the object!
267 */
268 virtual void ModifyObject(TimeValue t, ModContext & mc, ObjectState * os, INode * node);
269
270 /*
271 ** Since our modifier will be storing information based on the vertex indices, whenever
272 ** the topology of its input is changed things will no longer work correctly. Therefore,
273 ** we tell max that we depend on the topology remaining the same.
274 */
275 virtual BOOL DependOnTopology(ModContext &mc) { return TRUE; }
276
277 /*
278 ** What types of objects can we modify: The skin modifier will only work with TRIOBJ's
279 */
280 virtual Class_ID InputType() { return Class_ID(TRIOBJ_CLASS_ID,0); }
281
282 /*
283 ** Saving and loading. Remember to call the base class's save and load functions as well.
284 */
285 IOResult Save(ISave *isave);
286 IOResult Load(ILoad *iload);
287 virtual IOResult LoadLocalData(ILoad *iload, LocalModData **pld);
288 virtual IOResult SaveLocalData(ISave *isave, LocalModData *ld);
289
290 /*
291 ** For SkinModifierClass, we allow vertex sub-object selection.
292 ** This function notifies an object being edited that the current sub object
293 ** selection level has changed. level==0 indicates object level selection.
294 ** level==1 or greater refer to the types registered by the object in the
295 ** order they appeared in the list when registered. If level >= 1, the object
296 ** should specify sub-object xform modes in the modes structure (defined in cmdmode.h).
297 */
298 void ActivateSubobjSel(int level, XFormModes& modes);
299
300 int HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt, ModContext* mc);
301 void SelectSubComponent(HitRecord *hitRec, BOOL selected, BOOL all, BOOL invert=FALSE);
302 void ClearSelection(int selLevel);//
303 void SelectAll(int selLevel);
304 void InvertSelection(int selLevel);
305
306 /*
307 ** An object that supports sub-object selection can choose to
308 ** support named sub object selection sets. Methods in the the
309 ** interface passed to objects allow them to add items to the
310 ** sub-object selection set drop down.
311 ** The following methods implement named sub-obj selection sets
312 */
313 virtual BOOL SupportsNamedSubSels() { return TRUE; }
314 virtual void ActivateSubSelSet(TSTR &setName);
315 virtual void NewSetFromCurSel(TSTR &setName);
316 virtual void RemoveSubSelSet(TSTR &setName);
319
320 WSMObject * Get_WSMObject(void) { return (WSMObject*)GetReference(OBJ_REF); }
321 Interval Get_Validity(TimeValue t);
322
323 /*
324 ** Bone picking
325 */
326 virtual void User_Picked_Bone(INode * node);
327 virtual void User_Picked_Bones(INodeTab & nodetab);
328
329 /*
330 ** Auto-Attach vertices to nearest bone
331 */
332 void Auto_Attach_Verts(BOOL all = FALSE);
333
334 /*
335 ** Unlink selected verts (links them to the root or origin)
336 */
337 void Unlink_Verts(void);
338
339private:
340
341 /*
342 ** Windows dialog management and communication functions
343 */
344 void Install_Bone_Influence_Dialog(void);
345 void Remove_Bone_Influence_Dialog(void);
346
347 BOOL Bone_Influence_Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam);
348
349public:
350
351 /*
352 ** References for SkinModifierClass
353 */
354 enum {
357 };
358
360 INode * WSMNodeRef;
361
362 /*
363 ** Sub-Object Selection variables
364 */
365 enum {
368 };
369
371
372
373 /*
374 ** Bone Influence Dialog panel variables
375 */
377 ICustButton * LinkButton;
378 ICustButton * LinkByNameButton;
379 ICustButton * AutoLinkButton;
380 ICustButton * UnLinkButton;
381
382 /*
383 ** Cached pointers to some MAX objects
384 */
385 IObjParam * InterfacePtr;
386 SelectModBoxCMode * SelectMode;
387
388 /*
389 ** Load/Save Chunk ID's
390 */
391 enum {
393 };
394
395 /*
396 ** Friend "thunking" functions for the dialog handling.
397 */
398 friend BOOL CALLBACK _bone_influence_dialog_thunk(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam);
399};
400
401
402
403
404#endif
405
#define NULL
Definition BaseType.h:92
#define TRUE
Definition BaseType.h:109
#define FALSE
Definition BaseType.h:113
unsigned int UINT
Definition bittype.h:63
unsigned long ULONG
Definition bittype.h:64
#define BOOL
Definition Wnd_File.h:57
virtual void User_Picked_Bones(INodeTab &nodetab)
Definition skin.cpp:1327
void Create_Named_Selection_Sets(void)
Definition skin.cpp:1395
void EndEditParams(IObjParam *ip, ULONG flags, Animatable *next)
Definition skin.cpp:676
void InvertSelection(int selLevel)
Definition skin.cpp:1226
IObjParam * InterfacePtr
Definition skin.h:385
void BeginEditParams(IObjParam *ip, ULONG flags, Animatable *prev)
Definition skin.cpp:642
void SetReference(int i, RefTargetHandle rtarg)
Definition skin.cpp:739
SkinModifierClass(void)
Definition skin.cpp:599
void DeleteThis()
Definition skin.h:233
virtual void ActivateSubSelSet(TSTR &setName)
Definition skin.cpp:1338
virtual BOOL DependOnTopology(ModContext &mc)
Definition skin.h:275
virtual Class_ID InputType()
Definition skin.h:280
virtual ChannelMask ChannelsUsed()
Definition skin.h:256
void Install_Named_Selection_Sets(void)
Definition skin.cpp:1442
virtual void RemoveSubSelSet(TSTR &setName)
Definition skin.cpp:1390
virtual BOOL SupportsNamedSubSels()
Definition skin.h:313
virtual void NewSetFromCurSel(TSTR &setName)
Definition skin.cpp:1385
int SubObjSelLevel
Definition skin.h:370
int NumRefs()
Definition skin.h:247
SelectModBoxCMode * SelectMode
Definition skin.h:386
RefTargetHandle Clone(RemapDir &remap=NoRemap())
Definition skin.cpp:635
RefTargetHandle GetReference(int i)
Definition skin.cpp:730
void SelectSubComponent(HitRecord *hitRec, BOOL selected, BOOL all, BOOL invert=FALSE)
Definition skin.cpp:1067
ICustButton * LinkByNameButton
Definition skin.h:378
ICustButton * LinkButton
Definition skin.h:377
INode * WSMNodeRef
Definition skin.h:360
friend BOOL CALLBACK _bone_influence_dialog_thunk(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition skin.cpp:1754
virtual void NotifyInputChanged(Interval changeInt, PartID partID, RefMessage message, ModContext *mc)
Definition skin.h:263
SkinWSMObjectClass * WSMObjectRef
Definition skin.h:359
WSMObject * Get_WSMObject(void)
Definition skin.h:320
SClass_ID SuperClassID()
Definition skin.h:236
virtual IOResult SaveLocalData(ISave *isave, LocalModData *ld)
Definition skin.cpp:923
virtual void ModifyObject(TimeValue t, ModContext &mc, ObjectState *os, INode *node)
Definition skin.cpp:766
Interval Get_Validity(TimeValue t)
Definition skin.cpp:708
virtual IOResult LoadLocalData(ILoad *iload, LocalModData **pld)
Definition skin.cpp:930
void Default_Init(void)
Definition skin.cpp:620
RefResult NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID &partID, RefMessage message)
Definition skin.cpp:747
void GetClassName(TSTR &s)
Definition skin.h:234
HWND BoneInfluenceHWND
Definition skin.h:376
IOResult Save(ISave *isave)
Definition skin.cpp:878
CreateMouseCallBack * GetCreateMouseCallBack()
Definition skin.h:242
IOResult Load(ILoad *iload)
Definition skin.cpp:894
void Unlink_Verts(void)
Definition skin.cpp:1528
ICustButton * UnLinkButton
Definition skin.h:380
ICustButton * AutoLinkButton
Definition skin.h:379
Class_ID ClassID()
Definition skin.h:237
int HitTest(TimeValue t, INode *inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt, ModContext *mc)
Definition skin.cpp:993
void SelectAll(int selLevel)
Definition skin.cpp:1172
void Auto_Attach_Verts(BOOL all=FALSE)
Definition skin.cpp:1465
virtual ChannelMask ChannelsChanged()
Definition skin.h:257
void ClearSelection(int selLevel)
Definition skin.cpp:1116
TCHAR * GetObjectName()
Definition skin.h:235
virtual void User_Picked_Bone(INode *node)
Definition skin.cpp:1284
void ActivateSubobjSel(int level, XFormModes &modes)
Definition skin.cpp:947
static HWND SotHWND
Definition skin.h:169
RefResult NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID &partID, RefMessage message)
Definition skin.cpp:287
void Remove_Bone(INode *node)
Definition skin.cpp:475
int Get_Base_Pose_Time(void)
Definition skin.h:155
static ISpinnerControl * BasePoseSpin
Definition skin.h:175
virtual ~SkinWSMObjectClass()
Definition skin.cpp:160
static ICustButton * RemoveBonesButton
Definition skin.h:174
@ BONE_SEL_MODE_ADD_MANY
Definition skin.h:189
@ BONE_SEL_MODE_REMOVE_MANY
Definition skin.h:190
IOResult Save(ISave *isave)
Definition skin.cpp:521
TCHAR * GetObjectName()
Definition skin.h:82
int To_Ref_Index(int boneidx)
Definition skin.h:145
virtual void User_Picked_Bone(INode *node)
Definition skin.cpp:372
virtual void SetReference(int i, RefTargetHandle rtarg)
Definition skin.cpp:275
void Set_Bone_Selection_Mode(int mode)
Definition skin.cpp:412
int DoOwnSelectHilite()
Definition skin.h:103
void BeginEditParams(IObjParam *ip, ULONG flags, Animatable *prev)
Definition skin.cpp:177
int BoneSelectionMode
Definition skin.h:193
INodeTab & Get_Bone_List(void)
Definition skin.h:152
void Add_Bones(INodeTab &nodetab)
Definition skin.cpp:465
int Find_Closest_Bone(const Point3 &vertex)
Definition skin.cpp:571
static HWND BoneListHWND
Definition skin.h:171
Modifier * CreateWSMMod(INode *node)
Definition skin.cpp:320
friend BOOL CALLBACK _skeleton_dialog_thunk(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition skin.cpp:1645
void Remove_Bones(INodeTab &nodetab)
Definition skin.cpp:484
BOOL Skeleton_Dialog_Proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition skin.cpp:1658
static ICustButton * AddBonesButton
Definition skin.h:173
int Add_Bone(INode *node)
Definition skin.cpp:429
int Find_Bone(INode *node)
Definition skin.cpp:513
void BuildMesh(TimeValue t)
Definition skin.cpp:328
void EndEditParams(IObjParam *ip, ULONG flags, Animatable *next)
Definition skin.cpp:219
static IObjParam * InterfacePtr
Definition skin.h:172
static HWND SkeletonHWND
Definition skin.h:170
virtual RefTargetHandle GetReference(int i)
Definition skin.cpp:258
virtual void User_Picked_Bones(INodeTab &nodetab)
Definition skin.cpp:392
INodeTab BoneTab
Definition skin.h:194
IOResult Load(ILoad *iload)
Definition skin.cpp:538
virtual int NumRefs()
Definition skin.h:95
Class_ID ClassID()
Definition skin.h:83
RefTargetHandle Clone(RemapDir &remap=NoRemap())
Definition skin.cpp:249
int Get_Base_Pose_Frame(void)
Definition skin.h:154
int Num_Bones(void)
Definition skin.h:150
void Update_Bone_List(void)
Definition skin.cpp:494
INode * Get_Bone(int idx)
Definition skin.h:151
int To_Bone_Index(int refidx)
Definition skin.h:144
void DeleteThis()
Definition skin.h:79
void Build_Tri(Face *f, int a, int b, int c)
Definition skin.cpp:365
CreateMouseCallBack * GetCreateMouseCallBack()
Definition skin.cpp:310
#define SKIN_OBJ_CLASS_ID
Definition skin.h:49
#define SKIN_MOD_CLASS_ID
Definition skin.h:50
ClassDesc * Get_Skin_Mod_Desc()
Definition skin.cpp:114
ClassDesc * Get_Skin_Obj_Desc()
Definition skin.cpp:93