Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
void harvesterXMesh::rotateAtPoint(D3DXVECTOR3 vRotate) { this->fRotX += vRotate.x; // Rotation this->fRotY += vRotate.y; // Rotation this->fRotZ += vRotate.z; // Rotation D3DXMATRIX mRotX; // Rotationsmatrix X-Achse D3DXMATRIX mRotY; // Rotationsmatrix Y-Achse D3DXMATRIX mRotZ; // Rotationsmatrix Z-Achse D3DXMATRIX mTranslate; // Translationsmatrix D3DXMATRIX mTranslate1; // Translationsmatrix float fx = 0; float fy = 0; float fz = 0; if (this->fPosX >= 0) fx = -this->fPosX; else fx = this->fPosX; if (this->fPosY >= 0) fy = -this->fPosY; else fy = this->fPosY; if (this->fPosZ >= 0) fz = -this->fPosZ; else fz = this->fPosZ; // Translationsmatrix erstellen D3DXMatrixTranslation(&mTranslate, fx, fy, fz); // verschieben des Modells // Rotationsmatrix X-Achse erstellen D3DXMatrixRotationX(&mRotX,vRotate.x); // Rotationsmatrix Y-Achse erstellen D3DXMatrixRotationY(&mRotY,vRotate.y); // Rotationsmatrix Z-Achse erstellen D3DXMatrixRotationZ(&mRotZ,vRotate.z); if (vRotate.x != 0 || vRotate.y != 0 || vRotate.z != 0) { // Rotationsmatrix X-Achse mit MeshMatrix multiplizieren D3DXMatrixMultiply(&mTranslate,&mTranslate,&mRotX); // Rotationsmatrix Y-Achse mit MeshMatrix multiplizieren D3DXMatrixMultiply(&mTranslate,&mTranslate,&mRotY); // Rotationsmatrix Z-Achse mit MeshMatrix multiplizieren D3DXMatrixMultiply(&mTranslate,&mTranslate,&mRotZ); } // Translationsmatrix erstellen D3DXMatrixTranslation(&mTranslate1, -fx, -fy, -fz); D3DXMatrixMultiply(&mTranslate,&mTranslate,&mTranslate1); D3DXMatrixMultiply(&mMeshMatrix,&mMeshMatrix,&mTranslate); } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
void harvesterXMesh::rotateAtPoint(D3DXVECTOR3 vRotate) { this->fRotX += vRotate.x; // Rotation this->fRotY += vRotate.y; // Rotation this->fRotZ += vRotate.z; // Rotation D3DXMATRIX mRotX; // Rotationsmatrix X-Achse D3DXMATRIX mRotY; // Rotationsmatrix Y-Achse D3DXMATRIX mRotZ; // Rotationsmatrix Z-Achse D3DXMATRIX mTranslate; // Translationsmatrix D3DXMATRIX mTranslate1; // Translationsmatrix float fx = 0; float fy = 0; float fz = 0; if (this->fPosX >= 0) fx = -this->fPosX; else fx = this->fPosX; if (this->fPosY >= 0) fy = -this->fPosY; else fy = this->fPosY; if (this->fPosZ >= 0) fz = -this->fPosZ; else fz = this->fPosZ; // Translationsmatrix erstellen D3DXMatrixTranslation(&mTranslate, fx, fy, fz); // verschieben des Modells zum Koordinatenursprung // Rotationsmatrix X-Achse erstellen D3DXMatrixRotationX(&mRotX,vRotate.x); // Rotationsmatrix Y-Achse erstellen D3DXMatrixRotationY(&mRotY,vRotate.y); // Rotationsmatrix Z-Achse erstellen D3DXMatrixRotationZ(&mRotZ,vRotate.z); if (vRotate.x != 0 || vRotate.y != 0 || vRotate.z != 0) { // Rotationsmatrix X-Achse mit MeshMatrix multiplizieren D3DXMatrixMultiply(&mTranslate,&mTranslate,&mRotX); // Rotationsmatrix Y-Achse mit MeshMatrix multiplizieren D3DXMatrixMultiply(&mTranslate,&mTranslate,&mRotY); // Rotationsmatrix Z-Achse mit MeshMatrix multiplizieren D3DXMatrixMultiply(&mTranslate,&mTranslate,&mRotZ); } // Transformationmatrix = TranslationsmatrixDesRadius * Rotationsmatrix * TranslationsmatrixImWeltKoordSystem // Translationsmatrix erstellen D3DXMatrixTranslation(&mTranslate1, -fx, -fy, -fz); // das Objekt wieder zurueckschieben D3DXMatrixMultiply(&mTranslate,&mTranslate1,&mTranslate); D3DXMatrixMultiply(&mMeshMatrix,&mTranslate,&mMeshMatrix); // die resultierende Transformationsmatrix } |
Werbeanzeige