Ejemplo n.º 1
0
        protected virtual void CalculateTransforms()
        {
            ProfilerShort.Begin("MySkinnedEntity.CalculateTransforms");

            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Clear bones");
            foreach (var bone in Bones)
            {
                bone.Translation = Vector3.Zero;
                bone.Rotation    = Quaternion.Identity;
            }
            VRageRender.MyRenderProxy.GetRenderProfiler().StartNextBlock("Update bones");

            UpdateBones();

            VRageRender.MyRenderProxy.GetRenderProfiler().StartNextBlock("ComputeAbsoluteTransforms");
            for (int i = 0; i < Bones.Count; i++)
            {
                MyCharacterBone bone = Bones[i];
                bone.ComputeAbsoluteTransform();
                m_boneRelativeTransforms[i] = bone.ComputeBoneTransform();
                BoneAbsoluteTransforms[i]   = bone.AbsoluteTransform;
            }
            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();


            ProfilerShort.End();
        }
Ejemplo n.º 2
0
        protected virtual void CalculateTransforms(float distance)
        {
            ProfilerShort.Begin("MySkinnedEntity.CalculateTransforms");

            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Clear bones");
            //foreach (var bone in Bones)
            //{
            //    bone.Translation = Vector3.Zero;
            //    bone.Rotation = Quaternion.Identity;
            //}
            VRageRender.MyRenderProxy.GetRenderProfiler().StartNextBlock("Update bones");

            if (!UseNewAnimationSystem)
            {
                UpdateBones(distance);
            }

            VRageRender.MyRenderProxy.GetRenderProfiler().StartNextBlock("ComputeAbsoluteTransforms");
            var characterBones = AnimationController.CharacterBones;

            for (int i = 0; i < characterBones.Length; i++)
            {
                MyCharacterBone bone = characterBones[i];
                bone.ComputeAbsoluteTransform();
                AnimationController.BoneRelativeTransforms[i] = bone.ComputeBoneTransform();  // MOVE TO ANIM CONTROLLER
                BoneAbsoluteTransforms[i] = bone.AbsoluteTransform;
            }
            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();


            ProfilerShort.End();
        }
Ejemplo n.º 3
0
        private void UpdateDecalPositions()
        {
            m_decalUpdateCache.Clear();
            foreach (var pair in m_boneDecals)
            {
                int             boneIndex = pair.Key;
                MyCharacterBone bone      = AnimationController.CharacterBones[boneIndex];
                bone.ComputeAbsoluteTransform();
                Matrix boneTrans = bone.SkinTransform * bone.AbsoluteTransform;;
                for (int it = 0; it < pair.Value.Count; it++)
                {
                    MyDecalHitInfo decal         = pair.Value[it];
                    Vector3        positionTrans = Vector3.Transform(decal.Position, ref boneTrans);
                    Vector3        normalTrans   = Vector3.TransformNormal(decal.Normal, boneTrans);
                    m_decalUpdateCache.Add(new MyDecalPositionUpdate()
                    {
                        ID = decal.ID, Position = positionTrans, Normal = normalTrans
                    });
                }
            }

            MyDecals.UpdateDecals(m_decalUpdateCache);
        }