コード例 #1
0
        /// <summary>
        ///     Clones this instance.
        /// </summary>
        /// <returns>The cloned animated model data.</returns>
        public InternalSkinnedModel Clone()
        {
            var newModel = new InternalSkinnedModel();

            newModel.graphics    = this.graphics;
            newModel.BoundingBox = this.BoundingBox;

            for (int i = 0; i < this.Meshes.Count; i++)
            {
                SkinnedMesh         currentMesh   = this.Meshes[i];
                SkinnedVertexBuffer currentBuffer = currentMesh.VertexBuffer as SkinnedVertexBuffer;
                var newVertices = new SkinnedVertex[currentMesh.NumVertices];
                Array.Copy(currentBuffer.CpuVertices, newVertices, currentBuffer.CpuVertices.Length);

                var newBuffer = new SkinnedVertexBuffer(currentBuffer.VertexBufferFormat);
                newBuffer.SetData(newVertices, currentBuffer.VertexCount);
                var newIndexBuffer = new IndexBuffer(this.internalindices[i]);
                var newMesh        = new SkinnedMesh(
                    currentMesh.VertexOffset,
                    currentMesh.NumVertices,
                    currentMesh.IndexOffset,
                    currentMesh.NumPrimitives,
                    newBuffer,
                    newIndexBuffer,
                    PrimitiveType.TriangleList);
                newMesh.Name = currentMesh.Name;

                newModel.Meshes.Add(newMesh);

                this.graphics.BindIndexBuffer(newModel.Meshes[i].IndexBuffer);
                this.graphics.BindVertexBuffer(newModel.Meshes[i].VertexBuffer);
            }

            return(newModel);
        }
コード例 #2
0
ファイル: SkinnedModel.cs プロジェクト: sizzles/Components
 /// <summary>
 /// Reload the static model
 /// </summary>
 protected override void UnloadModel()
 {
     if (this.InternalModel != null && !string.IsNullOrEmpty(this.InternalModel.AssetPath))
     {
         this.Assets.UnloadAsset(this.InternalModel.AssetPath);
         this.BoundingBox   = new BoundingBox();
         this.InternalModel = null;
     }
 }
コード例 #3
0
        /// <summary>
        /// Performs further custom initialization for this instance.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            this.boneTransforms  = new Matrix[this.Animation.InternalAnimation.BindPose.Count];
            this.worldTransforms = new Matrix[this.Animation.InternalAnimation.BindPose.Count];
            this.skinTransforms  = new Matrix[this.Animation.InternalAnimation.BindPose.Count];

            this.skinnedModel = this.Model.InternalModel.Clone();
        }
コード例 #4
0
ファイル: SkinnedModel.cs プロジェクト: sizzles/Components
        /// <summary>
        /// Reload the static model
        /// </summary>
        protected override void LoadModel()
        {
            if (!string.IsNullOrEmpty(this.ModelPath))
            {
                this.InternalModel = Assets.LoadAsset <InternalSkinnedModel>(this.ModelPath);

                if (!this.customBoundingBoxSet)
                {
                    this.BoundingBox = this.InternalModel.BoundingBox;
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources
        /// </summary>
        /// <param name="disposing">
        /// <c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.
        /// </param>
        protected override void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                if (disposing)
                {
                    if (this.skinnedModel != null)
                    {
                        this.skinnedModel.Unload();
                        this.skinnedModel = null;
                    }

                    this.disposed = true;
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// Refresh the model references
        /// </summary>
        private void RefreshModel()
        {
            if (this.skinnedModel == null ||
                (this.skinnedModel.AssetPath != this.Model.ModelPath))
            {
                if (this.skinnedModel != null)
                {
                    this.skinnedModel.Unload();
                    this.skinnedModel = null;
                }

                if (this.Model.InternalModel != null)
                {
                    this.skinnedModel = this.Model.InternalModel.Clone();
                    Array.Resize(ref this.meshMaterials, this.skinnedModel.Meshes.Count);
                    Array.Resize(ref this.updateVertexBuffer, this.skinnedModel.Meshes.Count);
                }

                this.boneNames.Clear();
            }
        }
コード例 #7
0
ファイル: SkinnedModel.cs プロジェクト: xiaotie/Components
 /// <summary>
 /// Performs further custom initialization for this instance.
 /// </summary>
 protected override void Initialize()
 {
     this.InternalModel = Assets.LoadAsset <InternalSkinnedModel>(this.ModelPath);
     this.BoundingBox   = this.InternalModel.BoundingBox;
 }