[Bleeding] I've created a body, how to get its sceneNode?

FriedChicken

30-04-2008 09:14:59

It didn't work when I did like this

playerBody = mScene->createBody("player", new Cube(6.18,4,10), Vector3(350,200,350), "model: cube.1m.mesh, scale: 6.18 4 10", "mass: 300");

mSceneMgr->getSceneNode("player");

betajaen

30-04-2008 09:35:03

Okay, the quick and correct way of doing it is this (which you may want to turn into a macro or function, if used a lot.)

SceneNode* node = 0;
if (b->getRenderableTypeHash() == NxOgreClass_OgreNodeRenderable) {
node = static_cast<OgreNodeRenderable*>(b->getRenderable())->getNode();
}


Where "b" is the name of your body and must be a "Body" class, and only works with the default "OgreSceneRenderer" that comes with NxOgre.

Toby

01-05-2008 14:07:39

Better way is to create your own body class. Your body class will inherit of Actor and RenderableSource. Then you can store an OgreNodeRenderable in it and you will be able to get Ogre scenenode by calling getNode() on it.

betajaen

01-05-2008 14:14:20

This lovely article will show how to do it, just ignore the second section as it applies to '22.

http://www.nxogre.org/Inheriting_Actor_ ... type_class

Tsh't

02-05-2008 07:17:42

I saw in changelog since 0.9-34 you can also use "node:" in ActorParams as a parameter to pass your own created node name. Is it working in bleeding ? I don't see any reference of this parameter string in actor param list in the code in 1.0 rev 21... And "params.mNodeName" seems to be not defined neither.
Another way to do it now ?

betajaen

02-05-2008 07:26:12

No, "node" implies a renderable. Which Actors aren't RenderableSources and they must be completely non Rendersystem specific.

The closest to that is using this is NodeRenderableParams given in when you create a body or any inherited Actor with a RenderableSource.

identifier: node-name, identifier-type: reference"

Notice the reference part on the identifier-type, if it isn't there. NxOgre will try and create a node with "node-name", with the reference it just finds the node and copies the pointer. This behaviour is specific to Ogre renderer supplied by NxOgre, any others the behaviour may be different.

I'm slowly creating a series of articles at NxOgre.org explaining in great detail on how the Rendersystem works.

http://www.nxogre.org/RenderSystem

Obviously not finished, but now and again - I like to take ten minutes to add another paragraph.

Tsh't

02-05-2008 19:53:20

Thanks. It makes sense ! As I have a function which only load rendering resources when needed, it fits pretty well.
It's also a third solution to get sceneNodes I think, create it yourself, keep node and the body in a single class for your object...

betajaen

02-05-2008 20:32:39

It's also a third solution to get sceneNodes I think, create it yourself, keep node and the body in a single class for your object...

If you have to. But the OgreNodeRenderable class has a wealth of Node and Entity functions which you can mix and match together. If I must say it's a neat little class for Ogre without the NxOgre bits.