OgreMeshTool, LODs and v2 format

Design / architecture / roadmap discussions related to future of Ogre3D (version 2.0 and above)
Post Reply
Hrenli
Halfling
Posts: 63
Joined: Tue Jun 14, 2016 12:26 pm
x 9

OgreMeshTool, LODs and v2 format

Post by Hrenli » Tue Aug 15, 2017 7:24 pm

Hi,

I am trying to get autogenerated LODs directly to v2 .mesh file using OgreMeshTool. Everything seems to work fine if I use v1 format. If I try to generate LODs directly into v2 format I am getting this error:
LOD Generation only works on v1 meshes at the moment.
Export it as -v1, run the command again, and re-export it to -v2
If I follow the error's suggestion by running:
OgreMeshTool.exe -autogen file.mesh.xml
OgreMeshTool.exe -v2 file.mesh
LODs seems to get lost from the file during second step no matter what... Is it me doing something stupid or it's not possible to get v2 .mesh file with LODs inside at the moment?
0 x

User avatar
SolarPortal
OGRE Contributor
OGRE Contributor
Posts: 128
Joined: Sat Jul 16, 2011 8:29 pm
Location: UK
x 4
Contact:

Re: OgreMeshTool, LODs and v2 format

Post by SolarPortal » Tue Aug 15, 2017 11:40 pm

Hi, i know this isnt for the OgreMeshTool.exe, but i had troubles when doing it in c++ and generating a manual v2 mesh that needed lods.
The problem stemmed from not being able to set the lod values to the v2 mesh / submesh and save to disk; so i made these changes:

* Add an additional 3 commands to OgreMesh2.cpp at around line 400: ( I only used the last 2 functions )

Code: Select all

    
...   
        const LodValueArray* _getLodValueArray(void) const                      { return &mLodValues; }
        void clearLodValues() { mLodValues.clear(); }
        void setLodValue(Ogre::Real index) { mLodValues.push_back(index); }
...
* Compile and then run in your app with this sort of function:

Code: Select all

void setupLodValues(int numLods, Ogre::MeshPtr mesh)
{
	Ogre::Real distances[5] = { 0, 20, 40, 50, 60 };
	mesh->clearLodValues();
	for (int i = 0; i < numLods; i++){
		mesh->setLodValue(distances[i]);
	}
}
As long as you add the lod vao to the submesh with something similar to this:

Code: Select all

	
	...	
	Ogre::VertexArrayObject* lodvao = vaoManager->createVertexArrayObject(vertexBuffers, indexBuffer, Ogre::OT_TRIANGLE_LIST);
	subMesh->mVao[Ogre::VpNormal].push_back( lodvao );
	subMesh->mVao[Ogre::VpShadow].push_back( lodvao );
	...
then you can add your own lod meshes and it will save to the v2 mesh format and can be read back from the file.

Hope this helps :)
0 x
Lead developer of the Skyline Game Engine: http://www.aurasoft-skyline.co.uk

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 3940
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 170
Contact:

Re: OgreMeshTool, LODs and v2 format

Post by dark_sylinc » Wed Aug 16, 2017 2:37 am

I should probably add this to my TODO list. I didn't know it was broken.

Thanks for posting the workaround :)
0 x

User avatar
SolarPortal
OGRE Contributor
OGRE Contributor
Posts: 128
Joined: Sat Jul 16, 2011 8:29 pm
Location: UK
x 4
Contact:

Re: OgreMeshTool, LODs and v2 format

Post by SolarPortal » Wed Aug 16, 2017 2:33 pm

no problem :)
0 x
Lead developer of the Skyline Game Engine: http://www.aurasoft-skyline.co.uk

Hrenli
Halfling
Posts: 63
Joined: Tue Jun 14, 2016 12:26 pm
x 9

Re: OgreMeshTool, LODs and v2 format

Post by Hrenli » Thu Aug 17, 2017 11:12 am

Thanks SolarPortal, I played with loading of different files a bit more and you are right. It seems that mLodValues is the only thing which is really missing. mNumLods is always 1 nowdays for v2 meshes but it seems not to be used at all. And mVao-s for submeshes seem to be loading correctly already with LODs.
0 x

Post Reply