public static Body Create(int segments, double radius, double height) { var creator = new GraphicsCreator(); double alpha = 2.0 * Math.PI / segments; double half = height / 2.0; double z0 = -half; double z1 = half; creator.AddFace(false, false); for (int i = 0; i < segments; i++) { double x0 = (Math.Sin(i * alpha) * radius); double y0 = (Math.Cos(i * alpha) * radius); double x1 = (Math.Sin((i + 1) * alpha) * radius); double y1 = (Math.Cos((i + 1) * alpha) * radius); var p1 = new Position3D(x0, y0, z0); var p2 = new Position3D(x0, y0, z1); var p3 = new Position3D(x1, y1, z0); var p4 = new Position3D(x1, y1, z1); creator.AddTriangle(p1, p2, p3); creator.AddTriangle(p3, p2, p4); } creator.AddFace(true, false); for (int i = 0; i < segments; i++) { double x0 = (Math.Sin(i * alpha) * radius); double y0 = (Math.Cos(i * alpha) * radius); double x1 = (Math.Sin(((i + 1) * alpha).Modulo2Pi()) * radius); double y1 = (Math.Cos(((i + 1) * alpha).Modulo2Pi()) * radius); double x2 = 0.0; double y2 = 0.0; var p1 = new Position3D(x0, y0, z1); var p2 = new Position3D(x1, y1, z1); var p3 = new Position3D(x2, y2, z1); creator.AddTriangle(p1, p3, p2); } creator.AddFace(true, false); for (int i = 0; i < segments; i++) { double x0 = (Math.Sin(i * alpha) * radius); double y0 = (Math.Cos(i * alpha) * radius); double x1 = (Math.Sin(((i + 1) * alpha).Modulo2Pi()) * radius); double y1 = (Math.Cos(((i + 1) * alpha).Modulo2Pi()) * radius); double x2 = 0.0; double y2 = 0.0; var p1 = new Position3D(x0, y0, z0); var p2 = new Position3D(x1, y1, z0); var p3 = new Position3D(x2, y2, z0); creator.AddTriangle(p1, p2, p3); } var body = creator.CreateBody(); return(body); }
public static Body Create(int segments, double radius1, double radius2, double length, double depth) { var creator = new GraphicsCreator(); var topLoop = CreateTopBottomFace(segments, radius1, radius2, length, depth, depth, creator, true); var bottomLoop = CreateTopBottomFace(segments, radius1, radius2, length, depth, 0.0, creator, false); CreateSideFace(topLoop, bottomLoop, creator); var body = creator.CreateBody(); return(body); }
public static Body Create(double size) { size = size > 0 ? size / 2.0 : 0.5; var p1 = new Position3D(-size, -size, -size); var p2 = new Position3D(size, -size, -size); var p3 = new Position3D(size, -size, size); var p4 = new Position3D(-size, -size, size); var p5 = new Position3D(-size, size, -size); var p6 = new Position3D(size, size, -size); var p7 = new Position3D(size, size, size); var p8 = new Position3D(-size, size, size); var creator = new GraphicsCreator(); // South creator.AddFace(true, false); creator.AddTriangle(p1, p2, p3); creator.AddTriangle(p3, p4, p1); // East creator.AddFace(true, false); creator.AddTriangle(p2, p6, p7); creator.AddTriangle(p7, p3, p2); // North creator.AddFace(true, false); creator.AddTriangle(p6, p5, p8); creator.AddTriangle(p8, p7, p6); // West creator.AddFace(true, false); creator.AddTriangle(p5, p1, p4); creator.AddTriangle(p4, p8, p5); // Top creator.AddFace(true, false); creator.AddTriangle(p4, p3, p7); creator.AddTriangle(p7, p8, p4); // Bottom creator.AddFace(true, false); creator.AddTriangle(p2, p1, p5); creator.AddTriangle(p5, p6, p2); var body = creator.CreateBody(); return(body); }
public static Body Create( int segments1, int segments2, double radius1, double radius2, bool hasBorder1, bool hasBorder2, bool facetted1, bool facetted2, double length, double depth, Matrix44D originFrame) { var creator = new GraphicsCreator(); creator.SetOriginFrame(originFrame); var(topLoop1, topLoop2) = CreateTopBottomFace(segments1, segments2, radius1, radius2, length, depth, depth, creator, true); var(bottomLoop1, bottomLoop2) = CreateTopBottomFace(segments1, segments2, radius1, radius2, length, depth, 0.0, creator, false); CreateSideFace(topLoop1, topLoop2, bottomLoop1, bottomLoop2, hasBorder1, hasBorder2, facetted1, facetted2, creator); var body = creator.CreateBody(); return(body); }
public static Body Create(int count, double size) { var creator = new GraphicsCreator(); var positions = CreatePositions(count, size); for (var y = 0; y < count; y++) { for (var x = 0; x < count; x++) { var point1 = positions[x][y]; var point2 = positions[x][y + 1]; var point3 = positions[x + 1][y + 1]; var point4 = positions[x + 1][y]; creator.AddFace(true, false); creator.AddTriangle(point1, point2, point4); creator.AddTriangle(point3, point4, point2); } } size = size * count; size = size > 0 ? size / 2.0 : 0.5; var hight = 2; var p1 = new Position3D(-size, -size, -hight); var p2 = new Position3D(size, -size, -hight); var p3 = new Position3D(size, -size, 0); var p4 = new Position3D(-size, -size, 0); var p5 = new Position3D(-size, size, -hight); var p6 = new Position3D(size, size, -hight); var p7 = new Position3D(size, size, 0); var p8 = new Position3D(-size, size, 0); // South creator.AddFace(true, false); creator.AddTriangle(p1, p2, p3); creator.AddTriangle(p3, p4, p1); // East creator.AddFace(true, false); creator.AddTriangle(p2, p6, p7); creator.AddTriangle(p7, p3, p2); // North creator.AddFace(true, false); creator.AddTriangle(p6, p5, p8); creator.AddTriangle(p8, p7, p6); // West creator.AddFace(true, false); creator.AddTriangle(p5, p1, p4); creator.AddTriangle(p4, p8, p5); // Bottom creator.AddFace(true, false); creator.AddTriangle(p2, p1, p5); creator.AddTriangle(p5, p6, p2); var body = creator.CreateBody(); return(body); }