3d iso

Résolu
niketou Messages postés 295 Date d'inscription dimanche 4 mai 2003 Statut Membre Dernière intervention 6 décembre 2010 - 8 janv. 2006 à 17:59
Galmiza Messages postés 573 Date d'inscription samedi 16 novembre 2002 Statut Membre Dernière intervention 9 avril 2008 - 8 janv. 2006 à 22:03
Salut a tous.
J'ai besoin d"un fortiche en math.
Je veux faire une vue isometrique,voici mes variable de la camera:

D3DXVECTOR3 vEyePt( PX,PY,PZ );
D3DXVECTOR3 vLookatPt( LX, LY,LZ);
D3DXVECTOR3 vUpVec( 0.0f, 1.0f, 0.0f );
D3DXMATRIXA16 matView;
D3DXMatrixIdentity( &matView );
D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec );
g_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );


D3DXMATRIXA16 matProj;
D3DXMatrixIdentity( &matProj );
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 500.0f );
g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );

Quels calculs dois je utiliser pour avancer,deplacer a droite et tourner sur 360° la camera dans un monde 3d ?.
Merci a tous.

2 réponses

Galmiza Messages postés 573 Date d'inscription samedi 16 novembre 2002 Statut Membre Dernière intervention 9 avril 2008 1
8 janv. 2006 à 22:03
Pour la 3D isométrique, il n'y a pas de perspective, donc il te faut une matrice de projection orthogonale.



D3DXMatrixPerspectiveFovLH, non.

D3DXMatrixOrthoLH, oui.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/D3DXMATRIXperspectivefovlh.asp



Le reste peut-être laissé tel quel.
3
Galmiza Messages postés 573 Date d'inscription samedi 16 novembre 2002 Statut Membre Dernière intervention 9 avril 2008 1
8 janv. 2006 à 21:57
Pour les mouvements dans le monde, il te faut un vecteur directionCamera normé.

A chaque boucle, vLookatPt = vEyePt + directionCamera;

L'appui sur une touche de déplacement modifie la position de la camera.

Bouger la souris modifie le vecteur de direction (de la camera).



Dans le code qui suit, rotation->y est l'angle autour de l'axe
vertical (y), rotation->x est l'angle autour de l'axe x. Ils valent
0 lorsque la direction de la camera est (0,0,1).



D3DXVECTOR3 *rotation = g_pDirect3D->GetRotation();

D3DXVECTOR3 *camera = g_pDirect3D->GetCamera();



float player_vitesse = 100.0f;



//si on a appuyé sur la touche de gauche

if (KEYDOWN(pkeyBuffer, DIK_LEFT))

{

camera->x -= player_vitesse*delta_time*cosf(rotation->y);

camera->z += player_vitesse*delta_time*sinf(rotation->y);

}



//si on a appuyé sur la touche de droite

if (KEYDOWN(pkeyBuffer, DIK_RIGHT))

{

camera->x += player_vitesse*delta_time*cosf(rotation->y);

camera->z -= player_vitesse*delta_time*sinf(rotation->y);

}



//si on a appuyé sur la touche haut

if (KEYDOWN(pkeyBuffer, DIK_UP))

{

camera->x += player_vitesse*delta_time*sinf(rotation->y)*cosf(rotation->x);

camera->z += player_vitesse*delta_time*cosf(rotation->y)*cosf(rotation->x);

camera->y += player_vitesse*delta_time*sinf(rotation->x);

}



//si on a appuyé sur la touche bas

if (KEYDOWN(pkeyBuffer, DIK_DOWN))

{

camera->x -= player_vitesse*delta_time*sinf(rotation->y)*cosf(rotation->x);

camera->z -= player_vitesse*delta_time*cosf(rotation->y)*cosf(rotation->x);

camera->y -= player_vitesse*delta_time*sinf(rotation->x);

}
0
Rejoignez-nous