mirror of https://github.com/axmolengine/axmol.git
Merge pull request #5 from dabingnn/newRendererParticleSystem
New renderer particle system
This commit is contained in:
commit
5f902d95b3
|
@ -409,20 +409,44 @@ void ParticleSystemQuad::postStep()
|
||||||
// CHECK_GL_ERROR_DEBUG();
|
// CHECK_GL_ERROR_DEBUG();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
void ParticleSystemQuad::draw()
|
void ParticleSystemQuad::draw()
|
||||||
{
|
{
|
||||||
CCASSERT( _particleIdx == _particleCount, "Abnormal error in particle quad");
|
CCASSERT( _particleIdx == _particleCount, "Abnormal error in particle quad");
|
||||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_transformMatrix);
|
//quad command
|
||||||
|
if(_particleIdx > 0)
|
||||||
|
{
|
||||||
|
//transform vertices
|
||||||
|
std::vector<V3F_C4B_T2F_Quad> drawQuads(_particleIdx);
|
||||||
|
memcpy(&drawQuads[0], _quads, sizeof(V3F_C4B_T2F_Quad) * _particleIdx);
|
||||||
|
AffineTransform worldTM = getNodeToWorldTransform();
|
||||||
|
for(int index = 0; index <_particleIdx; ++index)
|
||||||
|
{
|
||||||
|
V3F_C4B_T2F_Quad* quad = _quads + index;
|
||||||
|
|
||||||
CustomCommand* cmd = CustomCommand::getCommandPool().generateCommand();
|
Point pt(0,0);
|
||||||
cmd->init(0, _vertexZ);
|
pt = PointApplyAffineTransform( Point(quad->bl.vertices.x, quad->bl.vertices.y), worldTM);
|
||||||
cmd->func = CC_CALLBACK_0(ParticleSystemQuad::onDraw, this);
|
drawQuads[index].bl.vertices.x = pt.x;
|
||||||
Renderer::getInstance()->addCommand(cmd);
|
drawQuads[index].bl.vertices.y = pt.y;
|
||||||
|
|
||||||
|
pt = PointApplyAffineTransform( Point(quad->br.vertices.x, quad->br.vertices.y), worldTM);
|
||||||
|
drawQuads[index].br.vertices.x = pt.x;
|
||||||
|
drawQuads[index].br.vertices.y = pt.y;
|
||||||
|
|
||||||
|
pt = PointApplyAffineTransform( Point(quad->tl.vertices.x, quad->tl.vertices.y), worldTM);
|
||||||
|
drawQuads[index].tl.vertices.x = pt.x;
|
||||||
|
drawQuads[index].tl.vertices.y = pt.y;
|
||||||
|
|
||||||
|
pt = PointApplyAffineTransform( Point(quad->tr.vertices.x, quad->tr.vertices.y), worldTM);
|
||||||
|
drawQuads[index].tr.vertices.x = pt.x;
|
||||||
|
drawQuads[index].tr.vertices.y = pt.y;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QuadCommand* cmd = QuadCommand::getCommandPool().generateCommand();
|
||||||
|
cmd->init(0, _vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &drawQuads[0], _particleIdx);
|
||||||
|
Renderer::getInstance()->addCommand(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
//TODO render particle using quad command
|
|
||||||
// QuadCommand* cmd = new QuadCommand(0, _vertexZ, _texture->getName(), _shaderProgram, _blendFunc, _quads, _particleIdx);
|
|
||||||
// Renderer::getInstance()->addCommand(cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleSystemQuad::onDraw()
|
void ParticleSystemQuad::onDraw()
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
|
|
||||||
#define VBO_SIZE 1024
|
#define VBO_SIZE 8192
|
||||||
#define DEFAULT_RENDER_QUEUE 0
|
#define DEFAULT_RENDER_QUEUE 0
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
Loading…
Reference in New Issue