THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 03/10/2012 at 19:30, xxxxxxxx wrote:
Ok, I found out some stuff (by trial & error)
I created a document with an emitter that shoots particles. The document also contains a Null. After attaching the following code to the emitter, the Null follows the first particle. No orientation, just position:
import c4d
import struct
def GetDouble(p,buffer) :
# each double takes up 8 bytes
num=struct.unpack("d",buffer[p*8:(p*8)+8])
return float(num[0])
def main() :
emitter=op.GetObject()
# yes, the particles data is in the Tparticle tag of the emitter
p_tag=emitter.GetTag(c4d.Tparticle)
if p_tag is None: return
null=doc.SearchObject("Null")
if null is None:return
# GetLowlevelDataAddressR is for read-only
# GetLowlevelDataAddressW will allow the writing also
# The SDK has them badly spelled
# The "level" is spelled "Level" in the SDK
buffer=p_tag.GetLowlevelDataAddressR()
pos=c4d.Vector(GetDouble(0,buffer),GetDouble(1,buffer),GetDouble(2,buffer))
null.SetAbsPos(pos)
The SDK states that the particle information is:
Position (vector)
Direction (vector)
Wing (Vector)
Lifetime (float)
Bits (bits)
Well on the first 24 bytes of the ByteSeq buffer we have, in fact, Position:
Position.x - Bytes 0 to 7
Position.y - Bytes 8 to 15
Position.z - Bytes 16 to 23
The direction is as follows:
Direction.x - Bytes 24 to 31
Direction.y - Bytes 32 to 39
Direction.z - Bytes 40 to 47
The Wing is as follows:
Wing.x - Bytes 48 to 55
Wing.y - Bytes 56 to 63
Wing.z - Bytes 64 to 71
The direction returns what looks like the orientation of the emitter itself (kind of).
The wing... I really don't know how to interpret it. It looks like the Speed vector. But I would like that anyone more versed on particles to tell me.
From bytes 72 to 79 there is a double that grows slowly from 0.0000 in increments of 0.04 at each frame. That is consistent with my document as it is set to 25 fps, because 1/25 is 0.04
The problem is that it keeps growing even after the particle is gone.
That is because I haven't found out how to know how many particles are alive and whether the particle is alive or not. That is probably in the bits information but I really don't know how to interpret that.
So, with all I found out so far, would anyone help out into finding some more? :-)