Esempio n. 1
0
        public Mesh BuildMesh(Transform[] boneArray, int textureIndex)
        {
            Mesh mesh = new Mesh();

            Vector3[] vertices = null;
            int[]     indices  = null;

            VertexMapper.GetVertices(ref vertices, data.GetBodyPoses(), data.GetBodySizes());
            VertexMapper.GetIndices(ref indices);

            mesh.vertices  = vertices;
            mesh.triangles = indices;

            Vector3[] uvs = null;
            UVMapper.GetUV(ref uvs, data.GetUVPoses(), data.GetUVSizes(), textureIndex);
            mesh.SetUVs(0, new List <Vector3>(uvs));

            Matrix4x4[]  bindPoses = null;
            BoneWeight[] weight    = null;

            SkinMapper.GetBoneWieghts(ref weight);
            Rigger.GetBindPoses(ref bindPoses, transform, boneArray);

            mesh.boneWeights = weight;
            mesh.bindposes   = bindPoses;

            return(mesh);
        }
Esempio n. 2
0
        public static Mesh BuildMesh(CharacterData data)
        {
            Mesh mesh = new Mesh();

            Vector3[] vertices = null;
            int[]     indices  = null;

            VertexMapper.GetVertices(ref vertices, data.GetBodyPoses(), data.GetBodySizes());
            VertexMapper.GetIndices(ref indices);

            mesh.vertices  = vertices;
            mesh.triangles = indices;

            Vector3[] uvs = null;
            UVMapper.GetUV(ref uvs, data.GetUVPoses(), data.GetUVSizes());
            mesh.SetUVs(0, new List <Vector3>(uvs));

            return(mesh);
        }
Esempio n. 3
0
        Clone
        (
            Boolean copyMetadataValues,
            Boolean copyTag
        )
        {
            AssertValid();

            const String MethodName = "Clone";

            IGraph oNewGraph = new Graph(m_eDirectedness);

            // Copy the base-class fields to the new edge.

            this.CopyTo(oNewGraph, copyMetadataValues, copyTag);

            // The vertices need to be copied to the new graph.  Loop through the
            // vertices in this original graph.

            IVertexCollection oNewVertices = oNewGraph.Vertices;

            foreach (IVertex oOriginalVertex in m_oVertexCollection)
            {
                IVertex oNewVertex = oOriginalVertex.Clone(
                    copyMetadataValues, copyTag);

                // To make it easier to copy the edges in this original graph,
                // temporarily store the ID of the new vertex in the Tag of the
                // original vertex.  Save the Tag so it can be restored later.

                oOriginalVertex.Tag =
                    new VertexMapper(oOriginalVertex.Tag, oNewVertex);

                oNewVertices.Add(oNewVertex);
            }

            // The edges need to be copied to the new graph.  Loop through the
            // edges in this original graph.

            IEdgeCollection oNewEdges = oNewGraph.Edges;

            foreach (IEdge oOriginalEdge in m_oEdgeCollection)
            {
                // Get the original edge's vertices.

                IVertex oOriginalVertex1, oOriginalVertex2;

                EdgeUtil.EdgeToVertices(oOriginalEdge, this.ClassName, MethodName,
                                        out oOriginalVertex1, out oOriginalVertex2);

                // Retrieve the VertexMapper objects that were temporarily stored
                // in the vertices' Tags.

                Debug.Assert(oOriginalVertex1.Tag is VertexMapper);
                Debug.Assert(oOriginalVertex2.Tag is VertexMapper);

                VertexMapper oVertexMapper1 = (VertexMapper)oOriginalVertex1.Tag;
                VertexMapper oVertexMapper2 = (VertexMapper)oOriginalVertex2.Tag;

                // Get the new vertices that correspond to the original edge's
                // vertices.

                IVertex oNewVertex1 = oVertexMapper1.NewVertex;
                IVertex oNewVertex2 = oVertexMapper2.NewVertex;

                // Copy the original edge, connecting the new vertices in the
                // process.

                IEdge oNewEdge = oOriginalEdge.Clone(copyMetadataValues, copyTag,
                                                     oNewVertex1, oNewVertex2,
                                                     oOriginalEdge.IsDirected);

                oNewEdges.Add(oNewEdge);
            }

            // Restore the original vertices' Tags.

            foreach (IVertex oOriginalVertex in m_oVertexCollection)
            {
                Debug.Assert(oOriginalVertex.Tag is VertexMapper);

                VertexMapper oVertexMapper = (VertexMapper)oOriginalVertex.Tag;

                oOriginalVertex.Tag = oVertexMapper.OriginalVertexTag;
            }

            return(oNewGraph);
        }