Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10379 in orxonox.OLD


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

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

Location:
trunk/src
Files:
11 edited
5 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/story_entities/game_world.cc

    r10376 r10379  
    449449
    450450    /* update tick the rest */
    451     this->dataTank->localCamera->tick(this->dtS);
     451    State::getCamera()->tick(this->dtS);
    452452    AnimationPlayer::getInstance()->tick(this->dtS);
    453453    PhysicsEngine::getInstance()->tick(this->dtS);
     
    578578void GameWorld::applyCameraSettings()
    579579{
    580   this->dataTank->localCamera->apply ();
    581   this->dataTank->localCamera->project ();
     580
     581  State::getCamera()->apply ();
     582  State::getCamera()->project ();
    582583  GraphicsEngine::storeMatrices();
    583584}
  • trunk/src/story_entities/game_world_data.cc

    r10317 r10379  
    3030#include "player.h"
    3131#include "camera.h"
     32#include "cameraman.h"
    3233#include "terrain.h"
    3334#include "skybox.h"
     
    7071  this->glmis = NULL;
    7172
    72   this->localCamera = NULL;
     73
    7374  this->localPlayer = NULL;
    7475  this->sky = NULL;
     
    9899
    99100  PNode::getNullParent();
    100   this->localCamera = new Camera();
    101   this->localCamera->setName ("GameWorld-Camera");
    102   State::setCamera(this->localCamera, this->localCamera->getTarget());
    103 
     101  Camera* localCamera = new Camera();
     102    localCamera->setName ("GameWorld-Camera");
     103  State::setCamera(localCamera, localCamera->getTarget());
     104  CameraMan* camMan = new CameraMan();
     105  State::setCameraman(camMan);
    104106  LightManager::getInstance();
    105107
     
    283285  State::setPlayer(NULL);
    284286  this->localPlayer = NULL;
    285   this->localCamera = NULL;
    286287  State::setCamera(NULL, NULL);
    287288  this->sky = NULL;
     
    333334  LoadParamXML(root, "GameRule", this, GameWorldData, loadGameRule);
    334335
    335   LoadParam(root, "clip-region", this->localCamera, Camera, setClipRegion);
     336  LoadParam(root, "clip-region", State::getCameraman(), CameraMan, setClipRegion);
    336337
    337338
     
    339340  //LoadParamXML(root, "PhysicsEngine", PhysicsEngine::getInstance(), PhysicsEngine, loadParams);
    340341
    341   if( this->sky != NULL)
    342     this->localCamera->addChild(this->sky);
    343   OrxSound::SoundEngine::getInstance()->setListener(this->localCamera);
     342
     343  OrxSound::SoundEngine::getInstance()->setListener(State::getCamera());
    344344
    345345  return ErrorMessage();
  • trunk/src/story_entities/game_world_data.h

    r9869 r10379  
    5656    GLMenuImageScreen*            glmis;          //!< The Level-Loader Display
    5757
    58     Camera*                       localCamera;    //!< The current camera
     58
    5959    Player*                       localPlayer;    //!< The player, you fly through the level.
    6060    WorldEntity*                  sky;            //!< The environmental sky of orxonox
  • trunk/src/story_entities/menu/game_menu.cc

    r10368 r10379  
    110110  this->subscribeEvent(ES_MENU, SDLK_ESCAPE);
    111111
    112   this->dataTank->localCamera->setRelCoor(this->cameraVector);
     112  State::getCamera()->setRelCoor(this->cameraVector);
    113113  //this->dataTank->localCamera->setFovy(60);
    114114
     
    391391  Quaternion q(/*0.00005*/ dt * .1, Vector(0.0, 1.0, 0.0));
    392392  this->cameraVector = q.apply(this->cameraVector);
    393   this->dataTank->localCamera->setRelCoor(this->cameraVector);
    394   this->dataTank->localCamera->getTarget()->setRelCoorSoft(0,0,0);
     393  State::getCamera()->setRelCoor(this->cameraVector);
     394  State::getCamera()->getTarget()->setRelCoorSoft(0,0,0);
    395395}
    396396
  • trunk/src/util/state.cc

    r9406 r10379  
    2020
    2121#include "camera.h"
     22#include "cameraman.h"
    2223
    2324#ifndef NULL
     
    3132Camera* State::camera = NULL;
    3233CameraTarget* State::cameraTarget = NULL;
     34
     35CameraMan* State::cameraManager = NULL;
    3336
    3437PNode* State::cameraNode = NULL;
     
    6366  State::cameraTargetNode = cameraTarget;
    6467}
     68
     69
     70void State::setCameraman(CameraMan* cm)
     71
     72{
     73  State::cameraManager=cm;
     74}
  • trunk/src/util/state.h

    r10368 r10379  
    1818class ObjectManager;
    1919class GameRules;
    20 
     20class CameraMan;
    2121class ScriptManager;
    2222
     
    4242  /** @returns a Pointer to the CameraTarget */
    4343  static inline PNode* getCameraTargetNode() { return State::cameraTargetNode; };
     44
     45
     46
     47  /////////////////////
     48  /// CAMERAMANAGER ///
     49  /////////////////////
     50  /** @param CameraMan the PNode to the cameraManagerager,*/
     51  static void setCameraman(CameraMan*);
     52  static inline CameraMan* getCameraman() { return State::cameraManager; };
     53
    4454
    4555  ////////////////
     
    123133  static Camera*                camera;             //!< The current Camera.
    124134  static CameraTarget*          cameraTarget;       //!< The Camera Target.
     135  static CameraMan*             cameraManager;
    125136  static PNode*                 cameraNode;         //!< A reference to the camera
    126137  static PNode*                 cameraTargetNode;   //!< A reference to the cameraTarget
  • 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.