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.
- Imagine you have rotated the model with the mouse to some arbitrary position.
- You then press the XY view button and the model moves to the XY view.
- 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