Calculate the XYZ point of a sphere, given a UV coordinate of its texture

Software: Away3D 4.x

atmofunk, Newbie
Posted: 24 October 2011 05:15 PM   Total Posts: 3

I have created a primitive sphere. At runtime i’m generating a dynamic 2048x1024 texture for it. On this texture a tiny circle is drawn, which could be anywhere. I have the x/y of this circle on the texture, and consequently the corresponding UV coordinate. Now, i’d like to interpolate where exactly on my sphere [x,y,z] this little circle is located.

Does anyone know how I can accomplish this?

   

Avatar
80prozent, Sr. Member
Posted: 24 October 2011 07:27 PM   Total Posts: 430   [ # 1 ]

hi

i dont know if there is a helper class for this…

to get the uv-triangle, your uv is sitting in, you would have to loop through the IndexData of your Mesh and calculate for each triangle if it is the uv-triangle your searching for (use barycentric cooardinates to test if uv is in uv-triangle)

here i see a problem you would run into, if your mesh have multiple triangles with the same uvs (uv-mirrored models).

if you have the indicies of the uv-triangle calculated you can use them to retrieve the 3 verticles that make up the triangle.

i guess to get the actual Vector3D on the calculated triangle, you could use the Barycentric cooardinates of your uv-point. not shure about that.

Hope that makes sense…

80

 Signature 

sorry…i hope my actionscript is better than my english…

   

atmofunk, Newbie
Posted: 24 October 2011 08:56 PM   Total Posts: 3   [ # 2 ]

thanks for this—i’ll investigate further.  Do you happen to know of an example of the BarycentricTest class?

   

Avatar
80prozent, Sr. Member
Posted: 24 October 2011 10:18 PM   Total Posts: 430   [ # 3 ]

hi

as far as i know there is no BaryCentrictest class available yet, so you must do the calculation yourself. cant give you much advice, because i just happend to learn about this the last days too.

look inside the HitTestRenderer.as in the function “getPreciseDetails” it uses barycentric coordinates to calculate if a Vector3D is inside a triangle in 3d space. i dont know if this calculation is done 100% correct, since the HitTestrenderer happens to not always (but in most cases) work correct.

For the purpose of getting the uv-triangle for a given uv, you wouldnt need to do this calculation in 3d, but as far as i understand, the concept and the math for 3d and 2d Barycentric coordinates are pretty much the same.

So doing some research about BaryCentric-Coordinates and looking into the HittestRenderer should give you a place to start.

 Signature 

sorry…i hope my actionscript is better than my english…

   

atmofunk, Newbie
Posted: 24 October 2011 10:23 PM   Total Posts: 3   [ # 4 ]

There is a BaryCentricTest class in away3d.tools.utils (away3d 4).  Thanks, tho.. I will look in to it further.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X