SetRotation On A Parented 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
kklouzal
Posts: 343
Joined: Sun Mar 28, 2010 8:14 pm
Location: USA - Arizona

SetRotation On A Parented Camera

Post by kklouzal »

I have an ICameraSceneNode which I've parented to another ISceneNode. In the event receiver when the mouse is moved I take the move delta and apply that to the camera's X and Y rotation accordingly. Unfortunately since I've parented the camera using setRotation() has no effect until you call bindTargetAndRotation(true) however once you've called this function setRotation not only set's the rotation of the camera but also set's the target of the camera thus moving the camera effects the rotation due to it trying to constantly point at a specific target location.

Why can you not call setRotation on a camera which has been parented? Shouldn't calling setRotation set the camera's rotation regardless?

Thank you for your time.
Dream Big Or Go Home.
Help Me Help You.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: SetRotation On A Parented Camera

Post by hendu »

Perhaps the call you're looking for is updateAbsolutePosition?
kklouzal
Posts: 343
Joined: Sun Mar 28, 2010 8:14 pm
Location: USA - Arizona

Re: SetRotation On A Parented Camera

Post by kklouzal »

Possibly, my only hitch here is that I've parented the camera to the node so there is no need to call any functions on the camera each frame as it's buried quite deep in a class hierarchy. I assumed setRotation would do as the name implies and set the rotation of the camera and hold that rotation until I set it again.
Dream Big Or Go Home.
Help Me Help You.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: SetRotation On A Parented Camera

Post by hendu »

edit: It's a bit unclear what you're trying to do.

Do you want to point the camera to a constant direction? You must then set the target every time the camera moves. The target is constant, no matter whether set through setTarget or bound rotation + setRotation.
kklouzal
Posts: 343
Joined: Sun Mar 28, 2010 8:14 pm
Location: USA - Arizona

Re: SetRotation On A Parented Camera

Post by kklouzal »

I just assumed calling setRotation on the camera node would set the angle of the camera and that angle would stay constant regardless of if the camera's position changed however this is not the case. I'll rework the code to call setRotation each frame to try and keep the camera at a constant angle.

It would be nice if when bindTargetAndRotation(false) you were able to use setRotation and the camera's angle would stay until calling setRotation again even when the camera has been parented to another object.
Dream Big Or Go Home.
Help Me Help You.
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: SetRotation On A Parented Camera

Post by mongoose7 »

I think the point is that, you are setting the relative rotation of the camers, as it has been parented. updateAbsolutePosition has to be called to *calculate* the actual transformation, since you didn't do that yourself. Maybe you forgot that setRotation only sets the local (relative) rotation?
Post Reply