Example #1
0
        /// <summary>
        /// Sets box to extents of original box, transformed by the given matrix</summary>
        /// <param name="M">Transformation matrix</param>
        public void Transform(Matrix4F M)
        {
            // http://www.ics.uci.edu/~arvo/code/TransformingBoxes.c
            // "Transforming Axis-Aligned Bounding Boxes",
            //  by Jim Arvo, in "Graphics Gems", Academic Press, 1990.
            float[] oldMin = new[] { Min.X, Min.Y, Min.Z };
            float[] oldMax = new[] { Max.X, Max.Y, Max.Z };

            float[] newMin = new[] { M.M41, M.M42, M.M43 };
            float[] newMax = new[] { newMin[0], newMin[1], newMin[2] };

            float[] mArray = M.ToArray();

            float a, b;

            for (int i = 0; i < 3; ++i)
            {
                for (int j = 0; j < 3; ++j)
                {
                    a = mArray[j * 4 + i] * oldMin[j];
                    b = mArray[j * 4 + i] * oldMax[j];

                    if (a < b)
                    {
                        newMin[i] += a;
                        newMax[i] += b;
                    }
                    else
                    {
                        newMin[i] += b;
                        newMax[i] += a;
                    }
                }
            }

            Min.X = newMin[0];
            Min.Y = newMin[1];
            Min.Z = newMin[2];

            Max.X = newMax[0];
            Max.Y = newMax[1];
            Max.Z = newMax[2];

            m_initialized = true;
        }
Example #2
0
 /// <summary>
 /// Sets the DomNode attribute to the given Matrix4F</summary>
 /// <param name="domNode">DomNode holding attribute</param>
 /// <param name="attribute">Attribute of the DomNode that contains the data</param>
 /// <param name="m">Matrix4F value to be set</param>
 public static void SetMatrix(DomNode domNode, AttributeInfo attribute, Matrix4F m)
 {
     domNode.SetAttribute(attribute, m.ToArray());
 }
Example #3
0
 public static void SetMatrix4x4(this DomNodeAdapter node, AttributeInfo attributeInfo, Matrix4F mat)
 {
     node.DomNode.SetAttribute(attributeInfo, mat.ToArray());
 }
Example #4
0
        public virtual void UpdateTransform()
        {
            Matrix4F xform = TransformUtils.CalcTransform(this);

            SetAttribute(Schema.gameObjectType.transformAttribute, xform.ToArray());
        }
        /// <summary>
        /// Computes transformation matrix from transformation related atrributes.</summary>
        public void ComputeTransform()
        {
            Matrix4F xform = TransformUtils.CalcTransform(m_transformable);

            SetAttribute(Schema.gameObjectType.transformAttribute, xform.ToArray());
        }
Example #6
0
 public static void SetMatrix4x4(this DomNodeAdapter node, AttributeInfo attributeInfo, Matrix4F mat)
 {
     node.DomNode.SetAttribute(attributeInfo, mat.ToArray());
 }
 /// <summary>
 /// Sets the DomNode attribute to the given Matrix4F</summary>
 /// <param name="domNode">DomNode holding attribute</param>
 /// <param name="attribute">Attribute of the DomNode that contains the data</param>
 /// <param name="m">Matrix4F value to be set</param>
 public static void SetMatrix(DomNode domNode, AttributeInfo attribute, Matrix4F m)
 {
     domNode.SetAttribute(attribute, m.ToArray());
 }