Exemple #1
0
/*
=============
CMod_PhysicsInit
=============
*/
void CMod_PhysicsInit() {
	Com_Printf("----- Initializing Newton Physics Engine -----\n");
	Com_Printf("Initialized with Newton Version %i.%i \n", NEWTON_MAJOR_VERSION, NEWTON_MINOR_VERSION);
	Com_Printf("----------------------------------------------\n");

	// create the Newton World
	bspModels.clear();
	g_world = NewtonCreate (AllocMemory, FreeMemory);

	// use the standard x86 floating point model  
	// Dushan - the engine will try to use the best possible hardware setting found in the current platform this is the default configuration
	NewtonSetPlatformArchitecture (g_world, 2);

	// Set up default material properties for newton
	defaultMaterialGroup = NewtonMaterialGetDefaultGroupID(g_world);
	NewtonMaterialSetDefaultFriction   (g_world, defaultMaterialGroup, defaultMaterialGroup, 0.9f, 0.5f);
	NewtonMaterialSetDefaultElasticity (g_world, defaultMaterialGroup, defaultMaterialGroup, 0.4f);
	NewtonMaterialSetDefaultSoftness   (g_world, defaultMaterialGroup, defaultMaterialGroup, 0.1f);
	NewtonMaterialSetCollisionCallback (g_world, defaultMaterialGroup, defaultMaterialGroup, NULL, NULL, NULL);
	NewtonMaterialSetDefaultCollidable (g_world, defaultMaterialGroup, defaultMaterialGroup, 1 );

	// configure the Newton world to use iterative solve mode 0
	// this is the most efficient but the less accurate mode
	NewtonSetSolverModel (g_world, 8);
	NewtonSetFrictionModel (g_world, 0);

	g_collision = NULL;
}
Exemple #2
0
int main (int argc, char* argv[])
{

	_CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF|_CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF));

	// initialize graphics system
	if (!InitGraphicsSystem (800, 600)) {
		exit (0);
	}
	// set a callback for destroying the world ate termination
	atexit (ShutDown);

	// Create a Simple Scene Manager
	g_sceneManager = new SceneManager();

	// set the memory allocators
	NewtonSetMemorySystem (AllocMemory, FreeMemory);

	// create the Newton World
	g_world = NewtonCreate ();

	// use the standard x87 floating point model  
	NewtonSetPlatformArchitecture (g_world, 0);

	// set a fix world size
//	dVector minSize (-500.0f, -500.0f, -500.0f);
//	dVector maxSize ( 500.0f,  500.0f,  500.0f);
//	NewtonSetWorldSize (g_world, &minSize[0], &maxSize[0]); 

	// initialize Newton Visual Debugger
#ifdef USE_VISUAL_DEBUGGER
	g_newtonDebugger = NewtonDebuggerCreateServer ();
#endif

	// configure the Newton world to use iterative solve mode 0
	// this is the most efficient but the less accurate mode
	NewtonSetSolverModel (g_world, 1);

	// now populate the world with Graphic and physical entities 
	CreateScene(g_world, g_sceneManager);

    // run the main application loop until the user terminate the app
    for (;;) {
        // Draw the screen. 
        AdvanceSimulation (GetTimeInMicrosenconds ());
    }

    // Never reached. 
    return 0;
}
Exemple #3
0
 void world::platform(unsigned n)
 {
     NewtonSetPlatformArchitecture(_world, n);
 }