JaveFX TriangleMesh Pyramid – it works, but why?

问题内容:

Making a 4-sided pyramid is explained ‘lightly’ in a few texts, as follows:

pyramid.getPoints().addAll(0,0,0); //0 = top
pyramid.getPoints().addAll(0, height, -hypotenuse/2); //1 = closest
pyramid.getPoints().addAll(-hypotenuse/2, height, 0); //2 = leftest
pyramid.getPoints().addAll(hypotenuse/2, height, 0); //3 = furthest
pyramid.getPoints().addAll(0, height, hypotenuse/2); //4 = rightest

pyramid.getTexCoords().addAll(0, 0);

pyramid.getFaces().addAll(0,0,2,0,1,0); //Left front side
pyramid.getFaces().addAll(0,0,1,0,3,0); //???
pyramid.getFaces().addAll(0,0,3,0,4,0); //Right back side
pyramid.getFaces().addAll(0,0,4,0,2,0); //???
pyramid.getFaces().addAll(4,0,1,0,2,0); //Bottom triangle at front???
pyramid.getFaces().addAll(4,0,3,0,1,0); //Bottom triangle right???

It works, but I don’t understand it. See Pyramid with vertex numbering
. The 2nd face added has vertices 0, 1, 3, so (reference figure) … it slices the pyramid in half. It is not an external face as far as I can tell.
Same with the 4th face, only now the slice is orthogonal to the 2nd face. And then the last 2 faces, which should be the triangles making up the square base of the pyramid. The first one goes from vertex 4 to vertex 1 to vertex 2, so … that is the front triangle of the pyramid base (is what I think). So I expect vertices 2,3,4 to form the back triangle of the pyramid base, but in the last line of code we see vertices 4,3,1, which (according to my logic) make up the right triangle of the pyramid base, i.e. does not complement the front triangle of the pyramid base. Can someone please explain this on-the-face-of-it simple geometric puzzle? And is there a proper indepth resource out there I can study?

Much obliged – Michael

问题评论:

原文地址:

https://stackoverflow.com/questions/47755750/javefx-trianglemesh-pyramid-it-works-but-why

Tags:,

添加评论