Frame index offset


https://forum.reallusion.com/Topic401359.aspx
Print Topic | Close Window

By RobertoColombo - 5 Years Ago
Hi RL,

in order to verify my finding, I am using the code provided at http://manual.reallusion.com/iClone/script/python/md_docs__way_to_control_prop.html 
I simplified the prop positioning with just a set of the X=100 at frame 1.
What happens when executed ? The prop has the X=100 at frame 2 !!
Therefore I did not find a way to set a key at frame 1...

Any hints ?

Here is the code:

import os, RLPy, math
from winreg import *

#-- Get iClone 7 default template path --#
Registry = ConnectRegistry(None, HKEY_LOCAL_MACHINE)
RawKey = OpenKey(Registry, r"SOFTWARE\Reallusion\iClone\7.0")
ic_template_path = os.path.abspath(QueryValueEx(RawKey, "Template Data" )[0])

#-- Load Box_001.iProp --#
RLPy.RFileIO.LoadFile(ic_template_path + "//iClone Template//Props//3D Blocks//Box_001.iProp")

#-- Get Prop --#
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box_001")

#-- Get Transform Control and Data --#
ts_control = prop.GetControl("Transform")
ts_data_block = ts_control.GetDataBlock()

#-- Set X transform Key to 100 at frame 1 --#
ts_data_block.SetData("Position/PositionX", RLPy.RTime.IndexedFrameTime(1, RLPy.RGlobal.GetFps()), RLPy.RVariant(100))
By gordryd - 5 Years Ago
What happens if you set it to Frame 0?
By Johnny (RL) - 5 Years Ago
Hi,

The time using in API is starting from 0, and should be decremented by 1 when retrieving the frame value from the UI.
RLPy.RTime.IndexedFrameTime(frame_on_UI - 1, RLPy.RGlobal.GetFps())
By RobertoColombo - 5 Years Ago
gordryd (1/16/2019)
What happens if you set it to Frame 0?

That`s the first thing I tried: the key frame 1 does not report the updated X value...

EIDT: ok, I tried again and that's what really happens.

The prop is moved but thr Modify window (F6) does not reports the correct X displacement.
It does only after Play is pressed at least once.
That's what cheated me because I had teh preview window without Grid and just relied on the X value in the Modify window.

So, now the question for RL are:

1. is it correct that the Modify window data is not updated ?
2. Because the Frame index in the timeline starts from 1, in my opinion, th eshift should be done seamlessly within the time to frame conversion routines.
    Can you plan also this update ? It iust not a big issue, obviously, but the API code should refer to what we see, i.e. frame numbering starting from 1.
    Anyway, it is something today not documented...

  Roberto

By dogged2003 - 5 Years Ago
RobertoColombo
Edit: without play (RLPy.RGlobal.Play(RLPy.RTime(0), RLPy.RTime(20))) screenshot is wrong.
Yesterday I completely reinstalled iClone. And your code works correctly. The key is set in the first frame.
https://forum.reallusion.com/uploads/images/166cb11d-a592-4a6e-ac9c-c324.jpg

Try make full reinstall iClone.
By The-any-Key - 5 Years Ago
Isn't it better to design using time instead of frames? So you can just set it at time 0. And if you need another "frame" you can just frame_you_need*RLPy.RGlobal.GetFps()

# Add first key
RLPy.RTime(0)

# Add at other frame
fps=RLPy.RGlobal.GetFps()
# frame count start at 0
frame=1
RLPy.RTime(frame*fps)
By RobertoColombo - 5 Years Ago
Hi,

it depends.
Both ways can have a meaning.
For exmaple, the videos that I usually make (here is an example: https://forum.reallusion.com/400937/Drifting) shall be synced on a chropma-keyed video and I work on frame index, i.e. I do not care about time, only what shall be the exact frame.
Anyway, IMO the shift of the index shall be done under-the-hood: time starts from 0, frames (at least on the Timeline) starts from 1.
Anyway, not a big issue...once it is documented (the available doc shall really be impoved... so much missing...)

  Roberto
By RobertoColombo - 5 Years Ago
dogged2003 (1/16/2019)
RobertoColombo
Yesterday I completely reinstalled iClone. And your code works correctly. The key is set in the first frame.
https://forum.reallusion.com/uploads/images/166cb11d-a592-4a6e-ac9c-c324.jpg

Try make full reinstall iClone.


Hi,

pls, see my FULL reply above with the UPDATED section.

Regards

  Roberto

By dogged2003 - 5 Years Ago
I’ve played around.
0 eq 1 frame
1 eq 2 frame
Try adding (as is in doc):

RLPy.RGlobal.Play(RLPy.RTime(0), RLPy.RTime(20))

And see True! Wow

P.S. 
Did not see the latest posts.

P.P.S. It seems to me that the RL programmers came from C ++. Because of this, we see not Python, but C ++ in Python. Hehe
By luke (RL) - 5 Years Ago

1. is it correct that the Modify window data is not updated ?

Yes, because of update the display value in modify panel or timeline will cause performance issue (getting slow) so all the values or UI will not update until you press the "Play" button.

2. Because the Frame index in the timeline starts from 1, in my opinion, the shift should be done seamlessly within the time to frame conversion routines.
    Can you plan also this update ? It just not a big issue, obviously, but the API code should refer to what we see, i.e. frame numbering starting from 1.
    Anyway, it is something today not documented...

hmm, we will discuss it internally, except the frame, there are many differences between core value and display value. I'm not sure it's a huge effort for us or not to make it the same. So I can't give you a solid answer now.

By Zeronimo - 5 Years Ago
the number of the first frame displayed in the timeline could be 0 and not 1. in this way the display of the frame number would be the same as for Python