Thread: Rotating a Cube

  1. #1
    Registered User
    Join Date
    May 2010

    Rotating a Cube

    Okay, just a quick question here.

    I'm working through a directx tutorial and I now know that you can make a rotating cube with this

        // set the world transform
        static float index = 0.0f; index+=0.03f;
    	D3DXMATRIX matRotateY;
    	D3DXMatrixRotationY(&matRotateY, index);
    	d3ddev->SetTransform(D3DTS_WORLD, &(matRotateY));
    And I've been tinkering with it, trying to make it rotate in two directions at once. Unfortunately there's no such function as D3DXMatrixRotationXY. No, that would be too easy. So what is the correct one? I tried putting a second rotation function after the first but the compiler only used the last one. I tried couching one inside the other like so:

    D3DXMatrixRotationX(D3DXMatrixRotationY(&matRotateY, index)),index2);
    No luck there either. But oddly enough that didn't give me any errors. Do I use D3DMatrixRotationAxis? I looked that up on the MSDN site but the syntax seemed confusing. Anyway, I appreciate any suggestions.

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001

    Note that this suffers from gimbal lock.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C Help. square and cube a user inputed number
    By Beedee5889 in forum C Programming
    Replies: 5
    Last Post: 03-11-2010, 01:53 PM
  2. 2d Cubik program in C
    By joot43 in forum C Programming
    Replies: 4
    Last Post: 05-25-2009, 07:17 AM
  3. Cube rotation math problem
    By n3v in forum Game Programming
    Replies: 6
    Last Post: 08-03-2007, 05:41 AM
  4. Rubix Cube Contest
    By The Brain in forum Contests Board
    Replies: 24
    Last Post: 01-15-2005, 05:33 PM
  5. rotating a cube around origin
    By ichijoji in forum Game Programming
    Replies: 1
    Last Post: 02-06-2003, 07:37 PM