camera position question

Started by
4 comments, last by KOzymandias 16 years, 4 months ago
I have created a plane of textured quads laying on the x and z axis. My issue occurs when i place the camera at (16.0f, 10.0f, 16.0f). The plane of textures is located at 0.0f on the y-axis. How come when i put the camera at the perpendicular angle (to look straight the plane) the plane of textures dissapears, but if i change the camera to something just off like (16.0f, 10.0f, 16.1f). also, the block of textures is 32x32 so 16 and 16 is the center, and my look at position is (16.0f, 0.0f, 16.0f). i can see it. any ideas? Thanks in advance!
Advertisement
Hard to guess what is the problem. Post some code please.
.
if i define my camera as the following my plane dissapears

D3DXMATRIX matView; // the view transform matrix
D3DXMatrixLookAtLH(&matView,
&D3DXVECTOR3 (16.0f, 40.0f, 16.0f), // the camera position
&D3DXVECTOR3 (16.0f, 0.0f, 16.0f), // the look-at position
&D3DXVECTOR3 (0.0f, 1.0f, 0.0f)); // the up direction
d3ddev->SetTransform(D3DTS_VIEW, &matView); // set the view transform

i figured out it only dissapears when my camera and look at position have the same x and z coordinates. all i have is one quad located at 16, 0, 16 to 17, 0, 17. if i change the camera to the following my quad appears again?

D3DXMATRIX matView; // the view transform matrix
D3DXMatrixLookAtLH(&matView,
&D3DXVECTOR3 (16.0f, 40.0f, 16.1f), // the camera position
&D3DXVECTOR3 (16.0f, 0.0f, 16.0f), // the look-at position
&D3DXVECTOR3 (0.0f, 1.0f, 0.0f)); // the up direction
d3ddev->SetTransform(D3DTS_VIEW, &matView); // set the view transform


these are my render states

d3ddev->SetRenderState(D3DRS_LIGHTING, TRUE); // turn on the 3D lighting
d3ddev->SetRenderState(D3DRS_ZENABLE, TRUE); // turn on the z-buffer
d3ddev->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(100, 100, 100)); // ambient light
d3ddev->SetRenderState(D3DRS_NORMALIZENORMALS, TRUE); // handle normals in scaling
When you look straight at the plane, the up vector is equal to the inverse of the forward vector, so you destroy your matrix. You'll need to either calculate the up vector, or use something like (0, 0, 1) if you're looking straight up or down.
so how would i accomplish having the view be directly down on the plane? im trying to simulate 2d in 3d. How would i calculate the up vector?
You can use another up vector as Evil Steve said, or have your plane vertical (XY or ZY).

This topic is closed to new replies.

Advertisement