Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10065 in orxonox.OLD for branches/camera/src


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

little update

Location:
branches/camera/src/world_entities
Files:
4 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
  • branches/camera/src/world_entities/camera.h

    r9869 r10065  
    5858  inline float distance(const PNode* node) const { return distance(node->getAbsCoor()); }
    5959
     60  void glLookAt(float eyex, float eyey, float eyez, float centerx, float centery, float centerz, float upx, float upy, float upz);
     61  Vector* VectorProd(Vector* v1, Vector* v2);
     62  void Rotate();
    6063  void tick(float dt);
    6164  void apply ();
  • branches/camera/src/world_entities/test_entity.cc

    r10018 r10065  
    2525
    2626
    27 
     27#include "material.h"
    2828
    2929#include "state.h"
     
    7373  this->registerObject(this, TestEntity::_objectList);
    7474  this->toList(OM_GROUP_00);
     75
     76  this->material = new Material();
     77  this->material->setIllum(3);
     78  this->material->setDiffuse(1.0,1.0,1.0);
     79  this->material->setSpecular(0.0,0.0,0.0);
     80  this->material->setAmbient(1.0, 1.0, 1.0);
     81  this->material->setDiffuseMap("maps/TE2.tga");
    7582}
    7683
     
    93100  glDisable(GL_LIGHTING);
    94101//   glDisable(GL_BLEND);
    95 // 
     102//
    96103//   glEnable(GL_TEXTURE_2D);
    97104//   glBindTexture(GL_TEXTURE_2D, media_container->getFrameTexture(counter));
     
    104111//PRINTF(0)("axis: %f\n", axis);
    105112glEnable(GL_BLEND);     // Turn Blending On
    106  
     113
    107114
    108115
     
    121128  glEnd();
    122129
    123  // glPopMatrix();
    124  // glPopAttrib();
     130  glPopMatrix();
     131  glPopAttrib();
    125132}
    126133
     
    130137void TestEntity::tick (float time)
    131138{
    132 if (state==0)
    133 i=0;
    134 else
    135 i=i+0.005;
    136 
    137 
    138 
    139 
     139  if (state==0 && i==1)
     140    i=0;
     141  if (state==1 && i<=1)
     142    i=i+0.005;
    140143}
    141144
    142145
    143 //void TestEntity::changeState (bool sta)
    144 //{
    145 //state=sta;
    146 //}
     146void TestEntity::changeState (bool sta)
     147{
     148  state=sta;
     149}
  • branches/camera/src/world_entities/test_entity.h

    r10018 r10065  
    55
    66class TiXmlElement;
    7 
     7class Material;
    88
    99class TestEntity : public WorldEntity
    1010{
    1111    ObjectListDeclaration(TestEntity);
     12
     13  private:
     14
     15    Material*       material;
    1216
    1317  public:
     
    1923    virtual void loadParams(const TiXmlElement* root);
    2024
    21 
     25    void changeState (bool);
    2226    virtual void tick (float time);
    2327    virtual void draw() const;
Note: See TracChangeset for help on using the changeset viewer.