[solved] [2.1] Can't export meshes with tangents. Again.

Problems building or running the engine, queries about how to use features etc.
Post Reply
Dugi
Halfling
Posts: 46
Joined: Tue Jul 23, 2013 2:37 pm
x 7

[solved] [2.1] Can't export meshes with tangents. Again.

Post by Dugi »

Hello,

This is mostly a continuation of problems from this thread, but in this case, the issue appears to be different. Not sure if I should necropost it or put it into the 2.1 thread instead, maybe a moderator could decide...

When I try to export a v2 mesh with tangents, it fails with message Exception caught: Meshes with shared vertex buffers can't be dearranged. Without tangents, it works. I could possibly subdivide the meshes a couple of times and hope that LoD would deal with it, avoiding normal maps completely, but something tells me that it's not the right approach.

I have a mesh created with Blender's exporter. I can export it into a v2 mesh totally fine as long as I don't want to generate any normals. Or export it with normals that were generated while exporting to a v1 mesh.

This is what I should do according to OgreMeshTool's help:

Code: Select all

OgreMeshTool -e -t -ts 4 -O puqs sourcefile [destfile]
This is what works well, but isn't supposed to generate tangents:

Code: Select all

OgreMeshTool -e -ts 4 -O puqs sourcefile [destfile]
This works too, but it does not produce the tangents despite the -t setting:

Code: Select all

OgreMeshTool -v2 -p -t sourcefile [destfile]
This is what I get:

Code: Select all

...blablabla...
Mesh names done.
XMLMeshSerializer import successful.
Exception caught: Meshes with shared vertex buffers can't be dearranged.
I have looked at the source code, but I think that these shared vertex buffers come from some other place than my file.

Any idea what I am doing wrong? Or is it a regression?
Last edited by Dugi on Wed Nov 23, 2016 8:33 am, edited 1 time in total.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5299
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1279
Contact:

Re: [2.1] Can't export meshes with tangents. Again.

Post by dark_sylinc »

I'll take a look.

For the time being as a workaround I suggest using MeshTool to convert to v2 file format, then run it again on the generated .mesh file with "-v1" to generate a valid v1 mesh, then run it again to generate the tangents.

Basically xml -> v2 mesh -> v1 mesh -> anything you want with tangents.
Dugi
Halfling
Posts: 46
Joined: Tue Jul 23, 2013 2:37 pm
x 7

Re: [2.1] Can't export meshes with tangents. Again.

Post by Dugi »

Thanks for the reply!

This is what worked:

Code: Select all

OgreMeshTool -v1 -e -ts 4 -O puqs sourcefile.mesh.xml
OgreMeshTool -v2 -e -t -ts 4 sourcefile.mesh
A smaller problem is that adding -O puqs (or any of these four letters) to the argument list completely messes up the geometry.

Converting a v2 mesh to a v1 mesh didn't work, reporting that Exception caught: v1 Mesh with name 'conversion' already exists. Fortunately, it wasn't necessary.
DainiusVaiksnys
Gnoblar
Posts: 20
Joined: Wed Apr 01, 2015 3:03 pm
x 2

Re: [solved] [2.1] Can't export meshes with tangents. Again.

Post by DainiusVaiksnys »

Converting a v2 mesh to a v1 mesh didn't work, reporting that Exception caught: v1 Mesh with name 'conversion' already exists.
I have a fix in my fork for converting v2 -> v1. You can see it here: https://bitbucket.org/DainiusVaiksnys/o ... 21af8bd071
Dugi
Halfling
Posts: 46
Joined: Tue Jul 23, 2013 2:37 pm
x 7

Re: [solved] [2.1] Can't export meshes with tangents. Again.

Post by Dugi »

Thank you. Works like a charm when I need to get an xml file from a mesh.
hyyou
Gremlin
Posts: 173
Joined: Wed Feb 03, 2016 2:24 am
x 17
Contact:

Re: [solved] [2.1] Can't export meshes with tangents. Again.

Post by hyyou »

I faced the same issue as Dugi (my Ogre version = 2017-07-18, 0aa1824ee51258db9a153378b66f423feb136e6e) :-

Code: Select all

Exception caught: v1 Mesh with name 'conversion' already exists
, while trying to use OgreMeshTool to convert v2 dot-mesh file to v1 dot-mesh file. (I wish to finally convert it to .xml.)

Was DainiusVaiksnys's commit merged into Ogre main branch?

I want to debug whether Ogre really loaded a certain dot-mesh file with tangent.
- Which files in Ogre that I should step-into to check?
- OgreMeshSerializerImpl.cpp? The code there is hard-to-understand for me.

I want to debug wrong value of qtangent in VertexShader_vs.glsl that caused by me.

Edit: For unsure reason, my qtangent problem is fixed by using flag "-e -t -ts 4 -O pqs" (not puqs) for OgreMeshTool, follow the Official tutorial in "V2MeshGameState.cpp", and don't call "v1Mesh->buildTangentVectors();".
Post Reply