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

DX8 Camera Question

Started by IceGod Apr 19, 2001 at 2:22 AM 0 replies 250+ views
Original Post
IceGod
IceGod
Hi, Say I''ve got an object centered about the origin, and positioned at z = 1.0f, so its 1 unit into the screen. In order to make the camera rotoate around that object so that it looks like the object is rotating in place, you''d need to translate the object to the origin, apply the view matrix, and then translate the object back (or so I thought). However, in order to get the effect I desired, I have to do this: D3DXMATRIX matView; D3DXMATRIX matTrans, matTrans2; D3DXMATRIX matRotationY; D3DXVECTOR3 vecEye( 0.0f, 0.0f, 1.0f ); D3DXMatrixTranslation( &matTrans, 0.0f, 0.0f, 1.0f ); D3DXMatrixTranslation( &matTrans2, 0.0f, 0.0f, -1.0f ); //use this to rotate our cameras eye about tye Y-axis D3DXMatrixRotationY( &matRotationY, timeGetTime() / 1000.0f ); //camera rotated about the y-axis, always looking at the //origin D3DXMatrixLookAtLH( &matView, D3DXVec3TransformCoord( &vecEye, &vecEye, &matRotationY ), &D3DXVECTOR3( 0.0f, 0.0f, 0.0f ), &D3DXVECTOR3( 0.0f, 1.0f, 0.0f ) ); //combine the matrices //do the first translation, then the view matrix, then //the 2nd translation D3DXMATRIX matTemp; D3DXMatrixMultiply( &matTemp, &matView, &matTrans ); D3DXMatrixMultiply( &matView, &matTrans2, &matTemp ); g_pd3dDevice->SetTransform( D3DTS_VIEW, &matView ); This makes absolutely no sense to me, its the exact opposite of what I would expect to do, can someone explain? IceGod

Topic Locked

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

Sign in to reply to this topic.