Author Topic: U and Me, erm sorry I meant V  (Read 2728 times)

0 Members and 1 Guest are viewing this topic.

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
U and Me, erm sorry I meant V
« 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.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: U and Me, erm sorry I meant V
« Reply #1 on: February 22, 2009 »
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
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: U and Me, erm sorry I meant V
« Reply #2 on: February 23, 2009 »
Thanks man, will have to work out how to get the min and max X and y positions of the verts.

Cheers,
Clyde.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won: