negi
24-12-2007 17:52:31
Hi All,
I have been working with OGRE for last 2 months, but just started using OGREODE .
I have a terrain with 20000+ trees and the player walks over the terrain. Now i want to detect collision between player and the trees.
What i have decided is i when adding player and those 20000 trees, i will add their geometries into "world space" and will register collision listener. Now two thoughts come to my mind:
1) Is it a good way to register geometries of 20000 trees ? Or we can do something better ? ( Anything other than grouping trees into bunches and using a single geometry for a bunch ? )
2) How can i create collision meshes for the trees ? So as to drop polygon count ?
Im using paged geometry to render trees. So i create only one tree entity but put it randomly over terrain. Here is the code:
TreeLoader3D *treeLoader = new TreeLoader3D(pg_trees, TBounds(0, 0, 1500, 1500));
pg_trees->setPageLoader(treeLoader);
//Load a tree entity
Entity *myEntity = mSceneMgrG->createEntity("Tree", "tree2.mesh");
//Randomly place 20,000 copies of the tree on the terrain
Vector3 position;
Radian yaw;
Real scale;
for (int i = 0; i < 20000; i++){
yaw = Degree(Math::RangeRandom(0, 360));
position.x = Math::RangeRandom(0, 1500);
position.z = Math::RangeRandom(0, 1500);
position.y = HeightFunction::getTerrainHeight(position.x, position.z);
scale = Math::RangeRandom(0.5f, 0.6f);
treeLoader->addTree(myEntity, position, yaw, scale);
}
So how to register tree geometry with ODE Space so that trees are collidable ?
Further in above code i do not create a scene node for trees. While EntityInformer::createSingleStaticBox() function it looks for scenenode of entity whose geometry is to be made:
BoxGeometry* EntityInformer::createSingleStaticBox(World *world, Space* space)
{
BoxGeometry* geom = new BoxGeometry(getSize(), world, space);
geom->setPosition(_node->getPosition());
geom->setOrientation(_node->getOrientation());
return geom;
}
Now since there is no scene node, this code wouldnt work.
Can anyone tell what to do here ?
Thanks
I have been working with OGRE for last 2 months, but just started using OGREODE .
I have a terrain with 20000+ trees and the player walks over the terrain. Now i want to detect collision between player and the trees.
What i have decided is i when adding player and those 20000 trees, i will add their geometries into "world space" and will register collision listener. Now two thoughts come to my mind:
1) Is it a good way to register geometries of 20000 trees ? Or we can do something better ? ( Anything other than grouping trees into bunches and using a single geometry for a bunch ? )
2) How can i create collision meshes for the trees ? So as to drop polygon count ?
Im using paged geometry to render trees. So i create only one tree entity but put it randomly over terrain. Here is the code:
TreeLoader3D *treeLoader = new TreeLoader3D(pg_trees, TBounds(0, 0, 1500, 1500));
pg_trees->setPageLoader(treeLoader);
//Load a tree entity
Entity *myEntity = mSceneMgrG->createEntity("Tree", "tree2.mesh");
//Randomly place 20,000 copies of the tree on the terrain
Vector3 position;
Radian yaw;
Real scale;
for (int i = 0; i < 20000; i++){
yaw = Degree(Math::RangeRandom(0, 360));
position.x = Math::RangeRandom(0, 1500);
position.z = Math::RangeRandom(0, 1500);
position.y = HeightFunction::getTerrainHeight(position.x, position.z);
scale = Math::RangeRandom(0.5f, 0.6f);
treeLoader->addTree(myEntity, position, yaw, scale);
}
So how to register tree geometry with ODE Space so that trees are collidable ?
Further in above code i do not create a scene node for trees. While EntityInformer::createSingleStaticBox() function it looks for scenenode of entity whose geometry is to be made:
BoxGeometry* EntityInformer::createSingleStaticBox(World *world, Space* space)
{
BoxGeometry* geom = new BoxGeometry(getSize(), world, space);
geom->setPosition(_node->getPosition());
geom->setOrientation(_node->getOrientation());
return geom;
}
Now since there is no scene node, this code wouldnt work.
Can anyone tell what to do here ?
Thanks