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

查看:273
本文介绍了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天全站免登陆