OpenGL Camera almost done

BlitzMax Forums/OpenGL Module/OpenGL Camera almost done

Chroma(Posted 2005) [#1]
Finally got a decent camera ported over. The only real problem I'm having is the orientation. I set the initial camera y position to 5 and it puts it at -5 in the world.

Can you guys check this out and see why the Y axis is inverted. Btw, the vector.bmx is below in it's own codebox.

The problem may lie here:
cam.ViewDir.Set(0.0, 0.0, 1.0)
cam.UpVector.Set(0.0, 1.0, 0.0)
cam.RightVector.Set(1.0, 0.0, 0.0)

The z component of ViewDir was originally set to -1 and that made positioning the camera on the z axis be in reverse. Soon as I get the bugs worked out I'll put this in the archives.

Controls: Arrow Keys to move and strafe - Mouse to look around.

Camera.bmx


Vector.bmx



Chroma(Posted 2005) [#2]
Just found out that the z axis is backwards in opengl so what I had originally was right all along:

cam.Position.Set(0.0, 0.0, 0.0)
cam.ViewDir.Set(0.0, 0.0, -1.0)
cam.UpVector.Set(0.0, 1.0, 0.0)
cam.RightVector.Set(1.0, 0.0, 0.0)



N(Posted 2005) [#3]
Nice of you to say 'thank you.' -_-


Chroma(Posted 2005) [#4]
Thanks for letting me know the z axis is backwards in opengl.


Chris C(Posted 2005) [#5]
I've noticed that when you move the mouse in a circle you appear to be rotating on the z axis, but rotatedz is zero

Can anyone explain whats going on?


Chroma(Posted 2005) [#6]
Sure, the cam.rotatez() command is basically like saying a=a+1. It's not actually setting the z rotation to 0 but just adding 0 to the existing value.

I'm trying to come up with a way to imitate the EntityRotate command but with no success so far. =( I don't really care to implement quats at this point so there still has to be a way to do it in it's current incarnation.


Chris C(Posted 2005) [#7]
think you are misunderstanding me.
move the mouse in a circle a few times you get a z rotation rotateedz is still 0


Chroma(Posted 2005) [#8]
Yep...I just saw that and was on my way back here to post it.

Something coming from x and y somehow...

The thing is...I know someone on here knows what's going on...it just takes longer these days for someone to see posts and reply because it seems the boards are less traveled these days. =\


Chris C(Posted 2005) [#9]
:) I'm fairly sure on of the view vectors is getting messed up, I'm not too sure you can combine those vector rotations X then Y then Z like you're doing, I think you need to do them together in one XYZ calculation.


JoshK(Posted 2005) [#10]
Hey hey, I believe I sent you some source code.


Chroma(Posted 2005) [#11]
Yep you did and thanks much but I haven't taken a peek at it yet. I'll do that now and see if it helps.


Chroma(Posted 2005) [#12]
I'm not too sure you can combine those vector rotations X then Y then Z like you're doing, I think you need to do them together in one XYZ calculation


If you could post a modification that'd be great. =)


Chris C(Posted 2005) [#13]
I had a quick play, but the origional C code suffers the same "feature", I'll take a look at the later after some sleep...


Chris C(Posted 2005) [#14]
found some code that uses quats (no nasty glulook at vectors :D ) to do local camera rotations

but that too has the same "feature" rotate the mouse
and you end up with a local z axis rotation too...

so I really dont understand whats going on if anyone could explain I'd be most greatful

heres the code for what its worth:



Chroma(Posted 2005) [#15]
Got your email Chris. That's a bad feature imo. We need a way to be able to set the z rot to 0. Kinda hard to do though when you're getting z rotation from x and y but it's not showing up on the z parameters. =(


Chris C(Posted 2005) [#16]
nah lol, its my bad! see the "small demo" topic, its a genuine effect of a rotation on two axes...


Chroma(Posted 2005) [#17]
Yeah but we still have to find a way to reset it to 0 on the z-axis...


Chris C(Posted 2005) [#18]
its not rotated on the z axis, it just looks like it is
LOCALLY there is no z axis rotation.

I *think* thats whats going on, blitz3d behaves in the same way anyhow

if you have blitz3d try this



Dubious Drewski(Posted 2005) [#19]
Can you guys tell me if this solves anything?