Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Sable::scanParticle(QPointF p)
- {
- QVector<Particle>::iterator itP;
- for (itP = particles.begin(); itP != particles.end(); ++itP)
- {
- if (qAbs(p.x() - itP->x()) < RAYON &&
- qAbs(p.y() - itP->y()) < RAYON)
- {
- QVector2D dir = QVector2D(p.x() - itP->x(),
- p.y() - itP->y());
- double dist = dir.length();
- if (dist < RAYON)
- {
- dir.normalize();
- QVector2D deltaPos = 3*dir*(RAYON-dist);
- itP->setX(itP->x() - deltaPos.x());
- itP->setY(itP->y() - deltaPos.y());
- }
- }
- }
- this->update();
- }
- void Particle::drawSand(const QVector<Particle> &ps)
- {
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(2, GL_DOUBLE, sizeof(Particle), &(ps[0].m_x));
- glEnableClientState(GL_COLOR_ARRAY);
- glColorPointer(3, GL_DOUBLE, sizeof(Particle), &(ps[0].r));
- glDrawArrays(GL_POINTS, 0, ps.count());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement