Results 1 to 4 of 4

Thread: Sorry but its another Local/Global rotation question

  1. #1
    Member Newbie
    Join Date
    Mar 2005
    Posts
    47

    Sorry but its another Local/Global rotation question

    Hi guys

    I have created an app that reads in Finite Element models (3 - 4 sided polys)

    So far its taken a couple of days to get it crudely working and I am loving this OGL stuff

    I have spent most of today on this forum looking for past posts on 3D rotation and local/global axes....

    So far my app rotates pretty well about the 3 global axes using glRotatef (I am using different mouse buttons to split the X Y and Z)

    Now my question.....

    The model rotates about its own axis system (global or whatever you wish to call it) ... fine I need to do this But....

    I also want to rotate about the screen X, Y and Z - in fact I want this to be my default rotation as its more intuitive and like other 3D apps I use

    To be clear - Imagine the screen as a 2D plane with X horizontal, Y vertical and Z out the screen - Thats the rotation axes I want

    I could do with a few pointers on what to research. The OGL Superbible is going home with me tonight.

    Is there a simple way to rotate about the screen or is it a 'transformation job - digging out my oooold Uni text books?'

    Many thanks for your time.

    Julian

  2. #2
    Guest

    Re: Sorry but its another Local/Global rotation question

    All transformations transform the coordinate system so once you transform you change the axes.

    That is, when you do glRotatef (90, 0, 1, 0), your initial x-axis and z-axis become z-axis (-ve) and x-axis (-ve) respectively. The initial y-axis stays put.

    I feel your pain cos I want to do that myself many times but this is the way OGL works.

  3. #3
    Guest

    Re: Sorry but its another Local/Global rotation question

    To be clear - Imagine the screen as a 2D plane with X horizontal, Y vertical and Z out the screen - Thats the rotation axes I want
    that's eye space. in opengl the eye is looking down the negative zaxis with the positive xaxis to the right and the positive yaxis going up.

    these 3 vectors form a right handed coordinate system for the eye.

    transforming points or vectors in eye space is no different than transforming points and vectors in any other space. its just another matrix as far as opengl is concerned.

    you could supply opengl the eye vectors yourself. each eye_* represents the desired oientation of each axis. how you define these axes is arbitrary. all you are doing is giving opengl the desired orientation of your coordinate system (rotation matrix).

    vec3 x = eye_right;
    vec3 y = eye_up;
    vec3 z = -eye_forward;
    float eye_rotation[16] = {
    x.x, x.y, x.z, 0,
    y.x, y.y, y.z, 0,
    z.x, z.y, z.z, 0,
    0, 0, 0, 1
    };
    glMultMatrixf(eye_rotation);

    consider that opengl matrices are column major, which means that points are premultiplied (multiplied on the left) for rotation, contrary to what you see in most texts, hence the eye axes are in the rows rather than the columns.

    rotation matrices are a lot easier to understand when you realize that they are nothing more than oriented coordinate systems. all you need to do is supply opengl with the desired orientation, either directly, or with glRotate commands, which do nothing more than create a matrix for you and multiply it onto the matrix stack.

  4. #4
    Member Newbie
    Join Date
    Mar 2005
    Posts
    47

    Re: Sorry but its another Local/Global rotation question

    Just thought I would feed back in case anyone else has similar problems.

    My 3D rotation issue was solved by lots of research into quaternions etc...

    The best thing I came up with is rotation using Ken Shoemake's code

    Here is a good place to start...

    www.psychology.nottingham.ac.uk/staff/cr1/3d.html

    or try google using - arc ball Ken Shoemake etc

    Julian

Similar Threads

  1. Replies: 1
    Last Post: 03-28-2018, 09:34 PM
  2. global & local size in 2D problem
    By pelliegia in forum OpenCL
    Replies: 2
    Last Post: 10-20-2012, 04:09 PM
  3. Regarding async_work_group_copy(global to local)
    By bharath.s.jois in forum OpenCL
    Replies: 28
    Last Post: 05-20-2011, 01:16 AM
  4. Local and global coordinate system
    By in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 10-12-2002, 07:10 PM
  5. Local and global axis
    By Simon Hall in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-26-2000, 06:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean