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:
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() :
// generate geometry if required
BaseObject *orig = op->GetDown(); // first child of the emitter
// create a null object to hold multiple copies of the generated object
basenull = BaseObject::Alloc(Onull);
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
// clone the child object
pt[i].obj = static_cast<BaseObject*>(orig->GetClone(COPYFLAGS_0, NULL));
// insert it under the null object
// set the absolute position of the new object from the corresponding particle position
// return the new object chain
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?
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 ?
On 23/06/2011 at 07:51, xxxxxxxx wrote:
That's correct. Not tried the inverted matrix, I'll try that now.
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).