0

My problem is that in Libgdx, I created a triangle in 3D thanks to the Mesh class in this simple piece of code :

mesh = new Mesh(true, 3, 3, 
                new VertexAttribute(VertexAttributes.Usage.Position, 3, "vPosition"));

mesh.setVertices(new float[] { vert1.x, vert1.y, vert1.z, vert2.x, vert2.y, vert2.z, vert3.x, vert3.y, vert3.z });
mesh.setIndices(new short[] { 0, 1, 2 });

What is important for me is to be able to change the vert1, vert2, vert3, which store the triangle vertices coordinates, as I want to create the triangle during the game.

When the triangle is displayed, it seems to appear at the desired place, according to what I give him in the verts Vector3.

Now, here's the thing : I used to camera.rotateAround() to create a way to look around the scene and I also created a small box to see if my script with the camera is merely working. It is ! I can see my box rotating if I move the camera. But when I rotate around the scene, the triangle I created doesn't rotate and stays exactly motionless at the screen, just like it was a 2D mesh !

So here is my question : How to make a 3D triangle in Libgdx and how to make a triangle render according to the camera movement ?

4

1 回答 1

0

在这里找到了解决方案:http ://www.badlogicgames.com/forum/viewtopic.php?f=11&t=10583&p=47800#p47800

ImmediateModeRenderer20 提供了一种临时方法来创建 3D 网格,包括三角形。

看起来 libgdx Mesh 类似乎只适用于 2D ......

于 2013-08-27T07:51:27.077 回答