[SOLVED]OGRE3DBody node attach problem

mamairaja

11-10-2009 13:05:33

I am a new comer to nxogre and this forum.
So Hi to all,
I have just started nxogre and have followed the tutorial series. Upto now I have managed to run everything. But having a small problem with when ataching a ogre scene node to OGRE3DBody.
Following is my code and the output is in the following screen shot. As u see the size of the shape is extremely large and tree is not touching the ground. I think the way I have made the new NxOgre::Capsule(boxRadiosu,boxHeight) is wrong. Can you please help me complete this with proper visualization with proper physics
Thank You in adavance!!!

//-----

NxOgre::RigidBodyDescription tree_desc;
tree_desc.mMass = 1000;

SceneNode *treeNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("TREE_NODE");
Entity* treeEnt = mSceneMgr->createEntity( "TREE_ENT", "myTree3.mesh");


treeNode->attachObject( treeEnt );

Ogre::Real boxHeight = treeEnt-> getBoundingBox().getSize().y;
Ogre::Real boxRadiosu = treeEnt-> getBoundingBox().getSize().z;

OGRE3DBody* treeBody = mRenderSystem->createBody(new NxOgre::Capsule(boxRadiosu,boxHeight), NxOgre::Vec3(20,2,20), treeNode, tree_desc);

//------

spacegaier

11-10-2009 23:47:00

Okay, two things here:

1. A capsule is the wrong shape for a tree (as betajaen told me): Either use a simplified version of the tree as a triangle mesh or make a composite shape out of it with two parts: capsule to represent the trunk and a sphere to represent the top leavy part.

2. The z-component of the bounding box size is not the radius but the diameter. So, pass only half the value to the NxOgre::Capsule. And for the height, you have to know the following thing (as written in the class description): Total height of capsule = height + 2 * radius Therefore your height, which you pass to the NxOgre::Capsule constructor, should be boxHeight - boxRadiosu

mamairaja

12-10-2009 16:24:29

Hi spacegaier
Your solution works nicely. Thank You very uch for the explanation.
I have tried the triangle mesh thing also. Seems that is the perfect solution. But isn't it consume more processing power? Because i do not need that much of complex physics for example leaves of the tree.
And highly appreciate if u can make hint for creating composite physics bodies :)

And one more thing.
height = boxHeight - boxRadiosu -1; works fine
height = boxHeight - boxRadiosu ; prompt an debug error.

But still height = boxHeight - boxRadiosu -1; not makes huge damage to the visualization.

Thank You again