Mailing List
Home
Forum Home
Softimage
Carrara
trueSpace
Dir3d-l
Maya - a powerful 3D animation and visual effects software
Macromedia Flash Development
Subjects
Cameras
scaleDown command
black out solved
Aircraft Tutorial
Mathematical XYZ ?
Its done This vs That
Its done first week
recommendations for screen video captures?
3DExplorer "Oddity "
New Director
ProTeam renewals
Fuel 's new websites (X post)
Blue peter create a make toy
targeting groups question
XPost: Shockwave 3D game ( sort of )
RES: RES: RES: Fish Modeling
Emitting particles from object intersection
Fuel 's new websites (X post)
Texturing
Big Break Contest Videos
New Plugins
Models and Texture on my updated site
Error Installing Patch tS6 6
Plasma?
Looking for Inspiration
Weird EMail Q
It 's done first week ?
Cherry not cranberry
New game
Camera Animation Problem
Particle plugins?
 
Create2DSkeleton/AppendBone root problem...

Create2DSkeleton/AppendBone root problem...

2005-06-14       - By Bradley R. Gabe

 Back
Reply:     1     2     3     4     5     6     7  

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>
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,
&quot;ChainRoot&quot;);<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&lt;selection.count; i++){<br><br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>// Grab
the global trans off the current item<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>effTrans =
selection(i).kinematics.global.transform;<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>// Pull
the position vector from the global transform;<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>effTrans
.GetTranslation(effPos);<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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 type=cite class=cite 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 type=cite class=cite 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>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
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></body>
</html>