  | | | Create2DSkeleton/AppendBone root problem... | Create2DSkeleton/AppendBone root problem... 2005-06-15 - By Morten Bartholdy
Back That's a gem Brad :)
-
Morten Bartholdy 3D & VFX Artist
-- -- Original Message -- -- From: Bradley R. Gabe To: 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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=iso-8859 (See http://iso-8859.ora-code.com)-1"> <META content="MSHTML 6.00.2800.1498" name=GENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=#ffffff> <DIV><FONT face=Arial size=2>That's a gem Brad :)</FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>-</FONT></DIV> <DIV> </DIV> <DIV><FONT face=Arial size=2>Morten Bartholdy<BR>3D & VFX Artist<BR><BR></FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <BLOCKQUOTE dir=ltr style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"> <DIV style="FONT: 10pt arial">-- -- Original Message -- -- </DIV> <DIV style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B> <A title=brad@(protected) href="mailto:brad@(protected)">Bradley R. Gabe</A> </DIV> <DIV style="FONT: 10pt arial"><B>To:</B> <A title=XSI@(protected) href="mailto:XSI@(protected)">XSI@(protected)</A> ; <A title=XSI@(protected) href="mailto:XSI@(protected)">XSI@(protected)</A> </DIV> <DIV style="FONT: 10pt arial"><B>Sent:</B> Wednesday, June 15, 2005 2:44 AM</DIV> <DIV style="FONT: 10pt arial"><B>Subject:</B> Re: Create2DSkeleton/AppendBone root problem...</DIV> <DIV><BR></DIV>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><FONT face="Courier New, Courier" color=#008000>// BEGIN SCRIPT -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<BR>// Create SIVector3 objects to store position vectors<BR></FONT><FONT face="Courier New, Courier">var rootPos = XSIMath.CreateVector3();<BR>var effPos = XSIMath.CreateVector3();<BR><BR></FONT><FONT face="Courier New, Courier" color=#008000>// Define Chain normal plane<BR></FONT><FONT face="Courier New, Courier">var normalArr = [0,1,0];<BR><BR></FONT><FONT face="Courier New, Courier" color=#008000>// Get the global transforms from your first 2 selected objects<BR></FONT><FONT face="Courier New, Courier">var rootTrans = selection(0).kinematics.global.transform;<BR>var effTrans = selection(1).kinematics.global.transform;<BR><BR></FONT><FONT face="Courier New, Courier" color=#008000>// Pull the position vectors from the transform objects<BR></FONT><FONT face="Courier New, Courier">rootTrans.GetTranslation(rootPos);<BR>effTrans .GetTranslation(effPos);<BR><BR></FONT><FONT face="Courier New, Courier" color=#008000>// Create your chain root<BR></FONT><FONT face="Courier New, Courier">var root = ActiveSceneRoot.Add3DChain(rootPos, effPos, normalArr, "ChainRoot");<BR>var bone0 = root.bones(0);<BR><BR></FONT><FONT face="Courier New, Courier" color=#008000>// Finish off the rest of the chain from the rest of the selection<BR></FONT><FONT face="Courier New, Courier">for(var i=2; i<selection.count; i++){<BR><BR><X-TAB> </X-TAB>/ / Grab the global trans off the current item<BR><X-TAB> </X-TAB >effTrans = selection(i).kinematics.global.transform;<BR><X-TAB> </X-TAB><BR><X-TAB> </X-TAB>// Pull the position vector from the global transform;<BR><X-TAB> </X-TAB >effTrans.GetTranslation(effPos);<BR><X-TAB> </X-TAB><BR><X-TAB> < /X-TAB>root.AddBone(effPos);<BR>}<BR><BR></FONT><FONT face="Courier New, Courier" color=#008000>// Get the global transform off the first bone<BR></FONT><FONT face="Courier New, Courier">var boneTrans = bone0.kinematics.global.transform; <BR><BR></FONT><FONT face="Courier New, Courier" color=#008000>// Assign the root and the first bone to the first bone's global trans<BR></FONT><FONT face="Courier New, Courier">root.kinematics.global.transform = boneTrans;<BR>bone0.kinematics.global.transform = boneTrans;<BR></FONT><FONT face="Courier New, Courier" color=#008000>// END SCRIPT -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<BR><BR> <BR></FONT> <BLOCKQUOTE class=cite cite="" type="cite">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>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 class=cite cite="" type="cite">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>My procedure involves creating the first bone in the chain using<BR><BR>1- Create2DSkeleton command to generate the first bone<BR>2- zero out the root to match a null correctly oriented.<BR>3- zero out the first joint.<BR>3- AppendBone to add additional bones.<BR><BR>Unfortunately, every time I use an AppendBone command, it seem to re-orient the root and throws off the rotation bone values.<BR><BR>If anyone has a better procedure for handling chain ganeration, with zeroing bones ???<BR><BR><BR>THX<BR>RSM<BR><BR>__ ____ ____ ____ ____ ____ ____ ____ __ __ ____ _____<BR>Raffaele Scaduto-Mendola - <A href="http://www.turbolinea.com/" eudora="autourl">www.turbolinea.com</A><BR> raffaele@(protected)<BR>---<BR>Unsubscribe? Mail Majordomo@(protected) with the following text in body:<BR>unsubscribe xsi</BLOCKQUOTE><BR>---<BR>Unsubscribe? Mail Majordomo@(protected) with the following text in body:<BR>unsubscribe xsi<BR></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>
|
|
 |