THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 02/06/2011 at 08:23, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R12
Platform:
Language(s) : C++ ;
---------
Like several others here have done, I'm trying to write my own particle system. At the moment I have got it to the stage where particles are emitted, move as required, and die at the right point. However, it all falls down when I move/rotate my emitter object while the particles are being emitted.
What should happen is that the particles emitted up to the point I move the emitter carry on in the direction they were moving before the move. What actually happens is that, for example, if I move the emitter along the X-axis, *all* the particles - new and old - are moved that distance along X as well.
Here's the very simple draw code in the plugin (it's a generator plugin). The object 'pt' is an array of particles:
DRAWRESULT MyParticle::Draw(BaseObject *op, DRAWPASS drawpass, BaseDraw *bd, BaseDrawHelp *bh)
{
LONG i;
Matrix mx;
if(drawpass != DRAWPASS_OBJECT)
return DRAWRESULT_SKIP;
mx = bh->GetMg();
bd->SetMatrix_Matrix(NULL, mx);
for(i = 0; i < particleCount; i++)
{
if(pt[i].alive)
bd->DrawSphere(pt[i].off, pt[i].size, pt[i].col, 0);
}
return DRAWRESULT_OK;
}
The particle class is a subclass of the C4D Particle class and the initial position of the particle is set relative to the emitter position. I'm a bit puzzled as to how I correct this behaviour. What it seems I need to do is convert the particle position into a global position rather than a relative one, but is that the right approach? Am I using SetMatrix_Matrix correctly? I'd be grateful for any pointers in the right direction!
Steve