void renderScene(int iteration) { RenderUtil::startRender(sCamera->getEye(), sCamera->getDir()); PxScene* scene; PxGetPhysics().getScenes(&scene,1); PxU32 nbActors = scene->getNbActors(PxActorTypeSelectionFlag::eRIGID_DYNAMIC); if(nbActors) { std::vector<PxRigidActor*> actors(nbActors); scene->getActors(PxActorTypeSelectionFlag::eRIGID_DYNAMIC, (PxActor**)&actors[0], nbActors); for (PxU32 i = 0; i < nbActors; i++) RenderUtil::renderActors(&actors[i], 1, false, PxVec3(0.3,0.3,0.3)); } if (iteration == 0) { char* result = "Initial Guess"; glRasterPos2i(20,-25); for(int i = 0; i < strlen(result); i++) glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, result[i]); } else { char* label = "Iteration #"; char buffer[10]; itoa(iteration, buffer, 10); char* result = new char[strlen(label)+strlen(buffer)]; sprintf(result,"%s%s",label,buffer); glRasterPos2i(20,-25); for(int i = 0; i < strlen(result); i++) glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, result[i]); } std::string buffer, result; matrix<double> state = render_system->getState(); std::string theta1 = "theta1 = " + to_string((long double) state(0,0)); std::string theta2 = "theta2 = " + to_string((long double) state(1,0)); std::string thetaDot1 = "thetaDot1 = " + to_string((long double) state(2,0)); std::string thetaDot2 = "thetaDot1 = " + to_string((long double) state(3,0)); glRasterPos2i(-35,38); for(int i = 0; i < theta1.length(); i++) glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, theta1[i]); glRasterPos2i(-37,33); for(int i = 0; i < theta2.length(); i++) glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, theta2[i]); glRasterPos2i(-39,28); for(int i = 0; i < thetaDot1.length(); i++) glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, thetaDot1[i]); glRasterPos2i(-41,23); for(int i = 0; i < thetaDot2.length(); i++) glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, thetaDot2[i]); RenderUtil::finishRender(); }
void renderCallback() { simulatePhysics(true); gGlutRenderer->startRender(sCamera->getEye(), sCamera->getDir()); PxScene* scene; PxGetPhysics().getScenes(&scene, 1); PxU32 nbActors = scene->getNbActors(PxActorTypeSelectionFlag::eRIGID_DYNAMIC | PxActorTypeSelectionFlag::eRIGID_STATIC); if (nbActors) { std::vector<PxRigidActor*> actors(nbActors); scene->getActors(PxActorTypeSelectionFlag::eRIGID_DYNAMIC | PxActorTypeSelectionFlag::eRIGID_STATIC, (PxActor**)&actors[0], nbActors); gGlutRenderer->renderActors(&actors[0], (PxU32)actors.size(), true); } gGlutRenderer->finishRender(); }
void PxCollectForExportScene(const PxScene& scene, PxCollection& collection) { // Collect actors { const PxActorTypeSelectionFlags selectionFlags = PxActorTypeSelectionFlag::eRIGID_STATIC |PxActorTypeSelectionFlag::eRIGID_DYNAMIC #if PX_USE_PARTICLE_SYSTEM_API |PxActorTypeSelectionFlag::ePARTICLE_SYSTEM |PxActorTypeSelectionFlag::ePARTICLE_FLUID #endif #if PX_USE_CLOTH_API |PxActorTypeSelectionFlag::eCLOTH #endif ; Ps::Array<PxActor*> objects(scene.getNbActors(selectionFlags)); const PxU32 nb = scene.getActors(selectionFlags, objects.begin(), objects.size()); PX_ASSERT(nb==objects.size()); PX_UNUSED(nb); for(PxU32 i=0; i<objects.size(); i++) objects[i]->collectForExport(collection); } // Collect constraints { Ps::Array<PxConstraint*> objects(scene.getNbConstraints()); const PxU32 nb = scene.getConstraints(objects.begin(), objects.size()); PX_ASSERT(nb==objects.size()); PX_UNUSED(nb); for(PxU32 i=0; i<objects.size(); i++) { PxU32 typeId; PxJoint* joint = reinterpret_cast<PxJoint*>(objects[i]->getExternalReference(typeId)); if(typeId == PxConstraintExtIDs::eJOINT) joint->collectForExport(collection); } } // Collect articulations { Ps::Array<PxArticulation*> objects(scene.getNbArticulations()); const PxU32 nb = scene.getArticulations(objects.begin(), objects.size()); PX_ASSERT(nb==objects.size()); PX_UNUSED(nb); for(PxU32 i=0; i<objects.size(); i++) objects[i]->collectForExport(collection); } // Collect aggregates { Ps::Array<PxAggregate*> objects(scene.getNbAggregates()); const PxU32 nb = scene.getAggregates(objects.begin(), objects.size()); PX_ASSERT(nb==objects.size()); PX_UNUSED(nb); for(PxU32 i=0; i<objects.size(); i++) objects[i]->collectForExport(collection); } }