getForwardVector?

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
yvanvds
Posts: 9
Joined: Sun Feb 15, 2009 12:55 pm
Contact:

getForwardVector?

Post by yvanvds »

Just a quick beginners question i could not find anything about on the Forums...

I am using FMOD for sound in my program, and for the listener position it uses 4 vectors: position, velocity, forward and up. Mapping position to a camerascenenode is not difficult, and i have not looked at velocity yet, but what about forward? There is a 'getUpVector' function, but nothing for the forward vector. Or is there?

What values correlate to this?
yvanvds
Posts: 9
Joined: Sun Feb 15, 2009 12:55 pm
Contact:

some progress, but not quite there

Post by yvanvds »

I found this code in the forums:

Code: Select all

irr::core::vector3df vector = irr::core::vector3df(0,0,1);
irr::core::matrix4 m;
m.setRotationDegrees(camera->getRotation());
m.transformVect(vector);
the vector should be the 'Forward' vector I am looking for. However it doesn't seem to be exactly right, because sound is now constantly swapping between left and right very fast.

any ideas?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

You could try (no guarantee):

Code: Select all

irr::core::vector3f forward = camera->getTarget() - camera->getPosition();

// maybe also needed (not sure what fmod expects):
forward.normalize();
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
yvanvds
Posts: 9
Joined: Sun Feb 15, 2009 12:55 pm
Contact:

Post by yvanvds »

Thanks! That was exactly what I needed. I didn't imagine it could be that simple. And FMOD vectors must be normalized indeed. It seems I'd better take some time to read up on matrixes and vectors when i find some time :oops:
Post Reply