silverklyph
Senior Newbie
Java games rock!


«
Posted
20031128 18:16:51 » 

Ok, I'm a noob to the very core of the definition of the word, but pardon the stupidity of my question:
I've been playing around with Xith3D for all of a week now, and I'm trying to use the the Cube.createCubeViaTriangles() idea to create a pyramid with a square base. Unfortunately, anytime i call the following method, it returns a simple, 2D triangle:
public static Geometry createTriangle(float x, float y, float z, float size){ float half = size/2f;
Point3f[] coords = new Point3f[] {
new Point3f(x, y+half, z), new Point3f((float)(x+half*Math.cos(Math.PI/6)), yhalf, (float)(z+half*Math.cos(Math.PI/2))), new Point3f((float)(xhalf*Math.cos(Math.PI/6)), yhalf, (float)(z+half*Math.cos(Math.PI/2))),
new Point3f(x, y+half, z), new Point3f((float)(x+half*Math.cos(Math.PI/6)), yhalf, (float)(z+half*Math.cos(Math.PI/2))), new Point3f((float)(x+half*Math.cos(Math.PI/6)), yhalf, (float)(zhalf*Math.cos(Math.PI/2))),
new Point3f(x, y+half, z), new Point3f((float)(xhalf*Math.cos(Math.PI/6)), yhalf, (float)(z+half*Math.cos(Math.PI/2))), new Point3f((float)(xhalf*Math.cos(Math.PI/6)), yhalf, (float)(zhalf*Math.cos(Math.PI/2))),
new Point3f(x, y+half, z), new Point3f((float)(xhalf*Math.cos(Math.PI/6)), yhalf, (float)(zhalf*Math.cos(Math.PI/2))), new Point3f((float)(x+half*Math.cos(Math.PI/6)), yhalf, (float)(zhalf*Math.cos(Math.PI/2))) };
Color3f[] colors = new Color3f[] {
new Color3f(1f,1f,1f), new Color3f(1f,0f,0f), new Color3f(0f,1f,0f),
new Color3f(0f,1f,0f), new Color3f(0f,0f,1f), new Color3f(1f,1f,1f),
new Color3f(1f,1f,1f), new Color3f(1f,0f,0f), new Color3f(0f,1f,0f),
new Color3f(0f,1f,0f), new Color3f(0f,0f,1f), new Color3f(1f,1f,1f), };
TriangleArray qa = new TriangleArray(coords.length, GeometryArray.COORDINATESGeometryArray.COLOR_3GeometryArray.TEXTURE_COORDINATE_2);
qa.setCoordinates(0,coords); qa.setColors(0,colors);
return qa; }
What am I doing wrong?
