Changeset 10379 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Jan 26, 2007, 10:58:31 AM (18 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 5 edited
- 5 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/Makefile.am
r10368 r10379 6 6 7 7 ## THESE ARE THE BASE CLASSES OF ALL WORLD_ENTITIES 8 libORXwe_a_SOURCES = world_entity.cc camera.cc playable.cc player.cc \8 libORXwe_a_SOURCES = world_entity.cc cameraman.cc camera.cc playable.cc player.cc \ 9 9 npcs/npc.cc weapons/weapon_manager.cc weapons/crosshair.cc \ 10 10 weapons/weapon.cc weapons/ammo_container.cc projectiles/projectile.cc \ … … 14 14 15 15 16 noinst_HEADERS = world_entity.h camera.h extendable.h playable.h \16 noinst_HEADERS = world_entity.h cameraman.h camera.h extendable.h playable.h \ 17 17 player.h npcs/npc.h weapons/weapon_manager.h weapons/crosshair.h \ 18 18 weapons/weapon.h weapons/ammo_container.h projectiles/projectile.h \ -
trunk/src/world_entities/WorldEntities.am
r10374 r10379 24 24 world_entities/test_entity.cc \ 25 25 world_entities/test_entity2.cc \ 26 world_entities/blackscreen.cc \ 26 27 world_entities/planet.cc \ 27 28 world_entities/bsp_entity.cc \ … … 151 152 test_entity.h \ 152 153 test_entity2.h \ 154 blackscreen.h \ 153 155 planet.h \ 154 156 bsp_entity.h \ -
trunk/src/world_entities/blackscreen.cc
r10377 r10379 23 23 #include "material.h" 24 24 #include "state.h" 25 #include "class_id_DEPRECATED.h"26 25 27 26 ObjectListDefinition(BlackScreen); -
trunk/src/world_entities/camera.cc
r10368 r10379 18 18 #include "key_mapper.h" 19 19 #include "glincl.h" 20 //#include "util/loading/load_param.h"20 #include "util/loading/load_param.h" 21 21 #include "world_entity.h" 22 #include "vector.h" 23 #include "targets.h" 24 25 26 22 27 23 28 ObjectListDefinition(Camera); 29 24 30 25 31 /** … … 51 57 this->setName("camera"); 52 58 this->target = new CameraTarget(); 53 59 this->target->masta=this; 54 60 this->subscribeEvent(ES_GAME, KeyMapper::PEV_VIEW0); 55 61 this->subscribeEvent(ES_GAME, KeyMapper::PEV_VIEW1); … … 89 95 void Camera::lookAt(PNode* target) 90 96 { 97 this->target->setParentSoft(target,0.2); 98 } 99 100 /** 101 * @returns The PNode of the Target (from there you can get position and so on 102 */ 103 PNode* Camera::getTargetNode() const 104 { 105 return (PNode*)this->target; 106 } 107 108 void Camera::setTargetNode(PNode* target) 109 { 91 110 this->target->setParent(target); 92 }93 94 /**95 * @returns The PNode of the Target (from there you can get position and so on96 */97 PNode* Camera::getTargetNode() const98 {99 return (PNode*)this->target;100 111 } 101 112 … … 186 197 this->viewVector = (this->target->getAbsCoor() - this->getAbsCoor()).getNormalized(); 187 198 this->frustumPlane = Plane(this->viewVector, this->getAbsCoor() + this->viewVector * 0.1); 188 189 199 this->upVector = this->getAbsDirV(); 190 200 191 201 // iteration for fovy 192 202 float tmpFovy = (this->toFovy - this->fovy); 193 203 if (fabsf(tmpFovy) > 0.01) 194 204 this->fovy += tmpFovy * fabsf(dt); 205 206 207 208 209 //iterate(float dt, translate, target) 210 target->translate(dt); 195 211 } 196 212 … … 227 243 Vector targetPosition = this->target->getAbsCoor(); 228 244 229 //Setting the Camera Eye, lookAt and up Vectors245 //Setting the Camera Eye, lookAt and up Vectors 230 246 gluLookAt(cameraPosition.x, cameraPosition.y, cameraPosition.z, 231 247 targetPosition.x, targetPosition.y, targetPosition.z, … … 269 285 } 270 286 271 /* 287 272 288 void Camera::loadParams(const TiXmlElement* root) 273 289 { … … 289 305 LoadParam(root, "viewNormalDistance", this, Camera, setViewNormalDistance); 290 306 } 291 */ 307 292 308 293 309 void Camera::setViewTopFovy(float fovy) … … 350 366 this->viewNormalDistance = Distance; 351 367 } 368 369 370 371 372 void Camera::glLookAt(float eyex, float eyey, float eyez, float centerx, float centery, float centerz, float upx, float upy, float upz) 373 { 374 //Vector* eye=new Vector(eyex, eyey, eyez); 375 Vector* center=new Vector (centerx, centery, centerz); 376 Vector* up=new Vector(upx, upy, upz); 377 378 center->x-=eyex; 379 center->y-=eyey; 380 center->z-=eyez; 381 382 center->normalize(); 383 up->normalize(); 384 Vector* s = VectorProd(center, up); 385 Vector* u = VectorProd(s, center); 386 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}; 387 388 glMultMatrixf(Matrix); 389 glTranslated(-eyex, -eyey, -eyez); 390 delete center; 391 delete up; 392 delete s; 393 delete u; 394 395 } 396 397 398 399 400 Vector* Camera::VectorProd(Vector* v1, Vector* v2) 401 { 402 Vector* temp= new Vector(); 403 temp->x=v1->y * v2->z - v1->z * v2->y; 404 temp->y=v1->z * v2->x - v1->x * v2->z; 405 temp->z=v1->x * v2->y - v1->y * v2->x; 406 return temp; 407 } 408 409 410 411 412 413 414 415 416 417 418 419 352 420 353 421 … … 355 423 // CAMERA-TARGET // 356 424 /////////////////// 425 //REATE_FACTORY(CameraTarget); 426 357 427 358 428 ObjectListDefinition(CameraTarget); 429 430 359 431 CameraTarget::CameraTarget() 360 432 { 361 433 this->registerObject(this, CameraTarget::_objectList); 362 434 // this->setParentMode(PNODE_MOVEMENT); 363 } 364 435 this->speed=1; 436 translateTo.x=0; 437 translateTo.y=0; 438 translateTo.z=0; 439 rotateBy.x=0; 440 rotateBy.y=0; 441 rotateBy.z=0; 442 target=createStick(); 443 } 444 445 446 void CameraTarget::detach() 447 { 448 masta->setParentSoft(target); 449 masta->getTargetNode()->setParentSoft(target); 450 } 451 452 PNode* CameraTarget::createStick() 453 { 454 return new Targets(); 455 } 456 457 458 void CameraTarget::atach(PNode* object) 459 { 460 masta->setParentSoft(object); 461 masta->getTargetNode()->setParentSoft(object); 462 } 463 464 465 466 467 Vector CameraTarget::iterate(float dt, const Vector* Target, const Vector* cam) 468 { 469 470 471 Vector tmpVec; 472 tmpVec= (*Target - *cam); 473 tmpVec.normalize(); 474 return tmpVec; 475 476 } 477 478 479 void CameraTarget::translate(float dt) 480 { 481 if (fabs(translateTo.len() - (target->getAbsCoor()).len()) >= 11 ) 482 { 483 printf("translate\n"); 484 Vector tmpVec= iterate(dt, &translateTo, &(masta->getAbsCoor())); 485 target->shiftCoor(speed*tmpVec.x, speed*tmpVec.y, speed*tmpVec.z); 486 } 487 } 488 489 Vector * CameraTarget::rotate(Vector* newPos, float speed) 490 { 491 492 } 493 494 void CameraTarget::jump(float x, float y, float z) 495 { 496 target->setAbsCoor(x,y,z); 497 } 498 499 500 void CameraTarget::trans(float x, float y, float z) 501 { 502 Vector tmpVec=Vector(x,y,z); 503 if( this->getParent()) 504 this->getParent()->setRelCoor(this->getParent()->getRelCoor()); 505 translateNow(&tmpVec); 506 } 507 508 void CameraTarget::translateNow(Vector* vec) 509 { 510 translateTo=*vec; 511 } 512 513 void CameraTarget::changeSpeed(float speed) 514 { 515 if (speed!=0) 516 this->speed=speed; 517 return; 518 } 519 520 521 bool CameraTarget::isDone() 522 { 523 if (fabs(translateTo.len() - (target->getAbsCoor()).len()) >= 11 ) 524 return 0; 525 else 526 return 1; 527 } -
trunk/src/world_entities/camera.h
r10368 r10379 11 11 #include "plane.h" 12 12 13 13 14 class World; 14 15 class CameraTarget; 15 16 class Event; 16 17 17 18 18 //! Camera … … 22 22 class Camera : public PNode, public EventListener 23 23 { 24 friend class CameraTarget; 25 friend class CameraMan; 24 26 ObjectListDeclaration(Camera); 25 27 public: … … 34 36 ViewTop 35 37 }; 36 38 public: 37 39 Camera(); 38 40 Camera(const TiXmlElement* root); … … 42 44 CameraTarget* getTarget() const { return this->target; }; 43 45 PNode* getTargetNode() const; 44 46 void setTargetNode(PNode* target); 45 47 void setAspectRatio(float aspectRatio); 46 48 inline float getAspectRatio() {return this->aspectRatio;}; … … 70 72 inline bool getEventHandling() {return this->eventHandling;} 71 73 74 void glLookAt(float eyex, float eyey, float eyez, float centerx, float centery, float centerz, float upx, float upy, float upz); 75 Vector* VectorProd(Vector* v1, Vector* v2); 76 void Rotate(); 72 77 void tick(float dt); 73 78 void apply (); … … 75 80 76 81 void process(const Event &event); 82 //CameraTarget* target; //!< The Target of the Camera (where this Camera Looks at) 77 83 78 //virtual void loadParams(const TiXmlElement* root);84 virtual void loadParams(const TiXmlElement* root); 79 85 80 86 void setViewTopFovy(float fovy); … … 132 138 class CameraTarget : public PNode 133 139 { 134 friend class Camera; 140 friend class Camera; //! The CameraTarget is a friend of Camera. noone else needs a CameraTarget, so noone else can create it. 135 141 ObjectListDeclaration(CameraTarget); 136 142 137 143 private: 138 144 CameraTarget(); 145 virtual ~CameraTarget() {} 146 float speed; 147 PNode* target; 148 PNode* freeTarget; 149 Camera* masta; 150 Vector translateTo; 151 Vector rotateBy; 152 139 153 140 154 public: 155 156 void detach(); 157 void atach(PNode* object); 158 Vector iterate(float dt, const Vector* target, const Vector* cam); 159 void translate(float dt); 160 void changeSpeed(float speed); 161 Vector* rotate(Vector* newPos, float speed); 162 void jump(float x, float y, float z); 163 void translateNow(Vector* vec); 164 PNode* createStick(); 165 void trans(float x, float y, float z); 166 bool isDone(); 141 167 }; 142 168 143 169 170 171 144 172 #endif /* _CAMERA_H */ 173 -
trunk/src/world_entities/test_entity.h
r9927 r10379 3 3 4 4 #include "world_entity.h" 5 #include "cameraman.h" 5 6 6 7 class TiXmlElement; 7 8 class Material; 8 9 9 10 class TestEntity : public WorldEntity 10 11 { 11 12 ObjectListDeclaration(TestEntity); 13 14 private: 15 16 CameraMan* CM; 12 17 13 18 public: … … 18 23 void init(); 19 24 virtual void loadParams(const TiXmlElement* root); 20 21 25 void test(); 26 void t2(); 27 void t3(); 28 void t4(); 29 void t5(); 30 void changeState (bool); 22 31 virtual void tick (float time); 23 32 virtual void draw() const;
Note: See TracChangeset
for help on using the changeset viewer.