Moderators: OGRE Team, MOGRE Moderators
using Mogre.PhysX;
// pseudo c#
class Whateva
{
static Physics p;
static Scene mainscene;
public static Physics InitPhysicsAndCreateScene()
{
var scd = new SceneDesc( SceneFlags.EnableActiveTransforms );
//
scd.BackgroundThreadCount = 2;
//
p = Phyics.Create();
mainscene = p.CreateScene( scd );
//
return p;
}
public static StopPhysics()
{
p.Dispose(); // also disposes all the scenes/actors/bodies/joints etcetera.
}
public static void OnFirstFrame()
{
mainscene.Simulate( 0 );
}
public static void AfterFrameUpdate()
{
// make all changes to the state of PhysX objects before this line
const float dt = 1.0f / 60;
//
// begin calculating next frame
mainscene.Simulate( dt );
}
public static void BeforeFrameUpdate()
{
// get physics results from previous frame
mainscene.FlushStream();
mainscene.FetchResults( SimulationStatuses.AllFinished, true );
mainscene.UpdateActiveTransforms();
// now copy all matrices (that have changed) from physx to your engine's scene graph
using ( var ats = mainscene.GetActiveTransforms() )
{
foreach ( var at in ats )
{
Node n = (Node)at.Actor.UserData; // I don't know what kind of scene elements Mogre uses, sorry
if ( n == null ) continue;
//
n.WorldMatrix = at.Actor2World;
}
}
}
}void DebugRenderer_renderData(DebugRenderable data)
{
data.Points;
data.Lines;
data.Triangles;
}Users browsing this forum: Beauty, Yahoo [Bot] and 4 guests