Articles Archive
Director Forums
Director Wiki
Job Board
Search
 
Shockwave 3D :  Director Online Forums
Questions about using 3D in Director 
Goto Thread: PreviousNext
Goto: Forum ListMessage ListNew TopicSearchLog In
FPS
Posted by: Kurbaga (---.azeronline.com)
Date: November 04, 2006 04:35AM

can someone explain to me how to trace Frame_Per_second during my 3Dscene running.
i've tried to do it by myself, but its always gets wrong
sad smiley



Re: FPS
Posted by: robotduck (---.dsl.pipex.com)
Date: November 06, 2006 03:38AM


Here's a behaviour script which displays the current frames per second. To use: create a new field or text member. Place it on stage. Create a new behaviour, paste in the code below, and place that behaviour onto the text sprite.

--------------------------------------------------------------


-- FPS Display Behaviour
-- Robotduck 2004

-- Place this behaviour on a sprite with a text or field cast member

property my, startMS, periodSecs, numFrames

on beginsprite me

my = sprite(me.spritenum)

startMS = the milliseconds
periodSecs = 3 -- (seconds between each update)
numFrames = 0

end

on enterFrame me

numFrames = numFrames + 1

currentMS = the milliseconds

if currentMS > startMS + periodSecs*1000 then

-- calculate fps since last update
fps = integer(numFrames / (periodSecs))
my.member.text = "FPS: "&fps

-- and reset the counters
numframes = 0
startMS = the milliseconds

end if

end


---------------------------------------------------------

enjoy!

- Ben


_____________________
duck_at_robotduck.com
www.robotduck.com : Shockwave games, tutorials & source code
http://www.robotduck.com/images/duck/duck_animated.gif



Re: FPS
Posted by: Kurbaga (---.azeronline.com)
Date: November 06, 2006 03:54AM

Greatsmiling smiley)
thanks

P.S. trying to get better perfomance, and i hope this thing 'll help me to trace




Re: FPS
Posted by: Loran (---.net81-65-82.noos.fr)
Date: November 07, 2006 01:05AM

hi,
an other way
__________
global FPS

property btime

on beginsprite me

btime = the milliseconds
fps = 0.

end

--

on exitframe me

vtime = the milliseconds
delta = vtime - btime
FPS = 1000./float(delta)
btime = vtime

end



Re: FPS
Posted by: robotduck (---.dsl.pipex.com)
Date: November 07, 2006 03:14AM

Actually, that's pretty much the same way, but with the averaging feature of my script removed.

The reason I use an average (a 3 second average in my example above), is that if you calculate the FPS each frame independantly it can fluctuate each frame, making it difficult to read and less useful. An averaged FPS reading is much more useful.

- Ben




_____________________
duck_at_robotduck.com
www.robotduck.com : Shockwave games, tutorials & source code
http://www.robotduck.com/images/duck/duck_animated.gif





Sorry, only registered users may post in this forum.
This forum powered by Phorum.