Here is how to read standard particle values
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 04/10/2012 at 09:29, xxxxxxxx wrote:
import c4d import struct # return the number of active particles def P_count(buffer) : count=0 for i in range(len(buffer)/88) : index=i*88 bits=int(struct.unpack("B",buffer[index+80:index+81])[0]) count+=(bits!=0) return count # return the ALIVE value of the particle p (0 or 1) def P_alive(p,buffer) : index=p*88 bits=int(struct.unpack("B",buffer[index+80:index+81])[0]) return (bits & 2) >> 1 # return the VISIBLE value of the particle p (0 or 1) def P_visible(p,buffer) : index=p*88 bits=int(struct.unpack("B",buffer[index+80:index+81])[0]) return (bits & 1) # returns the vector of the current position of particle p def P_position(p,buffer) : index=p*88 return c4d.Vector(struct.unpack("d",buffer[index:index+8])[0],struct.unpack("d",buffer[index+8:index+16])[0],struct.unpack("d",buffer[index+16:index+24])[0]) # returns the vector of the current direction of particle p def P_direction(p,buffer) : index=p*88 return c4d.Vector(struct.unpack("d",buffer[index+24:index+32])[0],struct.unpack("d",buffer[index+32:index+40])[0],struct.unpack("d",buffer[index+40:index+48])[0]) # returns the vector of the current wing of particle p def P_wing(p,buffer) : index=p*88 return c4d.Vector(struct.unpack("d",buffer[index+48:index+56])[0],struct.unpack("d",buffer[index+56:index+64])[0],struct.unpack("d",buffer[index+64:index+72])[0]) # returns the life of particle p (double) def P_lifetime(p,buffer) : index=p*88 return struct.unpack("d",buffer[index+72:index+80]) def main() : emitter=op.GetObject() p_tag=emitter.GetTag(c4d.Tparticle) if p_tag is None: return buffer=p_tag.GetLowlevelDataAddressW() count=P_count(buffer) # gets the number of active particles for i in range(count) : print "Particle "+str(i) # print the particle number print P_alive(i,buffer) # print the active state of the particle print P_visible(i,buffer) # print the visibility of the particle print P_position(i,buffer) # print the current position of the particle print P_direction(i,buffer) # print the current direction of the particle print P_wing(i,buffer) # print the current wing of the particle print P_lifetime(i,buffer) # print the lifespan value of the particle print " "
Now I only have two doubts.
The direction is not returning the particle direction but it is, in fact, returning a value that corresponds, somehow, to the direction of the emitter. What is this for?
And I don't know how to interpret the wing value.
Could someone help me out on this? -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/10/2012 at 06:55, xxxxxxxx wrote:
Hy Rui,
thank you for sharing!
Cheers,
André -
On 08/07/2015 at 08:25, xxxxxxxx wrote:
Hum... it's hard to read inside those particles...
Particle 12
Ӏ웖_ڻ!__/tg@__________________________________________"@_____________G٦E\_>@Yt*Է;@_Sf@__________________________________________"@_____________qO_Gp:@___Ƞ_)9__Tâd@__________________________________________"@_____________F_Ucۺwf_Ķ_S____________________________________________"@ݝݝݝ�_______Zn_ꒈ$ـ],_@_c@__________________________________________"@ݝݝݝ�_______qK_-GZC@xұpÖB@1n__@__________________________________________"@_____________ɜқ__E o̊0ȿ@_-u______________________What is this?
But what I really want is to change their attributes through my code... (nope... don't have thinking particles on my version)
Thanks
-
On 08/07/2015 at 09:09, xxxxxxxx wrote:
WOW!!! That is weird!!
Do you get regular readings from all particles before particle 12 or does it just happens at that particle?
You should get something like:Particle 0
1
1
Vector(-49.997, -27.852, 9.157)
Vector(1, 0, 0)
Vector(0, 0, 150)
(0.040000000000000001,)Particle 1
1
1
Vector(30.576, 27.968, 10.678)
Vector(1, 0, 0)
Vector(0, 0, 150)
(0.040000000000000001,)Particle 2
1
1
Vector(26.439, -12.844, 10.586)
Vector(1, 0, 0)
Vector(0, 0, 150)
(0.040000000000000001,)Particle 3
1
1
Vector(-0.663, -22.766, 9.231)
Vector(1, 0, 0)
Vector(0, 0, 150)
(0.040000000000000001,)Particle 4
1
1
Vector(-6.696, 5.894, 8.196)
Vector(1, 0, 0)
Vector(0, 0, 150)
(0.040000000000000001,)Particle 5
1
1
Vector(38.705, 36.178, 9.354)
Vector(1, 0, 0)
Vector(0, 0, 150)
(0.040000000000000001,)p.s. It is weird for two portuguese people to be talking in english
-
On 08/07/2015 at 09:55, xxxxxxxx wrote:
Ho... lol no... you code works like a charm....
the thing is that I made a function called 'set_position(p,buffer)' and then printed
struct.unpack("d",buffer[index:index+8])[0],
struct.unpack("d",buffer[index+8:index+16])[0],
struct.unpack("d",buffer[index+16:index+24])[0]I also printed the buffer to check what it was... and gave that...
Well, I was able to accomplish sort of what I wanted from another approach:
if emitter.CheckType(c4d.Oparticle) and emitter.GetDown() and emitter.GetCache() : emittercache = emitter.GetCache() particles = emittercache.GetChildren() i = 0 for particle in particles: particle.SetAbsPos(someVector) i += 1
but I keep interested in checking if it's possible to assign position to each particle with your approach...
I'm trying to read cvs files with position of stars (as well as other stuff like intensity and color) and create those particles with those attributes to control a point light (experimenting hehe)
Not sure how far I can go, but... since I have no Thinking Particles, I'm learning standard particles
Haven't checked what 'struck' and 'unpack' does...
PS: Hehe well... let's keep EN for others
-
On 08/07/2015 at 10:53, xxxxxxxx wrote:
I don't mess with this subject for a long time.
So, I never investigated further (and I only needed this to read the values, no writing).
Maybe it should be questioned in the forum, so that the official Maxon programmers could say something about it. -
On 08/07/2015 at 23:30, xxxxxxxx wrote:
The info is here:
c4d.modules.particles.Particle:
https://developers.maxon.net/docs/py/2023_2//help/modules/c4d.modules/particles/Particle/index.html#c4d.modules.particles.Particlewe can check everything here:
https://developers.maxon.net/docs/py/2023_2//help/misc/diagram.htmlThanks mate!