Gillian_Seed
10-08-2008 10:27:28
Hi,
I would like to add physics in my app, and I chose OgreNewt to do that (thank you very much, Walaber, for your work !).
I followed the very first steps from OgreNewt's Wikipage (
http://www.ogre3d.org/wiki/index.php/Newton_Game_Dynamics), and everything worked quite fine.
Now, I would like to configure my landscape in order to make it "solid".
So, here are 2 short questions :
1) since my terrain is not a plane landscape, I can forget about "CollisionPrimitives::Box()". So, using OgreNewt, how do you proceed with such terrains which have hills ?
2) It's a heightmap-based terrain, and, in my app, the terrain is loaded using a "terrain.cfg" file (so, it's not a mesh). Is this solution ok for adding collisions or isn't it convenient (= will I have to use a mesh) ?
Thank you for your pieces of advice !
walaber
11-08-2008 18:46:13
please search the forum, many users have used OgreNewt with the various terrain scene managers available, so I know it's possible.
Gillian_Seed
12-08-2008 08:56:32
Thank you for your reply, walaber !
Actually, of course, before posting my question, I did search the forum for some answers. And, in order to use OgreNewt, it appears that :
- my terrain should be an actual mesh, and not a heighmap-based terrain
- I will have to use OgreNewt's "TreeCollision serialization" feature.
But, since I'm a beginner with OgreNewt, it's still not crystal-clear for me (sorry), so, if anyone could :
- 1) confirm that I'm not going in the right direction with my heighmap-based terrain
and
- 2) give me some good resources/hints in order to start with the TreeCollision serialization
that would be really nice !
Thanks a lot !
terrain.cfg... is that the regular simple terrain what comes with ogre?
I have no idea how that works, but if you can access the heightmal data, the terrain's position offset and the terrain dimensions, you could do it similar to how I did it with ETM:
http://www.ogre3d.org/phpBB2addons/viewtopic.php?t=7721
and yes, serialisation is a good idea, if you have a huge terrain, it takes half an eternity to dynamically generate the collision
edit: treecollision is used by creating the TreeCollisionSerializer object, and then look at importTreeCollision and exportTreeCollision, its pretty simple.
don't forget to delete the object afterwards.
Btw@Walaber: it would be nice to be able to serialize to stream, too.
I had to make my own deserializer, since I store collision files in zip archives.
my "addCollisionFile" method:
bool ZipSaveFile::addTreeCollision(OgreNewt::CollisionPrimitives::TreeCollision *col,Ogre::String fileName)
{
if(hasFile(fileName))
return false;
//MemoryDataStreamPtr stream;
std::stringstream stream;
NewtonTreeCollisionSerialize(col->getNewtonCollision(),&ZipSaveFile::_tcSerialiseCallback,&stream);
addTextFile(stream.str(),fileName);
return true;
}
my serialize callback:
void ZipSaveFile::_tcSerialiseCallback(void* serializeHandle, const void* buffer, size_t size)
{
std::fstream *stream = static_cast<std::fstream*>(serializeHandle);
stream->write(static_cast<char*>(const_cast<void*>(buffer)),size);
}
not sure if this is a "clean" solution (stringstream and stuff) but it works for me...
Gillian_Seed
13-08-2008 10:06:45
Hi pra,
I checked what you did with ETM and OgreNewt, and I'll probably switch to ETM
Thanks a lot for your answer, I'll give it a try !!!