Thread: local axis

  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    46

    rotation issue

    I'm building a cube using other smaller cubes and its being constructed like this:

    a = world axis
    c = cube

    a c c
    c c c
    c c c

    Now I would like to move the axis to the center like this:

    c c c
    c a c
    c c c

    Currently my code looks like this:

    Code:
    glTranslate(0,0,-20);
    glRotatef(rot,0,1,0);
    for (int i = 0; i < 3; i++)
    {
       ... 2 more for's
       glPushMatrix();
        glTranslatef(...);
        drawCube();
      glPopMatrix();
    }
    How can I change the world axis to the center of cube?
    Last edited by sugarfree; 04-25-2010 at 11:31 PM.

  2. #2
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    So you have like 9 small cubes inside one big one? In that case you would subtract of all coordinates. If L is the length of a cube you would do like (x-L, y-L, z-L) for every cube that has coordinates (x,y,z), counting lets say from the top-right-deep corner.

    But it depends on what you mean transfer the center. What is your intention?

  3. #3
    Registered User
    Join Date
    Oct 2009
    Posts
    46
    What I would like is to rotate the cube[around its center] and not the world axis.
    Last edited by sugarfree; 04-26-2010 at 12:12 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Local and Roaming Profiles
    By BobS0327 in forum Tech Board
    Replies: 6
    Last Post: 01-20-2008, 09:03 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. AXIS and C++
    By bman1176 in forum C++ Programming
    Replies: 0
    Last Post: 03-29-2006, 11:00 AM
  4. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 398
    Last Post: 10-11-2005, 08:44 AM
  5. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM