@@ -409,20 +409,44 @@ void ParticleSystemQuad::postStep()
409409// CHECK_GL_ERROR_DEBUG();
410410// }
411411
412-
413412void ParticleSystemQuad::draw ()
414413{
415414 CCASSERT ( _particleIdx == _particleCount, " Abnormal error in particle quad" );
416- kmGLGetMatrix (KM_GL_MODELVIEW, &_transformMatrix);
417-
418- CustomCommand* cmd = CustomCommand::getCommandPool ().generateCommand ();
419- cmd->init (0 , _vertexZ);
420- cmd->func = CC_CALLBACK_0 (ParticleSystemQuad::onDraw, this );
421- Renderer::getInstance ()->addCommand (cmd);
415+ // quad command
416+ if (_particleIdx > 0 )
417+ {
418+ // transform vertices
419+ std::vector<V3F_C4B_T2F_Quad> drawQuads (_particleIdx);
420+ memcpy (&drawQuads[0 ], _quads, sizeof (V3F_C4B_T2F_Quad) * _particleIdx);
421+ AffineTransform worldTM = getNodeToWorldTransform ();
422+ for (int index = 0 ; index <_particleIdx; ++index)
423+ {
424+ V3F_C4B_T2F_Quad* quad = _quads + index;
425+
426+ Point pt (0 ,0 );
427+ pt = PointApplyAffineTransform ( Point (quad->bl .vertices .x , quad->bl .vertices .y ), worldTM);
428+ drawQuads[index].bl .vertices .x = pt.x ;
429+ drawQuads[index].bl .vertices .y = pt.y ;
430+
431+ pt = PointApplyAffineTransform ( Point (quad->br .vertices .x , quad->br .vertices .y ), worldTM);
432+ drawQuads[index].br .vertices .x = pt.x ;
433+ drawQuads[index].br .vertices .y = pt.y ;
434+
435+ pt = PointApplyAffineTransform ( Point (quad->tl .vertices .x , quad->tl .vertices .y ), worldTM);
436+ drawQuads[index].tl .vertices .x = pt.x ;
437+ drawQuads[index].tl .vertices .y = pt.y ;
438+
439+ pt = PointApplyAffineTransform ( Point (quad->tr .vertices .x , quad->tr .vertices .y ), worldTM);
440+ drawQuads[index].tr .vertices .x = pt.x ;
441+ drawQuads[index].tr .vertices .y = pt.y ;
442+
443+ }
444+
445+ QuadCommand* cmd = QuadCommand::getCommandPool ().generateCommand ();
446+ cmd->init (0 , _vertexZ, _texture->getName (), _shaderProgram, _blendFunc, &drawQuads[0 ], _particleIdx);
447+ Renderer::getInstance ()->addCommand (cmd);
448+ }
422449
423- // TODO render particle using quad command
424- // QuadCommand* cmd = new QuadCommand(0, _vertexZ, _texture->getName(), _shaderProgram, _blendFunc, _quads, _particleIdx);
425- // Renderer::getInstance()->addCommand(cmd);
426450}
427451
428452void ParticleSystemQuad::onDraw ()
0 commit comments