コード例 #1
0
        /// <summary>
        /// Clone the this instance
        /// </summary>
        /// <returns>The cloned instance</returns>
        public InternalStaticModel Clone()
        {
            var newModel = new InternalStaticModel();

            newModel.AssetPath     = this.AssetPath;
            newModel.graphics      = this.graphics;
            newModel.BoundingBox   = this.BoundingBox;
            newModel.MeshBonePairs = new Dictionary <int, int>(this.MeshBonePairs);
            newModel.Bones         = new List <Bone>(this.Bones);

            for (int i = 0; i < this.Meshes.Count; i++)
            {
                Mesh         currentMesh   = this.Meshes[i];
                VertexBuffer currentBuffer = currentMesh.VertexBuffer as VertexBuffer;

                var newBuffer = new VertexBuffer(currentBuffer.VertexBufferFormat);

                Matrix identity = Matrix.Identity;
                newBuffer.AppendBuffer(currentBuffer, ref identity);
                var newIndexBuffer = new IndexBuffer(currentMesh.IndexBuffer.Data);
                var newMesh        = new Mesh(
                    currentMesh.VertexOffset,
                    currentMesh.NumVertices,
                    currentMesh.IndexOffset,
                    currentMesh.NumPrimitives,
                    newBuffer,
                    newIndexBuffer,
                    currentMesh.PrimitiveType);
                newMesh.Name = currentMesh.Name;

                newModel.Meshes.Add(newMesh);
            }

            return(newModel);
        }