Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Get the (standard) particles information

    Scheduled Pinned Locked Moved PYTHON Development
    17 Posts 0 Posters 1.5k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 04/10/2012 at 08:57, xxxxxxxx wrote:

      I think this post might be of interest: https://developers.maxon.net/forum/topic/5919/6005_tparticle-data-not-available-in-python&PID=26813#26813

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 04/10/2012 at 09:23, xxxxxxxx wrote:

        That solution only works if there are objects as childs of the emitter and the "Show Objects" option is on.
        I want to be able to access the particle values even if there are no objects being created.
        And the good news are... I DID IT!!! 🙂
        Check out the code:

          
        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 " "   
        
        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 04/10/2012 at 09:25, xxxxxxxx wrote:

          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.
          And I don't know how to interpret the wing value.
          Could someone help me out on this?

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 05/10/2012 at 01:10, xxxxxxxx wrote:

            Originally posted by xxxxxxxx

            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.
            And I don't know how to interpret the wing value.
            Could someone help me out on this?

            All the information you're getting about a particle is listed and explained in the members of c4d.modules.particles.Particle (Python documentation).

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 05/10/2012 at 01:13, xxxxxxxx wrote:

              Originally posted by xxxxxxxx

              That solution only works if there are objects as childs of the emitter and the "Show Objects" option is on.
              I want to be able to access the particle values even if there are no objects being created.
              And the good news are... I DID IT!!! 🙂

              Ah ok, I understand now why you couldn't use this solution. Glad you found how to read the particles data.

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 05/10/2012 at 08:28, xxxxxxxx wrote:

                However, the information in the SDK about the standard particles is almost non-existent.
                Shouldn't it be more clear?

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 08/10/2012 at 02:36, xxxxxxxx wrote:

                  Originally posted by xxxxxxxx

                  However, the information in the SDK about the standard particles is almost non-existent.
                  Shouldn't it be more clear?

                  Have you looked into the Python docs (not COFFEE) at the page for the class c4d.modules.particles.Particle? I don't think there's more to add.

                  1 Reply Last reply Reply Quote 0
                  • H Offline
                    Helper
                    last edited by

                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                    On 08/10/2012 at 05:25, xxxxxxxx wrote:

                    Yes, I have looked into it, Yannick.
                    It tells me what information is present but it doesn't tell me where it is, how to get it, etc.

                    1 Reply Last reply Reply Quote 0
                    • H Offline
                      Helper
                      last edited by

                      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                      On 08/10/2012 at 06:03, xxxxxxxx wrote:

                      Originally posted by xxxxxxxx

                      However, the information in the SDK about the standard particles is almost non-existent.
                      Shouldn't it be more clear?

                      Yes, it should.

                      Cheers,
                      André

                      1 Reply Last reply Reply Quote 0
                      • H Offline
                        Helper
                        last edited by

                        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                        On 08/10/2012 at 07:53, xxxxxxxx wrote:

                        Also, besides not telling us how to get the raw data, it doesn't tells us how to get the elements out of the data.
                        As you can see from my exemplar above, it is not a straightforward method.

                        Rui Batista

                        1 Reply Last reply Reply Quote 0
                        • H Offline
                          Helper
                          last edited by

                          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                          On 08/10/2012 at 09:03, xxxxxxxx wrote:

                          Originally posted by xxxxxxxx

                          Also, besides not telling us how to get the raw data, it doesn't tells us how to get the elements out of the data.
                          As you can see from my exemplar above, it is not a straightforward method.

                          Rui Batista

                          The C++ documentation states that the array of particles is private (ParticleTag docs' page).
                          In fact the issue is: the C++ SDK's ParticleObject class isn't wrapped in Python. This class allows to easily access the particle array without having to figure how the particles are stored in memory.

                          1 Reply Last reply Reply Quote 0
                          • H Offline
                            Helper
                            last edited by

                            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                            On 08/10/2012 at 09:37, xxxxxxxx wrote:

                            So, should it be in the python SDK in the current form?
                            Because, as it is now, it shows information that is not accessible directly.

                            Rui Batista

                            1 Reply Last reply Reply Quote 0
                            • H Offline
                              Helper
                              last edited by

                              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                              On 09/10/2012 at 01:42, xxxxxxxx wrote:

                              Originally posted by xxxxxxxx

                              So, should it be in the python SDK in the current form?
                              Because, as it is now, it shows information that is not accessible directly.

                              Particle class is used when overriding ObjectData.ModifyParticles(). I think it was wrapped for that purpose. But yes, it should be possible to access directly the particles in an emitter with the Python SDK.

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post