Jump to content
  • Advertisement
Sign in to follow this  

Calculation point in 3D polygon, from 2D texture coordinates

This topic is 3896 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Basically what I'm looking for is a way to calculate the real position of a pixel in 3d world. I know the texture coordinates of that polygon(triangle), and it's 3d representation, i would like to loop through whole texture and retrieve positions for all points in it. so: for i = 0 to width for j = 0 to height if (i,j) in triangle_texture_coordinates point[i,j] = calculate( (i,j), triangle_texture_coordinates, triangle_positions )

Share this post

Link to post
Share on other sites
there is no fast way to accomplish that , texture uv coords are normalized , thus you can cycle trhough 0..1 and get the correct index.
You can follow this algorithm

first you need a bilinear transofrmation beetween the points rendered in the surface and points in 3d , this is achieved retriving the point coordinate in space for each vertex.
Once you have that, compute the normal for this surface
write polygon rasterizing function.
when you have rasterized each polygon scan line pass the extremes for
this scan line in a function which computes the plane
equation like this
a * ( x-px0 ) +b * ( y-py0 ) +c* ( z-pz0 )=0;

a,b,c is the normal vector
px0,py0,pz0 is a point lying on the plane, usually is the first vertex
you obtain from polygon coordinates.
now in side the main loop you have the x,y,z values spanning all the polygon
and with the function above you can easily compute the z coordinate
By the way i think that this method is computationally expensive
what are you trying exactly to do ?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!