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?
Camera orientation problem
-
- Posts: 914
- Joined: Fri Aug 03, 2007 12:43 pm
- Location: South Africa
- Contact:
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?
-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?
-
- Posts: 914
- Joined: Fri Aug 03, 2007 12:43 pm
- Location: South Africa
- Contact:
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.
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.
-
- Posts: 914
- Joined: Fri Aug 03, 2007 12:43 pm
- Location: South Africa
- Contact: