package de.gamezock.metacraft.data; import javax.vecmath.Point3f; import javax.vecmath.Vector3f; public class Triangle { private Point3f[] vertices; private Vector3f[] normals; public Triangle(Point3f v1, Point3f v2, Point3f v3) { vertices = new Point3f[3]; vertices[0] = v1; vertices[1] = v2; vertices[2] = v3; normals = new Vector3f[3]; Vector3f edge1 = new Vector3f(), edge2 = new Vector3f(); edge1.sub(v1, v2); edge2.sub(v3, v2); Vector3f normal = new Vector3f(); normal.cross(edge1, edge2); normal.normalize(); normals[0] = new Vector3f(normal); normals[1] = new Vector3f(normal); normals[2] = new Vector3f(normal); } public Point3f getVertex(int i) { return vertices[i]; } public Vector3f getNormal(int i) { return normals[i]; } }