Jump to content
  • Advertisement
Sign in to follow this  
Kalthorn

View matrix Problem

This topic is 4348 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What would cause a quad to completely disappear when only a slight location change is made to the location of the View matrix? Specifically: device.Transform.View = Matrix.LookAtLH (new Vector3(0, 10, -25), new Vector3(0, 0, 0), new Vector3(0, 1, 0)); Changing the z value of the location vector to anything less than -25 (-26, etc) or going above 12y or positive X will make it just up and disappear. I'm sure many other random values will or won't work but I'm looking for a general reasons this might happen. Backface culling is off. I've heard that making a look at vector parallel to the world up vector makes things go screwy but that should not be the case here. My quad upper left is at the origin while the bottom right is at (10,0,-10). Anything to point me in the right direction is appreciated.

Share this post


Link to post
Share on other sites
Advertisement
this is java right? cause if its C++ those new statements are memory leaks.. neway, my guess would be your projection matrix is set to clip at past those values. this code is in C++ but it shouldnt be hard to convert:


D3DXMATRIX matProj;
FLOAT fAspect = ((FLOAT)pBackBufferSurfaceDesc->Width) / pBackBufferSurfaceDesc->Height;
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, fAspect, 1.0f, 1000.0f );
V(pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj ));


you can look up the function but the 1.0 and the 1000.0 are the minimum and maximum z values. The D3DX_PI/4 is the number of radians you can see (the higher it is the wider your view).

Share this post


Link to post
Share on other sites
my guess would be its something like this:

float aspect = device.BackBufferSurfaceDesc.Width/device.BackBufferSurfaceDesc.Height;
device.Transform.Projection = Matrix.MatrixPerspectiveFovLH(3.141592/4,aspect,1,1000);

Share this post


Link to post
Share on other sites
The quad is on the X/Z plane. The upper left point on the quad is at the origin (0,0,0) the the bottom right is at (10,0,-10). The other points are (10,0,0) and (0,0,-10).

So I'm just looking forward and down on the a square from the view matrix.

Share this post


Link to post
Share on other sites
the call:

Matrix.LookAtLH
(new Vector3(0, 10, -25), new Vector3(0, 0, 0), new Vector3(0,1,0))

returns this matrix:

viewMatrix
{Determinant: 0.9999998
M11: 1
M12: 0
M13: 0
M14: 0
M21: 0
M22: 0.9284766
M23: -0.3713906
M24: 0
M31: 0
M32: 0.3713906
M33: 0.9284766
M34: 0
M41: 0
M42: 0
M43: 26.92582
M44: 1
}

My position values are completely wrong. Using the same vec3 later with matrix.Translate gets the location values correct.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!