D3DXVECTOR3 src(0.0f,0.0f,-1.0f); D3DXVECTOR3 r(1.0f,0.0f,0.0f); D3DXMATRIX mYaw; D3DXVec3TransformCoord(&r,&src,D3DXMatrixRotationY(&mYaw,mTurn)); D3DXVECTOR3 vCharPos(0.0f,0.0f,mWalkForward); D3DXVECTOR3 vCharFacing(r.x,r.y,r.z); D3DXVECTOR3 vEye; D3DXMATRIX mxView; static float posy = 1.0f; //posy += 0.001f; vEye = D3DXVECTOR3( vCharPos.x,0.25f , vCharPos.z += +6.0f ); //0.25f D3DXVECTOR3 vAt ( vCharPos.x, 0.125f, vCharPos.z ), //0.0125f vUp ( 0.0f, 1.0f, 0.0f ); vCharFacing.x *= .25; vCharFacing.y = 0.f; vCharFacing.z *= .25; vEye -= vCharFacing; vAt += vCharFacing; D3DXMatrixLookAtLH( &mxView, &vEye, &vAt, &vUp ); d3ddev->SetTransform( D3DTS_VIEW, &mxView );
Third person camera help directx 9
Posted 07 April 2012 - 01:05 AM
Posted 07 April 2012 - 10:27 AM
At first you must be create two class: CModel and CCamera.
Class CModel: controls the you 3D model (loading model, draw model, keyboard input);
Class CCamera: camera follows for model; to the position of the model you have to add the vector of camera position;
I.e.you must be distinguished two things: Model position and Camera position. In the class CCamera you must be get Model position from class CModel and add vector specifies the offset of the camera relative to the model.
Look.xyz vector of model must look to where you turn a model of the keyboard. And Look.xyz vector of camera must look on the model.
In the class CModel you must be construct World Matrix for model and in the class CCamera you must be construct View Matrix for your model and whole your 3D world.
Its very simple. See my source code: https://rapidshare.c...9/LaraCroft.rar
Posted 15 April 2012 - 12:41 PM
P.S. I often see your topics on the forum and I do not understand - you're really stupid or pretending? Really not understand, sorry.
Posted 16 April 2012 - 07:39 AM
How do you know if the OP likes OOP?
Try structs or open consideration for another next time outside your beliefs. Thank you.
20+ years of programming experience.
Posted 16 April 2012 - 11:05 AM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users