Changeset 10065 in orxonox.OLD for branches/camera/src/world_entities/camera.cc
- Timestamp:
- Dec 13, 2006, 3:23:05 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/camera/src/world_entities/camera.cc
r9869 r10065 18 18 #include "key_mapper.h" 19 19 #include "glincl.h" 20 #include "vector.h" 21 #include <iostream.h> 22 20 23 21 24 ObjectListDefinition(Camera); … … 138 141 this->viewVector = (this->target->getAbsCoor() - this->getAbsCoor()).getNormalized(); 139 142 this->frustumPlane = Plane(this->viewVector, this->getAbsCoor() + this->viewVector * 0.1); 140 141 143 this->upVector = this->getAbsDirV(); 144 145 146 142 147 143 148 … … 179 184 Vector targetPosition = this->target->getAbsCoor(); 180 185 181 //Setting the Camera Eye, lookAt and up Vectors182 gl uLookAt(cameraPosition.x, cameraPosition.y, cameraPosition.z,186 //Setting the Camera Eye, lookAt and up Vectors 187 glLookAt(cameraPosition.x, cameraPosition.y, cameraPosition.z, 183 188 targetPosition.x, targetPosition.y, targetPosition.z, 184 189 this->upVector.x, this->upVector.y, this->upVector.z); … … 217 222 } 218 223 } 224 225 /* 226 Vector* Camera::translate(Vector* newPos, float speed) 227 { 228 glTranslatef(Vector); 229 230 } 231 232 233 float Camera::iterate(float dt, Vector target) 234 { 235 Vector tmpVec = (this->getAbsCorr() - target); 236 if (tmpVec > 0.01) 237 Vector ret = this->getAbsCorr; 238 ret += tmpVec * fabsf(dt); 239 return ret; 240 } 241 */ 242 void Camera::Rotate() 243 { 244 this->fovy=this->fovy+1; 245 } 246 247 248 void Camera::glLookAt(float eyex, float eyey, float eyez, float centerx, float centery, float centerz, float upx, float upy, float upz) 249 { 250 //Vector* eye=new Vector(eyex, eyey, eyez); 251 Vector* center=new Vector (centerx, centery, centerz); 252 Vector* up=new Vector(upx, upy, upz); 253 254 center->x-=eyex; 255 center->y-=eyey; 256 center->z-=eyez; 257 258 center->normalize(); 259 up->normalize(); 260 Vector* s = VectorProd(center, up); 261 Vector* u = VectorProd(s, center); 262 GLfloat Matrix[]={s->x, s->y, s->z, 0, u->x, u->y, u->z, 0, -center->x, -center->y, -center->z, 0, 0, 0, 0, 1}; 263 264 glMultMatrixf(Matrix); 265 glTranslated(-eyex, -eyey, -eyez); 266 delete center; 267 delete up; 268 delete s; 269 delete u; 270 271 } 272 273 274 275 276 Vector* Camera::VectorProd(Vector* v1, Vector* v2) 277 { 278 Vector* temp= new Vector(); 279 temp->x=v1->y * v2->z - v1->z * v2->y; 280 temp->y=v1->z * v2->x - v1->x * v2->z; 281 temp->z=v1->x * v2->y - v1->y * v2->x; 282 return temp; 283 } 284 285 286 287 288 289 290 291 292 293 294 295 219 296 220 297 … … 228 305 this->registerObject(this, CameraTarget::_objectList); 229 306 // this->setParentMode(PNODE_MOVEMENT); 230 } 231 307 308 309 } 310 311 312 CameraTarget::detach() 313 { 314 State::getCameraTargetNode()->setParentSoft(NULL); 315 } 316 317 318 319 320
Note: See TracChangeset
for help on using the changeset viewer.