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
    • Recent
    • Tags
    • Users
    • Login

    Particle systems (again)

    Scheduled Pinned Locked Moved SDK Help
    4 Posts 0 Posters 527 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 23/06/2011 at 06:50, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   R12 
      Platform:   Windows  ;   
      Language(s) :     C++  ;

      ---------
      I'm completely stuck with this one. I'm still writing my particle emitter and it's working pretty well, but I have a problem with the emitter generating geometry.

      Here's what's supposed to happen. If you add a standard C4D emitter to a scene, and start it generating objects - let's say a cube is the child of the emitter - then play the animation, when you rotate the emitter any previously-generated cubes carry on in the direction they were heading in and new ones move in the new direction after the emitter is rotated.

      In my emitter, the objects work just fine until the emitter is rotated. Then, all previously-generated objects start moving in the new direction and new ones move in the wrong direction. For example, say the emitter is rotated on H to 45 degrees. The existing objects all continue to move along the Z-axis of the emitter, which is now rotated 45 degrees on H, while new objects move at 45 degrees to the emitter - which in world coordinates is 90 degrees on H. I should add, the positions of the actual particles are correct, it's the position of the geometry that's wrong.

      I've tried setting the position of the objects in many ways but none make any difference. Here's the code (irrelevant stuff removed) that I'm using, this is called in GetVirtualObjects() :

        
      if(bc->GetBool(PARTICLES_EMITTER_GEOMETRY))   
      {   
           // generate geometry if required   
           BaseObject *orig = op->GetDown();          // first child of the emitter   
           if(orig)   
           {   
                // create a null object to hold multiple copies of the generated object   
                basenull = BaseObject::Alloc(Onull);   
                if(basenull)   
                {   
                     for (i = 0; i < particleCount; i++)     // for each particle   
                     {   
                          // pointer to the generated object held in a class which is a subclass of the SDK Particle class   
                          pt[i].obj = NULL;   
                          // if particle is still active                       
                          if(pt[i].alive)   
                          {   
                               // clone the child object   
                               pt[i].obj = static_cast<BaseObject*>(orig->GetClone(COPYFLAGS_0, NULL));   
                               // insert it under the null object   
                               pt[i].obj->InsertUnderLast(basenull);   
                               // set the absolute position of the new object from the corresponding particle position   
                               pt[i].obj->SetAbsPos(pt[i].off);   
                          }   
                     }   
                     // return the new object chain   
                     return basenull;   
                }   
           }   
      }   
        
      

      What I don't understand is that I'm setting the generated object's absolute position, so why does the object move in a direction which appears to be relative to the emitter? I've also tried setting the global matrix of the cloned object, and get the same result.

      I'd be very grateful for any comments, particularly as to whether I'm going about this the right way or if I should be doing something completely different. Is this the correct method to generate geometry from a particle emitter, using GetVirtualObjects(), or is it just plain wrong?

      Many thanks,

      Steve

      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 23/06/2011 at 07:08, xxxxxxxx wrote:

        so, your drawn particles go ahead in the right direction but your cubes don't ?
        What about multiplying the cube's positions with the inverted Matrix of your emitter ?

        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 23/06/2011 at 07:51, xxxxxxxx wrote:

          That's correct. Not tried the inverted matrix, I'll try that now.

          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 23/06/2011 at 08:00, xxxxxxxx wrote:

            You sir, are a genius. Works like a charm now and behaves like C4D's emitter (which is what I want because it increases consistency for users).

            Thank you!

            Steve

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