Ejemplo n.º 1
0
        public void AddMesh(MeshIndexed sourceMesh, Color color)
        {
            int vertIndex = Vertices.Count;

            foreach (Vector3Ext point in sourceMesh.Vertices)
            {
                //
                Vector3Ext vector = new Vector3Ext(point.Position);

                vector.Position = Mult(ref rotationMatrix, point.Position);
                Vertices.Add(vector);
            }

            foreach (GlPolyIndex poly in sourceMesh.Polygons)
            {
                GlPolyIndex polyIndex = new GlPolyIndex();

                polyIndex.PointIndex = new int[poly.VertexCount];
                for (int j = 0; j < poly.VertexCount; j++)
                {
                    polyIndex.PointIndex[j] = vertIndex + poly.PointIndex[j];
                }

                if (poly.Attributes.HasColor)
                {
                    polyIndex.Attributes.Color = poly.Attributes.Color;
                }
                else
                {
                    polyIndex.Attributes.Color = color;
                }

                Polygons.Add(polyIndex);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add polygon from points. Points must be on a plane and
        /// form a convec ploygon.
        /// </summary>
        /// <param name="points"></param>
        public void AddPolygon(List <Point3DF> points)
        {
            GlPolyIndex index;

            int vertIndex = Vertices.Count;

            foreach (Point3DF vector in points)
            {
                Vertices.Add(new Vector3Ext(vector));
            }

            index            = new GlPolyIndex();
            index.PointIndex = new int[points.Count];

            for (int j = 0; j < points.Count; j++)
            {
                index.PointIndex[j] = vertIndex + j;
            }

            Polygons.Add(index);
        }
Ejemplo n.º 3
0
        public void AddPolygon(Polygon polygon)
        {
            GlPolyIndex index;

            int vertIndex = Vertices.Count;

            foreach (Vector3Ext vector in polygon.vertices)
            {
                Vertices.Add(vector);
            }

            index            = new GlPolyIndex();
            index.PointIndex = new int[polygon.vertices.Length];

            for (int j = 0; j < polygon.vertices.Length; j++)
            {
                index.PointIndex[j] = vertIndex + j;
            }

            Polygons.Add(index);
        }
Ejemplo n.º 4
0
        public void AddFacet(Facet facet)
        {
            int         vertIndex = Vertices.Count;
            GlPolyIndex polyIndex = new GlPolyIndex();

            foreach (Point3DF point in facet.Points)
            {
                //
                Vector3Ext vector = new Vector3Ext(point);

                vector.Position = Mult(ref rotationMatrix, point);
                Vertices.Add(vector);
            }

            polyIndex.PointIndex = new int[facet.Points.Length];
            for (int j = 0; j < facet.Points.Length; j++)
            {
                polyIndex.PointIndex[j] = vertIndex + j;
            }

            Polygons.Add(polyIndex);
        }