PDA

View Full Version : Particles, rotations and objectTMs


reForm
05-06-2008, 10:48 AM
I'm struggling to understand how to apply transforms and rotations to particles through maxscript.

This thread helped alot in some ways, but I'm still not getting the particle behaviour that I'm looking for. http://forums.cgsociety.org/showthread.php?f=98&t=600307&highlight=pivot+orientation

I'm using the standard object chunks p-flow birth script. But, after resetting my object chunks' x-forms, I want to rotate the object pivots to control the axis of rotation of the particles that are spawned at each object.

If I take a set of columns, for example, along one wall the x axis points away from the wall. I rotate the pivots of the columns on the perpendicular wall so their x-axis point away from the wall(90 degrees). I then want the particles spawned to start at a y rotation of 90 degrees... resulting in all the wall-particles to point out from the wall.

I've managed to get some control of the particles using a rotation, but they seem to be getting rotated around the pflow pivot.

in my birth script:

otm = ChunksArray[tt].objectTransform
piv = ChunksArray[tt].rotation
c_rot = chunksArray[tt].objectoffsetrot
rot = (inverse ((eulerangles 0 90 0) as quat))
nr = rotate otm rot
pCont.particleTM = nr

what is the difference between:
$.rotation
$.objectoffsetrot
$.transform.rotation

and how do they relate to :
pcont.particleTM.rotation
pcont.particleOrientation

I feel I'm getting close to understanding this, but given Eek's admission that it took him 5 years to suss this out, I think I'm just kidding myself ;)

My head hurts.

charleyc
05-08-2008, 12:23 AM
Ok, well since no one else has tackled this, I will offer what information I can off the top of my head and in the time I have right now.

$.rotation == Quaternian rotation value
$.objectoffsetrot == the rotational difference between the Node and its pivot (achieved if you rotate the pivot using Affect Pivot Only or Affect Object Only)
$.transform.rotation == same as $.rotation

and how do they relate to :
pcont.particleTM.rotation --- I am not sure what format this returns, but I would guess it is Euler
pcont.particleOrientation == particle rotation in Euler angles



Post the entire Birth Script and I will take a look at what is going on. Off hand it looks like it is written as it should be to get what you say you want. Although I am not sure you need the c-rot variable unless you have altered your objects pivots.

reForm
05-11-2008, 06:39 PM
Thanks, that kind of confirms what I was thinking.

Now my problem is with rotating using quat values.

If I have an object that is rotated on the x axis 180 degrees. Then I want a key 30 degrees further, ie 210.
With quat rotations i end up with -150 degrees rather than the preferred 210. What is the best way to deal with rotations to avoid this problem?

rot = (eulerangles 30 0 0) as quat
crot= (eulerangles 179 0 0) as quat
a = (rot + crot ) as eulerangles
this gives a = -151

reForm
05-13-2008, 06:35 PM
Ok... I've solved that problem now too... :) Setting the rotation controller directly fixed the issue.

Now, back to particles. I still can't work out how to take the rotation of a chunk to define the rotation of a particle :

If I have a box. Rotate the Pivot 45 degrees in the z-axis so if I was to rotate the object in local coords x, it would rotate towards one of its corners.

If said box is used as a chunk in a pflow, and I try to make the particle do the same rotation by rotating the particleorientatio [45 0 0]. it ALWAYS rotates the particle asthough it never received the orientation from the chunk TM.

This is the code I thought might do the right thing...

a = (ChunksArray[i].transform.rotation as quat)
r = ((eulerangles 90 0 0) as quat) * a
pCont.particleIndex = i
pCont.particleTM.rotation = r

Any help much appreciated!

reForm
05-13-2008, 06:48 PM
trying to apply a value to pCont.particleTM.rotation doesnt seem to do anything at all. Is the only way of applying orientation to a particle through pCont.particleOrientation?

reForm
05-13-2008, 07:08 PM
I "THINK" I might have made some progress...

a = ChunksArray[tt].objectOffsetRot as eulerangles
aq = ChunksArray[tt].objectOffsetRot
r = (eulerangles 0 0 0)
rq = (eulerangles 90 0 0) as quat
nr = (inverse aq * rq) as eulerangles
pCont.particleorientation = [ nr.x, nr.y, nr.z]


It looks like I'm getting the orientation of the source chunk to be passed to the orientation of the particles...

Am I going in the right direction?

CGTalk Moderation
05-13-2008, 07:08 PM
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.