20 static char data[64*16];
23 char *ret = &data[index*64];
25 if (index == 16 ) index = 0;
27 if ( v == FLT_MIN )
return "-INF";
28 if ( v == FLT_MAX )
return "INF";
44 sprintf(ret,
"%.9f", v );
45 const char *
dot = strstr(ret,
".");
48 int len = (int)strlen(ret);
49 char *foo = &ret[len-1];
50 while ( *foo ==
'0' ) foo--;
68 strcpy(mBaseName,fname);
69 char *
dot = strstr(mBaseName,
".obj");
72 sprintf(mObjName,
"%s_convex.obj", mBaseName );
78 mFph = fopen(mObjName,
"wb");
81 printf(
"########################################################################\r\n");
82 printf(
"# Perfomring approximate convex decomposition for triangle mesh %s\r\n", fname );
83 printf(
"# Input Mesh has %d vertices and %d triangles.\r\n", d.
mVcount, d.
mTcount );
84 printf(
"# Recursion depth: %d\r\n", d.
mDepth );
85 printf(
"# Concavity Threshold Percentage: %0.2f\r\n", d.
mCpercent );
86 printf(
"# Hull Merge Volume Percentage: %0.2f\r\n", d.
mPpercent );
87 printf(
"# Maximum output vertices per hull: %d\r\n", d.
mMaxVertices );
88 printf(
"# Hull Skin Width: %0.2f\r\n", d.
mSkinWidth );
89 printf(
"########################################################################\r\n");
94 fprintf(mFph,
"########################################################################\r\n");
95 fprintf(mFph,
"# Approximate convex decomposition for triangle mesh %s\r\n", fname );
96 fprintf(mFph,
"# Input Mesh has %d vertices and %d triangles.\r\n", d.
mVcount, d.
mTcount );
97 fprintf(mFph,
"# Recursion depth: %d\r\n", d.
mDepth );
98 fprintf(mFph,
"# Concavity Threshold Percentage: %0.2f\r\n", d.
mCpercent );
99 fprintf(mFph,
"# Hull Merge Volume Percentage: %0.2f\r\n", d.
mPpercent );
100 fprintf(mFph,
"# Maximum output vertices per hull: %d\r\n", d.
mMaxVertices );
101 fprintf(mFph,
"# Hull Skin Width: %0.2f\r\n", d.
mSkinWidth );
102 fprintf(mFph,
"########################################################################\r\n");
104 printf(
"Opened Wavefront file %s for output.\r\n", mObjName );
108 printf(
"Failed to open output file %s\r\n", mObjName );
118 for (
unsigned int i=0; i<mHulls.size(); i++)
130 printf(
"Received hull %d HullVolume(%0.3f)\r\n", mHullCount, result.
mHullVolume );
136 mHulls.push_back(cr);
138 fprintf(mFph,
"########################################################################\r\n");
139 fprintf(mFph,
"## Hull Piece %d with %d vertices and %d triangles.\r\n", mHullCount, result.
mHullVcount, result.
mHullTcount );
140 fprintf(mFph,
"########################################################################\r\n");
145 fprintf(mFph,
"v %0.9f %0.9f %0.9f\r\n", (
float)p[0], (
float)p[1], (
float)p[2] );
153 unsigned int i1 = *src++;
154 unsigned int i2 = *src++;
155 unsigned int i3 = *src++;
161 fprintf(mFph,
"f %d %d %d\r\n", i1+1, i2+1, i3+1 );
172 fprintf(fph,
" <geometry id=\"%s_%d-Mesh\" name=\"%s_%d-Mesh\">\r\n", mBaseName, index, mBaseName, index);
173 fprintf(fph,
" <convex_mesh>\r\n");
174 fprintf(fph,
" <source id=\"%s_%d-Position\">\r\n", mBaseName, index);
175 fprintf(fph,
" <float_array count=\"%d\" id=\"%s_%d-Position-array\">\r\n", cr->
mHullVcount*3, mBaseName, index);
188 fprintf(fph,
" </float_array>\r\n");
189 fprintf(fph,
" <technique_common>\r\n");
190 fprintf(fph,
" <accessor count=\"%d\" source=\"#%s_%d-Position-array\" stride=\"3\">\r\n", cr->
mHullVcount, mBaseName, index );
191 fprintf(fph,
" <param name=\"X\" type=\"float\"/>\r\n");
192 fprintf(fph,
" <param name=\"Y\" type=\"float\"/>\r\n");
193 fprintf(fph,
" <param name=\"Z\" type=\"float\"/>\r\n");
194 fprintf(fph,
" </accessor>\r\n");
195 fprintf(fph,
" </technique_common>\r\n");
196 fprintf(fph,
" </source>\r\n");
197 fprintf(fph,
" <vertices id=\"%s_%d-Vertex\">\r\n", mBaseName, index);
198 fprintf(fph,
" <input semantic=\"POSITION\" source=\"#%s_%d-Position\"/>\r\n", mBaseName, index);
199 fprintf(fph,
" </vertices>\r\n");
200 fprintf(fph,
" <triangles material=\"Material\" count=\"%d\">\r\n", cr->
mHullTcount );
201 fprintf(fph,
" <input offset=\"0\" semantic=\"VERTEX\" source=\"#%s_%d-Vertex\"/>\r\n", mBaseName, index);
202 fprintf(fph,
" <p>\r\n");
207 fprintf(fph,
"%d %d %d ", tri[0], tri[1], tri[2] );
215 fprintf(fph,
" </p>\r\n");
216 fprintf(fph,
" </triangles>\r\n");
217 fprintf(fph,
" </convex_mesh>\r\n");
218 fprintf(fph,
" </geometry>\r\n");
225 sprintf(scratch,
"%s.dae", mBaseName );
226 FILE *fph = fopen(scratch,
"wb");
230 printf(
"Saving convex decomposition of %d hulls to COLLADA file '%s'\r\n", (
int)mHulls.size(), scratch );
232 fprintf(fph,
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n");
233 fprintf(fph,
"<COLLADA version=\"1.4.0\" xmlns=\"http://www.collada.org/2005/11/COLLADASchema\">\r\n");
234 fprintf(fph,
" <asset>\r\n");
235 fprintf(fph,
" <contributor>\r\n");
236 fprintf(fph,
" <author>NxuStream2 converter - http://www.ageia.com</author>\r\n");
237 fprintf(fph,
" <authoring_tool>PhysX Rocket, PhysX Viewer, or CreateDynamics</authoring_tool>\r\n");
238 fprintf(fph,
" <comments>questions to: jratcliff@ageia.com</comments>\r\n");
239 fprintf(fph,
" <copyright></copyright>\r\n");
240 fprintf(fph,
" <source_data>chair_gothic_tilted</source_data>\r\n");
241 fprintf(fph,
" </contributor>\r\n");
242 fprintf(fph,
" <unit meter=\"1\" name=\"meter\"/>\r\n");
243 fprintf(fph,
" <up_axis>Y_UP</up_axis>\r\n");
244 fprintf(fph,
" </asset>\r\n");
245 fprintf(fph,
" <library_materials>\r\n");
246 fprintf(fph,
" <material id=\"Material\" name=\"Material\">\r\n");
247 fprintf(fph,
" <instance_effect url=\"#Material-fx\"></instance_effect>\r\n");
248 fprintf(fph,
" </material>\r\n");
249 fprintf(fph,
" </library_materials>\r\n");
250 fprintf(fph,
" <library_effects>\r\n");
251 fprintf(fph,
" <effect id=\"Material-fx\" name=\"Material\">\r\n");
252 fprintf(fph,
" <profile_COMMON>\r\n");
253 fprintf(fph,
" <technique id=\"Material-fx-COMMON\" sid=\"COMMON\">\r\n");
254 fprintf(fph,
" <phong>\r\n");
255 fprintf(fph,
" <ambient>\r\n");
256 fprintf(fph,
" <color>0.803922 0.588235 0.92549 1</color>\r\n");
257 fprintf(fph,
" </ambient>\r\n");
258 fprintf(fph,
" <diffuse>\r\n");
259 fprintf(fph,
" <color>0.803922 0.588235 0.92549 1</color>\r\n");
260 fprintf(fph,
" </diffuse>\r\n");
261 fprintf(fph,
" <specular>\r\n");
262 fprintf(fph,
" <color>0.631373 0.631373 0.631373 1</color>\r\n");
263 fprintf(fph,
" </specular>\r\n");
264 fprintf(fph,
" <shininess>\r\n");
265 fprintf(fph,
" <float>1</float>\r\n");
266 fprintf(fph,
" </shininess>\r\n");
267 fprintf(fph,
" <reflective>\r\n");
268 fprintf(fph,
" <color>0 0 0 1</color>\r\n");
269 fprintf(fph,
" </reflective>\r\n");
270 fprintf(fph,
" <transparent>\r\n");
271 fprintf(fph,
" <color>1 1 1 1</color>\r\n");
272 fprintf(fph,
" </transparent>\r\n");
273 fprintf(fph,
" <transparency>\r\n");
274 fprintf(fph,
" <float>0</float>\r\n");
275 fprintf(fph,
" </transparency>\r\n");
276 fprintf(fph,
" </phong>\r\n");
277 fprintf(fph,
" </technique>\r\n");
278 fprintf(fph,
" </profile_COMMON>\r\n");
279 fprintf(fph,
" </effect>\r\n");
280 fprintf(fph,
" </library_effects>\r\n");
281 fprintf(fph,
" <library_geometries>\r\n");
283 for (
unsigned int i=0; i<mHulls.size(); i++)
286 saveCOLLADA(fph,i,cr);
290 fprintf(fph,
" </library_geometries>\r\n");
291 fprintf(fph,
" <library_visual_scenes>\r\n");
292 fprintf(fph,
" <visual_scene id=\"Scene0-Visual\" name=\"Scene0-Visual\">\r\n");
293 fprintf(fph,
" <node id=\"%s-Node\" name=\"%s\" type=\"NODE\">\r\n", mBaseName, mBaseName );
294 fprintf(fph,
" <translate>0 0 0</translate>\r\n");
295 fprintf(fph,
" <rotate>1 0 0 0</rotate>\r\n");
296 fprintf(fph,
" </node>\r\n");
297 fprintf(fph,
" </visual_scene>\r\n");
298 fprintf(fph,
" </library_visual_scenes>\r\n");
299 fprintf(fph,
" <library_physics_materials>\r\n");
300 fprintf(fph,
" <physics_material id=\"pmat0_0-PhysicsMaterial\" name=\"pmat0_0-PhysicsMaterial\">\r\n");
301 fprintf(fph,
" <technique_common>\r\n");
302 fprintf(fph,
" <dynamic_friction>0.5</dynamic_friction>\r\n");
303 fprintf(fph,
" <restitution>0</restitution>\r\n");
304 fprintf(fph,
" <static_friction>0.5</static_friction>\r\n");
305 fprintf(fph,
" </technique_common>\r\n");
306 fprintf(fph,
" </physics_material>\r\n");
307 fprintf(fph,
" </library_physics_materials>\r\n");
308 fprintf(fph,
" <library_physics_models>\r\n");
309 fprintf(fph,
" <physics_model id=\"Scene0-PhysicsModel\">\r\n");
310 fprintf(fph,
" <rigid_body sid=\"%s-RigidBody\" name=\"%s\">\r\n", mBaseName, mBaseName);
311 fprintf(fph,
" <technique_common>\r\n");
312 fprintf(fph,
" <instance_physics_material url=\"#pmat0_0-PhysicsMaterial\"/>\r\n");
314 for (
unsigned int i=0; i<mHulls.size(); i++)
317 fprintf(fph,
" <shape>\r\n");
318 fprintf(fph,
" <translate>0 0 0</translate>\r\n");
319 fprintf(fph,
" <rotate>1 0 0 0</rotate>\r\n");
320 fprintf(fph,
" <instance_physics_material url=\"#pmat0_0-PhysicsMaterial\"/>\r\n");
321 fprintf(fph,
" <density>1</density>\r\n");
322 fprintf(fph,
" <extra>\r\n");
323 fprintf(fph,
" <technique profile=\"PhysX\">\r\n");
324 fprintf(fph,
" <skinWidth>%s</skinWidth>\r\n",
fstring( mSkinWidth ) );
325 fprintf(fph,
" </technique>\r\n");
326 fprintf(fph,
" </extra>\r\n");
327 fprintf(fph,
" <instance_geometry url=\"%s_%d-Mesh\"/>\r\n", mBaseName, i);
328 fprintf(fph,
" </shape>\r\n");
331 fprintf(fph,
" <dynamic>true</dynamic>\r\n");
332 fprintf(fph,
" <mass>1</mass>\r\n");
333 fprintf(fph,
" </technique_common>\r\n");
334 fprintf(fph,
" <extra>\r\n");
335 fprintf(fph,
" <technique profile=\"PhysX\">\r\n");
336 fprintf(fph,
" <extra>\r\n");
337 fprintf(fph,
" <technique profile=\"PhysX\">\r\n");
338 fprintf(fph,
" <linearDamping>0</linearDamping>\r\n");
339 fprintf(fph,
" <angularDamping>0</angularDamping>\r\n");
340 fprintf(fph,
" <solverIterationCount>32</solverIterationCount>\r\n");
341 fprintf(fph,
" </technique>\r\n");
342 fprintf(fph,
" </extra>\r\n");
343 fprintf(fph,
" <disable_collision>false</disable_collision>\r\n");
344 fprintf(fph,
" </technique>\r\n");
345 fprintf(fph,
" </extra>\r\n");
346 fprintf(fph,
" </rigid_body>\r\n");
347 fprintf(fph,
" </physics_model>\r\n");
348 fprintf(fph,
" </library_physics_models>\r\n");
349 fprintf(fph,
" <library_physics_scenes>\r\n");
350 fprintf(fph,
" <physics_scene id=\"Scene0-Physics\">\r\n");
351 fprintf(fph,
" <instance_physics_model url=\"#Scene0-PhysicsModel\">\r\n");
352 fprintf(fph,
" <instance_rigid_body target=\"#%s-Node\" body=\"%s-RigidBody\"/>\r\n", mBaseName, mBaseName );
353 fprintf(fph,
" <extra>\r\n");
354 fprintf(fph,
" <technique profile=\"PhysX\">\r\n");
355 fprintf(fph,
" </technique>\r\n");
356 fprintf(fph,
" </extra>\r\n");
357 fprintf(fph,
" </instance_physics_model>\r\n");
358 fprintf(fph,
" <technique_common>\r\n");
359 fprintf(fph,
" <gravity>0 -9.800000191 0</gravity>\r\n");
360 fprintf(fph,
" </technique_common>\r\n");
361 fprintf(fph,
" </physics_scene>\r\n");
362 fprintf(fph,
" </library_physics_scenes>\r\n");
363 fprintf(fph,
" <scene>\r\n");
364 fprintf(fph,
" <instance_visual_scene url=\"#Scene0-Visual\"/>\r\n");
365 fprintf(fph,
" <instance_physics_scene url=\"#Scene0-Physics\"/>\r\n");
366 fprintf(fph,
" </scene>\r\n");
367 fprintf(fph,
"</COLLADA>\r\n");
374 printf(
"Failed to open file '%s' for write access.\r\n", scratch );
381 fprintf(fph,
" <NxConvexMeshDesc id=\"%s_%d\">\r\n", mBaseName, index);
382 fprintf(fph,
" <points>\r\n");
395 fprintf(fph,
" </points>\r\n");
396 fprintf(fph,
" <triangles>\r\n");
401 fprintf(fph,
"%d %d %d ", tri[0], tri[1], tri[2] );
409 fprintf(fph,
" </triangles>\r\n");
410 fprintf(fph,
" </NxConvexMeshDesc>\r\n");
417 sprintf(scratch,
"%s.xml", mBaseName );
418 FILE *fph = fopen(scratch,
"wb");
422 printf(
"Saving convex decomposition of %d hulls to NxuStream file '%s'\r\n", (
int)mHulls.size(), scratch );
424 fprintf(fph,
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n");
425 fprintf(fph,
" <NXUSTREAM2>\r\n");
426 fprintf(fph,
" <NxuPhysicsCollection id=\"beshon\" sdkVersion=\"244\" nxuVersion=\"100\">\r\n");
427 fprintf(fph,
" <NxPhysicsSDKDesc id=\"SDK\">\r\n");
428 fprintf(fph,
" <hwPageSize>65536</hwPageSize>\r\n");
429 fprintf(fph,
" <hwPageMax>256</hwPageMax>\r\n");
430 fprintf(fph,
" <hwConvexMax>2048</hwConvexMax>\r\n");
431 fprintf(fph,
" </NxPhysicsSDKDesc>\r\n");
433 for (
unsigned int i=0; i<mHulls.size(); i++)
435 saveXML(fph, i, mHulls[i] );
439 fprintf(fph,
" <NxSceneDesc id=\"%s\">\r\n", mBaseName);
440 fprintf(fph,
" <filterBool>false</filterBool>\r\n");
441 fprintf(fph,
" <filterOp0>NX_FILTEROP_AND</filterOp0>\r\n");
442 fprintf(fph,
" <filterOp1>NX_FILTEROP_AND</filterOp1>\r\n");
443 fprintf(fph,
" <filterOp2>NX_FILTEROP_AND</filterOp2>\r\n");
444 fprintf(fph,
" <NxGroupsMask id=\"groupMask0\" bits0=\"0\" bits1=\"0\" bits2=\"0\" bits3=\"0\"/>\r\n");
445 fprintf(fph,
" <NxGroupsMask id=\"groupMask1\" bits0=\"0\" bits1=\"0\" bits2=\"0\" bits3=\"0\"/>\r\n");
446 fprintf(fph,
" <gravity>0 -9.800000191 0</gravity>\r\n");
447 fprintf(fph,
" <maxTimestep>0.016666668</maxTimestep>\r\n");
448 fprintf(fph,
" <maxIter>8</maxIter>\r\n");
449 fprintf(fph,
" <timeStepMethod>NX_TIMESTEP_FIXED</timeStepMethod>\r\n");
450 fprintf(fph,
" <maxBounds>FLT_MIN FLT_MIN FLT_MIN FLT_MAX FLT_MAX FLT_MAX</maxBounds>\r\n");
451 fprintf(fph,
" <NxSceneLimits id=\"limits\">\r\n");
452 fprintf(fph,
" <maxNbActors>0</maxNbActors>\r\n");
453 fprintf(fph,
" <maxNbBodies>0</maxNbBodies>\r\n");
454 fprintf(fph,
" <maxNbStaticShapes>0</maxNbStaticShapes>\r\n");
455 fprintf(fph,
" <maxNbDynamicShapes>0</maxNbDynamicShapes>\r\n");
456 fprintf(fph,
" <maxNbJoints>0</maxNbJoints>\r\n");
457 fprintf(fph,
" </NxSceneLimits>\r\n");
458 fprintf(fph,
" <simType>NX_SIMULATION_SW</simType>\r\n");
459 fprintf(fph,
" <groundPlane>true</groundPlane>\r\n");
460 fprintf(fph,
" <boundsPlanes>false</boundsPlanes>\r\n");
461 fprintf(fph,
" <NxSceneFlags id=\"flags\">\r\n");
462 fprintf(fph,
" <NX_SF_DISABLE_SSE>false</NX_SF_DISABLE_SSE>\r\n");
463 fprintf(fph,
" <NX_SF_DISABLE_COLLISIONS>false</NX_SF_DISABLE_COLLISIONS>\r\n");
464 fprintf(fph,
" <NX_SF_SIMULATE_SEPARATE_THREAD>true</NX_SF_SIMULATE_SEPARATE_THREAD>\r\n");
465 fprintf(fph,
" <NX_SF_ENABLE_MULTITHREAD>false</NX_SF_ENABLE_MULTITHREAD>\r\n");
466 fprintf(fph,
" </NxSceneFlags>\r\n");
467 fprintf(fph,
" <internalThreadCount>0</internalThreadCount>\r\n");
468 fprintf(fph,
" <backgroundThreadCount>0</backgroundThreadCount>\r\n");
469 fprintf(fph,
" <threadMask>1431655764</threadMask>\r\n");
470 fprintf(fph,
" <backgroundThreadMask>1431655764</backgroundThreadMask>\r\n");
471 fprintf(fph,
" <NxMaterialDesc id=\"Material_0\" userProperties=\"\" hasSpring=\"false\" materialIndex=\"0\">\r\n");
472 fprintf(fph,
" <dynamicFriction>0.5</dynamicFriction>\r\n");
473 fprintf(fph,
" <staticFriction>0.5</staticFriction>\r\n");
474 fprintf(fph,
" <restitution>0</restitution>\r\n");
475 fprintf(fph,
" <dynamicFrictionV>0</dynamicFrictionV>\r\n");
476 fprintf(fph,
" <staticFrictionV>0</staticFrictionV>\r\n");
477 fprintf(fph,
" <frictionCombineMode>NX_CM_AVERAGE</frictionCombineMode>\r\n");
478 fprintf(fph,
" <restitutionCombineMode>NX_CM_AVERAGE</restitutionCombineMode>\r\n");
479 fprintf(fph,
" <dirOfAnisotropy>1 0 0</dirOfAnisotropy>\r\n");
480 fprintf(fph,
" <NxMaterialFlag id=\"flags\">\r\n");
481 fprintf(fph,
" <NX_MF_ANISOTROPIC>false</NX_MF_ANISOTROPIC>\r\n");
482 fprintf(fph,
" <NX_MF_DISABLE_FRICTION>false</NX_MF_DISABLE_FRICTION>\r\n");
483 fprintf(fph,
" <NX_MF_DISABLE_STRONG_FRICTION>false</NX_MF_DISABLE_STRONG_FRICTION>\r\n");
484 fprintf(fph,
" </NxMaterialFlag>\r\n");
485 fprintf(fph,
" </NxMaterialDesc>\r\n");
486 fprintf(fph,
" <NxActorDesc id=\"%s\" userProperties=\"\" hasBody=\"true\" name=\"%s\">\r\n", mBaseName, mBaseName);
487 fprintf(fph,
" <globalPose>1 0 0 0 1 0 0 0 1 0 0 0 </globalPose>\r\n");
488 fprintf(fph,
" <NxBodyDesc>\r\n");
489 fprintf(fph,
" <mass>1</mass>\r\n");
490 fprintf(fph,
" <linearDamping>0</linearDamping>\r\n");
491 fprintf(fph,
" <angularDamping>0</angularDamping>\r\n");
492 fprintf(fph,
" <solverIterationCount>32</solverIterationCount>\r\n");
493 fprintf(fph,
" <NxBodyFlag id=\"flags\">\r\n");
494 fprintf(fph,
" <NX_BF_POSE_SLEEP_TEST>true</NX_BF_POSE_SLEEP_TEST>\r\n");
495 fprintf(fph,
" <NX_AF_DISABLE_COLLISION>false</NX_AF_DISABLE_COLLISION>\r\n");
496 fprintf(fph,
" </NxBodyFlag>\r\n");
497 fprintf(fph,
" </NxBodyDesc>\r\n");
498 fprintf(fph,
" <name>Bip01 Pelvis</name>\r\n");
499 for (
unsigned int i=0; i<mHulls.size(); i++)
501 fprintf(fph,
" <NxConvexShapeDesc id=\"Shape_%d\" meshData=\"%s_%d\">\r\n", i, mBaseName, i);
502 fprintf(fph,
" <NxShapeDesc>\r\n");
503 fprintf(fph,
" <localPose>1 0 0 0 1 0 0 0 1 0 0 0 </localPose>\r\n");
504 fprintf(fph,
" <skinWidth>0</skinWidth>\r\n");
505 fprintf(fph,
" </NxShapeDesc>\r\n");
506 fprintf(fph,
" </NxConvexShapeDesc>\r\n");
508 fprintf(fph,
" </NxActorDesc>\r\n");
510 fprintf(fph,
" </NxSceneDesc>\r\n");
511 fprintf(fph,
" <NxSceneInstance id=\"%s\">\r\n", mBaseName);
512 fprintf(fph,
" <sceneName>beshon</sceneName>\r\n");
513 fprintf(fph,
" <NxuUserProperties></NxuUserProperties>\r\n");
514 fprintf(fph,
" <rootNode>1 0 0 0 1 0 0 0 1 0 0 0</rootNode>\r\n");
515 fprintf(fph,
" <newScene>false</newScene>\r\n");
516 fprintf(fph,
" <ignorePlane>true</ignorePlane>\r\n");
517 fprintf(fph,
" <numSceneInstances>0</numSceneInstances>\r\n");
518 fprintf(fph,
" </NxSceneInstance>\r\n");
519 fprintf(fph,
" </NxuPhysicsCollection>\r\n");
520 fprintf(fph,
"</NXUSTREAM2>\r\n");
525 printf(
"Failed to open file '%s' for write access.\r\n", scratch );
540 int main(
int argc,
const char **argv)
544 printf(
"Usage: Test <meshanme.obj> (options)\r\n");
546 printf(
"Options:\r\n");
548 printf(
" -d<depth> : How deep to recursively split. Values of 3-7 are reasonable.\r\n");
549 printf(
" -c<percent> : Percentage of concavity to keep splitting. 0-20%% is reasonable.\r\n");
550 printf(
" -p<percent> : Percentage of volume delta to collapse hulls. 0-30%% is reasonable.\r\n");
551 printf(
" -v<maxverts> : Maximum number of vertices in the output hull. Default is 32.\r\n");
552 printf(
" -s<skinwidth> : Skin Width inflation. Default is 0.\r\n");
556 unsigned int depth = 5;
559 unsigned int maxv = 32;
563 for (
int i=2; i<argc; i++)
565 const char *o = argv[i];
567 if ( strncmp(o,
"-d",2) == 0 )
569 depth = (
unsigned int) atoi( &o[2] );
570 if ( depth < 0 || depth > 10 )
573 printf(
"Invalid depth value in switch, defaulting to 5.\r\n");
577 if ( strncmp(o,
"-c",2) == 0 )
579 cpercent = (float) atof( &o[2] );
580 if ( cpercent < 0 || cpercent > 100 )
583 printf(
"Invalid concavity percentage in switch, defaulting to 5.\r\n");
587 if ( strncmp(o,
"-p",2) == 0 )
589 ppercent = (float) atof( &o[2] );
590 if ( ppercent < 0 || ppercent > 100 )
593 printf(
"Invalid hull merge percentage in switch, defaulting to 5.\r\n");
597 if ( strncmp(o,
"-v",2) == 0 )
599 maxv = (
unsigned int) atoi( &o[2] );
600 if ( maxv < 8 || maxv > 256 )
603 printf(
"Invalid max vertices in switch, defaulting to 32.\r\n");
607 if ( strncmp(o,
"-s",2) == 0 )
609 skinWidth = (float) atof( &o[2] );
610 if ( skinWidth < 0 || skinWidth > 0.1f )
613 printf(
"Invalid skinWidth in switch, defaulting to 0.\r\n");
621 unsigned int tcount = wo.
loadObj(argv[1]);
648 printf(
"Input triangle mesh with %d triangles produced %d output hulls.\r\n", d.
mTcount, count );
656 printf(
"Failed to produce any convex hulls.\r\n");
663 printf(
"Sorry unable to load file '%s'\r\n", argv[1] );