How does the DebugRenderer works?

mrmclovin

20-07-2008 00:16:42

Hello,

Im trying to learn some basic physics, and now i need to visualise my shapes. I've read that debugrenderer should make this work. But im not sure how to set up properly ?

//create world
mWorld = new World("time-controller: ogre");
mWorld->createDebugRenderer(mSceneMgr);

// create scene
mScene = mWorld->createScene("myFirstScene", mSceneMgr, "gravity: yes, floor: yes, renderer: ogre");
Actor* body = mScene->createActor("cube", new CubeShape(10,10,10), Vector3(x,y,0), "mass: 15");


All i can see is three lines pointing at each dimention, at Vector3::ZERO, but no shapes ?

radsun

20-07-2008 09:21:42

Is that all nxogre code you have?
Maby you forget this in frame start:
mNxWorld->getPhysXDriver()->simulate(evt.timeSinceLastFrame);
mNxWorld->getPhysXDriver()->render(evt.timeSinceLastFrame);

or maybe try to create simple box:
static const Real mesh_scale = 0.02;
static const Real physics_scale = 2.0;
String name = "Box_";
Vector3 pos(0,2,0);

Ogre::Entity *E = mSceneMgr->createEntity( name + "_bodyEntity", "cube.mesh" );
E->setMaterialName("Examples/10PointBlock");
E->setNormaliseNormals(true);
E->setCastShadows(true);

Ogre::SceneNode *sn = mSceneMgr->getRootSceneNode()->createChildSceneNode( name + "_bodySceneNode" );
sn->attachObject( E );
sn->scale( Vector3::UNIT_SCALE * mesh_scale );

NxOgre::ActorParams ap;
ap.setToDefault();
ap.mMass = 10.0;
ap.mDensity = 0.0;

NxOgre::NodeRenderableParams nrp;
nrp.setToDefault();

nrp.mIdentifierUsage = NxOgre::NodeRenderableParams::IU_Use;
nrp.mIdentifier = sn->getName();

Vector3 _dimensions = Vector3::UNIT_SCALE * physics_scale;

NxOgre::Body *body = mNxScene->createBody( name,
new NxOgre::Cube(
_dimensions.x, //width
_dimensions.y, //height
_dimensions.z), //lenght
pos, // global pose
nrp,
ap ); //
:roll:

betajaen

20-07-2008 10:29:52

Is that all nxogre code you have?
Maby you forget this in frame start:
mNxWorld->getPhysXDriver()->simulate(evt.timeSinceLastFrame);
mNxWorld->getPhysXDriver()->render(evt.timeSinceLastFrame);


You don't need that if you using the ogre time-controller; which he has. Infact if you do that with the ogre time controller then the every Scene is twice as fast as it should be.

And that Body code can be optimized down to two/three lines. ;)

mrmclovin

20-07-2008 16:29:40

Thanks for your answers!

Is this line enough:mWorld->createDebugRenderer(mSceneMgr);

to get all shapes visualised or do I need to something else?

betajaen

20-07-2008 17:14:40

No, that's it. If you need any more debug physics information then you should use the Remote Debugger.

mrmclovin

20-07-2008 18:49:41

No, that's it. If you need any more debug physics information then you should use the Remote Debugger.

Hm, okey sounds good. It's just that, that i can't get it (the shape) on the screen ? Im using the code in the first post. If I use createBody() instead I'm able to see a mesh affefected by the gravity, but I still can't see the physicsshape ? What could I possibly have missed? Some param perheps?

thanks in advance.

radsun

20-07-2008 20:17:43

I have found it :wink:
change this:
Actor* body = mScene->createActor("cube", new CubeShape(10,10,10), Vector3(x,y,0), "mass: 15");
for that:
Actor* body = mScene->createActor("cube", new Cube(10,10,10), Vector3(x,y,0), "mass: 15");

mrmclovin

20-07-2008 23:17:26

I have found it :wink:
change this:
Actor* body = mScene->createActor("cube", new CubeShape(10,10,10), Vector3(x,y,0), "mass: 15");
for that:
Actor* body = mScene->createActor("cube", new Cube(10,10,10), Vector3(x,y,0), "mass: 15");


Yes, I had that line from start. The reason I changed to CubeShape was that I got this error using Cube():
error C2664: 'NxOgre::Cube::Cube(NxOgre::CubeShape &,NxOgre::Actor *,NxArray<ElemType,AllocType> &,NxOgre::Skeleton *)' : cannot convert parameter 1 from 'int' to 'NxOgre::CubeShape &'

The second param in Cube requiers an Actor which Im about to create , so it's not possible use Cube() !? Im confused ..

mcaden

21-07-2008 19:07:36

I don't know what implementation you're using, but NxOgre::Cube::Cube doesn't look like that at all to me.

mrmclovin

21-07-2008 19:21:06

I don't know what implementation you're using, but NxOgre::Cube::Cube doesn't look like that at all to me.
Im using 0.9. At least i think so. Will doublecheck.

betajaen

21-07-2008 19:46:00

CubeShape = 0.9
Cube = 1.0