Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 13, 2005, 4:30:07 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: simple-aiming function, with visible targetting-system

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/world_entities/src/world_entities/weapons/aim.cc

    r5558 r5559  
    2020#include "load_param.h"
    2121#include "graphics_engine.h"
    22 #include "glincl.h"
    2322#include "state.h"
     23#include "list.h"
    2424#include "material.h"
     25
     26#include "world_entity.h"
    2527
    2628using namespace std;
     
    5860
    5961  this->setLayer(E2D_LAYER_TOP);
    60   this->setRotationSpeed(5);
     62  this->setRotationSpeed(30.0* (float)rand()/RAND_MAX + 10.0);
    6163  this->setSize(GraphicsEngine::getInstance()->getResolutionX()/10.0);
    6264
    63 //  this->setBindNode(this);
     65  this->setBindNode(this);
    6466  this->material = new Material;
    6567}
     
    7981      .describe("the Speed with which the Aim should rotate");
    8082}
     83
     84void Aim::searchTarget(PNode* source)
     85{
     86  tIterator<WorldEntity>* iterator = State::getWorldEntityList()->getIterator();
     87  WorldEntity* entity = iterator->firstElement();
     88  while (likely(entity != NULL))
     89  {
     90    if (entity->isA(CL_NPC) && (source->getAbsCoor() - entity->getAbsCoor()).len() < 100)
     91    {
     92      this->setParent(entity);
     93      delete iterator;
     94      return;
     95    }
     96    entity = iterator->nextElement();
     97  }
     98
     99  delete iterator;
     100}
     101
    81102
    82103
     
    109130
    110131
    111   float z = 0.0f;
    112   glReadPixels ((int)this->getAbsCoor2D().x,
    113                  GraphicsEngine::getInstance()->getResolutionY()-(int)this->getAbsCoor2D().y-1,
    114                  1,
    115                  1,
    116                  GL_DEPTH_COMPONENT,
    117                  GL_FLOAT,
    118                  &z);
    119 
    120 
    121   GLdouble objX=.0, objY=.0, objZ=.0;
    122   gluUnProject(this->getAbsCoor2D().x,
    123                GraphicsEngine::getInstance()->getResolutionY()-this->getAbsCoor2D().y-1,
    124                .99,  // z
    125                GraphicsEngine::modMat,
    126                GraphicsEngine::projMat,
    127                GraphicsEngine::viewPort,
    128                &objX,
    129                &objY,
    130                &objZ );
    131 
    132   this->setAbsCoor(objX, objY, objZ);
     132//   float z = 0.0f;
     133//   glReadPixels ((int)this->getAbsCoor2D().x,
     134//                  GraphicsEngine::getInstance()->getResolutionY()-(int)this->getAbsCoor2D().y-1,
     135//                  1,
     136//                  1,
     137//                  GL_DEPTH_COMPONENT,
     138//                  GL_FLOAT,
     139//                  &z);
     140//
     141//
     142//   GLdouble objX=.0, objY=.0, objZ=.0;
     143//   gluUnProject(this->getAbsCoor2D().x,
     144//                GraphicsEngine::getInstance()->getResolutionY()-this->getAbsCoor2D().y-1,
     145//                .99,  // z
     146//                GraphicsEngine::modMat,
     147//                GraphicsEngine::projMat,
     148//                GraphicsEngine::viewPort,
     149//                &objX,
     150//                &objY,
     151//                &objZ );
     152//
     153//   this->setAbsCoor(objX, objY, objZ);
    133154}
    134155
Note: See TracChangeset for help on using the changeset viewer.