예제 #1
0
        /// <summary>
        /// Transforms the center of a rectangle
        /// </summary>
        /// <param name="rectangle">The rectangle to transform.</param>
        /// <param name="transformation">Transformation to apply.</param>
        public static void TransformCenter(this Box2D rectangle, Transformation transformation)
        {
            var newCenter = transformation.Transform(rectangle.GetCenter());

            rectangle.CenterX = newCenter.X;
            rectangle.CenterY = newCenter.Y;
        }
예제 #2
0
        /// <summary>
        /// Transforms the mesh by the specified transform.
        /// </summary>
        /// <param name="mesh">The mesh to transform.</param>
        /// <param name="transformation">The transformation.</param>
        /// <returns></returns>
        public static DefaultMesh Transform(this DefaultMesh mesh, Transformation transformation)
        {
            var newMesh = new DefaultMesh();

            newMesh.TexCoord.AddRange(mesh.TexCoord);
            newMesh.IDs.AddRange(mesh.IDs);
            foreach (var pos in mesh.Position)
            {
                var newPos = transformation.Transform(pos);
                newMesh.Position.Add(newPos);
            }
            foreach (var n in mesh.Normal)
            {
                var newN = Vector3.Normalize(Vector3.TransformNormal(n, transformation.Matrix));
                newMesh.Normal.Add(newN);
            }
            return(newMesh);
        }