Is this a good OpenGl camera?

BlitzMax Forums/OpenGL Module/Is this a good OpenGl camera?

Dubious Drewski(Posted 2005) [#1]
I've noticed many people having trouble with cameras and perspective in OpenGl, like Chroma and Vertex.
I have been studying OGl furiously for a little while now and I wrote what I believe to be a fully-functional
3d camera that rotates at it's local center (Vertex's problem)and doesn't change it's Z-axis of rotation(Chroma's bug).
[edit] How naive!


Does this program answer anyone's problems? Or am I missing something huge here?




Chris C(Posted 2005) [#2]
alas thats rotating on world axis's not camera local...


Dubious Drewski(Posted 2005) [#3]
Hmm. So what's the difference? As far as I know, there
aren't any ways to make actual cameras in OGL. You have to
move and rotate the world around you. That's not right? :/
This is where I learned that from.


Chris C(Posted 2005) [#4]
basically using your example look upwards and rotate left/right, if the rotations were local to camera you'd rotate in a straight line through the edge's of the screen.
in your sample when looking directly up you are still rotating round the world Y axis
look @ the code I posted here http://www.blitzbasic.com/Community/posts.php?topic=53272
when you look directly up or down and roate left/right the rotation is different
The apparent z axis rotation is actually not a rotation on the z axis but a natural consequence of rotation around local axes, try the blitz3d sample, it behaves in the same way...


Dubious Drewski(Posted 2005) [#5]
Ah, I understand what you mean. But wasn't that undesirable?
You eventually lose which way is 'up' with local rotations like that.
I modified my code a bit, now it allows vertical movement.
Isn't this exactly the kind of movement you'd want to have?
I don't know about you guys, but this is hugely usefull for me! Hehe.



Chris C(Posted 2005) [#6]
if you're just doing somthing where you're walking round on a terrain, or in say a quake type level, world axis rotations are generally fine, even desirable.
However if you want a flight sim or space ship type shooter you have to use local (camera) rotations.
Things get further compilcated with flight sims because you have to simulate the tendency for a plane to self level which involves converting local rotations into world rotations to find out how far off "trim" you are...


eizdealer(Posted 2005) [#7]
Hey guys,
I think my OpenGL / BlitzMax Camera Tutorial should help you and make things clear. It is very well commented code that's as easy as possible. I thought the community was aware of it but it seems I thought wrong.
Well this is the url: http://www.eizdealer.net/#coding
I hope you can use it! Maybe someone should tell the guys in the other thread as well...

Damn I forgot: The code won't work with the new BMax update. I have no idea what has to be changed but it's partially based on BlitzGL. Shouldn't be too much trouble though. I haven't been coding for quite a long time now... no time :(


Chris C(Posted 2005) [#8]
@eizdealer tried using your camera class b4, doesnt seem to be able to do *LOCAL* camera axis rotations...


eizdealer(Posted 2005) [#9]
Chris, did you have AttendLocalMatrix set to True? If so, it's .. ehr .. irritating. It should work. Although I have to admit I haven't tried the rotation using the local matrix.


Chris C(Posted 2005) [#10]
i had a play with it a while ago, tried a number of different things, but couldnt get it to rotate on the camera's axes...

I bodged together some some trackball code which will rotate on local x,y axes, but I'm not entirelly happy with it...
http://www.blitzbasic.com/Community/posts.php?topic=53272
about 1/2 down the thread

If you could have a look at your code and maybe put together a simple demo I'm sure a number of people would appreciate it (not least me!)


eizdealer(Posted 2005) [#11]
Maybe adding
	If KeyDown(KEY_Q)			Then Camera.Turn(        0.0,        0.0,        0.1)
	If KeyDown(KEY_E)			Then Camera.Turn(        0.0,        0.0,       -0.1)
to the controls can help. Actually I have no idea if this works, but I neither have the time to try it nor the time to work on it :(


Chris C(Posted 2005) [#12]
shame - its using global co-ords, still my trakball converted C code is doing me well enough while I wait for the 3d module...