Off center projection issue

I’m trying to implement the code that was freely given by a very kind developer at the following link:

http://forum.unity3d.com/threads/142383-Code-sample-Off-Center-Projection-Code-for-VR-CAVE-or-just-for-fun

Right now, all I’m trying to do is bring it in on one camera, but I have a few issues. My class, looks as follows:

using UnityEngine;
using System.Collections;

public class PerspectiveOffCenter : MonoBehaviour 
{

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}


	public static Matrix4x4 GeneralizedPerspectiveProjection(Vector3 pa, Vector3 pb, Vector3 pc, Vector3 pe, float near, float far)
	{
	    Vector3 va, vb, vc;
	    Vector3 vr, vu, vn;
	
	    float left, right, bottom, top, eyedistance;
	    
	    Matrix4x4 transformMatrix;
	    Matrix4x4 projectionM;
	    Matrix4x4 eyeTranslateM;
	    Matrix4x4 finalProjection;
	
	    ///Calculate the orthonormal for the screen (the screen coordinate system
	    vr = pb - pa;
	    vr.Normalize();
	    vu = pc - pa;
	    vu.Normalize();
	    vn = Vector3.Cross(vr, vu);
	    vn.Normalize(); 
	
	    //Calculate the vector from eye (pe) to screen corners (pa, pb, pc)
	    va = pa-pe;
	    vb = pb-pe;
	    vc = pc-pe;
	
	    //Get the distance;; from the eye to the screen plane
	    eyedistance = -(Vector3.Dot(va, vn));
	
	    //Get the varaibles for the off center projection
	    left 	= (Vector3.Dot(vr, va)*near)/eyedistance;
	    right  	= (Vector3.Dot(vr, vb)*near)/eyedistance;
	    bottom  = (Vector3.Dot(vu, va)*near)/eyedistance;
	    top 	= (Vector3.Dot(vu, vc)*near)/eyedistance;
	
	    //Get this projection
	    projectionM = PerspectiveOffCenter(left, right, bottom, top, near, far);
	
	    //Fill in the transform matrix
	    transformMatrix = new Matrix4x4();
	
	    transformMatrix[0, 0] = vr.x;
	    transformMatrix[0, 1] = vr.y;
	    transformMatrix[0, 2] = vr.z;
	    transformMatrix[0, 3] = 0;
	
	    transformMatrix[1, 0] = vu.x;
	    transformMatrix[1, 1] = vu.y;
	    transformMatrix[1, 2] = vu.z;
	    transformMatrix[1, 3] = 0;
	
	    transformMatrix[2, 0] = vn.x;
	    transformMatrix[2, 1] = vn.y;
	    transformMatrix[2, 2] = vn.z;
	    transformMatrix[2, 3] = 0;
	
	    transformMatrix[3, 0] = 0;
	    transformMatrix[3, 1] = 0;
	    transformMatrix[3, 2] = 0;
	    transformMatrix[3, 3] = 1;
	
	    //Now for the eye transform
	    eyeTranslateM = new Matrix4x4();
	
	    eyeTranslateM[0, 0] = 1;
	    eyeTranslateM[0, 1] = 0;
	    eyeTranslateM[0, 2] = 0;
	    eyeTranslateM[0, 3] = -pe.x;
	
	    eyeTranslateM[1, 0] = 0;
	    eyeTranslateM[1, 1] = 1;
	    eyeTranslateM[1, 2] = 0;
	    eyeTranslateM[1, 3] = -pe.y;
		
	    eyeTranslateM[2, 0] = 0;
	    eyeTranslateM[2, 1] = 0;
	    eyeTranslateM[2, 2] = 1;
	    eyeTranslateM[2, 3] = -pe.z;
		
	    eyeTranslateM[3, 0] = 0;
	    eyeTranslateM[3, 1] = 0;
	    eyeTranslateM[3, 2] = 0;
	    eyeTranslateM[3, 3] = 1f;
	
	    
	
	    //Multiply all together
	    finalProjection = new Matrix4x4();
	    finalProjection = Matrix4x4.identity * projectionM*transformMatrix*eyeTranslateM;
	
	    //finally return
	    return finalProjection;
	}
	
	// Update is called once per frame

	public void FixedUpdate () 
	{
    	Camera cam = camera;

    	//calculate projection
   	 	Matrix4x4 genProjection = GeneralizedPerspectiveProjection( new Vector3(0,1,0), new Vector3(1,1,0), new Vector3(0,0,0), new Vector3(0,0,0), cam.nearClipPlane, cam.farClipPlane);
																//(BottomLeftCorner, BottomRightCorner, TopLeftCorner, trackerPosition, cam.nearClipPlane, cam.farClipPlane);
    	cam.projectionMatrix = genProjection;   

	}	
}

My error lies in projectionM = PerspectiveOffCenter(left, right, bottom, top, near, far);

The debugger states: Expression denotes a type', where a variable’, value' or method group’ was expected.

Thus, I changed the line to read: projectionM = new PerspectiveOffCenter(left, right, bottom, top, near, far);

But then the error is changed to: The type PerspectiveOffCenter' does not contain a constructor that takes 6’ arguments. For reasons that are obvious.

So, finally, I changed the line to read: projectionM = new GeneralizedPerspectiveProjection(left, right, bottom, top, near, far);

And the error I get is: is a method' but a type’ was expected.

With this last error, I’m not sure what it is I should do / missing. Can anyone see what it is that I’m missing to fix this error?

as a matrix holds 4 rows of 4 i can see why your getting your error but i can’t remember exactly the proper method for declaring a new Matrix4x4 I do know that u can SetColumns which will be one of your rows perhaps u could use this somehow? ill have a look around the documentation and see if i can find out for you.

— EDIT — Here you go i put this together after going through the docs certainly something similar would work for u.

		Vector4 c1 = new Vector4 (1,1,1,1);
		Vector4 c2 = new Vector4 (1,1,1,1);
		Vector4 c3 = new Vector4 (1,1,1,1);
		Vector4 c4 = new Vector4 (1,1,1,1);

		Matrix4x4 v = new Matrix4x4 ();
		v.SetColumn(0, c1);
		v.SetColumn(1, c2);
		v.SetColumn(2, c3);
		v.SetColumn(3, c4);