The last three arguments to gluLookAt specify the camera's up vector. Alter this to roll the viewpoint.For example, assume that your camera is at (0,0,0), and is looking at something at (0,0,1). When the camera is upright, the up vector is (0,1,0). With a 90 degree roll to the left, the up vector will be (-1,0,0)

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at com.google.sites.lvgeeks.deepthought.utils.opengl.bettercam.VectorUtils.Vector3Multiplication(VectorUtils.java:38) at com.google.sites.lvgeeks.deepthought.utils.opengl.bettercam.CamBackEnd.rotateX(CamBackEnd.java:49) at com.google.sites.lvgeeks.deepthought.utils.opengl.bettercam.Awesomecam.look(Awesomecam.java:23) at engine.player.setview(player.java:52) at engine.WebWolf3d.display(WebWolf3d.java:163) at com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:78) at javax.media.opengl.GLCanvas$DisplayAction.run(GLCanvas.java:435) at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:194) at javax.media.opengl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:412) at javax.media.opengl.GLCanvas.display(GLCanvas.java:244) at javax.media.opengl.GLCanvas.paint(GLCanvas.java:277) at javax.media.opengl.GLCanvas.update(GLCanvas.java:354) at sun.awt.RepaintArea.updateComponent(RepaintArea.java:239) at sun.awt.RepaintArea.paint(RepaintArea.java:216) at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:301) at java.awt.Component.dispatchEventImpl(Component.java:4486) at java.awt.Component.dispatchEvent(Component.java:4240) at java.awt.EventQueue.dispatchEvent(EventQueue.java:599) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160) at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

Ur camera says: viewDir = viewDir.getNormal();But the values of viewDir are:X=0Y=0Z=0Now u look for the lenght of this vector, the lenght is 0.So the method give u Null.So your vector becomes Null.Anyway, viewDir sounds like an direction, put in a direction or you will get a crappy view

Quaternions are not enough. Sorry, it is not the title of the next James Bond Quaternions + non-eulerian transforms solve this problem. Quaternions + eulerian transforms don't solve this problem. I wrote a very long report about that in French in 2006.

Quaternions are not enough. Sorry, it is not the title of the next James Bond Quaternions + non-eulerian transforms solve this problem. Quaternions + eulerian transforms don't solve this problem. I wrote a very long report about that in French in 2006.

ok no exceptions, but the camera's staring in some random direction. how do i get it to look straight ahead at first like that trig cam i first had? failing that, does jmonkey or xith3d have a good camera class i can rip off?

The current rotations must respect the previous rotations to avoid gimbal lock to prevent any alignment of rotation axis which causes this problem. This problem doesn't depend on the mathematical way you choose to express rotations, it depends on the way to combine rotations. The problem comes from Euler's classical transform: R=Rx.Ry.Rz

Implicitely or explicitly you use it with matrices, quaternions, Euler or Cardan angles, ...

You should correct this transform and it works whatever you used to express your rotations:

R=R[R[R[Ox,a]Oy,b]R[Ox,a]Oz,c] . R[R[Ox,a]Oy,b] .R[Ox,a]

As far as I know, you want to use yaw, pitch and roll therefore you need to use this.

Nice try. Maybe you could remove the call to glRotatef and turn the up vector passed to gluLookAt (by using sine and cosine). You don't use the roll to compute lookx, looky and lookz, you won't have any gimbal lock with this piece of source code.

However, your up vector is wrong. When I look at something above me, my up vector isn't (0,1,0). The up vector depends on yaw, pitch and roll. Then, as you combine 3 rotations, there is a risk of gimbal lock and you should use the formula that I suggested in order to compute this vector correctly.

No, it works only when yaw = 0 and pitch = 0, otherwise the up vector is wrong. It's obvious, you don't use yaw and pitch to compute your up vector (or you have forgotten to copy/paste a piece of source code doing it). You already use yaw and pitch to compute the eye point and the reference point; if you don't want to use my formula but you want a correct result, use at least the yaw or the pitch to compute the up vector (so that you take into account the 3 rotations but not altogether in order to avoid the gimbal lock).

I have forgotten something. The following conventions are used in several 3D engines including Ardor3D:- the Euler yaw of rotation is called Bank, (rotation around x)- the Euler roll of rotation is called Heading (rotation around y)- the Euler pitch of rotation is called Attitude (rotation around z)With these definitions, the pitch (you called this the roll) is useless to compute the reference point and the roll is useless to compute the up vector.Maybe do this but with the convention used above:

I think the problem here is that beginners don't understand nor experience the problem. My advise would simply be to ignore the problem. Quaternions are a 'big thing' which require some motivation to dig into. As long as it works, it will seem like a lot of unnecessary complex math with exactly the same end result as one has now.

Sooner or later, with nested rotations, the problem will become obvious, and the developer will actually want to invest the time to fix it.

A nice start would be to try to see how lookAt works, and how the rotations are calculated. Once you understand what happens underneath, you can see how to integrate that '-roll rotation over the Z axis' into the equation.

Hi, appreciate more people! Σ ♥ = ¾Learn how to award medals... and work your way up the social rankings!

I think the problem here is that beginners don't understand nor experience the problem. My advise would simply be to ignore the problem. Quaternions are a 'big thing' which require some motivation to dig into. As long as it works, it will seem like a lot of unnecessary complex math with exactly the same end result as one has now.

That's why I suggested him a simpler solution using almost the same source code.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org