コード例 #1
0
        private void Update(EvaluationContext context)
        {
            var   s     = Scale.GetValue(context) * UniformScale.GetValue(context);
            var   r     = Rotation.GetValue(context);
            float yaw   = MathUtil.DegreesToRadians(r.Y);
            float pitch = MathUtil.DegreesToRadians(r.X);
            float roll  = MathUtil.DegreesToRadians(r.Z);
            var   t     = Translation.GetValue(context);
            var   objectToParentObject = Matrix.Transformation(Vector3.Zero, Quaternion.Identity, new Vector3(s.X, s.Y, s.Z), Vector3.Zero,
                                                               Quaternion.RotationYawPitchRoll(yaw, pitch, roll), new Vector3(t.X, t.Y, t.Z));


            // transpose all as mem layout in hlsl constant buffer is row based
            objectToParentObject.Transpose();

            if (Invert.GetValue(context))
            {
                objectToParentObject.Invert();
            }

            _matrix[0]   = objectToParentObject.Row1;
            _matrix[1]   = objectToParentObject.Row2;
            _matrix[2]   = objectToParentObject.Row3;
            _matrix[3]   = objectToParentObject.Row4;
            Result.Value = _matrix;
        }