当前位置: 首页>>代码示例>>C#>>正文


C# Matrix.Decompose方法代码示例

本文整理汇总了C#中System.Matrix.Decompose方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix.Decompose方法的具体用法?C# Matrix.Decompose怎么用?C# Matrix.Decompose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Matrix的用法示例。


在下文中一共展示了Matrix.Decompose方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Keyframe

 public Keyframe(Bone bone, float time, Matrix output, InterpolationType interpolation)
 {
     Bone = bone;
     Time = time;
     Transform = output;
     Interpolation = interpolation;
     Transform.Decompose(out Scale, out Rotation, out Translation);
 }
开发者ID:RomanHodulak,项目名称:DeferredLightingD3D11,代码行数:8,代码来源:Keyframe.cs

示例2: AnimationData

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="matrix">Matrix to decompose</param>
        public AnimationData(Matrix matrix)
        {
            Vector3 s;
            Vector3 t;
            Quaternion r;
            matrix.Decompose(out s, out r, out t);

            Rotation = r;
            Scaling = s;
            Translation = t;
        }
开发者ID:chantsunman,项目名称:SharpDX_Demo,代码行数:15,代码来源:AnimationManager.cs

示例3: CreateBoneList

        public static remSkin CreateBoneList(ImportedMesh mesh, Matrix lMeshMatrixInv)
        {
            if (mesh.BoneList == null || mesh.BoneList.Count == 0)
            {
                return null;
            }

            Dictionary<int, float>[] boneDic = new Dictionary<int, float>[mesh.BoneList.Count];
            for (int i= 0; i < mesh.BoneList.Count; i++)
            {
                boneDic[i] = new Dictionary<int, float>();
            }
            int vertexOffset = 0;
            foreach (ImportedSubmesh submesh in mesh.SubmeshList)
            {
                List<ImportedVertex> vertices = submesh.VertexList;
                for (int i = 0; i < vertices.Count; i++)
                {
                    ImportedVertex vert = vertices[i];
                    for (int j = 0; j < vert.BoneIndices.Length; j++)
                    {
                        if (vert.BoneIndices[j] == 0xFF)
                            continue;

                        boneDic[vert.BoneIndices[j]].Add(vertexOffset + i, vert.Weights[j]);
                    }
                }
                vertexOffset += vertices.Count;
            }

            remSkin remBoneList = new remSkin(mesh.BoneList.Count);
            remBoneList.mesh = new remId(mesh.Name);
            Vector3 scale, translate;
            Quaternion rotate;
            lMeshMatrixInv.Decompose(out scale, out rotate, out translate);
            scale.X = Math.Abs(scale.X);
            scale.Y = Math.Abs(scale.Y);
            scale.Z = Math.Abs(scale.Z);
            Matrix combinedCorrection = Matrix.Scaling(-1f / scale.X, 1f / scale.Y, -1f / scale.Z) * lMeshMatrixInv;
            for (int i = 0; i < mesh.BoneList.Count; i++)
            {
                remBoneWeights boneWeights = new remBoneWeights();
                boneWeights.bone = new remId(mesh.BoneList[i].Name);
                Matrix lMatrix = Matrix.Invert(mesh.BoneList[i].Matrix);
                boneWeights.matrix = Matrix.Invert(lMatrix * combinedCorrection);
                boneWeights.vertexIndices = new int[boneDic[i].Count];
                boneDic[i].Keys.CopyTo(boneWeights.vertexIndices, 0);
                boneWeights.vertexWeights = new float[boneDic[i].Count];
                boneDic[i].Values.CopyTo(boneWeights.vertexWeights, 0);
                remBoneList.AddChild(boneWeights);
            }
            return remBoneList;
        }
开发者ID:hejob,项目名称:SB3Utility,代码行数:53,代码来源:remReplace.cs

示例4: SceneGraph

        public SceneGraph(Matrix transformMatrix, IRenderable renderable = null)
        {
            //
            // Setup dirtyables...
            //
            D_Transform = new Dirtyable<Matrix>(() => { return Matrix.Transformation(Vector3.Zero, Quaternion.Identity, Scale, Vector3.Zero, Rotation, Translation); });
            D_WorldTransform = new Dirtyable<Matrix>(() =>
            {
                if (Parent == null)
                {
                    return D_Transform.Value;
                }
                else
                {
                    // TODO KAM: I'm not sure if this is the proper order in which to multiply matrices to find the WorldTransform
                    return D_Transform.Value * Parent.D_WorldTransform.Value;
                }
            });

            //
            // Setup transformation data...
            //
            Vector3 trans;
            Quaternion rot;
            Vector3 scale;
            transformMatrix.Decompose(out scale, out rot, out trans);
            Translation = trans;
            Rotation = rot;
            Scale = scale;

            //
            // Setup other data...
            //
            Parent = null;
            Children = new Dictionary<string, SceneGraph>();
            Renderable = renderable;
        }
