Results 1 to 7 of 7

Thread: Get Matrix rotations...

  1. #1
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    Get Matrix rotations...

    Hi,

    [pascal]
    case CameraType of
    cameraFree:
    begin
    D3DXQuaternionRotationYawPitchRoll(Quat, Rotation.x + CameraShake.Rotation.x,
    Rotation.y + CameraShake.Rotation.y,
    Rotation.z + CameraShake.Rotation.z);
    D3DXMatrixRotationQuaternion( matRot, Quat );
    D3DXMatrixTranslation(matPos, Position.X, Position.Y, Position.Z);

    D3DXMatrixMultiply(matView, matRot, matPos);

    D3DXMatrixInverse( matView, nil, matView );

    Screen.Device.SetTransform(D3DTS_VIEW, matView);
    end;
    cameraTarget:
    begin
    D3DXMatrixLookAtLH(matView, Position, TargetPoint, WolrdUp);

    Screen.Device.SetTransform( D3DTS_VIEW, matView );

    // Somewhere here: Rotation := GetRot(matView );
    end;
    end;
    [/pascal]

    This piece of code I use to setup my camera in 3D view. However when I have a cameraTarget, I want to be able to retrieve teh rotation. How can I get the rotation from matView

    I realy need it. I use it to rotate the particles

    Greets Michiel
    NecroSOFT - End of line -

  2. #2

    Get Matrix rotations...

    I had a similar question at GameDev.net, this is the answer:

    http://www.gamedev.net/community/for...asp?ID=2818743

  3. #3
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    Get Matrix rotations...

    It retrieves the position. I need the rotation. I tried the code, but it didn't work in they way I want it...

    btw: is there a way to just make teh camera rotate to a specified point? that rotation I can use to transform teh camera. In that case teh problem is solved.
    NecroSOFT - End of line -

  4. #4

    Get Matrix rotations...

    Think it this way: with D3DXMatrixLookAtLH() you define the camera position (pEye vector) and the objective (pAt vector). Set the objective 1 unit from the eye, and rotate the objective using the eye as pivot.

  5. #5
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    Get Matrix rotations...

    I take a look at that tomorrow... thanks for the advice
    NecroSOFT - End of line -

  6. #6

    Get Matrix rotations...

    I don't know how(and I don't think you can) you can convert the matrix directly to axisangle rotations

    I would just convert the matrix into a quaternion and from that turn it into a rotation vector
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  7. #7
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    Get Matrix rotations...

    I solved the problem:
    [pascal] Rotation.x := -ArcTan2(TargetPoint.z - Position.z, TargetPoint.x - Position.x)+(Pi*0.5);

    x := (TargetPoint.x - Position.x) * (TargetPoint.x - Position.x);
    z := (TargetPoint.z - Position.z) * (TargetPoint.z - Position.z);

    Rotation.y := ArcTan2(Sqrt(x+z), TargetPoint.y - Position.y)-(Pi*0.5);
    Rotation.z := 0;[/pascal]
    NecroSOFT - End of line -

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •