Difference between revisions of "IC Python API:RLPy RTime"

From Reallusion Wiki!
Jump to: navigation, search
m (GetFrameTime)
m (IndexedFrameTime)
Line 63: Line 63:
 
===IndexedFrameTime===
 
===IndexedFrameTime===
  
{{Input|
+
<syntaxhighlight lang="Python">
 
def RLPy.RTime.IndexedFrameTime(nFrameindex,nFps)
 
def RLPy.RTime.IndexedFrameTime(nFrameindex,nFps)
}}
+
</syntaxhighlight>
  
 
Get the frame time from the frame index.  
 
Get the frame time from the frame index.  
Line 71: Line 71:
 
Since iClone runs 60 frames per second, the resultant time in milliseconds is the usually the frame count divided by 60 times 1000.
 
Since iClone runs 60 frames per second, the resultant time in milliseconds is the usually the frame count divided by 60 times 1000.
  
{{Code|<nowiki>
+
<syntaxhighlight lang="Python">
 
import RLPy
 
import RLPy
  
Line 77: Line 77:
 
time = RLPy.RTime.IndexedFrameTime(180, RLPy.RGlobal.GetFps())
 
time = RLPy.RTime.IndexedFrameTime(180, RLPy.RGlobal.GetFps())
 
print(time.GetValue())
 
print(time.GetValue())
</nowiki>}}
+
</syntaxhighlight>
  
 
===GetValue===
 
===GetValue===

Revision as of 23:05, 14 January 2019

Main article: System Module.

Class in RLPy / Inherits from: _object

Description

This class is used to hold and manipulate timing information.

Time is stored internally in system as milliseconds. Most API methods that require or return timing information do so through variables of this type. This class also provide methods to convert between Frame and RTime, such as GetFrameIndex() and IndexedFrameTime(). Use of GetFrameTime() can ensure that RTime is on the correct frame.

Operators

This class supports the mathematical operators.

Member Functions

GetFrameIndex

def RLPy.RTime.GetFrameIndex(kTime, nFps)

Convert the current time to frame index. Since iClone is 60 frames per second, the return value is usually the time in seconds times 60.

The following example gives the frame index at the 3 second mark:

import RLPy

#create a time object of 3 seconds
time = RLPy.RTime(3000)

#print the frame index at the 3 second mark: 180
print(RLPy.RTime.GetFrameIndex(time, RLPy.RGlobal.GetFps()))

GetFrameTime

def RLPy.RTime.GetFrameTime(kTime,nFps)

Deduce the frame time from a time object.

The RTime object may not give a time that perfectly matches a frame. Call this function to get the closest frame time for a RTime object - not to be confused with frame index.

The following code retrieves the frame accurate time from a given time value.

import RLPy

#Construct time object that does not align perfectly with a frame:
time = RLPy.RTime(3005)

#Derive the nearest frame time from the RTime object.
frame_time = RLPy.RTime.GetFrameTime(time, RLPy.RGlobal.GetFps())

#Print the frame time: 3000
print(frame_time.GetValue())

IndexedFrameTime

def RLPy.RTime.IndexedFrameTime(nFrameindex,nFps)

Get the frame time from the frame index.

Since iClone runs 60 frames per second, the resultant time in milliseconds is the usually the frame count divided by 60 times 1000.

import RLPy

#Derive the frame time from the frame index: 3000 (ms)
time = RLPy.RTime.IndexedFrameTime(180, RLPy.RGlobal.GetFps())
print(time.GetValue())

GetValue

def RLPy.RTime.GetValue(self)

Get the time in milliseconds for this RTime object.

The following example fetches the current frame time in milliseconds. The current frame time is indicated by the position of your play-head in the timeline.

Code:
import RLPy

#Print the current frame time 
time = RLPy.RGlobal.GetTime()
print(time.GetValue())