Changeset 3028 in orxonox.OLD for orxonox/branches/bezierTrack/src/camera.cc
- Timestamp:
- Nov 30, 2004, 2:50:59 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/bezierTrack/src/camera.cc
r3023 r3028 44 44 actual_place.pos.y = 10.0; 45 45 actual_place.pos.z = -5.0; 46 47 // Initializing Target 48 target = new CameraTarget (Vector (0,0,0)); 49 46 50 } 47 51 … … 79 83 switch(cameraMode) 80 84 { 81 82 case ELLIPTICAL: 83 { 84 //r = actual_place.r 85 Orxonox *orx = Orxonox::getInstance(); 86 Location lookat; 87 Placement plFocus; 88 if( bound != NULL) 89 { 90 bound->get_lookat (&lookat); 91 orx->get_world()->calc_camera_pos (&lookat, &plFocus); 92 Quaternion *fr; 93 if(t < 20.0) 94 { 95 Vector *start = new Vector(0.0, 1.0, 0.0); 96 //r = /*actual_place.r*/ *start - plFocus.r; 97 r = *(new Vector(0.0, 5.0, 0.0)); 98 99 Vector up(0.0, 0.0, 1.0); 100 101 Vector op(1.0, 0.0, 0.0); 102 float angle = angle_deg(op, *start); 103 printf("angle is: %f\n", angle); 104 105 //if in one plane 106 from = new Quaternion(angle, up); 107 108 //from = new Quaternion(*start, *up); 109 //&from = &plFocus.w; 110 //fr = &plFocus.w; real quaternion use 111 112 113 114 Vector vDirection(1.0, 0.0, 0.0); 115 //vDirection = plFocus.w.apply(vDirection); 116 to = new Quaternion(vDirection, *start); 117 res = new Quaternion(); 118 } 119 //printf("vector r = %f, %f, %f\n",r.x, r.y, r.z ); 120 rAbs = r.len(); 121 if(t < 30.0) /* FIXME!!*/ 122 { 123 ka = rAbs / deltaTime*deltaTime; 124 } 125 /* this is the new length of the vector */ 126 //float len = ka * powf((deltaTime - t), 2); 127 128 /* calc the rotation */ 129 /* 130 Vector axis(0.0, 0.0, 1.0); 131 if(t < 30.0) 132 a0 = PI/4 - atanf(fabs(r.x) / fabs(r.y)); 133 printf("a0 = %f\n", a0); 134 float angle = a0/deltaTime * (deltaTime - t); 135 printf("angle is: %f\n", angle); 136 Quaternion q(angle, axis); 137 */ 138 //r = q.apply(r); 139 //r = r * (len/r.len()); 140 141 //res->quatSlerp(from, to, t/deltaTime, res); 142 res->quatSlerp(to, from, t/deltaTime, res); 143 144 Vector ursp(0.0, 0.0, 0.0); 145 desired_place.pos = /*plFocus.r -*/ ursp - res->apply(r); 146 147 printf("desired place is: %f, %f, %f\n", desired_place.pos.x, desired_place.pos.y, desired_place.pos.z); 148 //plLastBPlace = *bound->get_placement(); 149 } 150 } 151 break; 152 case SMOTH_FOLLOW: 153 { 154 Placement *plBound = bound->get_placement(); 155 Location lcBound; 156 if(bound != null) 157 { 158 bound->get_lookat(&lcBound); 159 Vector vDirection(0.0, 0.0, 1.0); 160 vDirection = plBound->rot.apply(vDirection); 161 desired_place.pos = (vDirection * ((lcBound.dist-10.0)/* / l*/)) + Vector(0,0,5.0); 162 } 163 break; 164 } 165 /* this is a camera mode that tries just to follow the entity. */ 166 case STICKY: 167 { 168 if(bound != null) 169 { 170 Placement *plBound = bound->get_placement(); 171 Vector vDirection(0.0, 0.0, 1.0); 172 Vector eclipticOffset(0.0, 0.0, 5.0); 173 vDirection = plBound->rot.apply(vDirection); 174 desired_place.pos = plBound->pos - vDirection*10 + eclipticOffset; 175 } 176 break; 177 } 178 /* the camera is handled like an entity and rolls on the track */ 85 179 86 case NORMAL: 180 Location lookat; 87 this->setPosition(world->track->getPos() - world->track->getDir() *10 +Vector (0,0,5), WORLD); 88 target->setPosition(world->track->getPos(), WORLD); 89 90 Location lookat; 181 91 if( bound != NULL && world != NULL ) 182 92 { … … 206 116 // TO DO: implement options for frustum generation 207 117 glFrustum(-1.0, 1.0, -1.0, 1.0, 1.5, 250.0); 208 //Vector up(0,0,1);209 //Vector dir(1,0,0);210 //Quaternion q(dir,up);211 //float matrix[4][4];212 //q.conjugate().matrix (matrix);213 //glMultMatrixf ((float*)matrix);214 //glTranslatef (10,0,-5);215 //216 //dir = Vector(-1,-1,0);217 //q = Quaternion( dir, up);218 //glMatrixMode (GL_MODELVIEW);219 //glLoadIdentity ();220 //q.matrix (matrix);221 //glMultMatrixf ((float*)matrix);222 //glTranslatef (2,2,0);223 //224 //glBegin(GL_TRIANGLES);225 //glColor3f(1,0,0);226 //glVertex3f(0,0,0.5);227 //glColor3f(0,1,0);228 //glVertex3f(-0.5,0,-1);229 //glColor3f(0,0,1);230 //glVertex3f(0.5,0,-1);231 //glEnd();232 118 233 119 // ===== first camera control calculation option 234 120 // rotation 121 Vector eye = this->getPosition(WORLD); 122 Vector targetV = target->getPosition(WORLD); 123 124 gluLookAt (eye.x, eye.y, eye.z, 125 targetV.x, targetV.y, targetV.z, 126 0,0,1); 127 235 128 float matrix[4][4]; 236 129 actual_place.rot.conjugate().matrix (matrix); 237 130 /* orientation and */ 238 glMultMatrixf ((float*)matrix);131 // glMultMatrixf ((float*)matrix); 239 132 /* translation */ 240 glTranslatef (-actual_place.pos.x, -actual_place.pos.y,- actual_place.pos.z);133 // glTranslatef (-actual_place.pos.x, -actual_place.pos.y,- actual_place.pos.z); 241 134 //Placement *plBound = bound->get_placement(); 242 135 … … 297 190 this->world = world; 298 191 } 192 193 194 195 CameraTarget::CameraTarget () 196 { 197 198 199 } 200 201 CameraTarget::CameraTarget (Vector pos) 202 { 203 this->setPosition (pos, WORLD); 204 }
Note: See TracChangeset
for help on using the changeset viewer.