PDA

View Full Version : problems with axis direction



mithun_daa
11-03-2003, 06:57 AM
this, i think is a begginer level problem and so i posted it in the beginers section, but did not get a good respone. hopefully someone over here will help me out.

i m having problems with the direction of my x-axis, it seems to be increasing from right to left. i m using VB6. i have been programming with opengl for 2 yrs now, but i never came across such a prob. this is the first time im using VB with opengl. i have set the camera postion right. iv tried a lot of thingz but i dont know whatz goin wrong. i havent used the "glscalef", so that shouldnt be a prob. plz help.

Andrea Rossini
11-03-2003, 07:13 AM
maybe you are using translation/rotation functions in a loop without save/restore of the initial matrix (PushMatrix PopMatrix).

http://www.opengl.org/discussion_boards/ubb/wink.gif

Rog
11-03-2003, 07:13 AM
Any danger of seeing some code?

mithun_daa
11-03-2003, 07:26 AM
herez some of the code that might help

"setviewport code"

........
wglMakeCurrent mlngPic1hDC, mlngWindowcontext
Pic1.Scale (-100, 100)-(100, -100)
intWidth = Pic1.ScaleWidth
intHeight = Pic1.ScaleHeight
If intHeight = 0 Then
intHeight = 1
End If
glViewport -100, -100, intWidth, intHeight


"setting the projection"

glMatrixMode GL_PROJECTION
glLoadIdentity
glFrustum -100, 100, -100, 100, 10, 210
glMatrixMode GL_MODELVIEW
glLoadIdentity
gluLookAt dblXCam, dblYCam, dblzcam, 0, 0, 100, 0, 1, 0
glShadeModel smSmooth
glEnable glcDepthTest
glEnable (glcBlend)

"rendering function"

glMatrixMode GL_MODELVIEW
glLoadIdentity
glEnable (GL_DEPTH_TEST)
'set back color of map
glClearColor 0, 0, 0, 1
glClear clrColorBufferBit
glClear clrDepthBufferBit
gluLookAt dblXCam, 0, dblzcam, 0, 0, 100, 0, 1, 0
glEnable (glcLighting)
glEnable glcLight0
glEnable glcColorMaterial
glColorMaterial faceFrontAndBack, cmmAmbientAndDiffuse
glPushMatrix
glLineWidth 2
glColor3f 0, 1, 0
glBegin bmLines
glVertex3f -99, -99, 209
glVertex3f -99, 199, 209
glEnd
glColor3f 1, 1, 1
glBegin bmLines
glVertex3f -99, -99, 209
glVertex3f -99, -99, 11
glVertex3f -99, -99, 209
glVertex3f 99, -99, 209
glEnd

...........

Rog
11-03-2003, 07:40 AM
gluLookAt dblXCam, dblYCam, dblzcam, 0, 0, 100, 0, 1, 0

What do you have in dblXCam, dblYCam, dblzcam? Specifically in dblzcam?

mithun_daa
11-03-2003, 08:06 AM
i have 0 as my dblzcam,dblXcam dblYcam



Originally posted by Rog:


gluLookAt dblXCam, dblYCam, dblzcam, 0, 0, 100, 0, 1, 0

What do you have in dblXCam, dblYCam, dblzcam? Specifically in dblzcam?

Adrian
11-03-2003, 08:26 AM
Try,
gluLookAt (dblXCam, dblYCam, dblzcam, 0, 0, -100, 0, 1, 0)

From the spec
"The matrix maps the reference point to the negative z axis"

mithun_daa
11-03-2003, 08:33 AM
nope. that doesnt work.


Originally posted by Adrian:
Try,
gluLookAt (dblXCam, dblYCam, dblzcam, 0, 0, -100, 0, 1, 0)

From the spec
"The matrix maps the reference point to the negative z axis"

mithun_daa
11-03-2003, 08:57 AM
k fine it works,thank u, but this is not how i want it. cause its gonna mess up all my calculations, cause whatz happening now is it is still drawing in the opposite direction if i c it from front. its just cause im looking from the opposite direction and that is why its working right. why do u think this is happening? i think im goin wrong somewhere else. thankz 4 ur help though.


Originally posted by Adrian:
ok how about
gluLookAt (dblXCam, dblYCam, dblzcam, 0, 0, 0, 0, 1, 0)

where dblzcam=100
http://www.opengl.org/discussion_boards/ubb/smile.gif

mithun_daa
11-03-2003, 08:58 AM
i m not using any translation or rotation functions in my project.


Originally posted by Andrea Rossini:
maybe you are using translation/rotation functions in a loop without save/restore of the initial matrix (PushMatrix PopMatrix).

http://www.opengl.org/discussion_boards/ubb/wink.gif

Rog
11-03-2003, 09:07 AM
Originally posted by mithun_daa:
k fine it works,thank u, but this is not how i want it. cause its gonna mess up all my calculations, cause whatz happening now is it is still drawing in the opposite direction if i c it from front. its just cause im looking from the opposite direction and that is why its working right. why do u think this is happening? i think im goin wrong somewhere else. thankz 4 ur help though.

Ok, now I'm suspicous about:


glViewport -100, -100, intWidth, intHeight
The (-100, -100) is supposed to be the viewport origin in Window coordinates. These don't make sense being negative (correct me someone?). Perhaps this is resulting in a matrix that's flipping left/right.

Can you do a glGet to see what the viewport actually is set to?

mithun_daa
11-03-2003, 09:19 AM
the (-100, -100) is the lower left corner of the viewport (according to the red book).


Originally posted by Rog:
The (-100, -100) is supposed to be the viewport origin in Window coordinates. These don't make sense being negative (correct me someone?). Perhaps this is resulting in a matrix that's flipping left/right.

Can you do a glGet to see what the viewport actually is set to?[/B]

Rog
11-03-2003, 09:51 AM
Originally posted by mithun_daa:

the (-100, -100) is the lower left corner of the viewport (according to the red book).

Yep. That's ok (I think). However, if I do this -


Pic1.Scale (-100, 100)-(100, -100)
intWidth = Pic1.ScaleWidth
intHeight = Pic1.ScaleHeight

I get intHeight = -200, which is definitely not valid for glViewport. Can you confirm what you get?

mithun_daa
11-03-2003, 10:06 AM
ge, thanx 4 lettin me know that, somewher down the lane im sure it would have created havoc 4 me. but the original problem still persists.


Originally posted by Rog:


Pic1.Scale (-100, 100)-(100, -100)
intWidth = Pic1.ScaleWidth
intHeight = Pic1.ScaleHeight

I get intHeight = -200, which is definitely not valid for glViewport. Can you confirm what you get?

mithun_daa
11-03-2003, 01:47 PM
still doesnt work