Hi,
i was wondering what should be a good way for fixing the frames per second to the desired framerate (?)
tks!
c
Hi,
i was wondering what should be a good way for fixing the frames per second to the desired framerate (?)
tks!
c
You can, of course, slow down the frame rate to a desired constant fps. You would do this by putting:
clock-mode limited
clock-frame-rate 20
or whatever fps you wanted, in your Config.prc. There are lots of good reasons for running at a constant frame rate, rather than at Pandaās default, which is to run as fast as it can go.
This wonāt work to make your frame rate faster, though; for instance, putting āclock-frame-rate 100ā wonāt make your game suddenly run at 100 fps. If you want to improve your frame rate, you have to optimize your code to do less work per frame.
David
of course, the panda still cannot do miracles
thatās exactly the config commands i was looking for, thanks a lot!
c
Not exactly on topic but hopefully someone watching this thread can help me.
Iām fine with Panda3D grabbing lots of CPU when the scene is actually changing. In many of my applications (visualizations rather than games) the scene will be static most of the time, with most changes being due to the user navigating the scene with the mouse.
What seems to make sense to me is to increase the max frame rate while the mouse navigation is occurring, but then to drop down to some low frame rate otherwise. Is this something that can be done? All of the frame rate stuff Iāve seen mentioned involves the Config.prc which suggests to me that it can only be set once at startup.
actually in that case you donāt use run, but a just call each frame when you want to render it (based off mouse move or window redraw events).
When window updates just call
taskMgr.step()
Ok, thanks Iāll give that a try. Will I need to implement all the mouse navigation stuff myself though?
Actually, I have a better idea. Why not create a task that calculates how much the mouse has moved, then calls time.sleep(t) where t is, say, 0.04 if the mouse hasnāt moved, and 0 when the mouse moves.
another method i cant think of is add some sleep time inbetween the tasks.
I think its base.setSleep(.1) for sleeping 1/10 of a second. Or you can to call time.sleep(.1) yourself when there is no events.
Making calls to sleep is a simple and easy way to slow down your applicationās use of CPU, though it doesnāt tend to result in a very steady frame rate.
You can also change the clock frame rate at runtime. Just use globalClock.setFrameRate(). To put it in limited mode, either use clock-mode limited in your Config.prc file as described above, or at runtime use globalClock.setMode(ClockObject.MLimited).
David
@drwr: Thanks, I gave that a try and it does work, though with a bit of a quirk, at first. The CPU utilization when not navigating the scene is indeed reduced (how much itās reduced depends on how low I force the frame rate to be). The problem initially was that now Panda would only give me mouse events every 1/5th of a second, and this resulted in jerkyness when the user starts to do mouse navigation.
But what I ended up doing and works pretty well is this:
First, set up a task every frame that does this:
Also, set up mouse event response as follows:
Just to give a very unscientific idea of performance:
FPS = 1 (mouse outside 3D window): CPU usage ~ 7%
FPS = 30 (mouse inside 3D window): CPU usage ~ 61%
FPS = 1000 (navigating with mouse): CPU usage ~ 86%*
Thanks to all for the help and ideas.
iāve just found out, that setting the clock-mode and clock-frame-rate as mentioned by drwr doesnāt work when set as described here. setting the same through config file works fine
pro-rsoft gave me this and it works just fine for changing a running programās framerate:
from pandac.PandaModules import ClockObject
FPS = 30
globalClock = ClockObject.getGlobalClock()
globalClock.setMode(ClockObject.MLimited)
globalClock.setFrameRate(FPS)
cheers