understanding framelistener


28-12-2012 13:37:45


I've been using panda3d for a while but am now trying out python ogre. panda3d is awesome but i like how python ogre looks and its integration of quaternions is something i've been looking for a while.

Am currently used to a more freeflowing code structure but am trying to adjust to python ogre's zen. one thing that's confusing me most is the framelistener.

how can i pass a series of objects to this framelistener? the tutorials are really top notch but i cannot find the answer in them.

all i want is iterate through a list of spheres and get them to rotate on their own axis to start with.

do i need to define a frame listener for each sphere?


30-12-2012 05:17:25

I suppose you are using the SampleFramework as in the wiki tutorial. You sure don't need a framelistener for each sphere. One simple way to do it would be to derive from the SampleFramework.FrameListener and create a member variable to hold the list of references of SceneNodes to animate in it. Then in the method frameRenderingQueued of your derived framelistener, iterate through all the nodes in the list and apply the incremental values to roll, yaw or pitch.

In your main application (ie derived from SampleFramework.Application) override the method _createFrameListener; instantiate your derived framelistener class and add it to the root (refer to the wiki tutorial). Now when you create scene nodes, just add it to list of animated object of your framelistener.

Also note that if you want the rotation to be independent of the framerate, be sure to take into account the frameEvent.timeSinceLastFrame in the frameRenderingQueued method.

I am just suggesting a quick and dirty solution. There might be other better ways. Hope that helps :)


04-01-2013 03:39:49

Thank you very much for replying. Quick and dirty solution is fine for me!