forked from code-google-com/stretchmesh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
curveColliderLocator.cpp
587 lines (507 loc) · 19.6 KB
/
curveColliderLocator.cpp
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
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
#include "curveColliderLocator.h"
#include <maya/MGlobal.h>
#include <maya/MFnNumericAttribute.h>
#include <maya/MPlugArray.h>
#include <maya/MFnTypedAttribute.h>
#include <maya/MFnNurbsCurve.h>
#include <maya/MQuaternion.h>
#include <maya/MFnMatrixAttribute.h>
#include <maya/MDagPath.h>
#include <maya/MMatrix.h>
#include <maya/MPointArray.h>
#ifndef M_PI
#include <math.h>
#endif
#include "ksUtils.h"
#include "IncludeMFnPluginClass.h"
#include "CRSpline.h"
#if defined(OSMac_MachO_)
#include <OpenGL/glu.h>
#else
#include <GL/glu.h>
#endif
MTypeId curveColliderLocator::id( 0x00113001 );
MObject curveColliderLocator::colliderCurveIn;
MObject curveColliderLocator::colliderRadiusIn;
MObject curveColliderLocator::colliderXform;
MObject curveColliderLocator::colliderColorR;
MObject curveColliderLocator::colliderColorG;
MObject curveColliderLocator::colliderColorB;
MObject curveColliderLocator::colliderTransparency;
bool curveColliderLocator::Registered = false;
curveColliderLocator::curveColliderLocator()
{}
curveColliderLocator::~curveColliderLocator()
{}
MStatus curveColliderLocator::compute(const MPlug &plug, MDataBlock &data)
{
return MS::kUnknownParameter;
}
void curveColliderLocator::draw(M3dView &view, const MDagPath &path,
M3dView::DisplayStyle style,
M3dView::DisplayStatus status)
{
//
// Get the input curve
//
MObject thisNode = thisMObject();
MPlug radiusPlug(thisNode, colliderRadiusIn);
MPlug colorPlugR(thisNode, colliderColorR);
MPlug colorPlugG(thisNode, colliderColorG);
MPlug colorPlugB(thisNode, colliderColorB);
MPlug colorPlugT(thisNode, colliderTransparency);
MPlug radiusElement;
double radius;
double radius2;
double param;
double param2;
double paramNorm;
radiusPlug.getValue(radius);
MStatus stat;
MQuaternion rotateQuat;
double degreesToRadians = ( M_PI/ 180.0 );
double radiansToDegrees = ( 180.0/M_PI );
double rotateRadians;
MVector crvNormalRotated;
MPointArray radiusPts;
MPoint radiusPt;
// Alternate method of getting the MFnNurbsCurve:
MPlug curvePlug(thisNode, colliderCurveIn);
MPlugArray inputCrvArray;
curvePlug.connectedTo(inputCrvArray, true, false);
MObject crvColliderObj = inputCrvArray[0].node();
MFnNurbsCurve cColliderFn(crvColliderObj, &stat);
if(!stat){
MGlobal::displayInfo(MString("Error creating MFnNurbsCurve for collider curve"));
return;
}
MFnDagNode crvDagNode(crvColliderObj);
MDagPath crvDagPath;
crvDagNode.getPath(crvDagPath);
MMatrix crvXform = crvDagPath.inclusiveMatrix();
int numSpans = cColliderFn.numSpans();
MPoint crvPoint;
MPoint crvPoint2;
GLUquadricObj* qobj = gluNewQuadric();
view.beginGL();
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// DRAW SMOOTH SHADED
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
if ( ( style == M3dView::kFlatShaded ) || ( style == M3dView::kGouraudShaded ) ) {
glPushAttrib( GL_ALL_ATTRIB_BITS );
glShadeModel(GL_SMOOTH);
glEnable(GL_LIGHTING);
glEnable(GL_BLEND);
glEnable(GL_LIGHT0);
glMatrixMode( GL_MODELVIEW );
float3 color;
colorPlugR.getValue(color[0]);
colorPlugG.getValue(color[1]);
colorPlugB.getValue(color[2]);
float transparency;
colorPlugT.getValue(transparency);
float diffuse[] = {color[0], color[1], color[2], transparency};
float specular[] = { 0.7f, 0.7f, 0.7f, transparency};
float shine[] = { 100.0f };
float ambient[] = { 0.2f, 0.2f, 0.2f, transparency };
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular);
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, shine);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient);
// Draw the beginning and ending sphere caps
glPushMatrix();
cColliderFn.getPointAtParam(0, crvPoint, MSpace::kWorld);
crvPoint = crvPoint*crvXform;
glTranslatef(crvPoint.x, crvPoint.y, crvPoint.z);
radiusElement = radiusPlug.elementByPhysicalIndex(0, &stat);
radiusElement.getValue(radius);
gluSphere(qobj, radius, 16, 16);
glPopMatrix();
glPushMatrix();
cColliderFn.getPointAtParam(numSpans, crvPoint, MSpace::kWorld);
crvPoint = crvPoint*crvXform;
glTranslatef(crvPoint.x, crvPoint.y, crvPoint.z);
radiusElement = radiusPlug.elementByPhysicalIndex( (radiusPlug.numElements() - 1), &stat);
radiusElement.getValue(radius);
gluSphere(qobj, radius, 16, 16);
glPopMatrix();
int numStacks = numSpans*30;
int numSlices = 32;
// Initialize our point array with the radius values
radiusPts.clear();
radiusPts.setLength(radiusPlug.numElements());
for(int radiusItr = 0; radiusItr < radiusPlug.numElements(); radiusItr++){
radiusElement = radiusPlug.elementByPhysicalIndex(radiusItr, &stat);
if(!stat){MGlobal::displayError(MString("Could not get radius element.")); return;}
radiusElement.getValue(radius);
radiusPt.x = (double)radius; radiusPt.y = 0.0; radiusPt.z = 0.0;
radiusPts[radiusItr] = radiusPt;
}
if(numStacks>1){
for(uint crvItr = 0; crvItr < numStacks - 1; crvItr++){
param = (float(crvItr)/float(numStacks-1))*numSpans;
param2 = (float(crvItr+1)/float(numStacks-1))*numSpans;
cColliderFn.getPointAtParam(param, crvPoint, MSpace::kWorld);
crvPoint = crvPoint*crvXform;
cColliderFn.getPointAtParam(param2, crvPoint2, MSpace::kWorld);
crvPoint2 = crvPoint2 * crvXform;
// Determine the radius value
int lastRadiusIndex = radiusPlug.numElements() - 1;
if(lastRadiusIndex == 0){
radiusElement = radiusPlug.elementByPhysicalIndex(0, &stat);
if(!stat){MGlobal::displayError(MString("Could not get radius element.")); return;}
radiusElement.getValue(radius);
radius2 = radius;
}else if(lastRadiusIndex > 0){
paramNorm = param/numSpans;
radiusPt = getInterpolatedSplinePoint(paramNorm, radiusPts);
radius = radiusPt.x;
paramNorm = param2/numSpans;
radiusPt = getInterpolatedSplinePoint(paramNorm, radiusPts);
radius2 = radiusPt.x;
}
// First, we need to determine our starting position by travelling along the normal
MVector crvNormal = cColliderFn.normal(param, MSpace::kWorld);
crvNormal = crvNormal * crvXform;
MVector crvTangent = cColliderFn.tangent(param, MSpace::kWorld);
crvTangent = crvTangent * crvXform;
crvNormal.normalize();
crvTangent.normalize();
MVector crvNormal2 = cColliderFn.normal(param2, MSpace::kWorld);
crvNormal2 = crvNormal2 * crvXform;
MVector crvTangent2 = cColliderFn.tangent(param2, MSpace::kWorld);
crvTangent2 = crvTangent2 * crvXform;
crvNormal2.normalize();
crvTangent2.normalize();
// glTranslatef(crvNormal.x, crvNormal.y, crvNormal.z);
glBegin(GL_QUADS);
for(int sliceItr = 0; sliceItr < numSlices; sliceItr++){
// quad vertex 4
rotateRadians = ((((float)sliceItr+1)/numSlices)*360)*degreesToRadians;
rotateQuat.setAxisAngle(crvTangent, rotateRadians);
crvNormalRotated = crvNormal.rotateBy(rotateQuat);
glNormal3f(crvNormalRotated.x, crvNormalRotated.y, crvNormalRotated.z );
glVertex3f((float)crvPoint.x + (crvNormalRotated.x*radius),
(float)crvPoint.y + (crvNormalRotated.y*radius),
(float)crvPoint.z + (crvNormalRotated.z*radius));
// quad vertex 3
rotateRadians = ((((float)sliceItr+1)/numSlices)*360)*degreesToRadians;
rotateQuat.setAxisAngle(crvTangent2, rotateRadians);
crvNormalRotated = crvNormal.rotateBy(rotateQuat);
glNormal3f(crvNormalRotated.x, crvNormalRotated.y, crvNormalRotated.z );
glVertex3f((float)crvPoint2.x + (crvNormalRotated.x*radius2),
(float)crvPoint2.y + (crvNormalRotated.y*radius2),
(float)crvPoint2.z + (crvNormalRotated.z*radius2));
// quad vertex 2
rotateRadians = (((float)sliceItr/numSlices)*360)*degreesToRadians;
rotateQuat.setAxisAngle(crvTangent2, rotateRadians);
crvNormalRotated = crvNormal.rotateBy(rotateQuat);
glNormal3f(crvNormalRotated.x, crvNormalRotated.y, crvNormalRotated.z );
glVertex3f((float)crvPoint2.x + (crvNormalRotated.x*radius2),
(float)crvPoint2.y + (crvNormalRotated.y*radius2),
(float)crvPoint2.z + (crvNormalRotated.z*radius2));
// quad vertex 1
rotateRadians = (((float)sliceItr/numSlices)*360)*degreesToRadians;
rotateQuat.setAxisAngle(crvTangent, rotateRadians);
crvNormalRotated = crvNormal.rotateBy(rotateQuat);
glNormal3f(crvNormalRotated.x, crvNormalRotated.y, crvNormalRotated.z );
glVertex3f((float)crvPoint.x + (crvNormalRotated.x*radius),
(float)crvPoint.y + (crvNormalRotated.y*radius),
(float)crvPoint.z + (crvNormalRotated.z*radius));
}
glEnd();
}
}
glPopAttrib();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// END SMOOTH SHADED
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// DRAW WIREFRAME
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
if ( style == M3dView::kWireFrame || status == M3dView::kActive || status == M3dView::kLead) {
glPushAttrib( GL_ALL_ATTRIB_BITS );
// Draw the beginning and ending sphere caps
// Quadrilateral strips
glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
glPushMatrix();
cColliderFn.getPointAtParam(0, crvPoint, MSpace::kWorld);
crvPoint = crvPoint*crvXform;
glTranslatef(crvPoint.x, crvPoint.y, crvPoint.z);
radiusElement = radiusPlug.elementByPhysicalIndex(0, &stat);
radiusElement.getValue(radius);
gluSphere(qobj, radius, 16, 16);
glPopMatrix();
glPushMatrix();
cColliderFn.getPointAtParam(numSpans, crvPoint, MSpace::kWorld);
crvPoint = crvPoint*crvXform;
glTranslatef(crvPoint.x, crvPoint.y, crvPoint.z);
radiusElement = radiusPlug.elementByPhysicalIndex( (radiusPlug.numElements() - 1), &stat);
radiusElement.getValue(radius);
gluSphere(qobj, radius, 16, 16);
glPopMatrix();
int numStacks = numSpans*10;
int numSlices = 32;
// Initialize our point array with the radius values
radiusPts.clear();
radiusPts.setLength(radiusPlug.numElements());
for(int radiusItr = 0; radiusItr < radiusPlug.numElements(); radiusItr++){
radiusElement = radiusPlug.elementByPhysicalIndex(radiusItr, &stat);
if(!stat){MGlobal::displayError(MString("Could not get radius element.")); return;}
radiusElement.getValue(radius);
radiusPt.x = (double)radius; radiusPt.y = 0.0; radiusPt.z = 0.0;
radiusPts[radiusItr] = radiusPt;
}
for(uint crvItr = 0; crvItr < numStacks; crvItr++){
param = (float(crvItr)/float(numStacks))*numSpans;
param2 = (float(crvItr+1)/float(numStacks))*numSpans;
cColliderFn.getPointAtParam(param, crvPoint, MSpace::kWorld);
crvPoint = crvPoint*crvXform;
cColliderFn.getPointAtParam(param2, crvPoint2, MSpace::kWorld);
crvPoint2 = crvPoint2 * crvXform;
// Determine the radius value
int lastRadiusIndex = radiusPlug.numElements() - 1;
if(lastRadiusIndex == 0){
radiusElement = radiusPlug.elementByPhysicalIndex(0, &stat);
if(!stat){MGlobal::displayError(MString("Could not get radius element.")); return;}
radiusElement.getValue(radius);
radius2 = radius;
}else if(lastRadiusIndex > 0){
paramNorm = param/numSpans;
radiusPt = getInterpolatedSplinePoint(paramNorm, radiusPts);
radius = radiusPt.x;
paramNorm = param2/numSpans;
radiusPt = getInterpolatedSplinePoint(paramNorm, radiusPts);
radius2 = radiusPt.x;
}
// First, we need to determine our starting position by travelling along the normal
MVector crvNormal = cColliderFn.normal(param, MSpace::kWorld);
crvNormal = crvNormal * crvXform;
MVector crvTangent = cColliderFn.tangent(param, MSpace::kWorld);
crvTangent = crvTangent * crvXform;
crvNormal.normalize();
crvTangent.normalize();
MVector crvNormal2 = cColliderFn.normal(param2, MSpace::kWorld);
crvNormal2 = crvNormal2 * crvXform;
MVector crvTangent2 = cColliderFn.tangent(param2, MSpace::kWorld);
crvTangent2 = crvTangent2 * crvXform;
crvNormal2.normalize();
crvTangent2.normalize();
// glTranslatef(crvNormal.x, crvNormal.y, crvNormal.z);
glBegin(GL_LINE_LOOP);
for(int sliceItr = 0; sliceItr < numSlices; sliceItr++){
// quad vertex 4
rotateRadians = ((((float)sliceItr+1)/numSlices)*360)*degreesToRadians;
rotateQuat.setAxisAngle(crvTangent, rotateRadians);
crvNormalRotated = crvNormal.rotateBy(rotateQuat);
glNormal3f(crvNormalRotated.x, crvNormalRotated.y, crvNormalRotated.z );
glVertex3f((float)crvPoint.x + (crvNormalRotated.x*radius),
(float)crvPoint.y + (crvNormalRotated.y*radius),
(float)crvPoint.z + (crvNormalRotated.z*radius));
// quad vertex 3
rotateRadians = ((((float)sliceItr+1)/numSlices)*360)*degreesToRadians;
rotateQuat.setAxisAngle(crvTangent2, rotateRadians);
crvNormalRotated = crvNormal.rotateBy(rotateQuat);
glNormal3f(crvNormalRotated.x, crvNormalRotated.y, crvNormalRotated.z );
glVertex3f((float)crvPoint2.x + (crvNormalRotated.x*radius2),
(float)crvPoint2.y + (crvNormalRotated.y*radius2),
(float)crvPoint2.z + (crvNormalRotated.z*radius2));
// quad vertex 2
rotateRadians = (((float)sliceItr/numSlices)*360)*degreesToRadians;
rotateQuat.setAxisAngle(crvTangent2, rotateRadians);
crvNormalRotated = crvNormal.rotateBy(rotateQuat);
glNormal3f(crvNormalRotated.x, crvNormalRotated.y, crvNormalRotated.z );
glVertex3f((float)crvPoint2.x + (crvNormalRotated.x*radius2),
(float)crvPoint2.y + (crvNormalRotated.y*radius2),
(float)crvPoint2.z + (crvNormalRotated.z*radius2));
// quad vertex 1
rotateRadians = (((float)sliceItr/numSlices)*360)*degreesToRadians;
rotateQuat.setAxisAngle(crvTangent, rotateRadians);
crvNormalRotated = crvNormal.rotateBy(rotateQuat);
glNormal3f(crvNormalRotated.x, crvNormalRotated.y, crvNormalRotated.z );
glVertex3f((float)crvPoint.x + (crvNormalRotated.x*radius),
(float)crvPoint.y + (crvNormalRotated.y*radius),
(float)crvPoint.z + (crvNormalRotated.z*radius));
}
glEnd();
}
glPopAttrib();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// END WIREFRAME
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// glEnable(GL_LIGHT0);
view.endGL();
}
bool curveColliderLocator::isBounded() const
{
return true;
}
MBoundingBox curveColliderLocator::boundingBox() const
{
// Start with the bounding box of the curve, then expand it by the largest radius value
MObject thisNode = thisMObject();
MPlug curvePlug(thisNode, colliderCurveIn);
MPlugArray inputCrvArray;
curvePlug.connectedTo(inputCrvArray, true, false);
// if inputCrvArray is empty, no curves are connected, so return an empty bounding box
if(inputCrvArray.length() == 0){
MBoundingBox emptyBBox;
return emptyBBox;
}
MObject crvColliderObj = inputCrvArray[0].node();
MFnDagNode crvDagNode(crvColliderObj);
// find the largest radius value
MPlug radiusPlug(thisNode, colliderRadiusIn);
MPlug radiusElement;
float maxRadius = 0;
float currentRadius;
for(int radiusItr = 0; radiusItr < radiusPlug.numElements(); radiusItr++){
radiusElement = radiusPlug.elementByPhysicalIndex(radiusItr);
radiusElement.getValue(currentRadius);
if (currentRadius > maxRadius){maxRadius = currentRadius;}
}
MPoint bBoxMin = crvDagNode.boundingBox().min();
MPoint bBoxMax = crvDagNode.boundingBox().max();
// expand the min and max points by the radius
bBoxMin.x = bBoxMin.x - maxRadius;
bBoxMin.y = bBoxMin.y - maxRadius;
bBoxMin.z = bBoxMin.z - maxRadius;
bBoxMax.x = bBoxMax.x + maxRadius;
bBoxMax.y = bBoxMax.y + maxRadius;
bBoxMax.z = bBoxMax.z + maxRadius;
MBoundingBox bBox(bBoxMin, bBoxMax);
return bBox;
}
void* curveColliderLocator::creator()
{
return new curveColliderLocator();
}
MStatus curveColliderLocator::initialize()
{
MFnNumericAttribute nAttr;
MStatus stat;
colliderRadiusIn = nAttr.create( "radius", "rd", MFnNumericData::kDouble );
nAttr.setDefault(1.0);
nAttr.setMin(0);
nAttr.setKeyable(true);
nAttr.setArray(true);
nAttr.setStorable(true);
nAttr.setWritable(true);
stat = addAttribute(colliderRadiusIn);
if (!stat) {
stat.perror("Could not add colliderRadiusIn attribute");
return stat;
}
// CREATE AND ADD ".inCurve" ATTRIBUTE:
MFnTypedAttribute inCurveAttrFn;
colliderCurveIn = inCurveAttrFn.create("colliderCurve", "ic", MFnData::kNurbsCurve);
inCurveAttrFn.setStorable(true);
inCurveAttrFn.setKeyable(false);
inCurveAttrFn.setReadable(true);
inCurveAttrFn.setWritable(true);
inCurveAttrFn.setCached(false);
stat = addAttribute(colliderCurveIn);
if (!stat) {
stat.perror("Could not add colliderCurveIn attribute");
return stat;
}
MFnMatrixAttribute mAttr;
colliderXform =mAttr.create("colliderXfm", "cx");
mAttr.setReadable(false);
mAttr.setKeyable(false);
mAttr.setConnectable(true);
stat = addAttribute( colliderXform );
if (!stat) {
stat.perror("Could not add colliderXform attribute");
return stat;
}
colliderColorR = nAttr.create( "colorR", "clr", MFnNumericData::kFloat );
nAttr.setDefault(0.2f);
nAttr.setMin(0.0f);
nAttr.setMax(1.0f);
nAttr.setKeyable(true);
nAttr.setStorable(true);
nAttr.setReadable(true);
nAttr.setWritable(true);
stat = addAttribute(colliderColorR);
if (!stat) {
stat.perror("Could not add colliderColorR attribute");
return stat;
}
colliderColorG = nAttr.create( "colorG", "clg", MFnNumericData::kFloat );
nAttr.setDefault(0.2f);
nAttr.setMin(0.0f);
nAttr.setMax(1.0f);
nAttr.setKeyable(true);
nAttr.setStorable(true);
nAttr.setReadable(true);
nAttr.setWritable(true);
stat = addAttribute(colliderColorG);
if (!stat) {
stat.perror("Could not add colliderColorG attribute");
return stat;
}
colliderColorB = nAttr.create( "colorB", "clb", MFnNumericData::kFloat );
nAttr.setDefault(0.8f);
nAttr.setMin(0.0f);
nAttr.setMax(1.0f);
nAttr.setKeyable(true);
nAttr.setStorable(true);
nAttr.setReadable(true);
nAttr.setWritable(true);
stat = addAttribute(colliderColorB);
if (!stat) {
stat.perror("Could not add colliderColorB attribute");
return stat;
}
colliderTransparency = nAttr.create( "colorT", "clt", MFnNumericData::kFloat );
nAttr.setDefault(1.0f);
nAttr.setMin(0.0f);
nAttr.setMax(1.0f);
nAttr.setKeyable(true);
nAttr.setStorable(true);
nAttr.setReadable(true);
nAttr.setWritable(true);
stat = addAttribute(colliderTransparency);
if (!stat) {
stat.perror("Could not add colliderTransparency attribute");
return stat;
}
return MS::kSuccess;
}
//
// Register node to plugin
//
MStatus curveColliderLocator::Register(MFnPlugin& ioPlugin)
{
MStatus status = ioPlugin.registerNode(MAYA_CURVECOLLIDERLOCATOR_NAME,
id,
&creator,
&initialize,
MPxNode::kLocatorNode);
if (!status)
{
status.perror("registerLocator");
}
if (MFAIL(status))
return MReturnStatus(status, "Failed to register " MAYA_CURVECOLLIDERLOCATOR_NAME " locator");
else
Registered = true;
return status;
}
//
// Deregister node to plugin
//
MStatus curveColliderLocator::Deregister(MFnPlugin& ioPlugin)
{
// Deregister the node
//
MStatus status = ioPlugin.deregisterNode(id);
if (MFAIL(status))
return MReturnStatus(status, "Failed to deregister " MAYA_CURVECOLLIDERLOCATOR_NAME " locator");
else
Registered = false;
return status;
}