Dark Bit Factory & Gravity
PROGRAMMING => General coding questions => Topic started by: Clyde on February 22, 2009
-
Was going to plonk this into the Blitz section, but this could be beneficial to others using there language of choice.
Here's the situation, I have model information for the Verts & Faces.
However I do not have the U and V's for each x,y,z of the verts.
Im hoping, there is a method you could show me please dudes, that can utilize the existing information to find out / make the u and v values.
Thanks very much,
Clyde.
-
UV aren't necessarily related to XYZ positions, so there's no way to work them out...but there are plenty of ways to compute UVs from XYZ that might be useful.
They are nearly all Projection Mappings. The simplest is to map the UVs from a plane.
One way to do that is to work out the min/max XY positions of the object, and scale them in to the 0->1 values for UVs.
eg, calculate the min/max XYs, then do this
dx = 1.0/(maxx - minx)
dy = 1.0/(maxy - miny)
Then, for any XYZ vertex, the UVs can be computed as
U = (x-minx) * dx
V = (y-miny) * dy
That will give you something usable. Other mappings are cube map, spherical map. There are lots of possibilities.
Jim
-
Thanks man, will have to work out how to get the min and max X and y positions of the verts.
Cheers,
Clyde.