- Timestamp:
- Nov 23, 2004, 3:44:06 PM (20 years ago)
- Location:
- orxonox/trunk/importer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/importer/framework.cc
r2953 r2963 21 21 glLoadIdentity(); 22 22 gluPerspective(45.0f,500/375,0.1f,dist * 5.0f); 23 gluLookAt (dist* dir.x, dist *dir.y, -dist *dir.z, 0,0,0, 0,1,0); 24 23 gluLookAt (0, dist , dist, 0,0,0, up.x,up.y,up.z); 24 25 glMatrixMode(GL_MODELVIEW); 26 glPushMatrix(); 27 // glRotatef (180, dir.x, dir.y, dir.z); 28 glMultMatrixf (*matQ); 25 29 obj->draw(); 30 31 glPopMatrix(); 26 32 27 33 SDL_GL_SwapBuffers(); // Swap the buffers … … 56 62 rotAxis = Vector (0.0,1.0,0.0); 57 63 rotAngle = 0; 64 65 matQ[0][0] = matQ[1][1] = matQ[2][2] = matQ[3][3] = 1; 58 66 rotQ = Quaternion (rotAngle, rotAxis); 59 67 rotQlast = rotQ; 60 68 dir = Vector (0.0, 0.0, 1.0); 69 up = Vector (0.0, 1.0, 0.0); 61 70 62 71 glEnable(GL_LIGHTING); … … 104 113 if (mouse1Down) 105 114 { 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))); 115 int mX = event.button.x; 116 int mY = event.button.y; 117 int wH = wHandler.screen->h; 118 int wW = wHandler.screen->w; 119 Vector tmpV (mX, mY, sqrt ( (float) abs(wH * wH/4 - (wW/2-mX) * (wW/2-mX) - (wH/2-mY) * (wH/2-mY)) )); 120 // printf ("tmpV: %f, %f, %f\n", tmpV.x, tmpV.y, tmpV.z); 107 121 p2 = tmpV-M; 108 109 122 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 123 // printf ("rotAxis: %f, %f, %f\n", rotAxis.x, rotAxis.y, rotAxis.z); 124 125 // in case that there is no rotation-axis defined 126 if (rotAxis.x != 0 || rotAxis.y != 0 || rotAxis.z != 0) 127 { 128 rotAxis.normalize(); 129 printf ("rotAxis: %f, %f, %f\n", rotAxis.x, rotAxis.y, rotAxis.z, rotAngle); 130 131 rotAngle = angle_rad (p1, p2); 132 rotQ = Quaternion (rotAngle, rotAxis); 133 rotQ = rotQ * rotQlast; 134 rotQ.norm(); 135 rotQ.matrix (matQ); 136 // dir = rotQ.apply(dir); 137 // dir.normalize(); 138 // printf ("rotAxis: %f, %f, %f, %f\n", dir.x, dir.y, dir.z, rotAngle); 139 } 140 rotQlast = rotQ; 116 141 p1 = p2; 142 117 143 } 118 144 break; … … 131 157 { 132 158 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))); 159 int mX = event.button.x; 160 int mY = event.button.y; 161 int wH = wHandler.screen->h; 162 int wW = wHandler.screen->w; 163 Vector tmpV (mX, mY, sqrt ( (float) abs(wH * wH/4 - (wW/2-mX) * (wW/2-mX) - (wH/2-mY) * (wH/2-mY)) )); 134 164 p1 = tmpV-M; 135 165 -
orxonox/trunk/importer/framework.h
r2952 r2963 18 18 19 19 Vector dir; 20 Vector up; 21 22 float matQ[4][4]; 23 20 24 Vector M; 21 25 Vector p1; … … 24 28 float rotAngle; 25 29 Quaternion rotQ; 30 Quaternion rotQlast; 26 31 27 32 bool mouse1Down;
Note: See TracChangeset
for help on using the changeset viewer.