git-svn-id: svn://db.shs.com.ru/libs@75 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -45,11 +45,12 @@ GLParticlesSystem::GLParticlesSystem(const QVector3D & pos): GLObjectBase() {
|
||||
|
||||
|
||||
void GLParticlesSystem::update() {
|
||||
//qDebug() << "update" << need_birth << tick_birth;
|
||||
if (!active_) return;
|
||||
//QMutexLocker locker(&mutex);
|
||||
Particle cp(lifeDuration_);
|
||||
if (birthEnabled_) need_birth += tick_birth;
|
||||
//qDebug() << "update" << particles.size();
|
||||
qDebug() << "update" << particles.size();
|
||||
if (need_birth >= 1.f) {
|
||||
cp.pos = emitterPosition_;
|
||||
//qDebug() << "speed" << cp.speed;
|
||||
@@ -134,8 +135,10 @@ void GLParticlesSystem::draw(QGLShaderProgram * prog, bool) {
|
||||
for (int i = 0; i < particles.size(); ++i)
|
||||
//particles[i].pos_h.setZ((particles[i].pos - apos).lengthSquared());
|
||||
particles[i].pos_h.setZ(particles[i].pos.distanceToPlane(apos, dir));
|
||||
//qSort(particles.begin(), particles.end());
|
||||
qSort(particles.begin(), particles.end());
|
||||
glBegin(GL_POINTS);
|
||||
foreach (const Particle & i, particles) {
|
||||
//glVertex3f(i.pos.x(), i.pos.y(), i.pos.z());
|
||||
a = (i.lifeDuration - i.lifeCurrent) / fade_time;
|
||||
if (a > 1.f) a = 1.f;
|
||||
a *= tr_a;
|
||||
@@ -178,7 +181,11 @@ void GLParticlesSystem::draw(QGLShaderProgram * prog, bool) {
|
||||
colors << tr_r << tr_g << tr_b << a;
|
||||
}
|
||||
}
|
||||
bool cae = glIsEnabled(GL_COLOR_ARRAY), nae = glIsEnabled(GL_NORMAL_ARRAY);
|
||||
glEnd();
|
||||
//bool cae = glIsEnabled(GL_COLOR_ARRAY), nae = glIsEnabled(GL_NORMAL_ARRAY);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
//glNormal3f(vn.x(), vn.y(), vn.z());
|
||||
glNormal3f(0., 0., 1.);
|
||||
@@ -193,6 +200,16 @@ void GLParticlesSystem::draw(QGLShaderProgram * prog, bool) {
|
||||
glDrawArrays(GL_QUADS, 0, vertices.size() / 3);
|
||||
glDepthMask(true);
|
||||
//glDisable(GL_ALPHA_TEST);
|
||||
if (!cae) glDisable(GL_COLOR_ARRAY);
|
||||
if (nae) glEnable(GL_NORMAL_ARRAY);
|
||||
//if (!cae) glDisable(GL_COLOR_ARRAY);
|
||||
//if (nae) glEnable(GL_NORMAL_ARRAY);
|
||||
}
|
||||
|
||||
|
||||
|
||||
GLParticlesSystem::Particle::Particle(float life_dur) {
|
||||
size = 1.;
|
||||
angle = lifeCurrent = 0.;
|
||||
speedDecay = 0.;
|
||||
lifeDuration = life_dur;
|
||||
tex_rect = QRectF(0, 0, 1, 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user