UV misery
by Chris Aiken · in Constructor · 07/01/2007 (4:59 pm) · 2 replies
I'm trying to read worldspawn data from a CSX file into a graphics engine I'm building and the UV mapping is giving me fits. I'm calculating the UV coordinates as follows:
U = (DotProduct(worldVertex, uAxis) * (1/textureWidth) * (1/scaleU)) + (offsetU * (1 / textureWidth))
V = (DotProduct(worldVertex, vAxis) * (1 / textureHeight) * (1 / scaleV)) + (offsetV * (1 / textureHeight))
For worldVertex, I've tried using the pretransformed vertices (the vertices stored in the CSX file) and the transformed vertices (after scaling and moving to position), and in both cases the textures don't have the same alignment as in Constructor's preview. Is there some flaw in my math, or is there an additional transformation I need to perform on the worldVertex before calculating the UV values?
U = (DotProduct(worldVertex, uAxis) * (1/textureWidth) * (1/scaleU)) + (offsetU * (1 / textureWidth))
V = (DotProduct(worldVertex, vAxis) * (1 / textureHeight) * (1 / scaleV)) + (offsetV * (1 / textureHeight))
For worldVertex, I've tried using the pretransformed vertices (the vertices stored in the CSX file) and the transformed vertices (after scaling and moving to position), and in both cases the textures don't have the same alignment as in Constructor's preview. Is there some flaw in my math, or is there an additional transformation I need to perform on the worldVertex before calculating the UV values?
#2
07/02/2007 (9:46 am)
It would be great if Matt could drop in with a quick explanation of Constructor's texture mapping. I'm getting nowhere on my own.
Torque 3D Owner Stephen Zepp