Re: import flame tracker to XSI?

Date : Wed, 19 Oct 2005 17:34:25 +0200
To : XSI(at)Softimage.COM
From : Arvid Björn <arvid.bjorn(at)palladiumfilm.com>
Subject : Re: import flame tracker to XSI?
Hey Stefan, here's a real simple one based on the .ascii-file (had some time to spare)
Apply changes where necesarry (ie. filename and null object)


//--------------------
var oFSys = new ActiveXObject("Scripting.FileSystemObject");

var f = oFSys.GetFile("C:\\test.txt");
var oS = f.OpenAsTextStream(1, 0);

var ts = ""; var nf = ""; var nx = ""; var ny = "";

while(!oS.AtEndOfStream)
{
ts = oS.ReadLine();
nf = ts.substr(3,4); // frame number
nx = ts.substr(11,6); //x value
ny = ts.substr(20,6); // y value
SetKey("null.kine.local.posx", parseFloat(nf), parseFloat(nx), null);
SetKey("null.kine.local.posy", parseFloat(nf), parseFloat(ny), null); }


oS.Close();
//--------------------


Stefan Andersson wrote:

yes it did Guy! thank you very much! I wasn't able to get those last
line's to work though.



oNull.Parameters("posx").AddFCurve2 aXKeys
oNull.Parameters("posy").AddFCurve2 aYKeys



But to be honest I haven't had that much time either to investigate... But I will have a look at it soon.

Thanks again!

/stefan
P.S. I wrote "Luc" instead of Guy... so it was you I meant... sorry...


On 10/19/05, Guy Rabiller <guy(at)alamaison.fr> wrote:


Did my message never reached the list ? :


17.10.2005 17:29 // -----------------------------------------------------------------------------

Hi Stefan,

its pretty easy to parse such file. The first field, before the column is
the frame number, second field before the coma is the X value, then after
the coma the Y value.

Use this kind of script ( its a ugly vbscript but it works ):

' ---[ Parse File
]-------------------------------------------------------
LogMessage CNS_NAME & " >>> Parsing File.."
Dim aXKeys,aYKeys
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.GetFile( "YourFileName" )
Set oTS = oFile.OpenAsTextStream( 1, 0 )
nbKeys = 1
Redim aXKeys(0)
Redim aYKeys(0)
Do While oTS.AtEndOfStream <> True
Redim Preserve aXKeys(nbKeys)
Redim Preserve aYKeys(nbKeys)
strLine = oTS.ReadLine
iPos1 = InStr(strLine,":")
iFrameNumber = Left(strLine,iPos1-1)
iPos2 = InStr(strLine,",")
fXKey = Mid(strLine,iPos1+1,iPos2-1-iPos1)
fYKey = Mid(strLine,iPos2+1)
LogMessage strLine &" ( k:"& CInt(iFrameNumber) &" x:"& CDbl(fXKey) &" y:"&
CDbl(fYKey) &")"
'
aXKeys(nbKeys-1) = CInt(iFrameNumber)
aXKeys(nbKeys) = (-1)*CDbl(fXKey)
'
aYKeys(nbKeys-1) = CInt(iFrameNumber)
aYKeys(nbKeys) = (-1)*CDbl(fYKey)
'
nbKeys = nbKeys + 2
Loop
oTS.Close()

The (-1)* has to be set or not depending of if you want to compensate or
not the tracker.

Then you can set keyframes with the arrays:

' ---[ Create FCurves
]---------------------------------------------------
oNull.Parameters("posx").AddFCurve2 aXKeys
oNull.Parameters("posy").AddFCurve2 aYKeys


Be aware however that if the flame artist used some offset somewhere in its tree, then the result wont match.

*Allways* ask the flame artist about any offset prior to use such files!


Hope this helps. -- guy rabiller | 3d technical director (at) LaMaison // -----------------------------------------------------------------------------



--
guy rabiller | 3d technical director (at) LaMaison




Stefan Andersson wrote: On 10/19/05, kim aldis <kim(at)cg-soup.com> wrote:


I was going to try and look at this earlier but it's been a bit of a week. This weekend, though, for sure.

Luc's little parser worked except that I wasn't able to put the
keyframes onto the null, but I guess that would be a minor thing to
fix. I haven't had time to look into it either yet... too much work...
ack...

It's a catch22 situation as always. Not enough time to do the research
to make the workflow faster, because you have too much work since you
haven't had time to do research... *stefan mumbles on*

/stefan

---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi





--- Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in
body: unsubscribe xsi



--- Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body: unsubscribe xsi




---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi


Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.