Cloth* createAttachedCloth(NxScene* scene, osg::Vec3f origin) { float w = 8.0f; float h = 8.0f; float d = 0.2f; Cloth *regularCloth = new Cloth(scene, origin, w, h, d, 0); if (!regularCloth->getNxCloth()) { printf("Error: Unable to create the cloth for the current scene.\n"); delete regularCloth; } else { int numX = (int)(w/d)+1; int numY = (int)(h/d)+1; int i1 = 0; NxVec3 p1 = regularCloth->getNxCloth()->getPosition(i1); int i2 = numX; NxVec3 p2 = regularCloth->getNxCloth()->getPosition(i2); int i3 = numX*(numY+1); NxVec3 p3 = regularCloth->getNxCloth()->getPosition(i3); int i4 = (numX+1)*(numY+1)-1; NxVec3 p4 = regularCloth->getNxCloth()->getPosition(i4); regularCloth->getNxCloth()->attachVertexToGlobalPosition(i1,p1); regularCloth->getNxCloth()->attachVertexToGlobalPosition(i2,p2); regularCloth->getNxCloth()->attachVertexToGlobalPosition(i3,p3); regularCloth->getNxCloth()->attachVertexToGlobalPosition(i4,p4); } return regularCloth; }
Cloth* createFreeCloth(NxScene* scene, osg::Vec3f origin) { Cloth *regularCloth = new Cloth(scene, origin, 8.0f, 8.0f, 0.2f, 0); if (!regularCloth->getNxCloth()) { printf("Error: Unable to create the cloth for the current scene.\n"); delete regularCloth; } else { //regularCloth->getNxCloth()->attachToShape(*capsule->getShapes(), 0); } return regularCloth; }