Changeset 4306 in orxonox.OLD for orxonox/branches
- Timestamp:
- May 26, 2005, 8:04:05 PM (20 years ago)
- Location:
- orxonox/branches/physics/src/subprojects/particles
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/physics/src/subprojects/particles/framework.cc
r4305 r4306 102 102 switch (event.type) { 103 103 case SDL_MOUSEMOTION: 104 PRINTF(4)("Mouse motion about %d,%d Pixels to (%d,%d).\n", 105 event.motion.xrel, event.motion.yrel, 106 event.motion.x, event.motion.y); 107 // TRACKBALL 108 if (mouse1Down) 104 { 105 Vector view = camera->getTarget()->getAbsCoor() - camera->getAbsCoor(); 106 Vector up = Vector(0, 1, 0); 107 up = camera->getAbsDir().apply(up); 108 Vector h = up.cross(view); 109 Vector v = h.cross(view); 110 h.normalize(); 111 v.normalize(); 112 113 if (mouseDown[1]) 114 camera->setRelCoor(camera->getRelCoor()+ h * event.motion.xrel *.05 - v * event.motion.yrel * .05); 115 if (mouseDown[3]) 116 camera->getTarget()->setRelCoor(camera->getTarget()->getRelCoor()+ h * event.motion.xrel *.05 - v * event.motion.yrel * .05); 117 118 } 119 break; 120 case SDL_MOUSEBUTTONDOWN: 121 switch (event.button.button) 109 122 { 110 /* 111 int mX = event.button.x; 112 int mY = event.button.y; 113 int wH = GraphicsEngine::getInstance()->getResolutionY(); 114 int wW = GraphicsEngine::getInstance()->getResolutionX(); 115 Vector tmpV (mX, mY, sqrt ( (float) abs(wH * wH/4 - (wW/2-mX) * (wW/2-mX) - (wH/2-mY) * (wH/2-mY)) )); 116 // PRINTF(0)("tmpV: %f, %f, %f\n", tmpV.x, tmpV.y, tmpV.z); 117 p2 = tmpV-M; 118 p2.y = -p2.y; 119 rotAxis = p1.cross(p2); 120 // PRINTF(0)("rotAxis: %f, %f, %f\n", rotAxis.x, rotAxis.y, rotAxis.z); 121 122 // in case that there is no rotation-axis defined 123 if (rotAxis.x != 0 || rotAxis.y != 0 || rotAxis.z != 0) 124 { 125 rotAxis.normalize(); 126 // PRINTF(0)("rotAxis: %f, %f, %f\n", rotAxis.x, rotAxis.y, rotAxis.z, rotAngle); 127 128 rotAngle = angleRad (p1, p2); 129 rotQ = Quaternion (rotAngle, rotAxis); 130 rotQ = rotQ * rotQlast; 131 rotQ.matrix (matQ); 132 // dir = rotQ.apply(dir); 133 // dir.normalize(); 134 // PRINTF(0)("rotAxis: %f, %f, %f, %f\n", dir.x, dir.y, dir.z, rotAngle); 135 } 136 rotQlast = rotQ; 137 p1 = p2; 138 */ 139 140 123 case 4: 124 PRINTF(4)("MouseWheel up\n"); 125 //zoomTo *= .5; 126 break; 127 case 5: 128 PRINTF(4)("MouseWheel down\n"); 129 //zoomTo *= 2.0; 130 break; 131 case 1: 132 case 2: 133 case 3: 134 mouseDown[event.button.button] = true; 135 break; 141 136 } 142 break; 143 case SDL_MOUSEBUTTONDOWN: 144 if (event.button.button == 4) 137 138 break; 139 case SDL_MOUSEBUTTONUP: 140 switch (event.button.button) 145 141 { 146 PRINTF(4)("MouseWheel up\n"); 147 // zoomTo *= .5; 142 case 1: 143 case 2: 144 case 3: 145 mouseDown[event.button.button] = false; 146 break; 148 147 } 149 else if (event.button.button == 5) 150 { 151 PRINTF(4)("MouseWheel down\n"); 152 // zoomTo *= 2.0; 153 } 154 else if (event.button.button == 1) 155 { 156 mouse1Down = true; 157 movement[0] = event.button.x; 158 movement[1] = event.button.y; 159 movement[2] = 0; 160 movement[3] = 0; 161 printf("test %d %d\n", movement[0], movement[1]); 162 /* 163 int mX = event.button.x; 164 int mY = event.button.y; 165 int wH = GraphicsEngine::getInstance()->getResolutionY(); 166 int wW = GraphicsEngine::getInstance()->getResolutionX(); 167 Vector tmpV (mX, mY, sqrt ( (float) abs(wH * wH/4 - (wW/2-mX) * (wW/2-mX) - (wH/2-mY) * (wH/2-mY)) )); 168 p1 = tmpV-M; 169 p1.y = -p1.y; 170 */ 171 } 172 else 173 { 174 PRINTF(0)("MouseButton %d pressed at (%d,%d).\n", 175 event.button.button, event.button.x, event.button.y); 176 } 177 178 break; 179 case SDL_MOUSEBUTTONUP: 180 if (event.button.button == 4); 181 else if (event.button.button == 5); 182 else if (event.button.button == 1) 183 mouse1Down =false; 184 else 185 { 186 PRINTF(4)("MouseButton %d released at (%d,%d).\n", 187 event.button.button, event.button.x, event.button.y); 188 } 189 break; 190 148 break; 191 149 case SDL_VIDEORESIZE: 192 150 GraphicsEngine::getInstance()->resolutionChanged(&event.resize); … … 247 205 // Hide the mouse cursor 248 206 SDL_ShowCursor(2); 249 mouse1Down = false; 207 208 for (int i = 0; i <MOUSE_BUTTON_COUNT; i++) 209 mouseDown[i] = false; 250 210 251 211 ResourceManager::getInstance()->setDataDir(DATA_DIRECTORY); -
orxonox/branches/physics/src/subprojects/particles/framework.h
r4305 r4306 7 7 8 8 #define DATA_DIRECTORY "~/svn/data/" 9 #define MOUSE_BUTTON_COUNT 8 9 10 10 11 class Camera; … … 20 21 21 22 Uint8* keys; // This variable will be used in the keyboard routine 22 bool mouse1Down; 23 bool mouse2Down; 23 bool mouseDown[MOUSE_BUTTON_COUNT]; 24 24 25 25 public:
Note: See TracChangeset
for help on using the changeset viewer.