Camera autotracking problem

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
r4
Gnoblar
Posts: 19
Joined: Mon Jan 24, 2005 12:02 pm

Camera autotracking problem

Post by r4 »

Hi guys,

I'm creating an application for academic purpose. It consists in an object positioned in the center of the scene (0,0,0) and then I generate the points of the bounding sphere of this object. Then I must to go through all this points and do some calculations allways looking at the center of the object.

To do that I'm using the setAutoTracking method from the camera class, so I only have to change the camera position because it is allways looking to the target object. But my problems appears at the top of the sphere. When the camera has to look towards negative Y axis it looks to another direction. That's strange because it is the only point where it happens. And the most strange thing is the fact that updating the direction of the camera manually using lookAt method (camera looks to (0,0,0) ) doesn't seem to work too.

Some ideas are welcome :?:

Thanks in advance!!! :D
User avatar
SuprChikn
Bugbear
Posts: 863
Joined: Tue Apr 19, 2005 6:10 am
Location: Melbourne, Aus
Contact:

Post by SuprChikn »

I've seen mention of this issue before, and from memory it has to do with using a fixed-yaw camera setup.

I think it works something like this:
Basically, the camera is always trying to have it's local up vector be as close as possible to world up (+Y).
When you're looking directly along the Y vector, there are an infinate number of possible yaw orientations that the camera can take, and none of them is better than any other using the normal criteria.

Have a read of the API, or search the forums for more info.

[edit] Have a read of this and this. [/edit]

PS. w00t, I'm now a veteran of these forums :)
User avatar
Kencho
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4011
Joined: Fri Sep 19, 2003 6:28 pm
Location: Burgos, Spain
x 2
Contact:

Post by Kencho »

Yep, that's the problem. You will have that issue when you try to look in a direction parallel to the up vector (usually in the direction of Y or -Y).

This is an idea I have that I haven't tried yet, but might work. When you're going to look in the same direction of your up vector, change temporally your up vector to X * CameraYawQuaternion, so it follows the natural camera movement, but you avoid that artifact.
As I said before, I haven't tried, but should work...
Image
Post Reply