[SOLVED] XSI exporter and calculate tangent error

The place for artists, modellers, level designers et al to discuss their approaches for creating content for OGRE.

[SOLVED] XSI exporter and calculate tangent error

Postby novaumas » Sun Feb 17, 2008 5:19 pm

Hi!

I'm having trouble getting the Softimage exporter to generate tangents for a model :?

It gives me the following message and won't let me export the mesh when I ask it to generate the tangents for me:
"Cannot locate an appropriate 2D texture coordinate set for all the vertex data in this mesh to create tangents from."

I've tried to export just the mesh and use the result to generate the tangents from the command line tools, and it gives me the same error message.

I've looked at the OgreMesh.cpp file, but being unfamiliar with many of the Ogre source yet, I can only try to guess what the problem may be.

Converting the mesh to xml format, it shows the following structure for vertices:
Code: Select all
<vertexbuffer positions="true" normals="true" colours_diffuse="true" texture_coord_dimensions_0="3" texture_coords="1">


And for each vertex something like this:
Code: Select all
<vertex>
  <position x="0.070082" y="1.32982" z="-0.316299" />
  <normal x="0.0905379" y="0.58691" z="-0.804574" />
  <colour_diffuse value="0 0.541176 0.47451 0.976471" />
  <texcoord u="0.911252" v="0.661697" w="0.3898" />
</vertex>


If you need more info or would like me to provide a test ogre mesh or XSI project, I'll be happy to :D

Thanks!
Last edited by novaumas on Thu Mar 13, 2008 5:56 am, edited 1 time in total.
User avatar
novaumas
Greenskin
 
Posts: 107
Kudos: 4
Joined: 21 Jan 2008
Location: Barcelona

Postby novaumas » Sun Feb 17, 2008 8:52 pm

Found a workaround, and I'm sure someone will find it of some use.

What I've done is:

Export the mesh without generating tangent information in the XSI exporter.

Use OgreXMLConverter to get the xml file of the mesh.

Change where it says 'texture_coord_dimensions_0="3"' to 'texture_coord_dimensions_0="2"'

Use the command line tools to convert back to binary mesh and generate the tangents.

It's a little bit cumbersome, but it gets the job done...

I think the real solution would be to fix this line in OgreMesh.cpp to accept VET_FLOAT3 as a valid type also, but haven't tested it, so can't really say.
Code: Select all
if (testElem->getType() == VET_FLOAT2)
{
  // Ok, we found it
  sourceElem = testElem;
}
User avatar
novaumas
Greenskin
 
Posts: 107
Kudos: 4
Joined: 21 Jan 2008
Location: Barcelona

Postby Lizard » Mon Feb 18, 2008 1:12 am

I don't think the exporter actually creates the tangent data does it ?

it only exports the tangent data already contained within the mesh.

try running the mesh through the ultimapper utility within XSI this should generate the tangent data for you which you can then export using the exporter .


I think that's right anyway I'm a bit of a newb at this myself but I had a similar error and using ultimapper fixed it.
Lizard
Halfling
 
Posts: 46
Kudos: 0
Joined: 21 Dec 2006
Location: Suffolk, England

Postby novaumas » Mon Feb 18, 2008 1:41 am

Hi Lizard,

I'm already using Ultimapper to generate the normal maps and tangents for XSI, but I'm quite sure it didn't export the tangents by default for my model :( You can see that in the vertex structure that resulted from the conversion to XML.

In the exporter there is a checkbox for the tangent data generation, so was trying to use that. I don't know if there is a way to use the tangent data calculated by XSI, but if there is, it surely isn't obvious.

Here is the structure for the model when I exported it, maybe it's not organised the way the exporter needs it to be:
Image

This model has gone through various conversions from and to obj format, don't know if that's relevant information either, but it's quite a normal process for a model.

Anyway, I did get to generate the tangents by using the workaround in my second post, but it would be nicer if the exporter and command line tools worked directly :D
User avatar
novaumas
Greenskin
 
Posts: 107
Kudos: 4
Joined: 21 Jan 2008
Location: Barcelona

Postby sinbad » Tue Feb 19, 2008 7:18 pm

