How to get raw heightmaps into ogre from PB ?
Posted: Tue Oct 20, 2015 2:55 pm
I found this in the ogre Wiki,
is there a chance to do this from PB, and if so, how exactly would i do that ?
Thanks & regards
Can I load raw height maps without using an image?
A. Yes
Terrain::ImportData imp;
imp.terrainSize = 513;
imp.worldSize = 12000;
imp.inputScale = 1.0;
imp.inputFloat = pRawFloats;
terrain->prepare(imp);
Basically, the new terrain doesn't need to use Image to load the height data, that's just a convenience. It far prefers it if you just give it a list of unscaled floats!
If your floats are just in a flat file, it's easy:
MemoryDataStream rawFloats(ResourceGroupManager::getSingleton().openResource(filename, groupName));
imp.inputFloat = (float*)rawFloats.getPtr();
Be aware though of endian issues when you're using raw files like this. This file will only work if saved / loaded on machines of the same endianness (this applies to Myrddin too).
Basically we don't do this via a filename because it's far more flexible just to accept packaged data like this, the float data can come from anywhere. Also, you can load / construct / modify it in a background thread and even call prepare() in a background thread so the entire terrain can be bootstrapped without blocking. Again, I would expect you only to do it this way at import time, the prepare(stream)/save/load functionality of Terrain is what you'd use after that.
is there a chance to do this from PB, and if so, how exactly would i do that ?
Thanks & regards
Can I load raw height maps without using an image?
A. Yes
Terrain::ImportData imp;
imp.terrainSize = 513;
imp.worldSize = 12000;
imp.inputScale = 1.0;
imp.inputFloat = pRawFloats;
terrain->prepare(imp);
Basically, the new terrain doesn't need to use Image to load the height data, that's just a convenience. It far prefers it if you just give it a list of unscaled floats!
If your floats are just in a flat file, it's easy:
MemoryDataStream rawFloats(ResourceGroupManager::getSingleton().openResource(filename, groupName));
imp.inputFloat = (float*)rawFloats.getPtr();
Be aware though of endian issues when you're using raw files like this. This file will only work if saved / loaded on machines of the same endianness (this applies to Myrddin too).
Basically we don't do this via a filename because it's far more flexible just to accept packaged data like this, the float data can come from anywhere. Also, you can load / construct / modify it in a background thread and even call prepare() in a background thread so the entire terrain can be bootstrapped without blocking. Again, I would expect you only to do it this way at import time, the prepare(stream)/save/load functionality of Terrain is what you'd use after that.
