31 lines
943 B
C++
31 lines
943 B
C++
#include "poisson.h"
|
|
#include <qmath.h>
|
|
#include <QtOpenGL>
|
|
#include <random>
|
|
Poisson::Poisson(point3D p, point3D v)
|
|
{
|
|
srand(0);
|
|
position = p * drand48();// origine du monde
|
|
vitesse = v ;//point3D((rand() % 10)/100.,(rand() % 3)/100.,(rand() % 10)/100.);// veteur null
|
|
v_init = vitesse;
|
|
distance = 0; // z&éros
|
|
}
|
|
void Poisson::anime( float temps ){
|
|
if(vitesse == point3D(0.,0.,0.))
|
|
vitesse = v_init;
|
|
position = position + vitesse * temps;
|
|
}
|
|
bool Poisson::dans_voisinage( point3D p, double seuil){
|
|
point3D m = p - position;
|
|
distance = sqrtf(pow(m.x,2) +pow(m.z,2) + pow(m.z,2));
|
|
return (distance > seuil ? false:true);
|
|
}
|
|
void Poisson::affiche(){
|
|
glColor3d(1.,03,.6);
|
|
glBegin(GL_TRIANGLE_STRIP);
|
|
glVertex3d(position.x+.5, position.y, position.z);
|
|
glVertex3d(position.x, position.y, position.z+1.);
|
|
glVertex3d(position.x-.5, position.y, position.z);
|
|
glEnd();
|
|
}
|