Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10379 in orxonox.OLD for trunk/src/world_entities


Ignore:
Timestamp:
Jan 26, 2007, 10:58:31 AM (18 years ago)
Author:
patrick
Message:

merged branche camera to trunk. resolved many conflicts as in the other projects too

Location:
trunk/src/world_entities
Files:
5 edited
5 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/Makefile.am

    r10368 r10379  
    66
    77## THESE ARE THE BASE CLASSES OF ALL WORLD_ENTITIES
    8 libORXwe_a_SOURCES = world_entity.cc                            camera.cc               playable.cc             player.cc \
     8libORXwe_a_SOURCES = world_entity.cc    cameraman.cc                    camera.cc               playable.cc             player.cc \
    99                                                npcs/npc.cc                             weapons/weapon_manager.cc               weapons/crosshair.cc \
    1010                                weapons/weapon.cc               weapons/ammo_container.cc               projectiles/projectile.cc \
     
    1414
    1515
    16 noinst_HEADERS = world_entity.h                                 camera.h                extendable.h            playable.h \
     16noinst_HEADERS = world_entity.h         cameraman.h                     camera.h                extendable.h            playable.h \
    1717                                player.h                                npcs/npc.h                              weapons/weapon_manager.h                weapons/crosshair.h \
    1818                                weapons/weapon.h                weapons/ammo_container.h                projectiles/projectile.h \
  • trunk/src/world_entities/WorldEntities.am

    r10374 r10379  
    2424                world_entities/test_entity.cc \
    2525                world_entities/test_entity2.cc \
     26                world_entities/blackscreen.cc \
    2627                world_entities/planet.cc \
    2728                world_entities/bsp_entity.cc \
     
    151152                test_entity.h \
    152153                test_entity2.h \
     154                blackscreen.h \
    153155                planet.h \
    154156                bsp_entity.h \
  • trunk/src/world_entities/blackscreen.cc

    r10377 r10379  
    2323#include "material.h"
    2424#include "state.h"
    25 #include "class_id_DEPRECATED.h"
    2625
    2726ObjectListDefinition(BlackScreen);
  • trunk/src/world_entities/camera.cc

    r10368 r10379  
    1818#include "key_mapper.h"
    1919#include "glincl.h"
    20 //#include "util/loading/load_param.h"
     20#include "util/loading/load_param.h"
    2121#include "world_entity.h"
     22#include "vector.h"
     23#include "targets.h"
     24
     25
     26
    2227
    2328ObjectListDefinition(Camera);
     29
    2430
    2531/**
     
    5157  this->setName("camera");
    5258  this->target = new CameraTarget();
    53 
     59  this->target->masta=this;
    5460  this->subscribeEvent(ES_GAME, KeyMapper::PEV_VIEW0);
    5561  this->subscribeEvent(ES_GAME, KeyMapper::PEV_VIEW1);
     
    8995void Camera::lookAt(PNode* target)
    9096{
     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*/
     103PNode* Camera::getTargetNode() const
     104{
     105  return (PNode*)this->target;
     106}
     107
     108void Camera::setTargetNode(PNode* target)
     109{
    91110  this->target->setParent(target);
    92 }
    93 
    94 /**
    95  * @returns The PNode of the Target (from there you can get position and so on
    96 */
    97 PNode* Camera::getTargetNode() const
    98 {
    99   return (PNode*)this->target;
    100111}
    101112
     
    186197  this->viewVector = (this->target->getAbsCoor() - this->getAbsCoor()).getNormalized();
    187198  this->frustumPlane = Plane(this->viewVector, this->getAbsCoor() + this->viewVector * 0.1);
    188 
    189199  this->upVector =  this->getAbsDirV();
    190200
    191 
     201  // iteration for fovy
    192202  float tmpFovy = (this->toFovy - this->fovy);
    193203  if (fabsf(tmpFovy) > 0.01)
    194204    this->fovy += tmpFovy * fabsf(dt);
     205
     206
     207
     208
     209  //iterate(float dt, translate, target)
     210  target->translate(dt);
    195211}
    196212
     
    227243  Vector targetPosition = this->target->getAbsCoor();
    228244
    229        // Setting the Camera Eye, lookAt and up Vectors
     245        //Setting the Camera Eye, lookAt and up Vectors
    230246  gluLookAt(cameraPosition.x, cameraPosition.y, cameraPosition.z,
    231247            targetPosition.x, targetPosition.y, targetPosition.z,
     
    269285}
    270286
    271 /*
     287
    272288void Camera::loadParams(const TiXmlElement* root)
    273289{
     
    289305  LoadParam(root, "viewNormalDistance", this, Camera, setViewNormalDistance);
    290306}
    291 */
     307
    292308
    293309void Camera::setViewTopFovy(float fovy)
     
    350366  this->viewNormalDistance = Distance;
    351367}
     368
     369
     370
     371
     372void 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
     400Vector* Camera::VectorProd(Vector* v1, Vector* v2)
     401{
     402Vector* temp= new Vector();
     403temp->x=v1->y * v2->z - v1->z * v2->y;
     404temp->y=v1->z * v2->x - v1->x * v2->z;
     405temp->z=v1->x * v2->y - v1->y * v2->x;
     406return temp;
     407}
     408
     409
     410
     411
     412
     413
     414
     415
     416
     417
     418
     419
    352420
    353421
     
    355423// CAMERA-TARGET //
    356424///////////////////
     425//REATE_FACTORY(CameraTarget);
     426
    357427
    358428ObjectListDefinition(CameraTarget);
     429
     430
    359431CameraTarget::CameraTarget()
    360432{
    361433  this->registerObject(this, CameraTarget::_objectList);
    362434  //  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
     446void CameraTarget::detach()
     447{
     448  masta->setParentSoft(target);
     449  masta->getTargetNode()->setParentSoft(target);
     450}
     451
     452PNode* CameraTarget::createStick()
     453{
     454  return new Targets();
     455}
     456
     457
     458void CameraTarget::atach(PNode* object)
     459{
     460  masta->setParentSoft(object);
     461  masta->getTargetNode()->setParentSoft(object);
     462}
     463
     464
     465
     466
     467Vector 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
     479void 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
     489Vector * CameraTarget::rotate(Vector* newPos, float speed)
     490{
     491
     492}
     493
     494void CameraTarget::jump(float x, float y, float z)
     495{
     496target->setAbsCoor(x,y,z);
     497}
     498
     499
     500void 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
     508void CameraTarget::translateNow(Vector* vec)
     509{
     510translateTo=*vec;
     511}
     512
     513void CameraTarget::changeSpeed(float speed)
     514{
     515  if (speed!=0)
     516this->speed=speed;
     517  return;
     518}
     519
     520
     521bool 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  
    1111#include "plane.h"
    1212
     13
    1314class World;
    1415class CameraTarget;
    1516class Event;
    16 
    1717
    1818//! Camera
     
    2222class Camera : public PNode, public EventListener
    2323{
     24  friend class CameraTarget;
     25  friend class CameraMan;
    2426  ObjectListDeclaration(Camera);
    2527public:
     
    3436    ViewTop
    3537  };
    36 
     38  public:
    3739  Camera();
    3840  Camera(const TiXmlElement* root);
     
    4244  CameraTarget* getTarget() const { return this->target; };
    4345  PNode* getTargetNode() const;
    44 
     46  void setTargetNode(PNode* target);
    4547  void setAspectRatio(float aspectRatio);
    4648  inline float getAspectRatio() {return this->aspectRatio;};
     
    7072  inline bool getEventHandling() {return this->eventHandling;}
    7173
     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();
    7277  void tick(float dt);
    7378  void apply ();
     
    7580
    7681  void process(const Event &event);
     82  //CameraTarget*     target;          //!< The Target of the Camera (where this Camera Looks at)
    7783
    78   //virtual void loadParams(const TiXmlElement* root);
     84  virtual void loadParams(const TiXmlElement* root);
    7985
    8086  void              setViewTopFovy(float fovy);
     
    132138class CameraTarget : public PNode
    133139{
    134   friend class Camera;             //! The CameraTarget is a friend of Camera. noone else needs a CameraTarget, so noone else can create it.
     140  friend class Camera;        //! The CameraTarget is a friend of Camera. noone else needs a CameraTarget, so noone else can create it.
    135141  ObjectListDeclaration(CameraTarget);
    136142
    137143private:
    138144  CameraTarget();
     145  virtual ~CameraTarget() {}
     146  float speed;
     147  PNode* target;
     148  PNode* freeTarget;
     149  Camera* masta;
     150  Vector translateTo;
     151  Vector rotateBy;
     152
    139153
    140154public:
     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();
    141167};
    142168
    143169
     170
     171
    144172#endif /* _CAMERA_H */
     173
  • trunk/src/world_entities/test_entity.h

    r9927 r10379  
    33
    44#include "world_entity.h"
     5#include "cameraman.h"
    56
    67class TiXmlElement;
    7 
     8class Material;
    89
    910class TestEntity : public WorldEntity
    1011{
    1112    ObjectListDeclaration(TestEntity);
     13
     14  private:
     15
     16  CameraMan* CM;
    1217
    1318  public:
     
    1823    void init();
    1924    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);
    2231    virtual void tick (float time);
    2332    virtual void draw() const;
Note: See TracChangeset for help on using the changeset viewer.