Results 1 to 2 of 2

Thread: D3DX, rotating object on both z and y axis?

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2003
    Posts
    56

    D3DX, rotating object on both z and y axis?

    Hey I'm trying to spin my object on both y and z axis.

    Like I don't care what axis i am rotating my object, im just trying to rotate 2 axis's at a time.

    this is the code that rotates on a z axis.
    D3DXMATRIXA16 matWorld;
    D3DXMatrixRotationZ( &matWorld, fAngle );
    g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );

    But how do i get it to rotate on both z and y, i tried the code below but it only rotates on the x axis.
    D3DXMATRIXA16 matWorld;
    D3DXMatrixRotationZ( &matWorld, fAngle );
    D3DXMatrixRotationX( &matWorld, fAngle );
    g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );

    Whats wrong?
    i just realised i spelt my name wrong....

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    The Rotation function builds a rotation matrix, overriding whatever is in the matrix at the moment. So:
    Code:
    D3DXMATRIXA16 matWorld, temp;
    D3DXMatrixRotationZ( &matWorld, fAngle );
    D3DXMatrixRotationX( &temp, fAngle );
    D3DXMatrixMultiply(&matWorld, &matWorld, &temp);
    g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

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



Click Here to Expand Forum to Full Width