Does anyone know how i can extend into the matrix struct.
Is this something to do with the aliasing to microsoft.xna.framework.
This doesn’t seem to be seen how the heck do you do this lol.
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace MyMgHelperStructsAndExtentions
{
using Microsoft.Xna.Framework;
// how many times has this screwed me up now.
// you know what i ill just toss a extension method in here
//
// or not !
//public struct Extensions {
public static class Extensions
{
//public static Matrix CreateLookAtForward(ref Matrix m, Vector3 cameraPosition, Vector3 cameraForward, Vector3 cameraUpVector)
public static Matrix CreateLookAtForward(this Matrix m, Vector3 cameraPosition, Vector3 cameraForward, Vector3 cameraUpVector)
{
Matrix result;
var cameraTarget = cameraPosition + cameraForward * 10f;
var vector = Vector3.Normalize(cameraPosition - cameraTarget);
var vector2 = Vector3.Normalize(Vector3.Cross(cameraUpVector, vector));
var vector3 = Vector3.Cross(vector, vector2);
result.M11 = vector2.X;
result.M12 = vector3.X;
result.M13 = vector.X;
result.M14 = 0f;
result.M21 = vector2.Y;
result.M22 = vector3.Y;
result.M23 = vector.Y;
result.M24 = 0f;
result.M31 = vector2.Z;
result.M32 = vector3.Z;
result.M33 = vector.Z;
result.M34 = 0f;
result.M41 = -Vector3.Dot(vector2, cameraPosition);
result.M42 = -Vector3.Dot(vector3, cameraPosition);
result.M43 = -Vector3.Dot(vector, cameraPosition);
result.M44 = 1f;
return result;
}