Du bist nicht angemeldet.

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

soxx

Frischling

  • »soxx« ist der Autor dieses Themas

Beiträge: 53

Wohnort: Klagenfurt

  • Private Nachricht senden

1

07.03.2006, 08:25

rotationsachse eines objektes verschieben

Hallo.

es klingt zwar blöd aber nun ja...
wie kann man die rotationsachse eines objektes verändern ?
es wird doch immer um den Koordinatenursprung gedreht (0,0,0)
nun ist aber mein objekt auf (0.25,0,0) positioniert - ich müsste es also um 0.25 rotieren lassen- wie stelle ich das am besten an ?

PS: habe keine forumseinträge dazu gefunden.

mfg
soxx

Nox

Supermoderator

Beiträge: 5 272

Beruf: Student

  • Private Nachricht senden

2

07.03.2006, 08:37

Also wenn du das Objekt um den Punkt rotieren lassen willst dann rechnest du Translations- x Rotations- Matrix.
PRO Lernkurs "Wie benutze ich eine Doku richtig"!
CONTRA lasst mal die anderen machen!
networklibbenc - Netzwerklibs im Vergleich | syncsys - Netzwerk lib (MMO-ready) | Schleichfahrt Remake | Firegalaxy | Sammelsurium rund um FPGA&Co.

soxx

Frischling

  • »soxx« ist der Autor dieses Themas

Beiträge: 53

Wohnort: Klagenfurt

  • Private Nachricht senden

3

07.03.2006, 10:56

Meinst du das etwa so ?

- entfernung von dem punkt zum mittelpunkt ausrechnen
- dann verschiebt man das Models um diese entfernung
- dreht das modell
- und schiebt es dann zurück


wie berechne ich diese entfernung ??
ich habe eine D3DXMATRIX <- Weltmatrix
und ich weiß wo der mittelpunkt ist (0,0,0) 8)

nur wie kann ich nur die entfernung ausrechnen ?

mfg
soxx

soxx

Frischling

  • »soxx« ist der Autor dieses Themas

Beiträge: 53

Wohnort: Klagenfurt

  • Private Nachricht senden

4

07.03.2006, 15:14

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);
}


ich habe nicht viel erfahrung... aber könnte sowas hinkommen - es funktioniert fast[/code]

Black-Panther

Alter Hase

Beiträge: 1 443

Wohnort: Innsbruck

  • Private Nachricht senden

5

07.03.2006, 15:21

Also:

Du schiebst das ganze um genau den Radius den du für die Rotation brauchst nach rechts (+x). Wieso +x --> Weil dann die x-Achse deine 0°-Marke ist! (Wie in der Mathematik). Wenn du das getan hast, rotierst du das ganze, wie dus brauchst, und verschiebst es dann noch dorhin wo dus haben willst:

Transformationmatrix = TranslationsmatrixDesRadius * Rotationsmatrix * TranslationsmatrixImWeltKoordSystem
stillalive studios
Drone Swarm (32.000 Dronen gleichzeitig steuern!)
facebook, twitter

soxx

Frischling

  • »soxx« ist der Autor dieses Themas

Beiträge: 53

Wohnort: Klagenfurt

  • Private Nachricht senden

6

07.03.2006, 15:32

man verzeihe mit meine anflug von unwissen :) aber wie komme ich auf den radius ?

ich habe mit fx, fy und fz die entfernung zu der 0-achse (0,0,0).

mit dem oben gezeigten code, rotiert das teil um sich selbst und um den mittelpunkt (0,0,0) ?????

mfg
soxx

Black-Panther

Alter Hase

Beiträge: 1 443

Wohnort: Innsbruck

  • Private Nachricht senden

7

07.03.2006, 15:42

ja dann brauchst du sowieso nur noch eine Translationsmatrix wenn das ganze um (0,0,0) rotieren soll.

Transformationsmatrix = Translationsmatrix(Vector(fx, fy, fz)) * Rotationsmatrix
stillalive studios
Drone Swarm (32.000 Dronen gleichzeitig steuern!)
facebook, twitter

soxx

Frischling

  • »soxx« ist der Autor dieses Themas

Beiträge: 53

Wohnort: Klagenfurt

  • Private Nachricht senden

8

07.03.2006, 15:43

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

}


hat funktioniert.
mfg
soxx

Werbeanzeige