#include <Object3d.hpp>
Inheritance diagram for CapteurVisuel3D::
Private Methods | |
CapteurVisuel3D (Scene3D *scene=NULL) | |
void | CalculPerspective () |
void | VisualisationFilaireObjet (HDC, const Objet3D &) |
void | VisualisationFilaireScene (HDC) |
Private Attributes | |
realtype | _spin |
realtype | _ouverture |
realtype | _profondeur |
Fenetre3D | _fenetre |
Vector3DH | _direction |
Matrice44 | _perspective |
|
Definition at line 97 of file Object3d.hpp. 00097 : Objet3D( scene ), 00098 _spin ( 0 ), 00099 _ouverture ( 0 ), 00100 _profondeur ( 0 ) { } |
|
Definition at line 14 of file Object3d.cpp. 00015 { 00016 // on prend pour le calcul, le vecteur inverse. 00017 Vector3DH direction( _direction.b, _direction.a ); 00018 00019 // Calcul de la distance D du point de visée à l'observateur. 00020 realtype D = _direction.norme(); 00021 00022 // theta: angle entre le vecteur direction et sa projection sur le plan XOY. 00023 // Calcul des sin et cos. 00024 realtype costheta = 0.0f, 00025 sintheta = 0.0f; 00026 00027 direction.cos_sinangle_ver(costheta, sintheta); 00028 00029 // phi : angle entre la projection du vecteur direction sur le plans XOY et 00030 // l'axe des abscisses. 00031 // Calcul des sin et cos. 00032 // Nb - le cas particulier où la visée est verticale rend la projection sur 00033 // le plans XOY égale à un point. Dans ce cas, il n'y à pas de calcul 00034 // d'angle possible. On suppose donc phi=0; 00035 00036 realtype cosphi= 0.0f, 00037 sinphi= 0.0f; 00038 00039 direction.cos_sinangle_hor(cosphi, sinphi); 00040 00041 // on intialise la matrice perspective 00042 _perspective.setIdentity(); 00043 00044 // On initialise la matrice de changement de repère. 00045 Matrice44 mat; 00046 mat.setIdentity(); 00047 00048 // Etape 1. On effectue la première translation de changement de repère. 00049 mat.setTranslateX(-direction.compox()); 00050 mat.setTranslateY(-direction.compoy()); 00051 mat.setTranslateZ(-direction.compoz()); 00052 00053 _perspective.multiplyByMatrix(mat); 00054 00055 // Etape 2. Rotation négative autour de l'axe Z0 de PI/2-phi. 00056 // nous avons cos PI/2-phi = sin phi 00057 // sin PI/2-phi = -cos phi 00058 // or nous effectuons un changement de repère ce qui implique la matrice 00059 // inverse d'ou phi devient -phi 00060 // nous avons cos -phi = cos phi 00061 // sin -phi = -sin phi 00062 // |sinphi cosphi 0 0| 00063 // |-cosphi sinphi 0 0| 00064 // B = | 0 0 1 0| 00065 // | 0 0 0 1| 00066 // 00067 mat.setIdentity(); 00068 mat.setRotateZ(sinphi, 00069 cosphi); 00070 _perspective.multiplyByMatrix(mat); 00071 00072 // Etape 3. Rotation positive autour de l'axe X1 de PI/2+theta 00073 // nous avons cos PI/2+theta = -sin theta 00074 // sin PI/2+theta = cos theta 00075 // or nous effectuons un changement de repère ce qui implique la matrice 00076 // inverse d'ou phi devient -theta 00077 // nous avons cos -theta = cos theta 00078 // sin -theta = -sin theta 00079 // | 1 0 0 0| 00080 // | 0 -sintheta -costheta 0| 00081 // B = | 0 costheta -sintheta 0| 00082 // | 0 0 0 1| 00083 // 00084 mat.setIdentity(); 00085 mat.setRotateX(-sintheta, 00086 -costheta ); 00087 _perspective.multiplyByMatrix(mat); 00088 00089 // Etape 4. Changement de sens d'axe X. repère direct. 00090 mat.setIdentity(); 00091 mat.xx = -1.0f; 00092 00093 _perspective.multiplyByMatrix(mat); 00094 00095 // Etape 5. Rotation du spin. 00096 realtype spin = ((realtype)(M_PI) / 180.0f)* _spin, 00097 cosspin = (realtype)cos( spin ), 00098 sinspin = (realtype)sin( spin ); 00099 00100 mat.setIdentity(); 00101 mat.setRotateZ(cosspin, -sinspin); 00102 00103 _perspective.multiplyByMatrix(mat); 00104 00105 // Etape 6. Normalisation et projection perspective à un point de fuite. 00106 mat.setIdentity(); 00107 realtype ouverture = (realtype)(M_PI / 180.0f)* _ouverture, 00108 halfsizeprojy = (realtype)tan(ouverture)* D, 00109 halfsizeprojx = halfsizeprojy*( _fenetre._halfsize.x/ 00110 _fenetre._halfsize.y); 00111 00112 // 6a - Normalisation xy 00113 mat.xx = 1.0f/halfsizeprojx; 00114 mat.yy = 1.0f/halfsizeprojy; 00115 00116 // 6b - perspective Z. 00117 mat.zw = 1.0f / D; 00118 00119 _perspective.multiplyByMatrix(mat); 00120 } |
|
|
|
Definition at line 162 of file Object3d.cpp. 00163 { 00164 if (!_dans ) return; 00165 _dans->VisualisationFilaire( dc, (RCapteurVisuel3D)*this ); 00166 } |
|
Definition at line 93 of file Object3d.hpp. |
|
Definition at line 92 of file Object3d.hpp. |
|
Definition at line 89 of file Object3d.hpp. |
|
Definition at line 94 of file Object3d.hpp. |
|
Definition at line 89 of file Object3d.hpp. |
|
Definition at line 89 of file Object3d.hpp. |