I am currently working on trying to convert 2D coordinates to 3D ones. Basically, I have the texture in 2D and I would like to be able to show on a 3D object, having the same texture applied to it, where I am pointing at.
Let's say I have the 2D texture of the world. I would like to be able to know, given U,V coordinates on the texture, to get the X,Y,Z coordinates on a sphere having the same texture applied to it.
I am using J3D and now I am working with blender and figure out what is the best way to tackle this problem.
Any idea?
EDIT:
Here is a graphical idea of what I am trying to achieve:
You get (X,Y) coordinates of a point on a 2D texture and, thanks to some function, get and visualize where it would be if it was placed on a 3D object (I define both the mapping and the object itself).
I'm not a J3D user not I've used it ever before, I've used these in Blender and OpenGL, so I think I can attempt this question.
I think you are having some trouble understanding texturing in 3D. You will not generate the vertices from the UV coordinates, you will use the UV coordinates (which I call
texCoords
for clarity) on the vertices to apply the textures to them. If you don't know how to do UV mapping in blender, you can watch my video here.Then you have some steps as specified in this tutorial.
First, you need to create a polygon. Hoping that you know it already, skipping it here. Then set the texture coordinates onto that polygon like this.
Assuming that the coordinates are in UV (Some also call them ST).
Then you load the texture image using the
TextureLoader
class.Then set it on the
appearance
using it'ssetTexture()
method. And that's it.Hope this helps.