Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 13, 2006, 3:23:05 PM (17 years ago)
Author:
gfilip
Message:

little update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/camera/src/world_entities/camera.cc

    r9869 r10065  
    1818#include "key_mapper.h"
    1919#include "glincl.h"
     20#include "vector.h"
     21#include <iostream.h>
     22
    2023
    2124ObjectListDefinition(Camera);
     
    138141  this->viewVector = (this->target->getAbsCoor() - this->getAbsCoor()).getNormalized();
    139142  this->frustumPlane = Plane(this->viewVector, this->getAbsCoor() + this->viewVector * 0.1);
    140 
    141143  this->upVector =  this->getAbsDirV();
     144
     145
     146
    142147
    143148
     
    179184  Vector targetPosition = this->target->getAbsCoor();
    180185
    181        // Setting the Camera Eye, lookAt and up Vectors
    182   gluLookAt(cameraPosition.x, cameraPosition.y, cameraPosition.z,
     186        //Setting the Camera Eye, lookAt and up Vectors
     187  glLookAt(cameraPosition.x, cameraPosition.y, cameraPosition.z,
    183188            targetPosition.x, targetPosition.y, targetPosition.z,
    184189            this->upVector.x, this->upVector.y, this->upVector.z);
     
    217222  }
    218223}
     224
     225/*
     226Vector* Camera::translate(Vector* newPos, float speed)
     227{
     228glTranslatef(Vector);
     229
     230}
     231
     232
     233float 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*/
     242void Camera::Rotate()
     243{
     244this->fovy=this->fovy+1;
     245}
     246
     247
     248void 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
     276Vector* Camera::VectorProd(Vector* v1, Vector* v2)
     277{
     278Vector* temp= new Vector();
     279temp->x=v1->y * v2->z - v1->z * v2->y;
     280temp->y=v1->z * v2->x - v1->x * v2->z;
     281temp->z=v1->x * v2->y - v1->y * v2->x;
     282return temp;
     283}
     284
     285
     286
     287
     288
     289
     290
     291
     292
     293
     294
     295
    219296
    220297
     
    228305  this->registerObject(this, CameraTarget::_objectList);
    229306  //  this->setParentMode(PNODE_MOVEMENT);
    230 }
    231 
     307
     308
     309}
     310
     311
     312CameraTarget::detach()
     313{
     314  State::getCameraTargetNode()->setParentSoft(NULL);
     315}
     316
     317
     318
     319
     320
Note: See TracChangeset for help on using the changeset viewer.