Treecollision - single mesh only?

pra

04-05-2007 23:41:03

I'm trying to use the .scene format. Copypasting the code from Ogre wiki was no problem, it created all objects and attachted them to a snige scenenode. Then i tried to create TreeCollision basing on this node, it didn't worked. I looked in the OgreNewt code, that can't possibly work, since it tries to retrieve one mesh attached to the node.
My question: should i create separate bodies for all meshes of the .scene, or should i try to modify OgreNewt to make it look for all meshes? (what's better: lots of small or one large treecollision body?)

if the second one:
(OgreNewt_CollisionPrimitives.cpp)
TreeCollision::TreeCollision( const World* world, Ogre::SceneNode* node, bool optimize ) : Collision( world )
{
Ogre::Vector3 scale;

start();

//now get the mesh!
Ogre::MovableObject* obj = node->getAttachedObject(0);
obj->getMovableType();

Ogre::MeshPtr mesh = ((Ogre::Entity*)obj)->getMesh();

//get scale
scale = node->getScale();

//find number of sub-meshes
unsigned short sub = mesh->getNumSubMeshes();

for (unsigned short cs=0;cs<sub;cs++)
{
Ogre::SubMesh* sub_mesh = mesh->getSubMesh(cs);
(...)
}
//done!
finish( optimize );
}

can i just run the for-loop over and over for each mesh, or ist it more complicated?

walaber

05-05-2007 01:30:01

there is a new parser that will traverse an entire set of SceneNodes and make a single TreeCollision from them. Look for it, it's in the latest version!

pra

05-05-2007 12:53:07

ah, cool!
alerady DLing

pra

05-05-2007 13:12:07

er, where exactly is this new version?

I DLed a OgreNewt.rar from walaber.com, but the code there looks the same...

Game_Ender

05-05-2007 15:20:53

OgreAddons in Ogre's CVS tree.

pra

05-05-2007 15:45:33

found it, will try this one

thx

pra

06-05-2007 16:32:49

Ah, it's called TreeCollisionSceneParser. OMFG, and I look at the TreeCollision constructor and wonder why it's still the same... -.-

well, let's see how it works...

pra

17-06-2007 20:30:57

ok, i see it has been updated in the CVS, but there is still one thing:
is it meant that the scenenode has to be at (0,0,0) and Quaternion::IDENTITY in order to be parsed correctly? I think it's not like this with the other treecollision parser.
in the code I posted in this thread, the bool rootNode param should take care of this. is there a reason it's not been used?
I think it's better with it, so i will use my code instead

walaber

18-06-2007 01:44:42

it should be working now. let me know if I missed something.

pra

18-06-2007 10:55:41

well, i don't see any changes in the CVS, and it still says last change: 2 days, and that's what i tested yesterday. or does the CVS just need time to show an update?

oddrose

08-07-2007 03:17:27

Hi, sorry about dragging up an old thread...

but you say (walaber) that the SceneParser "traverses an entire set of SceneNodes" ...but the parameter you send to it in the constructor is an OgreNewt::World....

are you supposed to put all the objects into a separate world first?

EDIT: Sorry...found the add-functions...my bad

goldman82

09-07-2007 12:06:20

hi,

is it good to attach all meshs to one node?! i think no.
if i attach all my meshs to one node, the system renders all meshs. also hidden meshs or meshs behind the camera. if i make a node for every single meshs the systems renders only the node in current view -> speed up the framerate!

goldman82