/*************************************************************************** gmf_visuals.cpp - methods for visualization of simulation ------------------- begin : Fri May 26th 2004 copyright : (C) 2004 by Andrew O'Neill,HiRes Grad Student email : oneill@phys.columbia.edu ***************************************************************************/ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "gmf_visuals.h" using namespace std; void InitVisuals(int argc, char** argv) { #ifdef VISUALS if(!Config.Visuals) { dout(INFO) << "Not using Visuals" << endl; return; } VisualsInitialized = true; dout(INFO) << "Initializing Visuals" << endl; glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA); glutInitWindowSize(800,600); glutInitWindowPosition(100,100); glutCreateWindow("GMF Simulation"); // glutFullScreen(); glClearColor (0.0, 0.0, 0.0, 0.0); glutDisplayFunc(DrawDetector); glutReshapeFunc(Reshape); glutKeyboardFunc(Keyboard); // glutIdleFunc(DrawDetector); // glDepthFunc(GL_LESS); // glEnable(GL_DEPTH_TEST); glShadeModel(GL_SMOOTH); glEnable(GL_CULL_FACE); GLfloat ambient[] = {0.4, 0.4, 0.4, 1.0 }; GLfloat position[] = {5.0, 5.0, 5.0, 1.0 }; GLfloat diffuse[] = {0.5, 0.5, 0.5, 1.0}; glEnable(GL_LIGHT0); glEnable(GL_LIGHTING); glLightfv(GL_LIGHT0, GL_POSITION, position); glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); glutMainLoop(); #endif } void DrawDetector() { #ifdef VISUALS glClear(GL_COLOR_BUFFER_BIT); glLoadIdentity(); // gluLookAt (Camera_Pos, Looking_At, Up-Axis) gluLookAt(-2.0, 1.5, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0); glScalef(1, 1, 1); glRotatef(0.2, 0.0, 0.0, 1.0); glPushMatrix(); glRotatef(0.2, 0.0, 0.0, 1.0); glColor4f(0.0,0.0,1.0, 0.5); // make a sphere to rep. the earth Vector3D Origin(0.0, 0.0, 0.0); glTranslatef( Origin.East(Config.Detector)*ZoomFactor, Origin.North(Config.Detector)*ZoomFactor, Origin.Up(Config.Detector)*ZoomFactor ); glutSolidSphere(EarthRadius*ZoomFactor, 36, 18); // make a cube to show detector position //glTranslatef (0.0, 0.0, 0.0); glTranslatef( -Origin.East(Config.Detector)*ZoomFactor, -Origin.North(Config.Detector)*ZoomFactor, -Origin.Up(Config.Detector)*ZoomFactor ); // glutSetColor(0, 0.5, 0.8, 0.3, 0.7); glColor4f(1.0, 0.0, 0.0, 1.0); glutWireCube(0.05); glColor4f(0.0, 1.0, 0.0, 1.0); glPopMatrix(); glutSwapBuffers(); // DrawStack(); #endif } void Reshape(int w, int h) { #ifdef VISUALS glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(-1.0, 1.0, -1.0, 1.0, 1.5, 20.0); glMatrixMode (GL_MODELVIEW); #endif } void Keyboard (unsigned char key, int x, int y) { switch (key) { case 27: exit(0); break; case 'm': MainSimLoop(); break; default: break; } } void Idle() { }