  | | | Create2DSkeleton/AppendBone root problem... | Create2DSkeleton/AppendBone root problem... 2005-06-15 - By Bradley R. Gabe
Back Thanks, Morten.
I think it serves as a better example for OM scripting and sharing transform data between scene nodes than as a useful production tool.
>That's a gem Brad :) > >- > >Morten Bartholdy >3D & VFX Artist > > > >-- -- Original Message -- -- >From: <mailto:brad@(protected)>Bradley R. Gabe >To: <mailto:XSI@(protected)>XSI@(protected) ; ><mailto:XSI@(protected)>XSI@(protected) >Sent: Wednesday, June 15, 2005 2:44 AM >Subject: Re: Create2DSkeleton/AppendBone root problem... > >Select any number of scene objects, then run the following jscript. It >will build a 2D chain with each bone pointing from one object to the next, >in the order they were selected. The chain root and first bone match >orientation. This is all object model, so it should be pretty fast, even >for large selections: > >// BEGIN SCRIPT >-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- >// Create SIVector3 objects to store position vectors >var rootPos = XSIMath.CreateVector3(); >var effPos = XSIMath.CreateVector3(); > >// Define Chain normal plane >var normalArr = [0,1,0]; > >// Get the global transforms from your first 2 selected objects >var rootTrans = selection(0).kinematics.global.transform; >var effTrans = selection(1).kinematics.global.transform; > >// Pull the position vectors from the transform objects >rootTrans.GetTranslation(rootPos); >effTrans.GetTranslation(effPos); > >// Create your chain root >var root = ActiveSceneRoot.Add3DChain(rootPos, effPos, normalArr, >"ChainRoot"); >var bone0 = root.bones(0); > >// Finish off the rest of the chain from the rest of the selection >for(var i=2; i<selection.count; i++){ > > // Grab the global trans off the current item > effTrans = selection(i).kinematics.global.transform; > > // Pull the position vector from the global transform; > effTrans.GetTranslation(effPos); > > root.AddBone(effPos); >} > >// Get the global transform off the first bone >var boneTrans = bone0.kinematics.global.transform; > >// Assign the root and the first bone to the first bone's global trans >root.kinematics.global.transform = boneTrans; >bone0.kinematics.global.transform = boneTrans; >// END SCRIPT >-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- > > >>Okay, I have a solution for you. But first a quick question: How are you >>getting your chain element coordinates, is it from existing elements in >>the scene? >> >>One thing to keep in mind is the chain creation commands and methods rely >>on global coordinates. So pulling them off existing nodes requires less >>code than having to convert your own coordinates from local to global for >>everything. >> >>>I'm not sure if there's a better way to do this trhough the object >>>model, but I am trying to build chains by specifying an array of (x,y,z >>>position coordinates) and a position for an up vector. >>> >>>My procedure involves creating the first bone in the chain using >>> >>>1- Create2DSkeleton command to generate the first bone >>>2- zero out the root to match a null correctly oriented. >>>3- zero out the first joint. >>>3- AppendBone to add additional bones. >>> >>>Unfortunately, every time I use an AppendBone command, it seem to >>>re-orient the root and throws off the rotation bone values. >>> >>>If anyone has a better procedure for handling chain ganeration, with >>>zeroing bones ??? >>> >>> >>>THX >>>RSM >>> >>>__ ____ ____ ____ ____ ____ ____ ____ ____ ____ _____ >>>Raffaele Scaduto-Mendola - www.turbolinea.com >>> raffaele@(protected) >>>--- >>>Unsubscribe? Mail Majordomo@(protected) with the following text in body: >>>unsubscribe xsi >> >>--- >>Unsubscribe? Mail Majordomo@(protected) with the following text in body: >>unsubscribe xsi
<html> <body> Thanks, Morten.<br><br> I think it serves as a better example for OM scripting and sharing transform data between scene nodes than as a useful production tool.<br><br> <br> <blockquote type=cite class=cite cite=""><font face="arial" size=2>That's a gem Brad :)<br> </font> <br> <font face="arial" size=2>-<br> </font> <br> <font face="arial" size=2>Morten Bartholdy<br> 3D & VFX Artist<br><br> </font> <br> <br>
<dl> <dd>-- -- Original Message -- -- <br>
<dd>From:</b> <a href="mailto:brad@(protected)">Bradley R. Gabe</a> <br>
<dd>To:</b> <a href="mailto:XSI@(protected)">XSI@(protected)</a> ; <a href= "mailto:XSI@(protected)">XSI@(protected)</a> <br>
<dd>Sent:</b> Wednesday, June 15, 2005 2:44 AM<br>
<dd>Subject:</b> Re: Create2DSkeleton/AppendBone root problem...<br><br>
<dd>Select any number of scene objects, then run the following jscript. It will build a 2D chain with each bone pointing from one object to the next, in the order they were selected. The chain root and first bone match orientation. This is all object model, so it should be pretty fast, even for large selections:<br ><br>
<dd><font face="Courier New, Courier" color="#008000">// BEGIN SCRIPT -- ------ -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -----<br>
<dd>// Create SIVector3 objects to store position vectors<br> </font> <dd>var rootPos = XSIMath.CreateVector3();<br>
<dd>var effPos = XSIMath.CreateVector3();<br><br>
<dd><font face="Courier New, Courier" color="#008000">// Define Chain normal plane<br> </font> <dd>var normalArr = [0,1,0];<br><br>
<dd><font face="Courier New, Courier" color="#008000">// Get the global transforms from your first 2 selected objects<br> </font> <dd>var rootTrans = selection(0).kinematics.global.transform;<br>
<dd>var effTrans = selection(1).kinematics.global.transform;<br><br>
<dd><font face="Courier New, Courier" color="#008000">// Pull the position vectors from the transform objects<br> </font> <dd>rootTrans.GetTranslation(rootPos);<br>
<dd>effTrans.GetTranslation(effPos);<br><br>
<dd><font face="Courier New, Courier" color="#008000">// Create your chain root <br> </font> <dd>var root = ActiveSceneRoot.Add3DChain(rootPos, effPos, normalArr, " ;ChainRoot");<br>
<dd>var bone0 = root.bones(0);<br><br>
<dd><font face="Courier New, Courier" color="#008000">// Finish off the rest of the chain from the rest of the selection<br> </font> <dd>for(var i=2; i<selection.count; i++){<br><br>
<dd><x-tab> </x-tab>// Grab the global trans off the current item<br>
<dd><x-tab> </x-tab>effTrans = selection(i).kinematics.global.transform;<br>
<dd><x-tab> </x-tab><br>
<dd><x-tab> </x-tab>// Pull the position vector from the global transform;<br>
<dd><x-tab> </x-tab>effTrans .GetTranslation(effPos);<br>
<dd><x-tab> </x-tab><br>
<dd><x-tab> </x-tab>root.AddBone (effPos);<br>
<dd>}<br><br>
<dd><font face="Courier New, Courier" color="#008000">// Get the global transform off the first bone<br> </font> <dd>var boneTrans = bone0.kinematics.global.transform; <br><br>
<dd><font face="Courier New, Courier" color="#008000">// Assign the root and the first bone to the first bone's global trans<br> </font> <dd>root.kinematics.global.transform = boneTrans;<br>
<dd>bone0.kinematics.global.transform = boneTrans;<br>
<dd><font face="Courier New, Courier" color="#008000">// END SCRIPT -- ---- --- -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---<br><br> <br> </font><blockquote type=cite class=cite cite=""> <dd>Okay, I have a solution for you. But first a quick question: How are you getting your chain element coordinates, is it from existing elements in the scene?<br><br>
<dd>One thing to keep in mind is the chain creation commands and methods rely on global coordinates. So pulling them off existing nodes requires less code than having to convert your own coordinates from local to global for everything .<br><br> <blockquote type=cite class=cite cite=""> <dd>I'm not sure if there's a better way to do this trhough the object model, but I am trying to build chains by specifying an array of (x,y,z position coordinates) and a position for an up vector.<br><br>
<dd>My procedure involves creating the first bone in the chain using<br><br>
<dd>1- Create2DSkeleton command to generate the first bone<br>
<dd>2- zero out the root to match a null correctly oriented.<br>
<dd>3- zero out the first joint.<br>
<dd>3- AppendBone to add additional bones.<br><br>
<dd>Unfortunately, every time I use an AppendBone command, it seem to re-orient the root and throws off the rotation bone values.<br><br>
<dd>If anyone has a better procedure for handling chain ganeration, with zeroing bones ???<br><br> <br>
<dd>THX<br>
<dd>RSM<br><br>
<dd>__ ____ ____ ____ ____ ____ ____ ____ ____ ____ _____<br>
<dd>Raffaele Scaduto-Mendola - <a href="http://www.turbolinea.com/" eudora= "autourl">www.turbolinea.com</a><br>
<dd> raffaele@(protected)<br>
<dd>---<br>
<dd>Unsubscribe? Mail Majordomo@(protected) with the following text in body: <br>
<dd>unsubscribe xsi</blockquote><br>
<dd>---<br>
<dd>Unsubscribe? Mail Majordomo@(protected) with the following text in body: <br>
<dd>unsubscribe xsi</blockquote> </dl></blockquote></body> </html>
|
|
 |