Archived

This topic is now archived and is closed to further replies.

lly20000

A transform problem ????

Recommended Posts

Now I was pick a point and I know this point U and V coordinate but I don''t know how to transform this U and V coordinate to my World coordinate that is X Y Z coordinate ??????????????????

Share this post


Link to post
Share on other sites
You have to know which direction the surface is facing - primarily Z, Y, or X either with flags or working out the normals of each surface.

to convert from UV to world space:
(surface facing primarily along the Z axis)
(assuming that surfacePosX/Y/Z is in the centre of the surface (hence '-surfaceHeight/2 or - surfaceWidth/2'))
(also assuming that the texture width and height is 1.0f)

pointU = 0.3f;
pointV = 0.4f;

pointX = (surfaceWidth * pointU ) + (surfacePosX-(surfaceWidth/2));
pointY = (surfaceHeight * pointV ) + (surfacePosY-(surfaceHeight/2));
pointZ = surfacePosZ; // no need to do anything with this

(surface facing primarily along the Y axis)

pointU = 0.3f;
pointV = 0.4f;

pointX = (surfaceWidth * pointU ) + (surfacePosX-(surfaceWidth/2));
pointY = surfacePosY;
pointZ = (surfaceHeight * pointV ) + (surfacePosZ-(surfaceHeight/2));

(surface facing primarily along the X axis)

pointU = 0.3f;
pointV = 0.4f;

pointX = surfacePosX;(
pointY = (surfaceHeight * pointV ) + (surfacePosY-(surfaceHeight/2));
pointZ = (surfaceWidth * pointU ) + (surfacePosZ-(surfaceWidth/2));

Hope that makes sense, it doesn't to me :S

[edited by - -indirectx- on March 19, 2004 8:24:21 AM]

Share this post


Link to post
Share on other sites