在java中将纹理映射到在整个表面上延伸的立方体?
我正在尝试将纹理映射到 M3G(移动 3d api J2me)中的立方体,但它会重复,而不是拉伸到立方体的整个面。我在立方体的每个面得到两个重复的纹理,但我只想每个面映射一个纹理。
这是相关代码:
private static final byte[] VERTEX_POSITIONS = {
-1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, // front
1, -1, 0, -1, -1, 0, 1, 1, 0, -1, 1, 0, // back
1, -1, 1, 1, -1, 0, 1, 1, 1, 1, 1, 0, // right
-1, -1, 0, -1, -1, 1, -1, 1, 0, -1, 1, 1, // left
-1, 1, 1, 1, 1, 1, -1, 1, 0, 1, 1, 0, // top
-1, -1, 0, 1, -1, 0, -1, -1, 1, 1, -1, 1 // bottom
};
private static final int[] TRIANGLE_INDICES = {
0, 1, 2, 3, // front
4, 5, 6, 7, // back
8, 9, 10, 11, // right
12, 13, 14, 15, // left
16, 17, 18, 19, // top
20, 21, 22, 23, // bottom
};
private static int[] TRIANGLE_LENGTHS = {
4, 4, 4, 4, 4, 4
};
private static final byte[] VERTEX_TEXTURE_COORDINATES = {
0, 1, 1, 1, 0, 0, 1, 0, // front
0, 1, 1, 1, 0, 0, 1, 0, // back
0, 1, 1, 1, 0, 0, 1, 0, // right
0, 1, 1, 1, 0, 0, 1, 0, // left
0, 1, 1, 1, 0, 0, 1, 0, // top
0, 1, 1, 1, 0, 0, 1, 0, // bottom
};
I'm trying to map a texture to a cube in M3G (mobile 3d api J2me), but it's getting repeated instead of streching over the entire face of a cube. I'm getting two repeated texture per face of the cube but I want just a single texture mapped per face.
Here is the relevant code:
private static final byte[] VERTEX_POSITIONS = {
-1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, // front
1, -1, 0, -1, -1, 0, 1, 1, 0, -1, 1, 0, // back
1, -1, 1, 1, -1, 0, 1, 1, 1, 1, 1, 0, // right
-1, -1, 0, -1, -1, 1, -1, 1, 0, -1, 1, 1, // left
-1, 1, 1, 1, 1, 1, -1, 1, 0, 1, 1, 0, // top
-1, -1, 0, 1, -1, 0, -1, -1, 1, 1, -1, 1 // bottom
};
private static final int[] TRIANGLE_INDICES = {
0, 1, 2, 3, // front
4, 5, 6, 7, // back
8, 9, 10, 11, // right
12, 13, 14, 15, // left
16, 17, 18, 19, // top
20, 21, 22, 23, // bottom
};
private static int[] TRIANGLE_LENGTHS = {
4, 4, 4, 4, 4, 4
};
private static final byte[] VERTEX_TEXTURE_COORDINATES = {
0, 1, 1, 1, 0, 0, 1, 0, // front
0, 1, 1, 1, 0, 0, 1, 0, // back
0, 1, 1, 1, 0, 0, 1, 0, // right
0, 1, 1, 1, 0, 0, 1, 0, // left
0, 1, 1, 1, 0, 0, 1, 0, // top
0, 1, 1, 1, 0, 0, 1, 0, // bottom
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论