object to rotate around the camera

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
FoxHound
Posts: 10
Joined: Fri Nov 18, 2005 2:11 pm

object to rotate around the camera

Post by FoxHound »

I've been checking the forums for a simular topic, I've gotten a lot of info by lurking that way, but I've not found this topic.

What I'm trying to do is put an object in front of the camera. This could be the same way you put a gun in a FPS game.

//get his position
core::vector3df e = camera->getAbsolutePosition();
core::vector3df f = camera->getRotation();


e.X += 50 * cos((f.Y)) * 3.14 / 180 );
e.Z += 50 * sin((f.Y) * 3.14 / 180 );



//set position
heros_gun->setPosition(e);
heros_gun->setRotation(camera->getRotation());

What's happening here is the object is rotating against the camera, basically going the opposite way the camera is panning. When the same code was used on a node it did just fine. What did I miss?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

cam->bindRotationAndTarget(true)
Post Reply