public static ConvexSurface loadCube(double scaleX, double scaleY, double scaleZ) { double r = 0.5; double[] face1 = { r * scaleX, r * scaleY, r * scaleZ, -r * scaleX, r * scaleY, r * scaleZ, -r * scaleX, r * scaleY, -r * scaleZ, r * scaleX, r * scaleY, -r * scaleZ }; // Top double[] face2 = { r * scaleX, r * scaleY, r * scaleZ, -r * scaleX, r * scaleY, r * scaleZ, -r * scaleX, -r * scaleY, r * scaleZ, r * scaleX, -r * scaleY, r * scaleZ }; // Front double[] face3 = { r * scaleX, r * scaleY, r * scaleZ, r * scaleX, -r * scaleY, r * scaleZ, r * scaleX, -r * scaleY, -r * scaleZ, r * scaleX, r * scaleY, -r * scaleZ }; // Right r = -0.5; double[] face4 = { r * scaleX, r * scaleY, r * scaleZ, -r * scaleX, r * scaleY, r * scaleZ, -r * scaleX, r * scaleY, -r * scaleZ, r * scaleX, r * scaleY, -r * scaleZ }; // Top double[] face5 = { r * scaleX, r * scaleY, r * scaleZ, -r * scaleX, r * scaleY, r * scaleZ, -r * scaleX, -r * scaleY, r * scaleZ, r * scaleX, -r * scaleY, r * scaleZ }; // Front double[] face6 = { r * scaleX, r * scaleY, r * scaleZ, r * scaleX, -r * scaleY, r * scaleZ, r * scaleX, -r * scaleY, -r * scaleZ, r * scaleX, r * scaleY, -r * scaleZ }; // Right ConvexSurface surface = new ConvexSurface(); surface.faces = new Face[6]; surface.faces[0] = new Face(face1, 4); surface.faces[1] = new Face(face2, 4); surface.faces[2] = new Face(face3, 4); surface.faces[3] = new Face(face4, 4); surface.faces[4] = new Face(face5, 4); surface.faces[5] = new Face(face6, 4); surface.SURFACE_TYPE = ConvexSurface.CUBE; surface.width = (float) scaleX; surface.height = (float) scaleX; surface.length = (float) scaleZ; surface.breakFaces(); surface.loadEdgeIndexing(); surface.loadPointIndexing(); return surface; }
public static ConvexSurface loadPrism( double scaleX, double scaleY, double scaleZ, double frontLeft, double frontRight, double backLeft, double backRight) { double r = 0.5; double[] face1 = { -r * scaleX, r * scaleY + frontLeft, r * scaleZ, -r * scaleX, r * scaleY + backLeft, -r * scaleZ, r * scaleX, r * scaleY + backRight, -r * scaleZ }; // Top1 double[] face2 = { r * scaleX, r * scaleY + frontRight, r * scaleZ, -r * scaleX, r * scaleY + backLeft, -r * scaleZ, r * scaleX, r * scaleY + backRight, -r * scaleZ }; // Top2 double[] face3 = { r * scaleX, r * scaleY + frontRight, r * scaleZ, -r * scaleX, r * scaleY + frontLeft, r * scaleZ, r * scaleX, r * scaleY + backRight, -r * scaleZ }; // Top3 double[] face4 = { r * scaleX, r * scaleY + frontRight, r * scaleZ, -r * scaleX, r * scaleY + frontLeft, r * scaleZ, -r * scaleX, r * scaleY + backLeft, -r * scaleZ }; // Top4 double[] face5 = { r * scaleX, r * scaleY + frontRight, r * scaleZ, -r * scaleX, r * scaleY + frontLeft, r * scaleZ, -r * scaleX, -r * scaleY, r * scaleZ, r * scaleX, -r * scaleY, r * scaleZ }; // Front double[] face6 = { r * scaleX, r * scaleY + frontRight, r * scaleZ, r * scaleX, -r * scaleY, r * scaleZ, r * scaleX, -r * scaleY, -r * scaleZ, r * scaleX, r * scaleY + backRight, -r * scaleZ }; // Right r = -0.5; double[] face7 = { r * scaleX, r * scaleY, r * scaleZ, -r * scaleX, r * scaleY, r * scaleZ, -r * scaleX, r * scaleY, -r * scaleZ, r * scaleX, r * scaleY, -r * scaleZ }; // bottom double[] face8 = { r * scaleX, r * scaleY, r * scaleZ, -r * scaleX, r * scaleY, r * scaleZ, -r * scaleX, -r * scaleY + backRight, r * scaleZ, r * scaleX, -r * scaleY + backLeft, r * scaleZ }; // Back double[] face9 = { r * scaleX, r * scaleY, r * scaleZ, r * scaleX, -r * scaleY + backLeft, r * scaleZ, r * scaleX, -r * scaleY + frontLeft, -r * scaleZ, r * scaleX, r * scaleY, -r * scaleZ }; // Left ConvexSurface surface = new ConvexSurface(); surface.faces = new Face[9]; surface.faces[0] = new Face(face1, 3); surface.faces[1] = new Face(face2, 3); surface.faces[2] = new Face(face3, 3); surface.faces[3] = new Face(face4, 3); surface.faces[4] = new Face(face5, 4); surface.faces[5] = new Face(face6, 4); surface.faces[6] = new Face(face7, 4); surface.faces[7] = new Face(face8, 4); surface.faces[8] = new Face(face9, 4); surface.SURFACE_TYPE = ConvexSurface.CUBE; surface.width = (float) scaleX; surface.height = (float) scaleX; surface.length = (float) scaleZ; surface.breakFaces(); surface.loadEdgeIndexing(); surface.loadPointIndexing(); return surface; }