Skip to main content
GameDev.net gamedev.net
🔒 Locked

Creating View Matrix

Started by choffstein Feb 17, 2005 at 6:30 PM 1 replies 500+ views
Original Post
choffstein
choffstein
I am working on a camera system, and stole some code from an online resource to try to understand how it works. However, once implemented, things stop working. I have narrowed the problem down to this bit of code:

	D3DXMATRIX view;
	D3DXMatrixIdentity(&view);

	D3DXVec3Normalize(&vLook, &vLook);
	D3DXVec3Cross(&vRight, &vUp, &vLook);
	D3DXVec3Normalize(&vRight, &vRight);
	D3DXVec3Cross(&vUp, &vLook, &vRight);
	D3DXVec3Normalize(&vUp, &vUp);

	view._11 = vRight.x;
	view._12 = vUp.x;
	view._13 = vLook.x;
	view._14 = 0.0f;

	view._21 = vRight.y;
	view._22 = vUp.y;
	view._23 = vLook.y;
	view._24 = 0.0f;

	view._31 = vRight.z;
	view._32 = vUp.z;
	view._33 = vLook.z;
	view._34 = 0.0f;

	view._41 = -D3DXVec3Dot(&vEye, &vRight);
	view._42 = -D3DXVec3Dot(&vEye, &vUp);
	view._43 = -D3DXVec3Dot(&vEye, &vLook);
	view._44 = 1.0f;
    
	pd3dDevice->SetTransform(D3DTS_VIEW, &view);
The vectors are preinitialized to:

	D3DXVECTOR3 vEye( 0.0f, 80.0f, -70.0f );
	D3DXVECTOR3 vLook( 0.0f, 0.0f, 0.0f );
	D3DXVECTOR3 vUp( 0.0f, 1.0f, 0.0f );
	D3DXVECTOR3 vRight(1.0f, 0.0f, 0.0f);
That is my UpdateViewMatrix() method, which is called pre rendering. With it commented out, everything renders normally. With it there, I cannot see anything on the screen. I printed out the vertices for each vector, and they looked fine. What am I doing wrong? Thanks!
Aldenar
Aldenar
vLook is (0, 0, 0), D3DXVec3Normalize() and D3DXVec3Cross() won't do any good with that :)
choffstein
choffstein
*whistles innocently*
Thanks!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.