Esempio n. 1
0
        /// <summary>
        /// Transform a given transformations and return the result matrix.
        /// </summary>
        /// <param name="trans">Transformations to transform.</param>
        /// <returns>Matrix with combined transformations.</returns>
        public Matrix Transform(Transformations trans)
        {
            // build matrix for given transformations
            Matrix transMatrix = trans.BuildMatrix();

            // get our world transformations
            Matrix worldMatrix = WorldTransformations;

            // combine and return
            return(transMatrix * worldMatrix);
        }
Esempio n. 2
0
        /// <summary>
        /// Transform a given transformations and return the result matrix.
        /// </summary>
        /// <param name="trans">Transformations to transform.</param>
        /// <returns>Matrix with combined transformations.</returns>
        public Matrix Transform(Transformations trans)
        {
            // build matrix for given transformations
            Matrix transMatrix = trans.BuildMatrix();

            // get our world transformations
            Matrix worldMatrix = WorldTransformations;

            // count the event
            Utils.CountAndAlert.Count(Utils.CountAndAlert.PredefAlertTypes.ForceUpdate);

            // combine and return
            return(transMatrix * worldMatrix);
        }
Esempio n. 3
0
        /// <summary>
        /// Calc final transformations for current frame.
        /// This uses an indicator to know if an update is needed, so no harm is done if you call it multiple times.
        /// </summary>
        protected virtual void DoTransformationsUpdateIfNeeded()
        {
            // if use external transformations, skip
            if (UseExternalTransformations)
            {
                _isDirty = false;
                return;
            }

            // if local transformations are dirty, or parent transformations are out-of-date, update world transformations
            if (_isDirty || WasParentUpdate)
            {
                // if local transformations are dirty, we need to update local transforms
                if (_isDirty)
                {
                    _localTransform = Transformations.BuildMatrix();
                }

                // if we got parent, apply its transformations
                if (Parent != null)
                {
                    _worldTransform             = _localTransform * Parent._worldTransform;
                    _parentLastTransformVersion = Parent._transformVersion;
                }
                // if not, world transformations are the same as local, and reset parent last transformations version
                else
                {
                    _worldTransform             = _localTransform;
                    _parentLastTransformVersion = 0;
                }

                // no longer dirty
                _isDirty = false;

                // called the function that mark world matrix change (increase transformation version etc)
                OnWorldMatrixChange();
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Build matrix from node transformations.
 /// </summary>
 public Matrix BuildTransformationsMatrix()
 {
     return(Transformations.BuildMatrix());
 }