Changeset 2952 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Nov 21, 2004, 11:40:54 PM (20 years ago)
- Location:
- orxonox/trunk/importer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/importer/framework.cc
r2940 r2952 14 14 rotatorP += rotatorV *(float)dt; 15 15 16 16 17 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 17 18 glLoadIdentity(); // Reset the view … … 20 21 glLoadIdentity(); 21 22 gluPerspective(45.0f,500/375,0.1f,dist * 5.0f); 22 gluLookAt (dist* sin(rotatorP),dist ,dist*cos(rotatorP), 0,0,0, 0,1,0);23 gluLookAt (dist* dir.x, dist *dir.y, dist *dir.z, 0,0,0, 0,1,0); 23 24 24 25 obj->draw(); … … 52 53 obj = new Object(); 53 54 55 M = Vector(wHandler.screen->w/2, wHandler.screen->h/2, 0); 56 rotAxis = Vector (0.0,1.0,0.0); 57 rotAngle = 0; 58 rotQ = Quaternion (rotAngle, rotAxis); 59 60 dir = Vector (0.0, 0.0, 1.0); 61 54 62 glEnable(GL_LIGHTING); 55 63 glEnable(GL_DEPTH_TEST); … … 77 85 // Hide the mouse cursor 78 86 SDL_ShowCursor(2); 87 mouse1Down = false; 79 88 80 89 // This is the main loop for the entire program and it will run until done==TRUE … … 92 101 event.motion.xrel, event.motion.yrel, 93 102 event.motion.x, event.motion.y); 103 // TRACKBALL 104 if (mouse1Down) 105 { 106 Vector tmpV (event.button.x, event.button.y, 2.0*sqrt ( (float) event.button.x * event.button.x *event.button.y * event.button.y / (wHandler.screen->h *wHandler.screen->h))); 107 p2 = tmpV-M; 108 109 rotAxis = p1.cross(p2); 110 rotAngle = angle_deg (p1, p2)/1000; 111 rotQ = Quaternion (rotAngle, rotAxis); 112 dir = rotQ.apply(dir); 113 dir.normalize(); 114 printf ("%f, %f, %f, %f\n", dir.x, dir.y, dir.z, rotAngle); 115 116 p1 = p2; 117 } 94 118 break; 95 119 case SDL_MOUSEBUTTONDOWN: … … 104 128 zoomTo *= 2.0; 105 129 } 130 else if (event.button.button == 1) 131 { 132 mouse1Down = true; 133 Vector tmpV (event.button.x, event.button.y, 2.0*sqrt ( (float) event.button.x * event.button.x *event.button.y * event.button.y / (wHandler.screen->h *wHandler.screen->h))); 134 p1 = tmpV-M; 135 136 } 106 137 else 107 138 { … … 112 143 113 144 break; 114 /* case SDL_MOUSEBUTTONUP: 145 case SDL_MOUSEBUTTONUP: 146 if (event.button.button == 4); 147 else if (event.button.button == 5); 148 else if (event.button.button == 1) 149 mouse1Down =false; 150 else 151 { 115 152 printf("MouseButton %d released at (%d,%d).\n", 116 153 event.button.button, event.button.x, event.button.y); 154 } 117 155 break; 118 */156 119 157 // If a quit event was recieved 120 158 case SDL_QUIT: … … 125 163 break; 126 164 } 165 166 127 167 } 128 168 -
orxonox/trunk/importer/framework.h
r2940 r2952 8 8 float rotatorP; 9 9 float rotatorV; 10 10 11 float dist; 11 12 float zoomTo; … … 15 16 Uint32 dt; 16 17 18 19 Vector dir; 20 Vector M; 21 Vector p1; 22 Vector p2; 23 Vector rotAxis; 24 float rotAngle; 25 Quaternion rotQ; 26 27 bool mouse1Down; 28 17 29 WindowHandler wHandler; // Create an instance of the whandler basecode class 18 30 Object* obj;
Note: See TracChangeset
for help on using the changeset viewer.