void RealTimeSimpleDestruction(SceneManager& system) { NewtonWorld* world; world = system.m_world; // create the sky box and the floor, BuildFloorAndSceneRoot (system); // save the system wit the world NewtonWorldSetUserData(system.m_world, &system); // Set a world destruction callback so that we can destroy all assets created for special effects NewtonWorldSetDestructorCallBack (system.m_world, DestroyWorldCallback); // Set a Function callback for when a Convex Body collision is destroyed if the force exceeded the Max break value NewtonSetDestroyBodyByExeciveForce (system.m_world, DestroyThisBodyCallback); // this will load a assets to create destruction special effects LoadDestructionCutterMesh (system.m_world); BreakableStruture (system, dVector (-10.0f, 0.0f, -10.0f, 0.0f), 2); BreakableStruture (system, dVector ( 10.0f, 0.0f, -10.0f, 0.0f), 5); BreakableStruture (system, dVector (-10.0f, 0.0f, 10.0f, 0.0f), 3); BreakableStruture (system, dVector ( 10.0f, 0.0f, 10.0f, 0.0f), 3); }
dNewton::dNewton() :m_maxUpdatePerIterations(2) { // create a newton world m_world = NewtonCreate(); // for two way communication between low and high lever, link the world with this class for NewtonWorldSetUserData(m_world, this); // set the simplified solver mode (faster but less accurate) NewtonSetSolverModel (m_world, 1); // by default runs on four micro threads NewtonSetThreadsCount(m_world, 4); // set the collision copy constructor callback NewtonWorldSetCollisionConstructorDestructorCallback (m_world, OnCollisionCopyConstruct, OnCollisionDestructorCallback); // use default material to implement traditional "Game style" one side material system int defaultMaterial = NewtonMaterialGetDefaultGroupID (m_world); NewtonMaterialSetCallbackUserData (m_world, defaultMaterial, defaultMaterial, m_world); NewtonMaterialSetCompoundCollisionCallback(m_world, defaultMaterial, defaultMaterial, OnCompoundSubCollisionAABBOverlap); NewtonMaterialSetCollisionCallback (m_world, defaultMaterial, defaultMaterial, OnBodiesAABBOverlap, OnContactProcess); // add a hierarchical transform manage to update local transforms new dNewtonTransformManager (this); // set the timer ResetTimer(); }
NzPhysWorld::NzPhysWorld() : m_gravity(NzVector3f::Zero()), m_stepSize(0.005f), m_timestepAccumulator(0.f) { m_world = NewtonCreate(); NewtonWorldSetUserData(m_world, this); }
PhysWorld3D::PhysWorld3D() : m_gravity(Vector3f::Zero()), m_maxStepCount(50), m_stepSize(0.005f), m_timestepAccumulator(0.f) { m_world = NewtonCreate(); NewtonWorldSetUserData(m_world, this); m_materialIds.emplace("default", NewtonMaterialGetDefaultGroupID(m_world)); }
// Constructor World::World(Ogre::Real desiredFps, int maxUpdatesPerFrames, Ogre::String name) : m_bodyInAABBIterator(this) { #ifndef WIN32 pthread_mutex_init(&m_ogreMutex, 0); #endif setUpdateFPS(desiredFps, maxUpdatesPerFrames); m_limits = Ogre::AxisAlignedBox(Ogre::Vector3(-100,-100,-100), Ogre::Vector3(100,100,100)); m_world = NewtonCreate(); if (!m_world) { // world not created! } NewtonWorldSetUserData( m_world, this ); // create the default ID. m_defaultMatID = new OgreNewt::MaterialID( this, NewtonMaterialGetDefaultGroupID( m_world ) ); m_leaveCallback = NULL; m_defaultAngularDamping = Ogre::Vector3(0.1f, 0.1f, 0.1f); m_defaultLinearDamping = 0.1f; m_debugger = new Debugger(this); // set the default solve mode to be iterative the fastest setSolverModel (SM_FASTEST); // use the more advanced hardware in the system Ogre::String description; setPlatformArchitecture (3); getPlatformArchitecture (description); // set one tread by default setThreadCount(1); // store the world by name in a static map worlds[name] = this; }
void DemoEntityManager::Cleanup () { // is we are run asynchronous we need make sure no update in on flight. if (m_world) { NewtonWaitForUpdateToFinish (m_world); } // destroy all remaining visual objects while (dList<DemoEntity*>::GetFirst()) { RemoveEntity (dList<DemoEntity*>::GetFirst()); } m_sky = NULL; // destroy the Newton world if (m_world) { // get serialization call back before destroying the world NewtonDestroy (m_world); m_world = NULL; } // memset (&demo, 0, sizeof (demo)); // check that there are no memory leak on exit dAssert (NewtonGetMemoryUsed () == 0); // create the newton world m_world = NewtonCreate(); // link the work with this user data NewtonWorldSetUserData(m_world, this); // set joint serialization call back CustomJoint::Initalize(m_world); // add all physics pre and post listeners // m_preListenerManager.Append(new DemoVisualDebugerListener("visualDebuger", m_world)); new DemoEntityListener (this); m_cameraManager = new DemoCameraListener(this); // m_postListenerManager.Append (new DemoAIListener("aiManager")); // set the default parameters for the newton world // set the simplified solver mode (faster but less accurate) NewtonSetSolverModel (m_world, 4); // newton 300 does not have world size, this is better controlled by the client application //dVector minSize (-500.0f, -500.0f, -500.0f); //dVector maxSize ( 500.0f, 500.0f, 500.0f); //NewtonSetWorldSize (m_world, &minSize[0], &maxSize[0]); // set the performance track function //NewtonSetPerformanceClock (m_world, dRuntimeProfiler::GetTimeInMicrosenconds); // clean up all caches the engine have saved NewtonInvalidateCache (m_world); // Set the Newton world user data NewtonWorldSetUserData(m_world, this); // we start without 2d render m_renderHood = NULL; m_renderHoodContext = NULL; }