J3D - 如何使用对象的 UV 映射将 2D 坐标转换为 3D 坐标 [英] J3D - How to use a UV mapping of an object to convert 2D coordinates to 3D ones

查看:33
本文介绍了J3D - 如何使用对象的 UV 映射将 2D 坐标转换为 3D 坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试将 2D 坐标转换为 3D 坐标.基本上,我有 2D 纹理,我希望能够在 3D 对象上显示,应用相同的纹理,我指向的地方.

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.

假设我拥有世界的 2D 纹理.我希望能够知道,给定纹理上的 U、V 坐标,获得应用了相同纹理的球体上的 X、Y、Z 坐标.

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.

我正在使用 J3D,现在我正在使用 Blender 并找出解决这个问题的最佳方法.

I am using J3D and now I am working with blender and figure out what is the best way to tackle this problem.

有什么想法吗?

编辑:

这是我想要实现的目标的图形化想法:

Here is a graphical idea of what I am trying to achieve:

您可以获得 2D 纹理上某个点的 (X,Y) 坐标,并且借助某些功能,可以获取并可视化将其放置在 3D 对象上的位置(我定义了映射和对象本身)).

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).

推荐答案

我不是 J3D 用户,我以前从未使用过它,我在 Blender 和 OpenGL 中使用过这些,所以我想我可以尝试一下问题.

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.

我认为您在理解 3D 纹理时遇到了一些问题.您不会从 UV 坐标生成顶点,您将使用顶点上的 UV 坐标(为了清晰起见,我将其称为 texCoords)将纹理应用于它们.如果您不知道如何在 Blender 中进行 UV 映射,您可以在这里观看我的视频.

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.

然后你有一些在中指定的步骤这个教程.

首先,您需要创建一个多边形.希望你已经知道它,在这里跳过它.然后像这样将纹理坐标设置到那个多边形上.

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.

polygon1.setTextureCoordinate (0, new Point2f(u1, v1));
polygon1.setTextureCoordinate (1, new Point2f(u2, v2)); 
polygon1.setTextureCoordinate (2, new Point2f(u3, v3));
polygon1.setTextureCoordinate (3, new Point2f(u4, v4));

假设坐标在 UV 中(有些人也称它们为 ST).

Assuming that the coordinates are in UV (Some also call them ST).

然后使用 TextureLoader 类加载纹理图像.

Then you load the texture image using the TextureLoader class.

Texture texImage = new TextureLoader("brick.jpg", this).getTexture();

然后使用它的 setTexture() 方法在 appearance 上设置它.就是这样.

Then set it on the appearance using it's setTexture() method. And that's it.

希望这会有所帮助.

这篇关于J3D - 如何使用对象的 UV 映射将 2D 坐标转换为 3D 坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