Ok, guys, sorry for a necroing the old post, but I've just started to play with LODs in 2.1 and... It doesn't seem to do ANYTHING to me.
Basically, I've created a simple scene into which I load some meshes very like V2Mesh tutorial shows (i.e. I switched back to v1 meshe format in the file I am loading). I just added that MeshLodGenerator snippet from the OP (almost 1:1, just switched the distances to 10 and 20 for easier testing) before I import that v1 mesh into v2 and add it to the scene node:
Code: Select all
Ogre::v1::MeshPtr v1Mesh = Ogre::v1::MeshManager::getSingleton().load(
"test.mesh", Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME,
Ogre::v1::HardwareBuffer::HBU_STATIC, Ogre::v1::HardwareBuffer::HBU_STATIC);
Ogre::LodConfig config(v1Mesh);
config.strategy = Ogre::DistanceLodBoxStrategy::getSingletonPtr();
config.createGeneratedLodLevel(10, 0.4);
config.createGeneratedLodLevel(20, 0.7);
Ogre::MeshLodGenerator::getSingletonPtr().generateLodLevels(config);
//Create a v2 mesh to import to, with a different name (arbitrary).
Ogre::MeshPtr v2Mesh = Ogre::MeshManager::getSingleton().createManual("test.mesh.imported", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Everything compiles and runs, but the results look EXACTLY as there are no any LODs. I've tried to play with different strategies (the same in config.strategy and later calling Ogre::LodStrategyManager::getSingleton().setDefaultStrategy() ) but still the same - original mesh is shown no matter how far I move the camera. That was strange, so I added that to check:
Code: Select all
class MyLodListener : public Ogre::LodListener {
virtual bool prequeueEntityMaterialLodChanged(Ogre::EntityMaterialLodChangedEvent & evt) {
logMessage("EntityMaterialLodChangedEvent");
return false;
}
virtual bool prequeueEntityMeshLodChanged(Ogre::EntityMeshLodChangedEvent & evt) {
logMessage("EntityMeshLodChangedEvent");
return false;
}
virtual bool prequeueMovableObjectLodChanged(const Ogre::MovableObjectLodChangedEvent & evt) {
logMessage("MovableObjectLodChangedEvent");
return false;
}
};
And then in the CreateScene01:
Code: Select all
MyLodListener* lodListener = new MyLodListener();
sceneManager->addLodListener(lodListener);
But neither of those prequeue functions are fired when I move the camera (even quite far). Also, just to try to see, I added exporting of the resulting v2 mesh after it being processed by the MeshLodGenerator. The file I get is 1:1 as if the very original mesh.xml converted to v2 mesh... Looks like there are just no LODs at all in my scene.
So, I am wondering - are the LODs working (I guess they should?) and if so, what am I doing wrong?
How one is supposed to use the LODs? Must be something stupid I am missing, like a generic init or something...