DTS, UVMapping question
by Shane McLeod · in Torque Game Engine · 01/16/2003 (3:45 pm) · 4 replies
As many of you know, I'm working on the trueSpace scnToDts exporter. I've been using the milkshape exporter code to springboard from and I seem to have hit a snag.
It appears as though the DTS format expects the total number of mesh vertices to equal the total number of texture coordinates. (Specifically, verts.sizeof( ) == tverts.sizeof( ) ).
How can this be? If you take a cube, and planar map it, you end up with 8 vertices and 12 UV coords, therefore the above test will always fail. There must be something I'm missing here. This seems to be the last hitch before I can get the beta out. I'm sure I just jinxed myself, but any clarification here would be extremely helpful.
It appears as though the DTS format expects the total number of mesh vertices to equal the total number of texture coordinates. (Specifically, verts.sizeof( ) == tverts.sizeof( ) ).
How can this be? If you take a cube, and planar map it, you end up with 8 vertices and 12 UV coords, therefore the above test will always fail. There must be something I'm missing here. This seems to be the last hitch before I can get the beta out. I'm sure I just jinxed myself, but any clarification here would be extremely helpful.
About the author
#2
I was worried about how the Torque would handle the duplicate spatial vertexes.
Anyway, thank you!
Shane
01/17/2003 (3:22 am)
Excellent, I sorta thought that was the solution but I just couldn't get around to accepting it.I was worried about how the Torque would handle the duplicate spatial vertexes.
Anyway, thank you!
Shane
#3
01/17/2003 (10:41 am)
I'm sorry, but what version of TrueSpace is this for again? At least, initially...
#4
01/17/2003 (12:16 pm)
I'm using 5.2 but I'm trying to stay away from anything added to the SDK that would prevent it from running on 4, 5, or 6. My goal is to support as many versions as possible.
Associate David Wyand
Gnometech Inc.
Yes, it is true that the Torque only allows a single uv coordinate for each vertex. In fact, it's not really a Torque requirement, but an OpenGL/DirectX one. If a polygon were to make use of a vertex with multiple uv pairs, how would it know which one to use?
The solution to this is to build your vertices by looking at your polygons. If two or more polygons share a vertex, and each have different uv value requirements, then you'll need multiple copies of that vertex. Each would have identical spatial coordinates but a different uv coordinate. You then point the polygon to the appropriate vertex.
Another case where this will occur is if you do cylindrical mapping. There will be a series of vertices that form the seam where the polygons on one side need a u (or v) coordinate of 0.0, while polygons on the other side would need a value of 1.0. Again, you'll need to duplicate the vertices and ensure that the polygons point to the correct ones. You'll also want to make sure that you calculate your normals as if the polygons shared the exact same vertices or you'll be able to see the seam (the smoothing would not work otherwise).
I've had to take care of this with the LightWave DTS exporter, and I used the above methods. Fortunately, the LightWave API has some nice features to help with this issue. Hopefully the TrueSpace API has the same.
Hopefully the above will help you along. If not, feel free to ask some more questions. Also, if someone has a more elegant solution, please do speak up.
- LightWave Dave