Ejemplo n.º 1
0
        private static void UpdateLocalMatrix(ref ModelNodeTransformation node)
        {
            var scaling = node.Transform.Scale;

            Matrix.Transformation(ref scaling, ref node.Transform.Rotation, ref node.Transform.Position, out node.LocalMatrix);
            node.IsScalingNegative = (scaling.X < 0.0f) ^ (scaling.Y < 0.0f) ^ (scaling.Z < 0.0f);
        }
Ejemplo n.º 2
0
        private static void UpdateLocalMatrix(ref ModelNodeTransformation node)
        {
            var        scaling = node.Transform.Scale;
            Quaternion rotation;

            //Bit of a hack to let us override the animation system with our own rotations
            if ((node.Flags & ModelNodeFlags.CustomRotationOverride) == ModelNodeFlags.CustomRotationOverride)
            {
                rotation = node.CustomRotation;
            }
            else
            {
                rotation = node.Transform.Rotation * node.CustomRotation;
            }

            Matrix.Transformation(ref scaling, ref rotation, ref node.Transform.Position, out node.LocalMatrix);
            node.IsScalingNegative = (scaling.X < 0.0f) ^ (scaling.Y < 0.0f) ^ (scaling.Z < 0.0f);
        }
Ejemplo n.º 3
0
        private void UpdateNode(ref ModelNodeTransformation node)
        {
            // Compute LocalMatrix
            if ((node.Flags & ModelNodeFlags.EnableTransform) == ModelNodeFlags.EnableTransform)
            {
                UpdateLocalMatrix(ref node);
            }

            var nodeTransformationsLocal = this.nodeTransformations;

            var parentIndex = node.ParentIndex;

            // Update Enabled
            bool renderingEnabledRecursive = (node.Flags & ModelNodeFlags.EnableRender) == ModelNodeFlags.EnableRender;

            if (parentIndex != -1)
            {
                renderingEnabledRecursive &= nodeTransformationsLocal[parentIndex].RenderingEnabledRecursive;
            }

            node.RenderingEnabledRecursive = renderingEnabledRecursive;

            if (renderingEnabledRecursive && (node.Flags & ModelNodeFlags.OverrideWorldMatrix) != ModelNodeFlags.OverrideWorldMatrix)
            {
                // Compute WorldMatrix
                if (parentIndex != -1)
                {
                    Matrix.Multiply(ref node.LocalMatrix, ref nodeTransformationsLocal[parentIndex].WorldMatrix, out node.WorldMatrix);
                    if (nodeTransformationsLocal[parentIndex].IsScalingNegative)
                    {
                        node.IsScalingNegative = !node.IsScalingNegative;
                    }
                }
                else
                {
                    node.WorldMatrix = node.LocalMatrix;
                }
            }
        }