Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3238 in orxonox.OLD for orxonox/branches/nico/src/camera.cc


Ignore:
Timestamp:
Dec 20, 2004, 2:42:54 AM (19 years ago)
Author:
bensch
Message:

orxonox/branches: updated branches: buerli, nico, sound. And moved bezierTrack to old.bezierTrack. Conflicts resolved in a usefull order.
Conflics mostly resolved in favor of trunk
merge.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/nico/src/camera.cc

    r2636 r3238  
    3030{
    3131  this->world = world;
    32   bound = NULL;
     32  this->bound = NULL;
    3333  /* give it some physical live */
    34   m = 10;
    35   a = new Vector(0.0, 0.0, 0.0);
    36   v = new Vector(0.0, 0.0, 0.0);
    37   fs = new Vector(0.0, 0.0, 0.0);
    38   cameraMode = NORMAL;
    39   deltaTime = 3000.0;
    40   cameraOffset = 1.0;
    41   cameraOffsetZ = 10.0;
    42   t = 0.0;
    43 
    44   actual_place.r.x = 0.0;
    45   actual_place.r.y = 10.0;
    46   actual_place.r.z = -5.0;
     34  this->m = 10;
     35  this->a = new Vector(0.0, 0.0, 0.0);
     36  this->v = new Vector(0.0, 0.0, 0.0);
     37  this->fs = new Vector(0.0, 0.0, 0.0);
     38  this->cameraMode = NORMAL;
     39  this->deltaTime = 3000.0;
     40  this->cameraOffset = 1.0;
     41  this->cameraOffsetZ = 10.0;
     42  this->t = 0.0;
     43
     44  this->actualPlace.r.x = 0.0;
     45  this->actualPlace.r.y = 10.0;
     46  this->actualPlace.r.z = -5.0;
    4747}
    4848
     
    6161   as smooth camera movement or swaying).
    6262*/
    63 void Camera::time_slice (Uint32 deltaT)
    64 {
    65   if(t <= deltaTime)
    66     {t += deltaT;}
     63void Camera::timeSlice (Uint32 deltaT)
     64{
     65  if( this->t <= deltaTime)
     66    {this->t += deltaT;}
    6767  //printf("time is: t=%f\n", t );
    68   update_desired_place ();
    69   jump (NULL);
     68  updateDesiredPlace();
     69  jump(NULL);
    7070}
    7171
     
    7676   bound entity's position on the track.
    7777*/
    78 void Camera::update_desired_place ()
     78void Camera::updateDesiredPlace ()
    7979{
    8080  switch(cameraMode)
     
    8989        if( bound != NULL)
    9090          {
    91             bound->get_lookat (&lookat);
    92             orx->get_world()->calc_camera_pos (&lookat, &plFocus);
     91            bound->getLookat (&lookat);
     92            orx->getWorld()->calcCameraPos (&lookat, &plFocus);
    9393            Quaternion *fr;
    9494            if(t < 20.0)
     
    101101               
    102102                Vector op(1.0, 0.0, 0.0);
    103                 float angle = angle_deg(op, *start);
     103                float angle = angleDeg(op, *start);
    104104                printf("angle is: %f\n", angle);
    105105
     
    144144
    145145            Vector ursp(0.0, 0.0, 0.0);
    146             desired_place.r = /*plFocus.r -*/ ursp - res->apply(r);
    147 
    148             printf("desired place is: %f, %f, %f\n", desired_place.r.x, desired_place.r.y, desired_place.r.z);
     146            desiredPlace.r = /*plFocus.r -*/ ursp - res->apply(r);
     147
     148            printf("desired place is: %f, %f, %f\n", desiredPlace.r.x, desiredPlace.r.y, desiredPlace.r.z);
    149149            //plLastBPlace = *bound->get_placement();
    150150          }
     
    153153    case SMOTH_FOLLOW:
    154154      {
    155         Placement *plBound = bound->get_placement();
     155        Placement *plBound = bound->getPlacement();
    156156        Location lcBound;
    157157        if(bound != null)
    158158          {
    159             bound->get_lookat(&lcBound);
     159            bound->getLookat(&lcBound);
    160160            Vector vDirection(0.0, 0.0, 1.0);
    161161            vDirection = plBound->w.apply(vDirection);
    162             desired_place.r = (vDirection * ((lcBound.dist-10.0)/* / l*/)) + Vector(0,0,5.0);
     162            desiredPlace.r = (vDirection * ((lcBound.dist-10.0)/* / l*/)) + Vector(0,0,5.0);
    163163          }
    164164        break;
     
    169169        if(bound != null)
    170170          {
    171             Placement *plBound = bound->get_placement();
     171            Placement *plBound = bound->getPlacement();
    172172            Vector vDirection(0.0, 0.0, 1.0);
    173173            Vector eclipticOffset(0.0, 0.0, 5.0);
    174174            vDirection = plBound->w.apply(vDirection);
    175             desired_place.r = plBound->r - vDirection*10 + eclipticOffset;
     175            desiredPlace.r = plBound->r - vDirection*10 + eclipticOffset;
    176176          }
    177177        break;
     
    182182      if( bound != NULL && world != NULL )
    183183        {
    184           bound->get_lookat (&lookat);
    185           world->calc_camera_pos (&lookat, &desired_place);
     184          bound->getLookat (&lookat);
     185          world->calcCameraPos (&lookat, &desiredPlace);
    186186        }
    187187      else
    188188        {
    189           desired_place.r = Vector (0,0,0);
    190           desired_place.w = Quaternion ();
     189          desiredPlace.r = Vector (0,0,0);
     190          desiredPlace.w = Quaternion ();
    191191        }
    192192      break;
     
    206206  // view
    207207  // TO DO: implement options for frustum generation
    208   glFrustum(-1.0, 1.0, -1.0, 1.0, 1.5, 250.0);
     208  //glFrustum(-1.0, 1.0, -1.0, 1.0, 1.5, 250.0);
     209  gluPerspective(60, 1.2f, 0.1, 250);
     210 
    209211  //Vector up(0,0,1);
    210212  //Vector dir(1,0,0);
     
    235237  // rotation
    236238  float matrix[4][4];
    237   actual_place.w.conjugate().matrix (matrix);
     239  actualPlace.w.conjugate().matrix (matrix);
    238240  /* orientation and */
    239241  glMultMatrixf ((float*)matrix);
    240242  /*  translation */
    241   glTranslatef (-actual_place.r.x, -actual_place.r.y,- actual_place.r.z);
    242   //Placement *plBound = bound->get_placement();
     243  glTranslatef (-actualPlace.r.x, -actualPlace.r.y,- actualPlace.r.z);
     244//Placement *plBound = bound->get_placement();
    243245
    244246  // ===== second camera control calculation option
    245247  /*
    246     gluLookAt(actual_place.r.x, actual_place.r.y, actual_place.r.z,
     248   gluLookAt(actual_place.r.x, actual_place.r.y, actual_place.r.z,
    247249              plBound->r.x, plBound->r.y, plBound->r.z,
    248250              0.0, 0.0, 1.0);
     
    263265  if( plc == NULL)
    264266    {
    265       actual_place = desired_place;
     267      actualPlace = desiredPlace;
    266268      //printf("Camera|jump: camer@ %f, %f, %f\n\n", actual_place.r.x, actual_place.r.y, actual_place.r.z);
    267269    }
    268270  else
    269271    {
    270       desired_place = *plc;
    271       actual_place = *plc;
     272      desiredPlace = *plc;
     273      actualPlace = *plc;
    272274    }
    273275}
     
    277279  \param entity: The enitity to bind the camera to
    278280       
    279         This sets the focus of the camera to the given entity. This means that it will use the given WorldEntity's
    280         Location and get_lookat() to determine the viewpoint the camera will render from.
    281         Note that you cannot bind a camera to a free entity.
     281  This sets the focus of the camera to the given entity. This means that it will use the given WorldEntity's
     282  Location and get_lookat() to determine the viewpoint the camera will render from.
     283  Note that you cannot bind a camera to a free entity.
    282284*/
    283285void Camera::bind (WorldEntity* entity)
     
    285287  if( entity != NULL)
    286288    {
    287       if( entity->isFree ()) printf("Cannot bind camera to free entity");
     289      if( entity->isFree()) printf("Cannot bind camera to free entity");
    288290      else
    289291        {
    290           bound = entity;
     292          this->bound = entity;
    291293        }
    292294    }
     
    298300  this->world = world;
    299301}
     302
     303
     304/**
     305   \brief destroy, reset the camera so that it doesn't perform anything anymore
     306
     307*/
     308void Camera::destroy()
     309{
     310  this->bound = NULL;
     311  this->world = NULL;
     312}
Note: See TracChangeset for help on using the changeset viewer.