Changeset 3390 in orxonox.OLD for orxonox/branches/nico/src/importer/heightMapViewer.cc
- Timestamp:
- Feb 2, 2005, 1:04:00 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/nico/src/importer/heightMapViewer.cc
r3384 r3390 21 21 22 22 upVector = Vector(0,1,0); 23 23 24 24 wireframe = false; 25 25 mousedown = false; 26 smoothShading = false; 26 27 27 28 } … … 38 39 cout << "HeightMapViewer init()" << endl; 39 40 40 if (windowhandler.createOpenGLWindow(WIDTH,HEIGHT,FULLSCREEN) == false) 41 #ifdef FULLSCREEN 42 if (!windowhandler.CreateGLWindow("height map viewer", WIDTH, HEIGHT, 32, true)) 43 #else 44 if (!windowhandler.CreateGLWindow("height map viewer", WIDTH, HEIGHT, 32, false)) 45 #endif 41 46 { 42 47 cout << "could not create OpenGL-Window." << endl; … … 46 51 if (terrain.loadBitmap(fileName) == false) 47 52 { 48 cout << "could not create OpenGL-Window." << endl;53 cout << "could not load bitmap." << endl; 49 54 return false; 50 55 } 51 56 52 terrain.createDisplayLists( 64, 64, 1);57 terrain.createDisplayLists(128, 128, 1); 53 58 54 59 return true; … … 73 78 { 74 79 case SDL_MOUSEMOTION: 75 if (mousedown)80 if (mousedown==true) 76 81 { 77 angleX = PI / 180 * event.motion.xrel * 0. 1;78 angleY = PI / 180 * event.motion.yrel * 0. 1;82 angleX = PI / 180 * event.motion.xrel * 0.2; 83 angleY = PI / 180 * event.motion.yrel * 0.2; 79 84 80 85 // Quaternion(angle,axis) 81 rotator = Quaternion( angleX,Vector(0,1,0));86 rotator = Quaternion(-angleX,Vector(0,1,0)); 82 87 sightDirection = rotator.apply(sightDirection); 88 89 #ifdef FULLSCREEN 90 rotator = Quaternion(angleY,perpendicular(sightDirection)); 91 #else 92 rotator = Quaternion(-angleY,perpendicular(sightDirection)); 93 #endif 83 94 84 rotator = Quaternion(-angleY,sightDirection.perpendicular());85 95 sightDirection = rotator.apply(sightDirection); 86 96 … … 99 109 switch(event.key.keysym.sym) 100 110 { 111 case SDLK_UP: 112 // move in direction of sight 113 cameraPos = cameraPos + sightDirection * 0.7; 114 updateView(); 115 break; 116 117 case SDLK_DOWN: 118 // move in direction of sight 119 cameraPos = cameraPos - sightDirection * 0.7; 120 updateView(); 121 break; 122 123 case SDLK_LEFT: 124 cameraPos = cameraPos + perpendicular(sightDirection) * 0.7; 125 updateView(); 126 break; 127 128 case SDLK_RIGHT: 129 cameraPos = cameraPos - perpendicular(sightDirection) * 0.7; 130 updateView(); 131 break; 132 133 case SDLK_s: 134 smoothShading = !smoothShading; 135 if (smoothShading) glShadeModel(GL_SMOOTH); 136 else glShadeModel(GL_FLAT); 137 break; 138 101 139 case SDLK_w: 102 140 wireframe = !wireframe; … … 105 143 break; 106 144 107 case SDLK_UP:108 // move in direction of sight109 cameraPos = cameraPos + sightDirection;110 updateView();111 break;112 113 case SDLK_DOWN:114 // move in direction of sight115 cameraPos = cameraPos - sightDirection;116 updateView();117 break;118 119 case SDLK_LEFT:120 cameraPos = cameraPos - sightDirection.perpendicular();121 updateView();122 break;123 124 case SDLK_RIGHT:125 cameraPos = cameraPos + sightDirection.perpendicular();126 updateView();127 break;128 129 145 case SDLK_r: 130 // restore original view vectors 131 cameraPos = Vector(0,0,40); 132 sightDirection = Vector(0,0,-1); 146 // reset view vectors 147 //cameraPos = Vector(0,0,40); 148 //sightDirection = Vector(0,0,-1); 149 cameraPos = Vector(73.9871,172.496,286.137); 150 sightDirection = Vector(0.23429,-0.736527,-0.625574); 151 133 152 updateView(); 134 153 break; … … 138 157 << "display list count: " << terrain.displayListCount << endl 139 158 << "first display list at: " << terrain.displayListStart << endl 159 << "camera position: " << "(" << cameraPos.x << "," << cameraPos.y << "," << cameraPos.z << ")" << endl 160 << "sightDirection: " << "(" << sightDirection.x << "," << sightDirection.y << "," << sightDirection.z << ")" << endl 140 161 << endl; 141 162 … … 165 186 SDL_GL_SwapBuffers(); 166 187 167 //SDL_Delay(100);188 SDL_Delay(1); 168 189 } 169 190 … … 175 196 // be sure to use up to date lookAt-vector 176 197 lookAt = cameraPos + sightDirection; 177 upVector = sightDirection.cross( sightDirection.perpendicular()) * -1;198 upVector = sightDirection.cross(perpendicular(sightDirection)); 178 199 179 200 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix … … 181 202 182 203 // Calculate The Aspect Ratio Of The Window 183 gluPerspective(45.0f,(GLfloat)WIDTH/(GLfloat)HEIGHT,0. 1f,100.0f);204 gluPerspective(45.0f,(GLfloat)WIDTH/(GLfloat)HEIGHT,0.5f,300.0f); 184 205 gluLookAt (cameraPos.x,cameraPos.y,cameraPos.z, 185 206 lookAt.x,lookAt.y,lookAt.z, … … 191 212 192 213 void HeightMapViewer::drawScene() 193 { 214 { 194 215 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 195 216 196 glutWireCube(1.0); 197 198 int i; 199 200 for (i=0; i<terrain.displayListCount; i++) 201 { 202 glCallList(terrain.displayListStart + i); 203 } 204 } 217 glPushMatrix(); 218 { 219 //glTranslatef(0.0,1.0,0.0); 220 glScalef(1,0.2,1); 221 222 for (int i=0; i<terrain.displayListCount; i++) 223 { 224 glCallList(terrain.displayListStart + i); 225 } 226 } 227 glPopMatrix(); 228 229 glColor3f(0.0,1.0,0.0); 230 // glutWireCube(1.0); 231 232 glColor3f(0.0,0.0,1.0); 233 glBegin(GL_POINTS); 234 for (float z=0;z<10;z++) 235 for (float x=0;x<10;x++) 236 glVertex3f(x,0,z); 237 glEnd(); 238 239 } 240 241 242 243 /** 244 \brief returns a vector that is perpendicular and lies in the xz-plane 245 */ 246 Vector perpendicular (Vector perpendic) 247 { 248 Vector r; 249 250 r.x = perpendic.z; 251 r.z = -perpendic.x; 252 253 r.normalize(); 254 255 return r; 256 }
Note: See TracChangeset
for help on using the changeset viewer.