scene node shakes when attached to fps camera

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
thatdudeoverthere
Posts: 28
Joined: Fri Apr 24, 2009 2:43 pm
Location: over there...

scene node shakes when attached to fps camera

Post by thatdudeoverthere »

The title basically sums up the problem. If I move left or right the scene node attached to the fps camera jerks and shakes really bad at first and after a few seconds lessens, but is still visibly shaking. If I move forward or backwards or rotate the camera all is fine. It's just the strafing movements that causes a problem. I went so far as to open up the second example that comes with Irrlicht and attached a scene node there and the problem still persists, but I'm getting around ~100 fps. And I don't remember having this problem with older versions of the Irrlicht (or maybe I'm not remembering correctly) :roll:

This is for example how I'm attaching the scene node to the camera

Code: Select all

 
scene::ICameraSceneNode* PlayerCamera = smgr->addCameraSceneNodeFPS(...etc...);
 
scene::IAnimatedMesh* gun = smgr->getMesh("gun.x");
scene::IAnimatedMeshSceneNode* gunNode = smgr->addAnimatedMeshSceneNode(gun);
gunNode->setPosition(core::vector3df(10,5,20));
gunNode->setParent(PlayerCamera);
 
 
any help is appreciated. :)
//Personal code

bool sarcasm;

void set_sarcastic()
{
sarcasm = true;
}
[img]
http://imgs.xkcd.com/comics/goto.png
[/img]
Mel
Competition winner
Posts: 2293
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: scene node shakes when attached to fps camera

Post by Mel »

the problem is the desynchronization between the camera and the gun. I think it can be solved by calling the updateAbsolutePosition() of the camera and the gun before the rendering. But i can't tell 100% for sure.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
thatdudeoverthere
Posts: 28
Joined: Fri Apr 24, 2009 2:43 pm
Location: over there...

Re: scene node shakes when attached to fps camera

Post by thatdudeoverthere »

Alright I'll give that a try and give some feed back on how it goes. :)
//Personal code

bool sarcasm;

void set_sarcastic()
{
sarcasm = true;
}
[img]
http://imgs.xkcd.com/comics/goto.png
[/img]
thatdudeoverthere
Posts: 28
Joined: Fri Apr 24, 2009 2:43 pm
Location: over there...

Re: scene node shakes when attached to fps camera

Post by thatdudeoverthere »

Okay that didn't work exactly, but I did some experimenting and found that if I do...

Code: Select all

 
    while(device->run())
    {
        if (device->isWindowActive())
        {
            driver->beginScene(true, true, video::SColor(255,200,200,200));
            //first call to drawAll()
            smgr->drawAll();
 
            camera->updateAbsolutePosition();
            gunnode->updateAbsolutePosition();
 
             //second call to drawAll()
            smgr->drawAll();
            driver->endScene();
 
                            ........
 

and then proceed to move left/right with the camera it draws two instances of the node (from the two calls to 'smgr->drawAll()') but only one of the two nodes does the shaking the other one behaves like I want... :?
//Personal code

bool sarcasm;

void set_sarcastic()
{
sarcasm = true;
}
[img]
http://imgs.xkcd.com/comics/goto.png
[/img]
chronologicaldot
Competition winner
Posts: 699
Joined: Mon Sep 10, 2012 8:51 am

Re: scene node shakes when attached to fps camera

Post by chronologicaldot »

With respect to what Mel suggested, what did you try exactly?
This?:

Code: Select all

 
while(device->run())
    {
        if (device->isWindowActive())
        {
            camera->updateAbsolutePosition();
            gunnode->updateAbsolutePosition();
 
            driver->beginScene(true, true, video::SColor(255,200,200,200));
            smgr->drawAll();
            driver->endScene();
 
thatdudeoverthere
Posts: 28
Joined: Fri Apr 24, 2009 2:43 pm
Location: over there...

Re: scene node shakes when attached to fps camera

Post by thatdudeoverthere »

@chronologicaldot Yes I tried that code snippet, but it did not work.
//Personal code

bool sarcasm;

void set_sarcastic()
{
sarcasm = true;
}
[img]
http://imgs.xkcd.com/comics/goto.png
[/img]
chronologicaldot
Competition winner
Posts: 699
Joined: Mon Sep 10, 2012 8:51 am

Re: scene node shakes when attached to fps camera

Post by chronologicaldot »

Hmm.. It sounds like the position updating is the problem. How do you know that the node isn't shaking forward and backward when you move those directions? Is the camera positioned directly behind the node?
I'd try setting the position of the note to 0,0,0 and see if the problem persists.

Code: Select all

 
gunNode->setPosition(core::vector3df(0,0,0));
 
thatdudeoverthere
Posts: 28
Joined: Fri Apr 24, 2009 2:43 pm
Location: over there...

Re: scene node shakes when attached to fps camera

Post by thatdudeoverthere »

yep the problem still persists even with the position set to (0,0,0) and still no shaking from moving forwards or backwards...
//Personal code

bool sarcasm;

void set_sarcastic()
{
sarcasm = true;
}
[img]
http://imgs.xkcd.com/comics/goto.png
[/img]
chronologicaldot
Competition winner
Posts: 699
Joined: Mon Sep 10, 2012 8:51 am

Re: scene node shakes when attached to fps camera

Post by chronologicaldot »

Hm... It might be with IAnimatedMeshSceneNode because of post-rendering activity. Try a regular scene node and see if the problem persists.
wing64
Competition winner
Posts: 242
Joined: Wed Jul 23, 2008 2:35 am
Location: Thailand
Contact:

Re: scene node shakes when attached to fps camera

Post by wing64 »

Try call PlayerCamera->render( ) before drawall(). Maybe it help.
Post Reply