Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Rookie rotation issue?

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

    Rookie rotation issue?

    Ok this is probably a rookie mistake caused by my ignorance, but if anyone could spot the mistake I would be most grateful

    This is what is happening in my app....

    The user uses the LHM button to dynamically rotate/pan/zoom.
    I use a class based on Ken Schomakers Arc ball. This basically returns a matrix ---- mNow

    This works fine.

    However I would like to put a few buttons in my app for standard views XY, YZ etc

    I have done this like so --- Press a button and do,,,,
    glLoadIdentity
    glRotatef 180, 0, 1, 0

    Also fine...

    Now the problem/issue.

    1. Imagine you have rotated the model with the mouse to some arbitrary position.
    2. You then press the XY view button and the model moves to the XY view.
    3. You now wish to rotate the model again via the mouse.

    You (the user) would expect the model to rotate from an XY start position (position 2)

    What happens is that as soon as you click the mouse in the graphics region the model 'flicks' back to its position at 1 above and does not start from the XY position. It just looks wrong.

    Its driving me nuts...

    I suspect its some sort of matrix stack thing but I don't know really...

    The code (editited to remove stuff not relevant??) is below

    Can anyone spot the mistake?

    Thanks guys

    Julian

    (edit - the code indentations have gone - sorry)
    ================================================== ==============================
    Public Sub Draw()
    'This is where all the action takes place
    'All the OGL rendering is done here

    Dim mNow!(0 To 15), radius!

    Ball.GetValue mNow

    'This parameter sets the scale for the view based on the Ball Rad
    'This is used as a zoom
    radius = Ball.radius * sngZoomFactor

    glPushMatrix
    glMultMatrixf mNow(0)

    glScalef radius, radius, radius

    Select Case gintView
    Case 0
    Case 1 '1=XY Top
    glLoadIdentity
    Case 2 '2=XY Bottom
    glLoadIdentity
    glRotatef 180, 0, 1, 0
    Case 3 '3=XZ Front
    glLoadIdentity
    glRotatef 90, 1, 0, 0
    Case 4 '4=XZ Back
    glLoadIdentity
    glRotatef -90, 1, 0, 0
    Case 5 '5=YZ Left
    glLoadIdentity
    glRotatef 90, 0, 1, 0
    Case 6 '6=YZ Right
    glLoadIdentity
    glRotatef -90, 0, 1, 0
    Case 7 '7=ISO
    glLoadIdentity
    glRotatef 45, 0, 1, 0
    glRotatef 10, 1, 0, 0
    Case Else
    End Select

    ==================================
    THE OGL DISPLAY LIST STUFF IS HERE
    ==================================

    glPopMatrix

    End Sub

  2. #2
    Intern Newbie
    Join Date
    Mar 2005
    Posts
    47

    Re: Rookie rotation issue?

    Thinking about it...

    Is it a case that mNow is set at some arbitrary rotation/view and isn't being set to the XY view matrix when I press the button?

    Edit Hmmmm just tried this crude load of mNow

    glLoadIdentity
    mNow(0) = 1
    mNow(1) = 0
    mNow(2) = 0
    mNow(3) = 0
    mNow(4) = 0
    mNow(5) = 1
    mNow(6) = 0
    mNow(7) = 0
    mNow(8) = 0
    mNow(9) = 0
    mNow(10) = 1
    mNow(11) = 0
    mNow(12) = 0
    mNow(13) = 0
    mNow(14) = 0
    mNow(15) = 1

    Same problem.

    When I comment out the glLoadIdentity line the model doesn't move back (the problem)... However, it doesn't seem to do anything... It doesnt move at all!

    I bet this is a really simple/daft one :-)

Posting Permissions

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