Camera orientation problem

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Paul J
Posts: 8
Joined: Tue May 26, 2009 11:23 pm

Camera orientation problem

Post by Paul J »

Hello, I'm having a problem with irrlicht's camera and I'm hoping somebody can give me a hand. Here is a brief overview of the problem:

I have written (from scratch) a 2d physics engine that considers movement in the x-y plane, and am now attempting to create something using it where the player can move in this plane (i.e. x-y is the 'ground' plane) and is followed by a typical 'over-the-shoulder' 3rd-person camera (where the z-axis is the up/down one). However, since the irrlicht camera is set up to treat the y-axis as the up/down axis, I'm having a bit of trouble getting this to behave as I want it.

After a bit of fiddling (and some heartfelt swearwords), I figured out that to set the rotation manually of an ICameraSceneNode I needed to set bindTargetAndRotation(), however doing this the camera still seems to want to orient itself so that 'upwards' is positive y (whereas I actually want it to be z). I have tried using setUpVector() on the assumption that this would help me define the camera's local coordinate system however this produces very weird behavior (flickering(!), changing the camera angle seemingly based on the direction the camera has moved between frames (!?)) and doesn't seem to do what I want it to anyway so that would seem to be the wrong approach.

So, is it possible to re-define the camera orientation in the way I am trying to do (I'm hoping so; I don't want to have to go through 3,000 lines of physics engine and switch over my coordinate system) and I'm just being a bit dim somewhere? And if so, where might I be going wrong?
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

iI enjoyed reading your post, and i found it amusing you didnt check the documentation!

setUpVector (const core::vector3df &pos)=0

Sets the up vector of the camera.


Its all in the documentation, and i cant wait to see the engine you have worked on.
Paul J
Posts: 8
Joined: Tue May 26, 2009 11:23 pm

Post by Paul J »

You didn't read what I wrote properly; I did read the documentation and I did use setUpVector, but it did not have the desired effect (in fact, it has a number of very strange effects). So, I infer from what you are saying that my approach is correct, and this is either a bug or (far more likely) my contextual use of it is wrong. I'll post the code I'm using when I get home from work but essentially my approach is this:

-set up vector
-set bindTargetandRotation
-set position
-set rotation

Is this the correct procedure? Should I be doing it in this order? Is there something else I need to set?
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

Ah sorry, i did read wrong..

Is the camera in orthoganal view? Is that the view you want or did you want a 2.5d style thing?

Also, the rotational stuff is relative, so if you were setting it all the time it would be changing all the time? or am i confused again.
Paul J
Posts: 8
Joined: Tue May 26, 2009 11:23 pm

Post by Paul J »

Aha! Many thanks!

My mistake was in using Rotation at all, since as you point out it's relative to the local coordinate system of the camera and thus effectively a transformation operation (which, to me, seems slightly counter-intuitive since other scene nodes don't appear to work that way, but ho-hum). I've swapped over to just setting a target a certain distance ahead of my player character in the direction he's facing and it works a lot better.
Post Reply