ICameraSceneNode::getUpVector() buggy?

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
MeLikeyCode
Posts: 1
Joined: Wed Apr 25, 2018 3:59 pm

ICameraSceneNode::getUpVector() buggy?

Post by MeLikeyCode »

Hello everyone!

I'm new to using IrrLicht, glad to be here! Straight to the problem:
It seems that ICameraSceneNode::getUpVector() always returns the same vector even when I change its target!

Here is what I'm doing:

ICameraSceneNode* camNode = sceneManager->addCameraSceneNode();
auto camUp = camera->getUpVector(); // is initially {0,1,0}
auto camTarget = camera->getTarget();
camNode->setTarget({camTarget.X,camTarget.Y + 10,camTarget.Z})
camUp = camNode->getUpVector(); // is STILL {0,1,0}

It seems changing the camera target does not change the up vector? Is this a bug? If not, How am I supposed to get the ACTUAL camera up vector?

Thanks so much!
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: ICameraSceneNode::getUpVector() buggy?

Post by CuteAlien »

The up-vector is set - it's not automatic. Interestingly similar thread was just brought up a few days ago, so explanation why that wouldn't work in there: http://irrlicht.sourceforge.net/forum/v ... =2&t=52241
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: ICameraSceneNode::getUpVector() buggy?

Post by Mel »

The up vector is currently only a hint. it doesn't get updated because it is necesary that it remains as such, but you can change it so the proper up vector is calculated according to it. You can calculate the up vector doing the cross product of the view vector AND that hint to get a left vector (the vector thet points to the left as seen from the camera), and then crossing that left vector with the view vector again to get the proper up vector. Take a look at the CBillboardSceneNode source to get actual code (AFAIK) that calculates the up vector correctly
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Post Reply