ICameraSceneNode problems

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
[DEF]
Posts: 17
Joined: Thu Jul 29, 2010 8:30 am

ICameraSceneNode problems

Post by [DEF] »

I'm having problems moving an ICameraSceneNode, it's seems that whenever I go to move it, it points in some weird direction, until I stop moving it. Might be better explained with some code:

Code: Select all

ICameraSceneNode* camera = smgr->addCameraSceneNode();
camera->bindTargetAndRotation(true);

......

cursorPosition = device->getCursorControl()->getPosition();
device->getCursorControl()->setPosition(SCREEN_WIDTH/2, SCREEN_HEIGHT/2);
double mouseMultiplier = 0.25;
lookAngle_y += (cursorPosition.X-(SCREEN_WIDTH/2))*mouseMultiplier;
lookAngle_x += (cursorPosition.Y-(SCREEN_HEIGHT/2))*mouseMultiplier;
            
camera->setRotation(vector3df(lookAngle_x, lookAngle_y, 0));
            
if (receiver.IsKeyDown(KEY_KEY_W)) {
        camera->setPosition(camera->getPosition() + vector3df(0, 1, 0));
}
lazerblade
Posts: 194
Joined: Thu Mar 18, 2010 3:31 am
Contact:

Post by lazerblade »

You have to handle the look at target and the up vector and gimbal lock and local rotation if you want to transform the camera. My recommendation is that you just use a pre-made camera handling class like this one:

http://irrlicht.sourceforge.net/phpBB2/ ... 5&start=15

8)
LazerBlade

When your mind is racing, make sure it's not racing in a circle.

3d game engine: http://sites.google.com/site/lazerbladegames/home/ray3d
lazerBlade blog: http://lazerbladegames.blogspot.com/
[DEF]
Posts: 17
Joined: Thu Jul 29, 2010 8:30 am

Post by [DEF] »

Ahaha!! Yes, your camera class is very well set out, thankyou!! :D I've seen other code snippets on the forum that also do it similar. But yours look quite complete!
lazerblade
Posts: 194
Joined: Thu Mar 18, 2010 3:31 am
Contact:

Post by lazerblade »

Thank you, :D
LazerBlade

When your mind is racing, make sure it's not racing in a circle.

3d game engine: http://sites.google.com/site/lazerbladegames/home/ray3d
lazerBlade blog: http://lazerbladegames.blogspot.com/
Post Reply