  | | | Objects 2 particles scripts not working!? | Objects 2 particles scripts not working!? 2005-04-24 - By brad
Back Yes it's a snapshot of 1 frame, and it shows how to grab transforms out of a particle cloud.
To get motion on the nulls, there are options: 1- Plot the particle path, then constrain a null to the path. Rotation is derived from path tangency. 2- Plot the particle position and rotation values per frame directly to the local transform of the null. 3- Write a scripted op that counts particles and grabs position and rotation data continuously.
Options 1 and 2 are easier to script, but different from eachother. They also are a a shot deal, so if you tune the cloud, you have to re-run the script.
Option 3 is harder to script, slower in performance, but would create live links to your cloud.
Option 2 would be easy to derive from the scripts I've already posted, since the hard part of getting the transforms out of the cloud and onto a null is already taken care of. It would need to be made into a loop that grabs the transforms per frame, then plots them.
I'll be on a long flight home shortly, so if nobody else picks up from here I can write option 2, but it may be a couple of days.
-Brad
-- ----Original Message-- ---- > That did the trick! Am I correct in assuming this is a sort of snapshot > particles script - it doesn't constrain the nulls to the particles so the > nulls follow the animation!? > > Morten > > > On Sun, 24 Apr 2005 04:44:58 +0000, "brad" <brad@(protected)> wrote : > > > It is indeed jscript. When you install the script, make sure to press > the parse button at the bottom of the install PPG. > > > > In XSI, you can have a single script file with many functions. When you > parse the script, you can specify which function and input arguments you > want XSI to run when you run the command or press the button. In this > case, there is only one function, so that one will be selected by default. > > > > -Brad > > -- ----Original Message-- ---- > > >��Thanks again Brad - that seems to want to do the trick. > > >�� > > >��Now I have little clue about scripting - from the syntax I am guessing > > >��this is jscript, so I gave it a .js extension, changed XSI scripting > to > > >��jscript, selected the cloud and tried running it, but it doesn't > really do > > >��anything in that case. How do I put it to use? > > >�� > > >��I really appreciate you taking the time Brad. > > >�� > > >��best > > >��Morten > > >�� > > >�� > > >�� > > >��On Sat, 23 Apr 2005 18:57:07 +0000, "brad" <brad@(protected)> wrote : > > >�� > > >��> There's no pleasing some people! :-) > > >��> > > >��> Here's a version that only works on clouds (since a point collection > > >��doesn't have rotation data), and includes rotation and scale in the > > >��transform. I'm also grabbing the size from the particle and setting > the > > >��null size parameter. You could use the particle size to set the null > scale > > >��if you want: > > >��> > > >��> function NullsOnCloud(inCloud) > > >��> { > > >��> ��if(!inCloud) inCloud = selection(0); > > >��> > > >��> ��// Get global transform from inCloud > > >��> ��var gTrans = inCloud.kinematics.global.transform; > > >��> > > >��> ��// Get particle collection from inCloud > > >��> ��var particles = inCloud.ActivePrimitive.particles; > > >��> > > >��> ��// For each particle, create a null and transform it to the point > > >��> ��var rootNull = ActiveSceneRoot.AddNull('ParticleNulls'); > > >��> ��for(var i=0; i<particles.count; i++){ > > >��> > > >��> �� ��var pTrans = XSIMath.CreateTransform(); > > >��> > > >��> �� ��// Set local translation from particle > > >��> �� ��var pos = particles(i).position; > > >��> �� ��pTrans.SetTranslation(pos); > > >��> > > >��> �� ��// Set local rotation from particle > > >��> �� ��var rot = particles(i).rotation; > > >��> �� ��pTrans.SetRotationFromXYZAngles(rot); > > >��> > > >��> �� ��// Multiply local transform by global trans of cloud > > >��> �� ��pTrans.MulInPlace(gTrans); > > >��> > > >��> �� ��// Create null and set global transform > > >��> �� ��var node = rootNull.AddNull('particle' + i + 'Null'); > > >��> �� ��node.kinematics.global.transform = pTrans; > > >��> > > >��> �� ��// Set the size of the null from the particle size > > >��> �� ��node.size.value = particles(i).size; > > >��> ��} > > >��> } > > >��> > > >��> > > >��> > > >��> -- ----Original Message-- ---- > > >��> >��Thanks Brad! I will give it a spin. From looking through it, it > > >��doesn't > > >��> >��give me particle rotations though does it? > > >��> >�� > > >��> >�� > > >��> >��Morten > > >��> >�� > > >��> >�� > > >��> >��On Sat, 23 Apr 2005 18:14:14 +0000, "brad" <brad@(protected)> > wrote : > > >��> >�� > > >��> >��> Below is a function that creates a null on each point of any > input > > >��> >��object (poly, nurb, or cloud). It can be parsed and made into a > > >��command > > >��> >��button which will work on any selected object. It should be > pretty > > >��easy to > > >��> >��hack if you need to replace the nulls with your own collection of > > >��objects: > > >��> >��> > > >��> >��> function NullsOnPoints(inObj) > > >��> >��> { > > >��> >��> ��// If nothing input, use the selection > > >��> >��> ��if(!inObj) inObj = selection(0); > > >��> >��> > > >��> >��> ��// Get global transform from inObj > > >��> >��> ��var gTrans = inObj.kinematics.global.transform; > > >��> >��> ��var pTrans = XSIMath.CreateTransform(); > > >��> >��> > > >��> >��> ��// Get point collection from inObj > > >��> >��> ��var points = inObj.ActivePrimitive.geometry.points; > > >��> >��> > > >��> >��> ��// For each point, create a null and transform it to the > point > > >��> >��> ��var rootNull = ActiveSceneRoot.AddNull('PosNulls'); > > >��> >��> ��for(var i=0; i<points.count; i++){ > > >��> >��> > > >��> >��> �� ��// Get position vector of point > > >��> >��> �� ��var pos = points(i).position; > > >��> >��> > > >��> >��> �� ��// Multiply position by the global transform of > the object > > >��> >��center > > >��> >��> �� ��pos.MulByTransformationInPlace(gTrans); > > >��> >��> �� ��pTrans.SetTranslation(pos); > > >��> >��> > > >��> >��> �� ��// Create null and set global transform > > >��> >��> �� ��var node = rootNull.AddNull('pnt' + i + 'Null'); > > >��> >��> �� ��node.kinematics.global.transform = pTrans; > > >��> >��> ��} > > >��> >��> } > > >��> >��> // END FUNCTION -- ---- ---- ---- ---- ---- ---- ---- --- > > >��> >��> > > >��> >��> > > >��> >��> -Brad > > >��> >��> CG Soup > > >��> >��> > > >��> >��> > > >��> >��> -- ----Original Message-- ---- > > >��> >��> >��I need to put objects on particles - not particle instances > as I > > >��need > > >��> >��to > > >��> >��> >��see where objects intersect with a collision surface. I > tried the > > >��> >��various > > >��> >��> >��scripts for attaching objects to particles, but they all > fail :( > > >��> >��> >�� > > >��> >��> >��I tried Olivier Lelardoux original one as well as the > modified > > >��ones by > > >��> >��> >��Todd Akita and Eric Lampi. They fail with different > messages and > > >��I > > >��> >��can't > > >��> >��> >��seem to get them to work, so I'm thinking maybe they don't > work > > >��in > > >��> >��4.2!? > > >��> >��> >�� > > >��> >��> >��I have tried all different combinations on picking > sessions, but > > >��> >��still no > > >��> >��> >��go - has anyone tried and made one of these scripts work in > 4.2 > > >��and > > >��> >��if so, > > >��> >��> >��could you give me a short do's and dont's list? > > >��> >��> >�� > > >��> >��> >��TIA! > > >��> >��> >�� > > >��> >��> >�� > > >��> >��> >��-- > > >��> >��> >��best regards > > >��> >��> >�� > > >��> >��> >��Morten Bartholdy > > >��> >��> >��Colorshop VFX > > >��> >��> >��Denmark > > >��> >��> >��--- > > >��> >��> >��Unsubscribe? Mail Majordomo@(protected) with the following > > >��text in > > >��> >��body: > > >��> >��> >��unsubscribe xsi > > >��> >��> -- ----Original Message-- ---- > > >��> >��> --- > > >��> >��> Unsubscribe? Mail Majordomo@(protected) with the following > text in > > >��> >��body: > > >��> >��> unsubscribe xsi > > >��> >��> > > >��> >��> > > >��> >��> > > >��> >�� > > >��> >��-- > > >��> >��best regards > > >��> >�� > > >��> >��Morten Bartholdy > > >��> >��Colorshop VFX > > >��> >��Denmark > > >��> >�� > > >��> >��--- > > >��> >��Unsubscribe? Mail Majordomo@(protected) with the following > text in > > >��body: > > >��> >��unsubscribe xsi > > >��> -- ----Original Message-- ---- > > >��> > > >��> --- > > >��> Unsubscribe? Mail Majordomo@(protected) with the following text in > > >��body: > > >��> unsubscribe xsi > > >��> > > >��> > > >��> > > >�� > > >��-- > > >��best regards > > >�� > > >��Morten Bartholdy > > >��Colorshop VFX > > >��Denmark > > >�� > > >�� > > >��--- > > >��Unsubscribe? Mail Majordomo@(protected) with the following text in > body: > > >��unsubscribe xsi > > -- ----Original Message-- ---- > > > > --- > > Unsubscribe? Mail Majordomo@(protected) with the following text in > body: > > unsubscribe xsi > > > > > > > > -- > best regards > > Morten Bartholdy > Colorshop VFX > Denmark > > > --- > Unsubscribe? Mail Majordomo@(protected) with the following text in body: > unsubscribe xsi -- ----Original Message-- ----
--- Unsubscribe? Mail Majordomo@(protected) with the following text in body: unsubscribe xsi
|
|
 |