ChangeEnvironmentDynamicsOperator

Introduced

v5.0

Description

Changes the rigid body dynamics engine (from physX to ODE or vice-versa) for the specified environment.

Scripting Syntax

ChangeEnvironmentDynamicsOperator( [InputEnvironment], [DynamicsEngine] );

Parameters

Parameter Type Description
InputEnvironment SimulationEnvironment Environment for which we want to change the rigid body dynamics engine

Default Value: Current active environment

DynamicsEngine siRBDEngine The dynamics engine to which you want to switch the specified environment

Default Value: siPhysXEngine

Examples

JScript Example

/*

	This example illustrates how to create a simple RigidBody simulation

	and then switch the dynamics engine

*/

var oCone = ActiveSceneRoot.AddGeometry("cone","MeshSurface");

var oModel = ActiveSceneRoot.AddModel();

oModel.Name = "Model";

var oGrid = oModel.AddGeometry("grid","MeshSurface");

// Move the cone

oCone.posy.value = 6.0;

// Modify the grid

oGrid.ulength.value = 24;

oGrid.vlength.value = 24;

oGrid.subdivu.value = 24;

oGrid.subdivv.value = 24;

// The following line creates the SimulationEnvironment object.

CreatePassiveRigidBody( oGrid );

CreateActiveRigidBody( oCone );

CreateForce( "Gravity" );

var oEnvironment = ActiveProject.ActiveScene.ActiveSimulationEnvironment;

// Switch the rigid body dynamics engine to PhyX by NVIDIA 

ChangeEnvironmentDynamicsOperator(  oEnvironment, siPhysXEngine);

// Results of running this script:

//  * If the currently used engine is the same as the one specified in

//    the command, there is no output.

//  * Otherwise the following output will be echoed (as appropriate):

//    //INFO : Switched to physX

//    or

//    //INFO : Switched to ODE

// Simulate

for(i =0 ; i < 100 ; i++)

{

	NextFrame();

	Refresh();

}

// Switch the rigid body dynamics engine to ODE

ChangeEnvironmentDynamicsOperator( oEnvironment, siOpenDynamicsEngine);

// Simulate again

FirstFrame();

Refresh();

for(i =0 ; i < 100 ; i++)

{

	NextFrame();

	Refresh();

}

See Also

CreateActiveRigidBody CreatePassiveRigidBody RemoveRigidBody AttachRigidBodies