HexiDave
02-03-2006 00:58:01
Let me preface this by saying that I am still quite new to Ogre programming. I can get the terrain to function as a TreeCollision just fine, but something tells me I misread the PLSM2 wiki guide on integrating the TreeCollisionSerializer mechanism. Here's the code (appologies for the poor coding style - I've been trying about everything I could think of for a few hours now and my head is about to explode...):
If I were to tear it back down to just exporting the serialized data, it would go off without a hitch. What I can only guess is that I'm exporting the data wrong and it crashes the importer later. It exports properly in that it goes to the right place and places data in the file as I tell it to (434kb per file, 64 tfiles in all.) When reading the files in my Hex editor, they ARE different, so they are saving properly (I guess.) This is a call-back function for each time PLSM2's tileLoad'ing mechanism fires.
The kicker for me is that (if you see the markers in the Log output) when I run it after the crash, I get this:
How the hell is it finishing the serialization and not making it to the next log marker? What's worse is sometimes it actually gets a second tile loaded!
So, I'm at your mercy here. I can't go any further until I get this crazy thing to work. I just updated my CVS this morning, so I'm about as up-to-date as I can be. Any help you can provide would be most appriciated. It's probably something very simple, but I'm just not seeing it.
Thanks again.
Edit: If the code is too difficult to read, I can go back and edit/comment it. Sorry bout that
void PhysicsManager::loadTerrainGeometry(Ogre::PagingLandScapeTile* tile, Ogre::Vector3* vertices, int numVertices, Ogre::IndexData* indexData)
{
PagingLandScapeTileInfo *blah = tile->getInfo();
log->logMessage("Loading: " + StringConverter::toString(blah->tileX) + "-" + StringConverter::toString(blah->tileZ));
if (tilesBodies[tile]==NULL)
{
log->logMessage("Got to Stage 1");
TreeCollisionSerializer* serializer=new TreeCollisionSerializer();
CollisionPrimitives::TreeCollision* collision;
String tileData = "coldata//tile"+StringConverter::toString(blah->tileX)+"-"+StringConverter::toString(blah->tileZ)+".collision";
std::ifstream file;
file.open(tileData.c_str());
if(!file.is_open()){
log->logMessage("Not Found: " + tileData);
collision = new CollisionPrimitives::TreeCollision(mWorld,numVertices,vertices,indexData,false);
serializer->exportTreeCollision(collision,"coldata//tile"+StringConverter::toString(blah->tileX)+"-"+StringConverter::toString(blah->tileZ)+".collision");
////////////////////////Problem starts here\\\\\\\\\\\\
}else{
log->logMessage("Found: " + tileData);
collision=new CollisionPrimitives::TreeCollision(mWorld);
Ogre::DataStreamPtr ptr(new FileStreamDataStream(&file));
serializer->importTreeCollision(ptr,collision);
log->logMessage("Serialized Data");
}
log->logMessage("Got to Stage 2");
Body* body=new Body(mWorld,collision);
delete collision;
body->attachToNode(tile->getSceneNode());
tilesBodies[tile]=body;
log->logMessage("Added to Map");
}/////////////////// End of loading block \\\\\\\\\\\
log->logMessage("Tile done!");
}If I were to tear it back down to just exporting the serialized data, it would go off without a hitch. What I can only guess is that I'm exporting the data wrong and it crashes the importer later. It exports properly in that it goes to the right place and places data in the file as I tell it to (434kb per file, 64 tfiles in all.) When reading the files in my Hex editor, they ARE different, so they are saving properly (I guess.) This is a call-back function for each time PLSM2's tileLoad'ing mechanism fires.
The kicker for me is that (if you see the markers in the Log output) when I run it after the crash, I get this:
19:32:41: Loading: 2-3
19:32:41: Got to Stage 1
19:32:41: Found: coldata//tile2-3.collision
19:32:41: Serialized Data
How the hell is it finishing the serialization and not making it to the next log marker? What's worse is sometimes it actually gets a second tile loaded!
So, I'm at your mercy here. I can't go any further until I get this crazy thing to work. I just updated my CVS this morning, so I'm about as up-to-date as I can be. Any help you can provide would be most appriciated. It's probably something very simple, but I'm just not seeing it.
Thanks again.
Edit: If the code is too difficult to read, I can go back and edit/comment it. Sorry bout that