Talk:Integrating the Newton Dynamics Engine

From C4 Engine Wiki

Jump to: navigation, search

In the ShotController::ProcessGeometryProperties()

I changed the

physicsController->SetForce(force * shotImpulse * 5.0F, zerovec);

to

physicsController->SetForce(force * shotImpulse, zerovec);

The shots tend not to blow the objects out of the map with this set --JamesH 15:41, 14 October 2006 (PDT)


To get a more realistic friction with Newton, change the code in

void PhysicsMgr::Init(void) 

From

	// set the linear solver model for faster speed 
	NewtonSetSolverModel (nWorld, 8); 

	// set the adpative friction model for faster speed 
	NewtonSetFrictionModel (nWorld, 1);

to

	// set the linear solver model for faster speed 
	NewtonSetSolverModel (nWorld, 0); 

	// set the adpative friction model for faster speed 
	NewtonSetFrictionModel (nWorld, 0);

--JamesH 16:27, 14 October 2006 (PDT)


The only thing to keep in mind when you switch the solver model to exact is that it will run a lot slower. So you will be able to simulate less objects in a given time span - FlashJackson


To bring the Controller registration into line with the rest of MGGame.

in MGGame.cpp Remove

static ControllerRegistration physicsbodyControllerReg(kControllerPhysicsBody, "Pbod", &PhysicsBodyController::ValidNode);

in the code above, find

lightningControllerReg(kControllerLightning, stringTable.GetString(StringID('CTRL', 'LTNG')), &LightningController::ValidNode),

and after this line add

physicsbodyControllerReg(kControllerPhysicsBody, stringTable.GetString(StringID('CTRL', 'PBOD')), &PhysicsBodyController::ValidNode);

in MGGame.h, find

ControllerRegistration       lightningControllerReg;

and after this line add

ControllerRegistration       physicsbodyControllerReg;

Find Game.txt which is in the import\txt folder, after the

'LTNG' "Lightning"

Add

'PBOD' "Physics Body"

To import the new Game.txt

  • Run C4, and access the console by pressing the tilde key.
  • In the console command line, type istring and press enter.
  • Select Game.txt from the list and click OK.

--JamesH 00:07, 17 October 2006 (PDT)