public ITriangleInstance AddTriangle(Triangle triangle)
        {
            var instance = new TriangleInstance(this);
            lock (m_instances)
            {
                m_instances.Add(instance);
            }

            instance.P1 = triangle.P1;
            instance.P2 = triangle.P2;
            instance.P3 = triangle.P3;
            instance.Color = triangle.Color;

            return instance;
        }
Beispiel #2
0
        public Triangle[] ToTriangles()
        {
            if(Triangles == null)
            {
                Triangles = new Triangle[(int)SLOTS];

                for (int i = 0; i < SLOTS; i++)
                {
                    var t1 = i+1 * SLOT_ANGLE;
                    var p1 = new Vector3(
                        (float)Math.Cos(t1) * Radius + Center.X,
                        (float)Math.Sin(t1) * Radius + Center.Y,
                        0);

                    if (i == 0)
                    {
                        var t0 = i * SLOT_ANGLE;
                        var p0 = new Vector3(
                            (float)Math.Cos(t0) * Radius + Center.X,
                            (float)Math.Sin(t0) * Radius + Center.Y,
                            0);

                        Triangles[0] = new Triangle()
                        {
                            P1 = Center,
                            P2 = p1,
                            P3 = p0,
                            Color = Color
                        };
                    }
                    else
                    {
                        var p = Triangles[i - 1].P3;

                        Triangles[i] = new Triangle()
                        {
                            P1 = Center,
                            P2 = p,
                            P3 = p1,
                            Color = Color
                        };
                    }
                }
            }

            return Triangles;
        }