1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
|
#ifndef shaveSDKTYPES_h
#define shaveSDKTYPES_h
// Shave and a Haircut
// (c) 2019 Epic Games
// US Patent 6720962
#ifdef _WIN32
#include <windows.h>
#include <process.h>
#else
#include <pthread.h>
#endif
#ifdef __cplusplus
#ifndef USECPP
extern "C"
{
#endif
#endif
//
// constants
//
#define SHAVE_FAR_CLIP 1000000.0f
#define SHAVE_NUM_PARAMS 60
#define SHAVE_NUM_GROUPS 5
#define SHAVE_MAX_LABEL_LEN 49
#define SHAVE_VERTS_PER_GUIDE 15
#define MAX_XSI_SHAVEINSTANCES 4
typedef enum
{
kBrushTranslate,
kBrushScale,
kBrushRotate,
kBrushStand,
kBrushPuff,
kBrushClump
} BRUSH_MODE;
typedef enum
{
kShaveHostMR = 0,
kShaveHostPRMAN = 1,
kShaveHostBuffer = 2
} SHAVE_RENDER_HOST;
//**********************************************************************
//
// STANDALONE ("PRIM") API TYPES
//
// The following types are used by the standalone ("PRIM") API
// functions.
//
//**********************************************************************
// stucture for a vertex
typedef struct
{
float x, y, z;
} VERT;
typedef struct
{
//
// For normal hair, this structure contains a set of hairs. Each hair
// has a sequence of vertices which run up the middle of it.
//
// For instanced hair, this structure contains a set of faces
// representing the instanced geometry. Each face has three or more
// vertices which define its perimeter. Vertices may be shared between
// adjoining faces.
//
//
// Total number of vertices returned in the 'v' member below. If a
// vertex is shared between multiple faces then it only counts once in
// this total.
//
int totalverts;
//
// For regular hair, 'totalfaces' contains the total number of hairs.
// Note that a separate hair is generated for each "pass", so if your
// shaveNode has passes set to 3 and 5,000 hairs, then totalfaces may
// be as high as 15,000.
//
// For instanced hair, 'totalfaces' contains the total number of
// polygonal faces in the instanced geometry.
//
int totalfaces;
//
// For normal hair, this is the total number of vertices in all of the
// hairs, combined.
//
// For instanced hair, it is the total number of face-vertices. If a
// vertex is shared between faces then it counts once for each face in
// this total.
//
int totalfverts;
//
// Table to translate face-vertex indices into vertex indices, suitable
// for indexing into 'v'.
//
int *facelist;
//
// Array giving the starting position within 'facelist' for each
// hair/face's vertices. The array contains one element per hair/face.
//
int *face_start;
//
// Array giving the ending position within 'facelist' for each
// hair/face's vertices. The array contains one element per hair/face.
//
// Note that the index give is one *beyond* the index of the
// hair/face's last vertex in 'facelist'. This means that the
// following will give you the number of vertices in the hair/face:
//
// face_end[N] - face_start[N]
//
int *face_end;
//
// Opacity of each hair/face.
//
float *opacity;
//
// Specularity for each hair/face.
//
float *spec;
//
// Gloss for each hair/face.
//
float *gloss;
//
// Gloss for each ambient/diffuse ratio for each hair/face.
//
float *ambdiff;
//
// Root color for each hair (doesn't apply to faces).
//
VERT *colorroot;
//
// Tip color for each hair (doesn't apply to faces).
//
VERT *colortip;
//
// Radius of each hair at its root (doesn't apply to faces).
//
float *radiusroot;
//
// Radius of each hair at its tip (doesn't apply to faces).
//
float *radiustip;
//
// Vertices.
//
// This is an array containing the worldspace positions for 'totalfaces'
// vertices.
//
// You access the vertices for a particular hair or face as follows:
//
// int firstVert = hairType.face_start[faceOrHairNumber];
// int lastVert = hairType.face_end[faceOrHairNumber] - 1;
//
// for (i = firstVert; i <= lastVert; i++)
// {
// int vertIndex = hairType.facelist[i];
// VERT vertPosition = hairType.v[vertIndex];
// ...
// }
//
// Be sure to note the '- 1' at the end of the initialization of
// 'lastVert'. That's because the 'face_end' array actually points to
// the first vertex *beyond* the end of the given hair/face.
//
VERT *v;
//
// Velocity per vertex. Accessed in the same way as 'v'.
//
VERT *velocity;
//
// Texture parameters per vertex. Accessed in the same way as 'v'.
//
// For normal hairs, u and v represent the texture parameters of the
// point on the surface from which they are growing. 'w' is a
// parameter which runs from 0.0 at the root to 1.0 at the tip.
//
// For instanced hair, u and v represent the texture coords at each
// vertex and 'w' is unused.
//
VERT *uvw;
//
// Not currently used.
//
VERT *uvw2;
//
// Surface normal per-hair. This gives the surface normal for the
// growth surface at the point where the hair is rooted.
//
// Not used for instanced hair.
//
VERT *surfNorm; // per hair (or per hair clump) - added this on April 16, 2004
int *index; // per strand - added this on july 3, 2009
float *alpha; // per strand - added this on july 3, 2009
// VERT *spec_tint; // 6.5
// VERT *spec_tint2; // 6.5
} HAIRTYPE;
typedef struct
{
// Number of UV sets per hair root.
char totalUVSets;
// Number of hair roots for which UV set information is given.
int totalRoots;
// For internal use only.
char *channelRef;
// The UVZ values for the hair roots. There will be 'totalUVSets'
// elements for each hair root. So 'totalUVSets' elements for root 0,
// followed by 'totalUVSets' elements for root 1, etc.
VERT *uvRoot;
} UVSETS;
//**********************************************************************
//
// INTERNAL STRUCTURES
//
// The remaining structures are internal to Shave and have no meaning
// within the standalone API.
//
//**********************************************************************
// simple data type for holding geometry
typedef struct
{
int totalverts;
int totalfaces;
int totalfverts;
int *facelist; // list of face verts
int *face_start; // face refferenced index into facelist
int *face_end; // face refferenced index into facelist
VERT *color; // vert refferenced color
VERT *v; // vert refferenced vertex position
VERT *velocity; // vertex velocity
VERT *uv; // vert refferenced uv info (x,y)
VERT *vn; // vert normals
float *alpha; // 3.9
int *id; // using this to store the hair or poly ID - facewise
float *r1,*r2; // face refferenced index into radius root and tip
int *index; // this is the index which includes passes and clones
// coming soon for subdivs
// int *pid; // facevert refferenced, same size as *facelist
// VERT *bary; // facevert refferenced, same size as *facelist
// pid reffers to the original face (after triangulaiton)
// bary reffers to vert weights on that original triangle
} WFTYPE;
typedef struct
{
WFTYPE mesh;
VERT *baryweights; // 1 per facevert
int *baryface; // 1 per face
} SUBDIVTYPE;
typedef struct
{
VERT guide[SHAVE_VERTS_PER_GUIDE];
VERT velocity[SHAVE_VERTS_PER_GUIDE];
int select[SHAVE_VERTS_PER_GUIDE];
int lock[SHAVE_VERTS_PER_GUIDE];
float weight[SHAVE_VERTS_PER_GUIDE]; // new for 4.0
float cut_value; // new for 4.0
int splitgroup;
int merge;
int vid;
VERT norm;
int zerosize;
int hidden; // new for 4.0
} SOFTGUIDE;
// settings parameters for hair groups
// [0]=hair
// [1]=beard
// [2]=eyebrows
// [3]=eyelashes
// [4]=splines
// this type contains general shave engine info
typedef struct
{
int haircount[SHAVE_NUM_GROUPS+1]; // # of hairs to be generated for each group
int passes[SHAVE_NUM_GROUPS+1]; // number of passes to generated
float slider_val[SHAVE_NUM_PARAMS][SHAVE_NUM_GROUPS + 1]; // slider settings
char slider_lable[SHAVE_NUM_PARAMS][SHAVE_NUM_GROUPS + 1][SHAVE_MAX_LABEL_LEN + 1]; // slider labels
int painted[SHAVE_NUM_PARAMS][SHAVE_NUM_GROUPS + 1]; // 1=has weight painting 0= no weight painting
int total_guides; // total # guide hairs
int instancing_status;
int collide[SHAVE_NUM_GROUPS + 1]; // collision on/off
int collision_method; // 0 = spheres 1 = surfaces
VERT frizz_anim_dir[SHAVE_NUM_GROUPS + 1]; // 0 = x 1 = y 2 = z
int segs[SHAVE_NUM_GROUPS + 1];
int dontinterpolate;
float geom_shadow;
int shadowHaircount[5]; // 2.7v51
int uv_link[60]; // 2.7v53
char name[64];
int tipfade;
float multrot; // 4.0 - this is for twist on mult hairs
VERT spec_tint; // 4.0 - this is for rendering
float springyness; // 4.0 - this is for dyn
float multrot_phase; // 4.0
float multrot_offset; // 4.0
int squirrel; // 5.5
float flyaway_percent; // 6.0
// int use_old_splayscale;
int clumps;
int rand_seed_offset;
VERT spec_tint2; // 6.0.39 - this is for rendering
} SHAVEPARMS;
// opaque multi-use data type
typedef struct
{
long size;
long pos;
char *data;
int ID;
int time;
} MEMFILE;
typedef struct
{
MEMFILE restMEM;
MEMFILE statMEM;
SHAVEPARMS shavep;
} SHAVENODE;
typedef float Matrix[4][4];
typedef struct
{
int Tpid; // face ID (after triangulation)
int UTpid; // faceID (with no triangulation)
int pntid[3]; // point IDs
float wgt[3]; // point weights
float baserad; // the base radius
float tiprad; // the tip radius
Matrix rest2zero[SHAVE_VERTS_PER_GUIDE]; // matricies for points on the guides
Matrix zero2world[SHAVE_VERTS_PER_GUIDE];
float u, v; // interpolated uv coords
VERT norm; // interpolated surface normal
float diff, spec, kspec, shad; // some render params
int killme; // some times empty hairs will get returned (for point count consistancy)
// because they've been 'killed' by densemaps, cutmaps, etc - this will let
// you know: killme=1
float ambient;
int mtl;
float restlength;
float cutlength;
int hairID;
int groupID;
unsigned long nodeID;
int depthpass;
float u2, v2; // 2.6v22
int shadowHair; // 2.7v51
VERT UV[60]; // 2.7v53
unsigned long shaveID; // 6.0
VERT spec_tint;
VERT spec_tint2;
} CURVEINFO;
// this stucture gets returned from make_a_curve, and make_a_curveROOT and contains
// all kinds of non vertex info.
typedef struct
{
VERT color;
VERT velocity;
float distance;
float opacity;
} VOXSAMP;
//
// Type for functions passed to SHAVEstart_thread().
//
// Note that 'threadID' is a Shave-specific ID ranging from 0 to one less
// than the number of threads in the thread group. It bears no
// relationship to any operating system thread ID.
//
typedef void ( *ThreadFunc ) ( unsigned threadID, void *data );
//
// Type for mutexes (mutual exclusions), used for locking.
//
#ifdef _WIN32
typedef HANDLE ShaveMutex;
#else
typedef pthread_mutex_t ShaveMutex;
#endif
//
// Type for conditions, used with mutexes for locking.
//
#ifdef _WIN32
typedef HANDLE ShaveCond;
#else
typedef pthread_cond_t ShaveCond;
#endif
#ifdef __cplusplus
#ifndef USECPP
}
#endif
#endif
#endif
|