Beispiel #1
0
        public static TriangleCollection CreateRectGeometry(float width, float height)
        {
            float halfWidth  = width * 0.5f;
            float halfHeight = height * 0.5f;
            var   tri1       = new Triangle(
                new Vector3(-halfWidth, -halfHeight, 0f),
                new Vector3(-halfWidth, halfHeight, 0f),
                new Vector3(halfWidth, halfHeight, 0f));
            var tri2 = new Triangle(
                new Vector3(-halfWidth, -halfHeight, 0f),
                new Vector3(halfWidth, halfHeight, 0f),
                new Vector3(halfWidth, -halfHeight, 0f));

            var result = new TriangleCollection();

            result.Add(tri1);
            result.Add(tri2);
            return(result);
        }
Beispiel #2
0
        public static TriangleCollection GetTriangles(PolyhedralSurface polyhedralsurface, string[] hexColors, int batchId)
        {
            var degenerated_triangles = 0;
            var allTriangles          = new TriangleCollection();

            for (var i = 0; i < polyhedralsurface.Geometries.Count; i++)
            {
                var      geometry = polyhedralsurface.Geometries[i];
                Triangle triangle;
                if (hexColors.Length > 0)
                {
                    if (hexColors.Length == 1)
                    {
                        triangle = GetTriangle(geometry, batchId, hexColors[0]);
                    }
                    else
                    {
                        if (hexColors.Length != polyhedralsurface.Geometries.Count)
                        {
                            throw new ArgumentOutOfRangeException($"Expected number of colors: {polyhedralsurface.Geometries.Count}, actual: {hexColors.Length}");
                        }
                        triangle = GetTriangle(geometry, batchId, hexColors[i]);
                    }
                }
                else
                {
                    triangle = GetTriangle(geometry, batchId, String.Empty);
                }

                if (triangle != null)
                {
                    allTriangles.Add(triangle);
                }
                else
                {
                    degenerated_triangles++;
                }
            }

            return(allTriangles);
        }
Beispiel #3
0
        public static TriangleCollection CreateRectGeometry(float width, float height)
        {
            float halfWidth = width * 0.5f;
            float halfHeight = height * 0.5f;
            var tri1 = new Triangle(
                new Vector3(-halfWidth, -halfHeight, 0f),
                new Vector3(-halfWidth, halfHeight, 0f),
                new Vector3(halfWidth, halfHeight, 0f));
            var tri2 = new Triangle(
                new Vector3(-halfWidth, -halfHeight, 0f),
                new Vector3(halfWidth, halfHeight, 0f),
                new Vector3(halfWidth, -halfHeight, 0f));

            var result = new TriangleCollection();
            result.Add(tri1);
            result.Add(tri2);
            return result;
        }