Changeset 3238 in orxonox.OLD for orxonox/branches/nico/src/camera.cc
- Timestamp:
- Dec 20, 2004, 2:42:54 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/nico/src/camera.cc
r2636 r3238 30 30 { 31 31 this->world = world; 32 bound = NULL;32 this->bound = NULL; 33 33 /* give it some physical live */ 34 m = 10;35 a = new Vector(0.0, 0.0, 0.0);36 v = new Vector(0.0, 0.0, 0.0);37 fs = new Vector(0.0, 0.0, 0.0);38 cameraMode = NORMAL;39 deltaTime = 3000.0;40 cameraOffset = 1.0;41 cameraOffsetZ = 10.0;42 t = 0.0;43 44 actual_place.r.x = 0.0;45 actual_place.r.y = 10.0;46 actual_place.r.z = -5.0;34 this->m = 10; 35 this->a = new Vector(0.0, 0.0, 0.0); 36 this->v = new Vector(0.0, 0.0, 0.0); 37 this->fs = new Vector(0.0, 0.0, 0.0); 38 this->cameraMode = NORMAL; 39 this->deltaTime = 3000.0; 40 this->cameraOffset = 1.0; 41 this->cameraOffsetZ = 10.0; 42 this->t = 0.0; 43 44 this->actualPlace.r.x = 0.0; 45 this->actualPlace.r.y = 10.0; 46 this->actualPlace.r.z = -5.0; 47 47 } 48 48 … … 61 61 as smooth camera movement or swaying). 62 62 */ 63 void Camera::time _slice (Uint32 deltaT)64 { 65 if( t <= deltaTime)66 {t += deltaT;}63 void Camera::timeSlice (Uint32 deltaT) 64 { 65 if( this->t <= deltaTime) 66 {this->t += deltaT;} 67 67 //printf("time is: t=%f\n", t ); 68 update _desired_place();69 jump 68 updateDesiredPlace(); 69 jump(NULL); 70 70 } 71 71 … … 76 76 bound entity's position on the track. 77 77 */ 78 void Camera::update _desired_place ()78 void Camera::updateDesiredPlace () 79 79 { 80 80 switch(cameraMode) … … 89 89 if( bound != NULL) 90 90 { 91 bound->get _lookat (&lookat);92 orx->get _world()->calc_camera_pos (&lookat, &plFocus);91 bound->getLookat (&lookat); 92 orx->getWorld()->calcCameraPos (&lookat, &plFocus); 93 93 Quaternion *fr; 94 94 if(t < 20.0) … … 101 101 102 102 Vector op(1.0, 0.0, 0.0); 103 float angle = angle _deg(op, *start);103 float angle = angleDeg(op, *start); 104 104 printf("angle is: %f\n", angle); 105 105 … … 144 144 145 145 Vector ursp(0.0, 0.0, 0.0); 146 desired _place.r = /*plFocus.r -*/ ursp - res->apply(r);147 148 printf("desired place is: %f, %f, %f\n", desired _place.r.x, desired_place.r.y, desired_place.r.z);146 desiredPlace.r = /*plFocus.r -*/ ursp - res->apply(r); 147 148 printf("desired place is: %f, %f, %f\n", desiredPlace.r.x, desiredPlace.r.y, desiredPlace.r.z); 149 149 //plLastBPlace = *bound->get_placement(); 150 150 } … … 153 153 case SMOTH_FOLLOW: 154 154 { 155 Placement *plBound = bound->get _placement();155 Placement *plBound = bound->getPlacement(); 156 156 Location lcBound; 157 157 if(bound != null) 158 158 { 159 bound->get _lookat(&lcBound);159 bound->getLookat(&lcBound); 160 160 Vector vDirection(0.0, 0.0, 1.0); 161 161 vDirection = plBound->w.apply(vDirection); 162 desired _place.r = (vDirection * ((lcBound.dist-10.0)/* / l*/)) + Vector(0,0,5.0);162 desiredPlace.r = (vDirection * ((lcBound.dist-10.0)/* / l*/)) + Vector(0,0,5.0); 163 163 } 164 164 break; … … 169 169 if(bound != null) 170 170 { 171 Placement *plBound = bound->get _placement();171 Placement *plBound = bound->getPlacement(); 172 172 Vector vDirection(0.0, 0.0, 1.0); 173 173 Vector eclipticOffset(0.0, 0.0, 5.0); 174 174 vDirection = plBound->w.apply(vDirection); 175 desired _place.r = plBound->r - vDirection*10 + eclipticOffset;175 desiredPlace.r = plBound->r - vDirection*10 + eclipticOffset; 176 176 } 177 177 break; … … 182 182 if( bound != NULL && world != NULL ) 183 183 { 184 bound->get _lookat (&lookat);185 world->calc _camera_pos (&lookat, &desired_place);184 bound->getLookat (&lookat); 185 world->calcCameraPos (&lookat, &desiredPlace); 186 186 } 187 187 else 188 188 { 189 desired _place.r = Vector (0,0,0);190 desired _place.w = Quaternion ();189 desiredPlace.r = Vector (0,0,0); 190 desiredPlace.w = Quaternion (); 191 191 } 192 192 break; … … 206 206 // view 207 207 // TO DO: implement options for frustum generation 208 glFrustum(-1.0, 1.0, -1.0, 1.0, 1.5, 250.0); 208 //glFrustum(-1.0, 1.0, -1.0, 1.0, 1.5, 250.0); 209 gluPerspective(60, 1.2f, 0.1, 250); 210 209 211 //Vector up(0,0,1); 210 212 //Vector dir(1,0,0); … … 235 237 // rotation 236 238 float matrix[4][4]; 237 actual _place.w.conjugate().matrix (matrix);239 actualPlace.w.conjugate().matrix (matrix); 238 240 /* orientation and */ 239 241 glMultMatrixf ((float*)matrix); 240 242 /* translation */ 241 glTranslatef (-actual _place.r.x, -actual_place.r.y,- actual_place.r.z);242 243 glTranslatef (-actualPlace.r.x, -actualPlace.r.y,- actualPlace.r.z); 244 //Placement *plBound = bound->get_placement(); 243 245 244 246 // ===== second camera control calculation option 245 247 /* 246 248 gluLookAt(actual_place.r.x, actual_place.r.y, actual_place.r.z, 247 249 plBound->r.x, plBound->r.y, plBound->r.z, 248 250 0.0, 0.0, 1.0); … … 263 265 if( plc == NULL) 264 266 { 265 actual _place = desired_place;267 actualPlace = desiredPlace; 266 268 //printf("Camera|jump: camer@ %f, %f, %f\n\n", actual_place.r.x, actual_place.r.y, actual_place.r.z); 267 269 } 268 270 else 269 271 { 270 desired _place = *plc;271 actual _place = *plc;272 desiredPlace = *plc; 273 actualPlace = *plc; 272 274 } 273 275 } … … 277 279 \param entity: The enitity to bind the camera to 278 280 279 280 281 281 This sets the focus of the camera to the given entity. This means that it will use the given WorldEntity's 282 Location and get_lookat() to determine the viewpoint the camera will render from. 283 Note that you cannot bind a camera to a free entity. 282 284 */ 283 285 void Camera::bind (WorldEntity* entity) … … 285 287 if( entity != NULL) 286 288 { 287 if( entity->isFree 289 if( entity->isFree()) printf("Cannot bind camera to free entity"); 288 290 else 289 291 { 290 bound = entity;292 this->bound = entity; 291 293 } 292 294 } … … 298 300 this->world = world; 299 301 } 302 303 304 /** 305 \brief destroy, reset the camera so that it doesn't perform anything anymore 306 307 */ 308 void Camera::destroy() 309 { 310 this->bound = NULL; 311 this->world = NULL; 312 }
Note: See TracChangeset
for help on using the changeset viewer.