void PhysicsTriMeshGeom::getTriangle( Int32 index, Vec3f& v0, Vec3f& v1, Vec3f& v2 ) { PhysicsTriMeshGeomPtr tmpPtr(*this); dVector3 _v0, _v1, _v2; dGeomTriMeshGetTriangle(tmpPtr->id, index, &_v0, &_v1, &_v2); v0.setValue(Vec3f(_v0[0], _v0[1], _v0[2])); v1.setValue(Vec3f(_v1[0], _v1[1], _v1[2])); v2.setValue(Vec3f(_v2[0], _v2[1], _v2[2])); }
void drawGeom(dGeomID g) { int gclass = dGeomGetClass(g); const dReal *pos = dGeomGetPosition(g); const dReal *rot = dGeomGetRotation(g); switch (gclass) { case dSphereClass: dsSetColorAlpha(0, 0.75, 0.5, 0.5); dsSetTexture (DS_CHECKERED); dsDrawSphere(pos, rot, dGeomSphereGetRadius(g)); break; case dBoxClass: { dVector3 lengths; dsSetColorAlpha(1, 1, 0, 0.5); dsSetTexture (DS_WOOD); dGeomBoxGetLengths(g, lengths); dsDrawBox(pos, rot, lengths); break; } case dTriMeshClass: { int numi = dGeomTriMeshGetTriangleCount(g); for (int i=0; i<numi; ++i) { dVector3 v0, v1, v2; dGeomTriMeshGetTriangle(g, i, &v0, &v1, &v2); dsSetTexture (DS_WOOD); dsSetDrawMode(DS_WIREFRAME); dsSetColorAlpha(0, 0, 0, 1.0); dsDrawTriangle(pos, rot, v0, v1, v2, true); dsSetDrawMode(DS_POLYFILL); dsSetColorAlpha(1, 1, 0, 0.5); dsDrawTriangle(pos, rot, v0, v1, v2, true); } break; } default: {} } }