Results 1 to 4 of 4

Thread: Camera control in DirectX 9 - Need help

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

    Camera control in DirectX 9 - Need help

    Hi there,

    Im trying to rotate my camera (yaw, pitch and roll). I found this code snippet in the internet somewhere:
    Code:
       // Genenerate a quaternion, using only the yaw from the player
       D3DXQuaternionRotationYawPitchRoll( &quat, cameraRotationYaw, 0.0f, 0.0f );
    
       // Now build the matrix
       D3DXMatrixAffineTransformation( &matOrientation, 1.25f, NULL, &quat, &cameraPosition );
    
       // We must take the inverse to get the appropriate transformation
       D3DXMatrixInverse( &matView, NULL, &matOrientation );
    I translated it to
    [pascal]
    D3DXQuaternionRotationYawPitchRoll(Quat, Rotation.x, Rotation.y, Rotation.z);
    D3DXMatrixAffineTransformation(matPos, 1.0, nil, Quat, Position);
    D3DXMatrixInverse( matView, nil, matPos );
    [/pascal]


    When I translate it te delphi I got an compiler error:
    Incompatible types 'TD3DXQuarternion' and 'PD3DXQuarternion'

    can anyone tell me how I translate TD3DXQuarternion to PD3DXQuarternion


    (error is given on the Quat, witch is a TD3DXQuarternion in D3DXQuaternionRotationYawPitchRoll, and D3DXMatrixAffineTransformation needs a PD3DXQuarternion)

    Could anyone help me with this ? Plzkthx
    NecroSOFT - End of line -

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

    Camera control in DirectX 9 - Need help

    The solution the this problem is

    [pascal]
    D3DXQuaternionRotationYawPitchRoll(Quat, Rotation.x, Rotation.y, Rotation.z);
    D3DXMatrixRotationQuaternion( matRot, Quat );
    D3DXMatrixTranslation(matPos, Position.X, Position.Y, Position.Z);

    D3DXMatrixMultiply(matView, matRot, matPos);

    D3DXMatrixInverse( matView, nil, matView );

    Device.SetTransform(D3DTS_VIEW, matView);
    [/pascal]
    NecroSOFT - End of line -

  3. #3

    Camera control in DirectX 9 - Need help

    I must have missed your original post, for it would have been a really easy answer. In the call to D3DXMatrixAffineTransformation, use the address-of operator by changing Quat to @Quat. This changes a TD3DXQuaternion to a PD3DXQuaternion.

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

    Camera control in DirectX 9 - Need help

    thnx
    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
  •