开发者ID:sessamekesh,项目名称:OutsideSimulator,代码行数:37,代码来源:SceneGraph.cs

示例5: RotateVector

 public static void RotateVector(ref Vector3 vec, ref Matrix m, ref Vector3 output)
 {
     Quaternion rotation;
     Vector3 scale;
     Vector3 translation;
     m.Decompose(out scale, out rotation, out translation);
     output = Vector3.Transform(vec, rotation);
 }
开发者ID:HaKDMoDz,项目名称:InVision,代码行数:8,代码来源:MathUtil.cs

示例6: MatrixToEuler

 public static Vector3 MatrixToEuler(ref Matrix m)
 {
     Vector3 translate;
     Vector3 scale;
     Quaternion rotate;
     m.Decompose(out scale, out rotate, out translate);
     return quaternionToEuler(ref rotate);
 }
开发者ID:HaKDMoDz,项目名称:InVision,代码行数:8,代码来源:MathUtil.cs

示例7: MatrixToSRT

 public static Vector3[] MatrixToSRT(Matrix m)
 {
     Quaternion q;
     Vector3[] srt = new Vector3[3];
     m.Decompose(out srt[0], out q, out srt[2]);
     srt[1] = QuaternionToEuler(q);
     return srt;
 }
开发者ID:anhlehoang410,项目名称:SB3Utility,代码行数:8,代码来源:Fbx.cs

示例8: UpdateBoneTransformation

        /// <summary>
        /// Updades the graphics transformation from the given physics transformation
        /// </summary>
        /// <param name="physicsTransform"></param>
        internal void UpdateBoneTransformation(ref Matrix physicsTransform)
        {
            if (ColliderShape.LocalOffset != Vector3.Zero || ColliderShape.LocalRotation != Quaternion.Identity)
            {
                physicsTransform = Matrix.Multiply(ColliderShape.NegativeCenterMatrix, physicsTransform);
            }

            //we need to extract scale only..
            Vector3 scale, translation;
            Matrix rotation;
            BoneWorldMatrix.Decompose(out scale, out rotation, out translation);

            var scaling = Matrix.Scaling(scale);
            Matrix.Multiply(ref scaling, ref physicsTransform, out BoneWorldMatrixOut);

            //todo propagate to other bones? need to review this.

            if (DebugEntity == null) return;

            if (ColliderShape.LocalOffset != Vector3.Zero || ColliderShape.LocalRotation != Quaternion.Identity)
            {
                physicsTransform = Matrix.Multiply(ColliderShape.PositiveCenterMatrix, physicsTransform);
            }

            physicsTransform.Decompose(out scale, out rotation, out translation);
            DebugEntity.Transform.Position = translation;
            DebugEntity.Transform.Rotation = Quaternion.RotationMatrix(rotation);
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:32,代码来源:PhysicsComponent.cs

示例9: UpdateTransformationComponent

        /// <summary>
        /// Updades the graphics transformation from the given physics transformation
        /// </summary>
        /// <param name="physicsTransform"></param>
        internal void UpdateTransformationComponent(ref Matrix physicsTransform)
        {
            var entity = Entity;

            if (ColliderShape.LocalOffset != Vector3.Zero || ColliderShape.LocalRotation != Quaternion.Identity)
            {
                physicsTransform = Matrix.Multiply(ColliderShape.NegativeCenterMatrix, physicsTransform);
            }

            //we need to extract scale only..
            Vector3 scale, translation;
            Matrix rotation;
            entity.Transform.WorldMatrix.Decompose(out scale, out rotation, out translation);

            var scaling = Matrix.Scaling(scale);
            Matrix.Multiply(ref scaling, ref physicsTransform, out entity.Transform.WorldMatrix);

            if (entity.Transform.Parent == null)
            {
                entity.Transform.LocalMatrix = entity.Transform.WorldMatrix;
            }
            else
            {
                //We are not root so we need to derive the local matrix as well
                var inverseParent = entity.Transform.Parent.WorldMatrix;
                inverseParent.Invert();
                Matrix.Multiply(ref entity.Transform.WorldMatrix, ref inverseParent, out entity.Transform.LocalMatrix);
            }

            Quaternion rotQuat;
            entity.Transform.LocalMatrix.Decompose(out scale, out rotQuat, out translation);
            entity.Transform.Position = translation;
            entity.Transform.Rotation = rotQuat;

            if (DebugEntity == null) return;

            if (ColliderShape.LocalOffset != Vector3.Zero || ColliderShape.LocalRotation != Quaternion.Identity)
            {
                physicsTransform = Matrix.Multiply(ColliderShape.PositiveCenterMatrix, physicsTransform);
            }

            physicsTransform.Decompose(out scale, out rotation, out translation);
            DebugEntity.Transform.Position = translation;
            DebugEntity.Transform.Rotation = Quaternion.RotationMatrix(rotation);
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:49,代码来源:PhysicsComponent.cs

示例10: DeriveBonePhysicsTransformation

        /// <summary>
        /// Computes the physics transformation from the TransformComponent values
        /// </summary>
        /// <returns></returns>
        internal void DeriveBonePhysicsTransformation(out Matrix derivedTransformation)
        {
            Matrix rotation;
            Vector3 translation;
            Vector3 scale;
            BoneWorldMatrix.Decompose(out scale, out rotation, out translation);

            var translationMatrix = Matrix.Translation(translation);
            Matrix.Multiply(ref rotation, ref translationMatrix, out derivedTransformation);

            //handle dynamic scaling if allowed (aka not using assets)
            if (CanScaleShape)
            {
                if (ColliderShape.Scaling != scale)
                {
                    ColliderShape.Scaling = scale;
                }
            }

            //Handle collider shape offset
            if (ColliderShape.LocalOffset != Vector3.Zero || ColliderShape.LocalRotation != Quaternion.Identity)
            {
                derivedTransformation = Matrix.Multiply(ColliderShape.PositiveCenterMatrix, derivedTransformation);
            }

            if (DebugEntity == null) return;

            derivedTransformation.Decompose(out scale, out rotation, out translation);
            DebugEntity.Transform.Position = translation;
            DebugEntity.Transform.Rotation = Quaternion.RotationMatrix(rotation);
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:35,代码来源:PhysicsComponent.cs

示例11: SetFrameMatrix

        public void SetFrameMatrix(int id,
			double m11, double m12, double m13, double m14,
			double m21, double m22, double m23, double m24,
			double m31, double m32, double m33, double m34,
			double m41, double m42, double m43, double m44)
        {
            Transform frame = Frames[id];
            Matrix m = new Matrix();

            m.M11 = (float)m11;
            m.M12 = (float)m12;
            m.M13 = (float)m13;
            m.M14 = (float)m14;

            m.M21 = (float)m21;
            m.M22 = (float)m22;
            m.M23 = (float)m23;
            m.M24 = (float)m24;

            m.M31 = (float)m31;
            m.M32 = (float)m32;
            m.M33 = (float)m33;
            m.M34 = (float)m34;

            m.M41 = (float)m41;
            m.M42 = (float)m42;
            m.M43 = (float)m43;
            m.M44 = (float)m44;

            Vector3 s, t;
            Quaternion q;
            m.Decompose(out s, out q, out t);
            frame.m_LocalPosition = t;
            frame.m_LocalRotation = q;
            frame.m_LocalScale = s;
            Changed = true;
        }
开发者ID:hejob,项目名称:SB3Utility,代码行数:37,代码来源:AnimatorEditor.cs

示例12: RigidBodyGetWorldTransform

        //This is valid for Dynamic rigidbodies (called once at initialization)
        //and Kinematic rigidbodies, called every simulation tick (if body not sleeping) to let the physics engine know where the kinematic body is.
        private void RigidBodyGetWorldTransform(out Matrix physicsTransform)
        {
            Data.PhysicsComponent.Simulation.SimulationProfiler.Mark();
            Data.PhysicsComponent.Simulation.UpdatedRigidbodies++;

            if (BoneIndex == -1)
            {
                DerivePhysicsTransformation(out physicsTransform);
            }
            else
            {
                DeriveBonePhysicsTransformation(out physicsTransform);
            }

            if (DebugEntity == null) return;

            Vector3 scale, pos;
            Quaternion rot;
            physicsTransform.Decompose(out scale, out rot, out pos);
            DebugEntity.Transform.Position = pos;
            DebugEntity.Transform.Rotation = rot;
        }
开发者ID:cg123,项目名称:xenko,代码行数:24,代码来源:RigidbodyComponent.cs


注:本文中的System.Matrix.Decompose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。