Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 8, 2008, 5:04:18 PM (16 years ago)
Author:
landauf
Message:
  • added a prediction-crosshair to the navigation focus
  • fixed a bug in SpaceShipAI's target movement prediction - bots are more accurate now
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/hud/Navigation.cc

    r1564 r1566  
    3636// TODO: remove the SpaceShip and CameraHandler dependencies
    3737#include "objects/SpaceShip.h"
     38#include "objects/Projectile.h"
    3839#include "objects/CameraHandler.h"
    3940#include "RadarObject.h"
     
    8788        navMarker_->hide();
    8889        aimMarker_->hide();
     90        aimMarker_->setMaterialName("Orxonox/NavCrosshair");
     91        aimMarker_->setDimensions(20, 20);
     92        aimMarker_->setUV(0.0, 0.0, 1.0, 1.0);
    8993        container_->addChild(navMarker_);
    9094        container_->addChild(aimMarker_);
     
    106110        navText_->setCaption(Ogre::StringConverter::toString(dist));
    107111
    108         Vector3 pos = focus_->getPosition();
    109112        Ogre::Camera* navCam = SpaceShip::getLocalShip()->getCamera()->cam_;
    110113        // transform to screen coordinates
    111         pos = navCam->getProjectionMatrix() * navCam->getViewMatrix() * pos;
     114        Vector3 pos = navCam->getProjectionMatrix() * navCam->getViewMatrix() * focus_->getPosition();
     115        Vector3 aimpos = navCam->getProjectionMatrix() * navCam->getViewMatrix() * getPredictedPosition(SpaceShip::getLocalShip()->getPosition(), Projectile::getSpeed(), focus_->getPosition(), focus_->getOrientedVelocity());
    112116
    113117        float xPosRel = 0.5*pos.x+0.5;
    114118        float yPosRel = 1-(0.5*pos.y+0.5);
     119        float xAimPosRel = 0.5*aimpos.x+0.5;
     120        float yAimPosRel = 1-(0.5*aimpos.y+0.5);
    115121        int xPos = (int) (xPosRel*windowW);
    116122        int yPos = (int) (yPosRel*windowH);
     123        int xAimPos = (int) (xAimPosRel*windowW);
     124        int yAimPos = (int) (yAimPosRel*windowH);
    117125        int xFromCenter = xPos-windowW/2;
    118126        int yFromCenter = yPos-windowH/2;
     
    133141            navMarker_->setMaterialName("Orxonox/NavArrows");
    134142            navMarker_->setDimensions(16,16);
     143            aimMarker_->hide();
    135144            float phiUpperCorner = atan((float)(windowW)/(float)(windowH));
    136145            // from the angle we find out on which edge to draw the marker
     
    210219            // object is in view
    211220            navMarker_->setMaterialName("Orxonox/NavTDC");
    212             navMarker_->setDimensions(24,24);
     221            navMarker_->setDimensions(35, 35);
    213222            navMarker_->setUV(0.0, 0.0, 1.0, 1.0);
    214223            navMarker_->setPosition(xPos-navMarker_->getWidth()/2, yPos-navMarker_->getHeight()/2);
     224
     225            aimMarker_->show();
     226            aimMarker_->setPosition(xAimPos-aimMarker_->getWidth()/2, yAimPos-aimMarker_->getHeight()/2);
     227
    215228            navText_->setPosition(xPos+navMarker_->getWidth()/2, yPos+navMarker_->getHeight()/2);
    216229        }
     
    259272        if(focus_ == NULL){
    260273            navMarker_->hide();
     274            aimMarker_->hide();
    261275            navText_->hide();
    262276        }
Note: See TracChangeset for help on using the changeset viewer.