static void Main(string[] args) { ShapeArea shapeArea = new ShapeArea(); shapeArea.PrintShapeArea("사각형", 20, 30, new AreaDelegate(RectangleArea)); shapeArea.PrintShapeArea("삼각형", 20, 30, TriangleArea); }
public void SetShape(FormType newForm) { Debug.Log("Setting particle magic shape to " + newForm.ToString()); if (currentShape == null) { currentShape = new ShapeArea(); } switch (newForm) { case FormType.Triangle: { currentShape.SetMesh(CreateTriangleMesh()); break; } case FormType.Ball: { currentShape.SetMesh(CreateCircleMesh(10)); break; } case FormType.Rectangle: { currentShape.SetMesh(CreateRectangleMesh()); break; } case FormType.Custom: // shapeType = ParticleSystemShapeType.Sprite; break; default: break; } }
public void SetShape(ShapeArea shape) { totalArea = shape.totalArea; areaArray = new NativeArray <float>(shape.triangleAreas, Unity.Collections.Allocator.TempJob); triangles = new NativeArray <int>(shape.GetMesh().triangles, Unity.Collections.Allocator.TempJob); float[] pointsX = new float[shape.GetMesh().vertices.Length]; float[] pointsY = new float[shape.GetMesh().vertices.Length]; float[] pointsZ = new float[shape.GetMesh().vertices.Length]; for (int i = 0; i < shape.GetMesh().vertices.Length; i++) { pointsX[i] = shape.GetMesh().vertices[i].x; pointsY[i] = shape.GetMesh().vertices[i].y; pointsZ[i] = shape.GetMesh().vertices[i].z; } verticesX = new NativeArray <float>(pointsX, Unity.Collections.Allocator.TempJob); verticesY = new NativeArray <float>(pointsY, Unity.Collections.Allocator.TempJob); verticesZ = new NativeArray <float>(pointsZ, Unity.Collections.Allocator.TempJob); }