コード例 #1
0
ファイル: SkinnedModelEntity.cs プロジェクト: raizam/GeonBit
        /// <summary>
        /// Draw this entity.
        /// </summary>
        /// <param name="parent">Parent node that's currently drawing this entity.</param>
        /// <param name="localTransformations">Local transformations from the direct parent node.</param>
        /// <param name="worldTransformations">World transformations to apply on this entity (this is what you should use to draw this entity).</param>
        public override void Draw(Node parent, ref Matrix localTransformations, ref Matrix worldTransformations)
        {
            // call base drawing
            base.Draw(parent, ref localTransformations, ref worldTransformations);

            // animate parts by updating bones transformations
            foreach (DictionaryEntry entry in _meshes)
            {
                // get mesh
                MeshEntity mesh = entry.Value as MeshEntity;

                // iterate parts and set bones
                foreach (var part in mesh.Mesh.MeshParts)
                {
                    // animate mesh parts by chosen method
                    switch (_animateMode)
                    {
                    // animate in gpu
                    case AnimatedMode.GPU:
                        part.Effect.GetMaterial().SetBoneTransforms(CurrAnimationTransform);
                        break;

                    // animate in cpu
                    case AnimatedMode.CPU:
                        part.UpdateVertices(CurrAnimationTransform);
                        break;
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Return a list with all materials in model.
        /// Note: if alternative materials are set, will return them.
        /// Note2: prevent duplications, eg if even if more than one part uses the same material it will only return it once.
        /// </summary>
        /// <returns>List of materials.</returns>
        public List <Materials.MaterialAPI> GetMaterials()
        {
            List <Materials.MaterialAPI> ret = new List <Materials.MaterialAPI>();

            foreach (DictionaryEntry entry in _meshes)
            {
                MeshEntity mesh = entry.Value as MeshEntity;
                for (int i = 0; i < mesh.Mesh.MeshParts.Count; ++i)
                {
                    Materials.MaterialAPI material = mesh.GetMaterial(i);
                    if (!ret.Contains(material))
                    {
                        ret.Add(material);
                    }
                }
            }
            return(ret);
        }