View Full Version : Problem assigning rotation to the particlevector

08-20-2010, 04:45 PM
I hope someone can help,

I'm trying to use a pflow script to have object chunks return to their position AND rotation.
The position is working fine if I set the pCont.particleVector = ChunksArray[i].pos
But... if the chunks are spinning, they do not return to their original rotations.

Setting the particlevector to ChunchsArray[i].transform causes the script to fail....

pCont.particleIndex = i
vpos = ChunksArray[i].transform
pCont.particleVector = vpos

Does the particlevector allow you to save the rotation aswell as the position of a particle chunk?

If so, how do I assign the rotation to the particlevector?

Here's my birthscript.

on ChannelsUsed pCont do
pCont.useAge = true
pCont.useTM = true
pCont.useVector = true

on Init pCont do
global ChunksArray = $Teapot* as array
global TM_Reset
-- TM_Reset = undefined

if ChunksArray != undefined do
if TM_Reset == undefined do TM_Reset = true
if TM_Reset do
Global ChunksArray_TM = for i in ChunksArray collect i.transform
TM_Reset = false

on Proceed pCont do
t = pCont.getTimeStart() as float
NumChunks = ChunksArray.count

if t < 0 do
for i = 1 to NumChunks do
pCont.particleIndex = pCont.NumParticles()
pCont.particleAge = 0
pCont.particleTM = ChunksArray_TM[i]
pCont.particleIndex = i
vpos = ChunksArray[i].pos
pCont.particleVector = vpos


on Release pCont do ()

Thanks for any help!

08-20-2010, 06:15 PM
Yes you can store rotation but the particleVector channel only holds one set of vector values, in this case you need at least 2, one for rotation and one for position. Seems we talked about this recently and I am trying to find a sample I whipped up.

A possible solution is to use the particleMatrix channel instead. This gives you the option to store up to 4 sets of vector data, 12 floats, or a single matrix. Just be aware that you need to assign your rotation and position values to a variable before inserting them into the matrixChannel.

You have box#3 don't you? It is way simpler/faster in a data op. You'd simply add a new in event piped to a input standard->position and a input standard->rotation, convert to matrix (select an appropriate channel for each) the out to a output standard-> Script Matrix or out to there own custom data channels for use later.

Then just recall these values in another data op downstream.

I couldn't find the scripted example I did earlier so I made another one. It uses both a Vector and a Matrix channel with a Go To Rotation and a Find Target.

EDIT: argh, something is wrong with the way particleOrientation is storing, it doesn't appear to be correct, I inserted a duplicate flow using data ops work work as they should, the scripted version is bungled for some reason. Working on it...

EDIT EDIT: Seems to be a time accuracy issue, just guessing

Anyway here is that scripted version with a simple box#3 setup in it.

08-23-2010, 05:19 PM
Hey Jonny,
Thanks so much for taking a look at this for me!
I tried your two pflows but I'm struggling to get then to work adequately with object chunks (through a birth script).
Using the data operators, the rotations appear to be working now, but not the positions!
I also noticed in your sample maxfile there are two problems: the rotation doesn't appear to smoothly rotate back to the original orientation, rather it snaps into place in the last frame before stopping. The position also seems inaccurate, but I think you already noticed this... and yes it looks like it's a timing issue.

I've attached your original scene but adjusted to object chunks, and my other scene using object chunks... (max2011 and 2009 respectively).
I wonder if any other pflow gurus can shed some light on where we might be going wrong?

Thanks again!

08-23-2010, 05:56 PM
No worries, be better if I could nail it down.

Me and rotations we are so tight...I think they hate me

Anyway, I tried to emulate the script version as close as possible with box#3 (as simple as it is). To get exact Position/Rotation/Scale using the Transform Matrix never seems to fail. So input the TM in the first op (while leaving the Particle Vector for use with Find Target) Output New it to a new global channel and recall it in the last event (everything should then match up tick for tack). The slow rotation in can be fixed with a Go To Rotation test, I had one but omitted it to make sure the operators were behaving correctly.

hmm, couldn't seem to grab the scene file?

08-23-2010, 09:36 PM
Looked at your scene, as mentioned switch the Euler Angles to TM-Matrix instead, rewire the final data op to reflect the change to TM.

This seems to work ok: Shot_150_Forum_Lozenge02.zip (http://4rand.com/misc/reForm/Shot_150_Forum_Lozenge02.zip)

08-24-2010, 11:53 AM
You, Sir, are a genius... ! That worked perfectly.... what a result!
Thanks again!

CGTalk Moderation
08-24-2010, 11:53 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.