User Tools

Site Tools


Scene Time

Summary

Below is an example demonstrating fundamental calculations when working with time, in Daz Studio.

API Areas of Interest

Example

Scene_Time.dsa
// Define an anonymous function;
// serves as our main loop,
// limits the scope of variables
(function(){
 
	// Define the number of Ticks Per Second
	var nTPS = 4800;
 
	// Get the number of Ticks Per Frame
	var nTPF = Scene.getTimeStep().valueOf();
 
	// Calculate the number of Frames Per Second
	var nFPS = nTPS / nTPF;
 
	// Get the current Scene time, in ticks
	var nTicks = Scene.getTime().valueOf();
 
	// Calculate the current frame number
	var nFrame = nTicks / nTPF;
 
	// Calculate the current number of seconds
	var nSecs = nTicks / nTPS;
 
	// Feedback information about the current state
	print( "TPF:", nTPF, "FPS:", nFPS );
	print( "------------------------------" );
	print( "Frame:", nFrame, "\tTick:", nTicks, "\tSecond:", nSecs );
	print( "------------------------------" );
 
	// Define frame range values
	var nInterval = 1;
	var nDuration = 60;
	var nStart = 0;
 
	// Iterate over the frame range
	for( var i = nStart, n = nStart + nDuration; i <= n; i += nInterval ){
		// Calculate the number of ticks for the i'th frame
		nTicks = i * nTPF;
 
		// Calculate the number of seconds for the i'th frame
		nSecs = nTicks / nTPS;
 
		// Feedback information about the i'th frame
		print( "Frame:", i, "\tTick:", nTicks, "\tSecond:", nSecs );
	}
 
// Finalize the function and invoke
})();