reForm
05-13-2008, 08:30 PM
I'm trying to use object-chunks pflow birth script but with the added joy of being able to retain the pivot orientation of the source mesh's within the particle.
When pflow creates the chunks, the particle rotations are all [0 0 0] rather than the rotation that I have specified by rotating the mesh pivots.
The script below is getting close to what I want but some objects are 180 degrees off of what they should be if I was to local-rotate the source objects. I assume its because I'm using euler and quat values when I need to use angleaxis values.
Any ideas how I can fix the math to get the result I'm looking for?
on Proceed pCont do
(
t = pCont.getTimeStart() as float
if t > 0 do
(
NumChunks = ChunksArray.count
tt = ((t/160))
if tt < NumChunks do
(
pCont.AddParticle()
pCont.particleIndex = pCont.NumParticles()
pCont.particleAge = 0
pCont.particleTM = ChunksArray[tt].objecttransform
pCont.particleShape = ChunksArray[tt].mesh
a = ChunksArray[tt].objectOffsetRot as eulerangles
aq = ChunksArray[tt].objectOffsetRot
rq = (eulerangles 90 0 0) as quat
nr = (inverse aq * rq) as eulerangles
pCont.particleorientation = [ nr.x,nr.y,nr.z]
)
)
)
My other thought is I need to normalise the quat values.... but then again, I dont actually understand what normalising a quat value does! Can anyone care to explain what it does, and in what situations you would want to normalise quat values?
When pflow creates the chunks, the particle rotations are all [0 0 0] rather than the rotation that I have specified by rotating the mesh pivots.
The script below is getting close to what I want but some objects are 180 degrees off of what they should be if I was to local-rotate the source objects. I assume its because I'm using euler and quat values when I need to use angleaxis values.
Any ideas how I can fix the math to get the result I'm looking for?
on Proceed pCont do
(
t = pCont.getTimeStart() as float
if t > 0 do
(
NumChunks = ChunksArray.count
tt = ((t/160))
if tt < NumChunks do
(
pCont.AddParticle()
pCont.particleIndex = pCont.NumParticles()
pCont.particleAge = 0
pCont.particleTM = ChunksArray[tt].objecttransform
pCont.particleShape = ChunksArray[tt].mesh
a = ChunksArray[tt].objectOffsetRot as eulerangles
aq = ChunksArray[tt].objectOffsetRot
rq = (eulerangles 90 0 0) as quat
nr = (inverse aq * rq) as eulerangles
pCont.particleorientation = [ nr.x,nr.y,nr.z]
)
)
)
My other thought is I need to normalise the quat values.... but then again, I dont actually understand what normalising a quat value does! Can anyone care to explain what it does, and in what situations you would want to normalise quat values?
