Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4358 in orxonox.OLD for orxonox


Ignore:
Timestamp:
May 28, 2005, 12:33:39 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: movenet is as it should be in framework

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/subprojects/framework.cc

    r4349 r4358  
    3535    {
    3636#ifdef GUI_MODULE
    37       while(gtk_events_pending()) 
     37      while(gtk_events_pending())
    3838        gtk_main_iteration();
    3939#endif
     
    6060 
    6161  camera->apply();
     62      printf("distance: %f\n", (camera->getTarget()->getAbsCoor()-camera->getAbsCoor()).len());
    6263 
    6364  SDL_GL_SwapBuffers(); // Swap the buffers
     
    9798          h.normalize();
    9899          v.normalize();
     100          float distance = view.len();
     101         
     102          Vector newCameraPos = camera->getAbsCoor();
     103          Vector newTargetPos = camera->getTarget()->getAbsCoor();
     104          int changed = 0;
    99105
    100106          if (mouseDown[1])
    101             camera->setRelCoor(camera->getRelCoor()+ h * event.motion.xrel *.05 - v * event.motion.yrel * .05);
     107            {
     108              newCameraPos = camera->getRelCoor()+ (h * event.motion.xrel - v * event.motion.yrel) * .005 * distance;
     109              changed += 1;
     110            }
    102111          if (mouseDown[3])
    103             camera->getTarget()->setRelCoor(camera->getTarget()->getRelCoor()+ h * event.motion.xrel *.05 - v * event.motion.yrel * .05);
     112            {
     113              newTargetPos = camera->getTarget()->getRelCoor() + (h * event.motion.xrel - v * event.motion.yrel) * .005 * distance;
     114              changed += 2;
     115            }
     116         
     117          Vector newView = newTargetPos - newCameraPos;
     118
     119          if (changed == 1)
     120            camera->setRelCoor(newCameraPos + newView * (1- distance/newView.len()));
     121          else if (changed == 2)
     122            camera->getTarget()->setRelCoor(newTargetPos - newView * (1-distance/newView.len()));
     123          else if (changed == 3)
     124            {
     125              camera->setRelCoor(newCameraPos);
     126              camera->getTarget()->setRelCoor(newTargetPos);
     127            }
    104128           
    105129        }
Note: See TracChangeset for help on using the changeset viewer.