view and projection matrices.

Jan 27, 2013 at 6:31 PM

Im trying to fill in the arguments to a method

SetMatrices(ref Matrix world, ref Matrix view, ref Matrix projection) ;

//I have tryed using


and a few others but the errors refer to not having the correct arguments and when I
add the ref keyword it makes the problem worse

A property, indexer or dynamic member access may not be passed as an out or ref parameter
which I cannot seem to overcome. Does anyone know a way?
Jan 27, 2013 at 9:03 PM

If I understand your problem correctly, you need to first save off the matrix from the calls you listed below as local variables, and then call SetMatrices() with those local variables.

Other than that, I cannot really say more because I'd have to see the actual call as you're calling it along with what you're trying to accomplish.

Jan 27, 2013 at 10:52 PM

I need to call SetMatrices inside Update() of my Xen Application class to satisfy "Gear Set"'s requirements.  Gearset at is a product to aid in xna development and as such it requires to know the world, view and projection matrices to work.  In context I have created the following code inside Update()

Matrix projection, view;
camera.GetCameraMatrix(out view);
projection = camera.Projection.ProjectionMatrix;
Gearset.GS.SetMatrices(ref world, ref view, ref projection);

The problem is that when I try to run the game, a system.exception is thrown by camera.Projection.ProjectionMatrix;
complaining that "Value does not fall within the expected range"
I am not sure how to solve the problem of passing these required matrices along. In the documentation
Projection.ProjectionMatrix and Camera.GetCameraMatrix were all I could find that could possibly give me the matrices that I need.

I see that xen encapsulates these view and projection matrices within camera, or so it seems and thats as far as I could figure out.
SetMatrices wants three references of type Microsoft.Xna.Framework.Matrix
Jan 28, 2013 at 2:51 AM

If you get the exception on launch, it could be an initialization order thing where you're querying camera info before it's available. You might need to check that the camera is actually providing "valid" info before sending it to SetMatrices(). For example, if the FOV is set to 0, this could cause Gearset to bitch about it. Try sending in some hardcoded matrices to see if that might do the trick. I believe XNA has some Matrix functions to create some view and projection matrices by giving some hardcoded parameters. Other than that, I'm not sure, but you could back track in your callstack when the exception is thrown and see what the matrices are, and that way deduce why the values don't fall in the expected range.

Hope that helps.