Totally Bamboozled... Anyone have any ideas???(SOLVED)

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
kendric
Posts: 71
Joined: Tue May 29, 2007 9:05 pm

Totally Bamboozled... Anyone have any ideas???(SOLVED)

Post by kendric »

I wanted to make my own fps camera just to have a little more control over how it works. So i basically used the same logic that is in the fps one provided, but i also provide a function that gets called every time newton(im using that for physics) moves my scene node.

So the flow of events is
newton pass time
newton callback with updated position
set scene node position
call my function

in my function this is all I do.

matrix4 mat;
vector3df rotation=camera->getRotation();
mat.setRotationDegrees(vector3df( rotation.X, rotation.Y,0));
vector3df t(0,0,1);
mat.transformVect(t);
t+=camera->getAbsolutePosition();
camera->setTarget(t);

Here is whats odd. The logic for looking around works fine if your not moving.
At the very beginning of the simulation you are falling towards the ground. No mouse inputs have happened so the look around via mouse(which is what works fine) has not happened yet. Rotation at this point in time is 0, so t is always 0,0,1 and target always is absolute position+0,0,1

What happens is the following: your guy starts falling, but irrlicht seems to be ignoring my setTargets and keeps the focal point straight ahead of where you start the free fall. The farther you fall the more the camera points towards straight up.

Now here is the oddest part. When the player finally hits the ground there is a small bounce. When the bounce happens the target finally kicks in and the view looks forward. Then the player bounces up a bit and it does the same sorta thing. When the player finally comes to rest the camera is looking perfectly straight ahead.

I have been bashing my head against this for a few hours now and I cannot see any connection between bouncing and the setTarget finally kicking in.

If anyone has any ideas I would love to hear them.

Thanks in advance.

***
Oh yeah, this may be relative too. The camera is attached to a scene node which is the player. The newton updates are being applied to the player's scene node. I tried using camera->getParent()->getAbsolutePosition() but that didnt seem to have an effect. In debugging this problem I have printed out the positions and the targets and they appear correct. You can see the objects falling towards the ground.

*** Additional information

The same thing happens when you walk around. It leaves the camera at your starting point(so if you move forward you are looking backward) until you stop moving, at which point it fixes itself. This suggest that it has something to do with scene nodes moving continually and then comming to rest or changing directions. Very strange.
Last edited by kendric on Thu Jul 12, 2007 5:33 pm, edited 1 time in total.
kendric
Posts: 71
Joined: Tue May 29, 2007 9:05 pm

Post by kendric »

Well I figured it out. I don't know if this is just a bug or something that is required.

Basically after you move the parent that the camera is attached to you call updateAbsolutePosition on the parents scene node.
Then in the cameras function that updates its facing, you call updateAbsolutePosition on the camera.

Doing both of those(on the latest release of the engine) fixed my problem.

Now i just have to work on the smoothness of my mouse control.
Post Reply