void Camera::rotate(const quaternion& q) { _modelViewMatrix *= q.toMatrix(); modelViewUpdated(); }
void display() { // test the perlin noise glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glPushMatrix(); { float mat[16]; cameraRotation.toMatrix(mat); glMultMatrixf(mat); if (display_vortons) { /*glEnable(GL_LIGHT0); glEnable(GL_LIGHTING);*/ for (vorton &v : vortons) { //glBegin(GL_POINTS); //glVertex3f(v.mPos[0], v.mPos[1], v.mPos[2]); glColor3f(0.0,0.5,0.5); glPushMatrix(); glTranslatef(v.mPos[0], v.mPos[1], v.mPos[2]); glutSolidSphere(.03, 8,8); glPopMatrix(); glBegin(GL_LINES); { glColor3f(1.0, 0.0, 0.0); glVertex3f(v.mPos[0], v.mPos[1], v.mPos[2]); glVertex3f(v.mPos[0]+v.mVel[0]*0.1, v.mPos[1]+v.mVel[1]*0.1, v.mPos[2]+v.mVel[2]*0.1); glColor3f(0.0, 1.0, 0.0); glVertex3f(v.mPos[0], v.mPos[1], v.mPos[2]); glVertex3f(v.mPos[0]+v.mVorticity[0]*0.1, v.mPos[1]+v.mVorticity[1]*0.1, v.mPos[2]+v.mVorticity[2]*0.1); } glEnd(); } } glDisable(GL_LIGHTING); glEnable(GL_POINT_SMOOTH); glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glPointSize(3); for (particle &p : tracers) { float col = (200-p.mLife)/200.0; glColor4f(col, col, col, (1-col)*0.05); if (particle_lines) { glBegin(GL_LINES); glVertex3f(p.mPos[0], p.mPos[1], p.mPos[2]); glVertex3f(p.mPos[0]-p.mVel[0]*gTimeStep, p.mPos[1]-p.mVel[1]*gTimeStep, p.mPos[2]-p.mVel[2]*gTimeStep); glEnd(); } else { glBegin(GL_POINTS); glVertex3f(p.mPos[0], p.mPos[1], p.mPos[2]); glEnd(); } } } glPopMatrix(); if (show_info) print_info(); glutSwapBuffers(); }