The tangents generation process needs a set of 2D texture coordinates to calculate the tangents from. It looks to me like your models only have 3D texture coordinates, which might be a result of the way you're UV unwrapping them. The fact that it works at all if you hack the XML to pretend it's 2D texture coords suggests that you didn't need or want 3D texture coords anyway - it's better to resolve the underlying issue and make sure your model has regular 2D UVs for its base mapping.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
 
Posts: 19261
Kudos: 69
Joined: 06 Oct 2002
Location: Guernsey, Channel Islands

Postby novaumas » Tue Feb 19, 2008 10:39 pm

I used max to unwrap the models, then exported them to .obj and opened them from xsi for normal map stuff, as it's the tool our animators work with.

max has uvw coordinates, so probably those were exported. The fact is that the w coordinate can be safely ignored for most models.

Taking that into account, I think that an artist tool should first and foremost be flexible. It's usability what you strive for, and having to work around the tools limitations is an important issue.

If the third mapping coordinate can be ignored safely, the generation process should allow it. Maybe a message indicating that the generation can be done only with uv coords, and that the 3rd component will be ignored.

So while I agree there is an underlying cause in the model, I think it shouldn't be a dead end for an artist.
User avatar
novaumas
Greenskin
 
Posts: 107
Kudos: 4
Joined: 21 Jan 2008
Location: Barcelona

Postby sinbad » Wed Feb 20, 2008 11:36 am

The problem is we have no way to know whether that 3rd coordinate can be ignored or not. The XSI exporter is smart enough to use UV or UVW projection in the right circumstances based on the unwrapping but the ability to know that is removed because you've passed it through an intermediate source - the unwrapping is now 'Explicit UVWs' so we respect that. The W values aren't even zero.

While I agree that the tool should be easy, this problem is specifically a result of the pipeline you've chosen. If you want you can alter the exporter to deal with it but it's really not a general case.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
 
Posts: 19261
Kudos: 69
Joined: 06 Oct 2002
Location: Guernsey, Channel Islands

Postby novaumas » Wed Feb 20, 2008 2:05 pm

The problem is we have no way to know whether that 3rd coordinate can be ignored or not

The fact that the user asks for tangent generation, and that tangent generation can only be done with a set of uv coordinates could be a pointer to ignoring the 3rd coordinate, as it's the only way to generate the tangent coordinates.
Another option would be exporting the tangents calculated by XSI, as it isn't so picky about the uv coordinates it's fed in order to calculate tangents.

The W values aren't even zero

You are right about that. It's common for all models unwrapped with Max. We are now using XSI because it's what our animators use, but I did the unwrapping and part of the modeling with Max as I'm more comfortable with it. Some other members of the team are using Roadkill to do the unwrapping.

While I agree that the tool should be easy, this problem is specifically a result of the pipeline you've chosen. If you want you can alter the exporter to deal with it but it's really not a general case.

It seems we don't agree on how the exporter should deal with the case :D

Anyway, thanks for the replies. I now know the official position on this :)
I think it's safe to leave the discussion here, as we could argue forever on this without agreeing, so it would be of little use.

Calling XSI users now... anyone know how to convert explicit uvws to simple uvs?
User avatar
novaumas
Greenskin
 
Posts: 107
Kudos: 4
Joined: 21 Jan 2008
Location: Barcelona

Postby novaumas » Thu Mar 13, 2008 5:55 am

We were still having problems with this, so dug deeper and found a way around the W coordinate issue. Perhaps it will be of use for XSI users with weird UV unwrapping workflows like us :D

Setting the W coordinate to 0 before exporting is the solution ( thanks sinbad ), the problem though is that there is no convenient way of editing the W coordinate in XSI, so it must be done through a script.

The following XSI vb script sets W coordinate of a texture projection to 0.
You must have your texture projection selected in order for it to work.
Code: Select all
set projection = Selection( 0 )
set objects = projection.parent

TranslateUVW objects, projection, 0, 0, 0, siAbsolute, siW, true
FreezeObj


Hope it's of some use ( I still would rather have the exporter do the job for me :twisted: )
User avatar
novaumas
Greenskin
 
Posts: 107
Kudos: 4
Joined: 21 Jan 2008
Location: Barcelona


Return to Artists & Content Creators

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest