/// <summary> /// Matrix Overload for Framework Match /// </summary> public static void Mult(ref Matrix left, ref Matrix right, out Matrix result) { #if OpenTK Matrix.Mult(ref left, ref right, out result); #else Matrix.Multiply(ref left, ref right, out result); #endif }
/// <summary> /// Compute World Matrix Starting From Node and Reading all Parents Transformations /// </summary> /// <param name="leaf"></param> /// <returns></returns> public static Matrix GetWorldMatrixFromNode(this NiAVObject leaf) { var current = leaf; var worldMatrix = Matrix.Identity; // For Each Parent Node while (current != null) { // Append Transformation To Matrix Matrix intermediate; #if SharpDX Matrix.Multiply(ref worldMatrix, ref current.Rotation, out intermediate); worldMatrix = intermediate; var scale = Matrix.Scaling(current.Scale); Matrix.Multiply(ref worldMatrix, ref scale, out intermediate); worldMatrix = intermediate; var translate = Matrix.Translation(current.Translation.X, current.Translation.Y, current.Translation.Z); Matrix.Multiply(ref worldMatrix, ref translate, out intermediate); worldMatrix = intermediate; #elif MonoGame Matrix.Multiply(ref worldMatrix, ref current.Rotation, out intermediate); worldMatrix = intermediate; var scale = Matrix.CreateScale(current.Scale); Matrix.Multiply(ref worldMatrix, ref scale, out intermediate); worldMatrix = intermediate; var translate = Matrix.CreateTranslation(current.Translation.X, current.Translation.Y, current.Translation.Z); Matrix.Multiply(ref worldMatrix, ref translate, out intermediate); worldMatrix = intermediate; #else Matrix.Mult(ref worldMatrix, ref current.Rotation, out intermediate); worldMatrix = intermediate; var scale = Matrix.CreateScale(current.Scale); Matrix.Mult(ref worldMatrix, ref scale, out intermediate); worldMatrix = intermediate; var translate = Matrix.CreateTranslation(current.Translation.X, current.Translation.Y, current.Translation.Z); Matrix.Mult(ref worldMatrix, ref translate, out intermediate); worldMatrix = intermediate; #endif current = current.Parent; } return(worldMatrix); }