package engineC3D; public class Prim { private Prim() { } public static Object getCube(Point3D coor, int width, int height, int depth){ Object cube = new Object(coor); //back face cube.addVertex( new Vertex( new Point3D(coor.x - width/2, coor.y - height/2, coor.z + depth/2), new Point3D(coor.x + width/2, coor.y - height/2, coor.z + depth/2), new Point3D(coor.x - width/2, coor.y + height/2, coor.z + depth/2) ) ); cube.addVertex( new Vertex( new Point3D(coor.x + width/2, coor.y - height/2, coor.z + depth/2), new Point3D(coor.x + width/2, coor.y + height/2, coor.z + depth/2), new Point3D(coor.x - width/2, coor.y + height/2, coor.z + depth/2) ) ); //face cube.addVertex( new Vertex( new Point3D(coor.x - width/2, coor.y - height/2, coor.z - depth/2), new Point3D(coor.x + width/2, coor.y - height/2, coor.z - depth/2), new Point3D(coor.x - width/2, coor.y + height/2, coor.z - depth/2) ) ); cube.addVertex( new Vertex( new Point3D(coor.x + width/2, coor.y - height/2, coor.z - depth/2), new Point3D(coor.x + width/2, coor.y + height/2, coor.z - depth/2), new Point3D(coor.x - width/2, coor.y+ height/2, coor.z - depth/2) ) ); //left vertex cube.addVertex( new Vertex( new Point3D(coor.x - width/2, coor.y - height/2, coor.z + depth/2), new Point3D(coor.x - width/2, coor.y - height/2, coor.z - depth/2), new Point3D(coor.x - width/2, coor.y + height/2, coor.z - depth/2) ) ); cube.addVertex( new Vertex( new Point3D(coor.x - width/2, coor.y + height/2, coor.z - depth/2), new Point3D(coor.x - width/2, coor.y + height/2, coor.z + depth/2), new Point3D(coor.x - width/2, coor.y - height/2, coor.z - depth/2) ) ); //right vertex cube.addVertex( new Vertex( new Point3D(coor.x + width/2, coor.y - height/2, coor.z + depth/2), new Point3D(coor.x + width/2, coor.y - height/2, coor.z - depth/2), new Point3D(coor.x + width/2, coor.y + height/2, coor.z - depth/2) ) ); cube.addVertex( new Vertex( new Point3D(coor.x + width/2, coor.y + height/2, coor.z - depth/2), new Point3D(coor.x + width/2, coor.y + height/2, coor.z + depth/2), new Point3D(coor.x + width/2, coor.y - height/2, coor.z - depth/2) ) ); //up vertrex cube.addVertex(new Vertex(new Point3D(coor.x + width/2, coor.y - height/2, coor.z - depth/2), new Point3D(coor.x - width/2, coor.y - height/2, coor.z - depth/2), new Point3D(coor.x - width/2, coor.y - height/2, coor.z + depth/2) ) ); cube.addVertex(new Vertex(new Point3D(coor.x - width/2, coor.y - height/2, coor.z + depth/2), new Point3D(coor.x + width/2, coor.y - height/2, coor.z + depth/2), new Point3D(coor.x + width/2, coor.y - height/2, coor.z - depth/2) ) ); //down vertex cube.addVertex(new Vertex(new Point3D(coor.x + width/2, coor.y + height/2, coor.z - depth/2), new Point3D(coor.x - width/2, coor.y + height/2, coor.z - depth/2), new Point3D(coor.x - width/2, coor.y + height/2, coor.z + depth/2) ) ); cube.addVertex(new Vertex(new Point3D(coor.x - width/2, coor.y + height/2, coor.z + depth/2), new Point3D(coor.x + width/2, coor.y + height/2, coor.z + depth/2), new Point3D(coor.x + width/2, coor.y + height/2, coor.z - depth/2) ) ); return cube; } }