Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1308


Ignore:
Timestamp:
May 16, 2008, 11:27:09 AM (16 years ago)
Author:
FelixSchulthess
Message:

dot on radar moves now, but not continious (nonsatisfying)

Location:
code/branches/hud3
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/hud3/bin/levels/sample.oxw

    r1290 r1308  
    1  <!--audio>
     1<!--
     2<audio>
    23        <ambient>
    34                <ogg src="allgorythm-lift_up" />
     
    78                <ogg src="tha_silent_partner_-_void" />
    89        </ambient>
    9   </audio-->
     10</audio>
     11-->
    1012
    1113<!--Ambient colourvalue="1,1,1" /-->
    1214<Skybox src="Orxonox/StarSkyBox" />
    13 <SpaceShip camera="true" position="0,0,0" scale="10" yawpitchroll="-90,-90,0" mesh="assff.mesh" maxSpeed="500" maxSideAndBackSpeed="50" maxRotation="1.0" transAcc="200" rotAcc="3.0" transDamp="75" rotDamp="1.0" />
     15<SpaceShip camera="true" position="0,0,0" scale="10" yawpitchroll="0,0,0" mesh="assff.mesh" maxSpeed="500" maxSideAndBackSpeed="50" maxRotation="1.0" transAcc="200" rotAcc="3.0" transDamp="75" rotDamp="1.0" />
    1416
    1517<NPC position="0,100,400" scale="1" mesh="razor.mesh"/>
  • code/branches/hud3/src/orxonox/hud/HUD.h

    r1302 r1308  
    4444namespace orxonox
    4545{
    46   class _OrxonoxExport HUD : Tickable
     46  class _OrxonoxExport HUD : public Tickable
    4747  {
    4848  private:
  • code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc

    r1302 r1308  
    6060        left_ = left;
    6161        top_ = top;
    62         count_ = 0;
     62        count_ = 100;
    6363        container_ = container;
    6464
    6565        shipPos_ = Vector3(0.0, 0.0, 0.0);
    66         targetPos_ = Vector3(42.0, 42.0, 0.0);
    67         initialDir_ = Vector3(0.0, 0.0, 1.0);
     66        targetPos_ = Vector3(42.0, 0.0, 0.0);
     67        initialDir_ = Vector3(1.0, 0.0, 0.0);
    6868        currentDir_ = initialDir_;
    69         initialOrth_ = Vector3(0.0, 1.0, 0.0);
     69        initialOrth_ = Vector3(0.0, 0.0, 1.0);
    7070        currentOrth_ = initialOrth_;
    71 
    72         alpha_ = acos((currentDir_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentDir_.length()));
    73         beta_ = acos((currentOrth_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentOrth_.length()));
    74         vec_ = currentDir_.crossProduct(currentOrth_);
    75 
    76         if(vec_.dotProduct(targetPos_ - shipPos_) > 0)
    77             right_ = true;
    78         else
    79             right_=false;
    80 
     71     
    8172        setMetricsMode(Ogre::GMM_PIXELS);
    8273        setPosition(left,top);
     
    8879        point->show();
    8980        container->addChild(point);
     81        point->setMaterialName("Orxonox/RedPoint");
     82        point->setDimensions(5,5);
     83        point->setMetricsMode(Ogre::GMM_PIXELS);
    9084
    91         if (right_){
    92             point->setPosition(sin(beta_)*alpha_/3.5*dim_/2+dim_/2+left-2,-cos(beta_)*alpha_/3.5*dim_/2+dim_/2+top-2);
    93             point->setMaterialName("Orxonox/RedPoint");
    94             point->setDimensions(5,5);
    95             point->setMetricsMode(Ogre::GMM_PIXELS);
    96         }
    97 
    98         else {
    99             point->setPosition(-sin(beta_)*alpha_/3.5*dim_/2+dim_/2+left-2,-cos(beta_)*alpha_/3.5*dim_/2+dim_/2+top-2);
    100             point->setMaterialName("Orxonox/RedPoint");
    101             point->setDimensions(5,5);
    102             point->setMetricsMode(Ogre::GMM_PIXELS);
    103         }
    10485    }
    10586
     
    11495
    11596    void RadarOverlayElement::update() {
     97        if(count_++ >= 100) {           // for testing purposes
     98                        count_ = 0;
     99                        COUT(3) << "pos:  " << shipPos_ << std::endl;
     100                        COUT(3) << "dir:  " << currentDir_ << std::endl;
     101                        COUT(3) << "orth: " << currentOrth_ << std::endl << std::endl;         
     102        }
    116103        shipPos_ = SpaceShip::instance_s->getPosition();
    117         currentDir_ = SpaceShip::instance_s->getOrientation()*initialDir_; // according to beni....
     104        currentDir_ = SpaceShip::instance_s->getOrientation()*initialDir_;              // according to beni....
     105                currentOrth_ = SpaceShip::instance_s->getOrientation()*initialOrth_;
     106               
     107                radius_ = acos((currentDir_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentDir_.length()));
     108        phi_ = acos((currentOrth_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentOrth_.length()));
     109        vec_ = currentDir_.crossProduct(currentOrth_);
     110        if(vec_.dotProduct(targetPos_ - shipPos_) > 0) right_ = true;
     111        else right_=false;
     112       
     113        if (right_){
     114            point->setPosition(sin(phi_)*radius_/3.5*dim_/2+dim_/2+left_-2,-cos(phi_)*radius_/3.5*dim_/2+dim_/2+top_-2);         
     115        }
     116        else {
     117            point->setPosition(-sin(phi_)*radius_/3.5*dim_/2+dim_/2+left_-2,-cos(phi_)*radius_/3.5*dim_/2+dim_/2+top_-2);
     118        }
    118119    }
    119120
  • code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc~

    r1295 r1308  
    2626*/
    2727
    28 /*      local coordinate system of space ship:
     28/*      local coordinate system of space ship at the beginning:
    2929
    3030                        y
     
    3333                        | /
    3434                        |/
    35                x +------O
     35   x +------O
    3636*/
    3737
     
    4242#include "RadarOverlayElement.h"
    4343
    44 
    4544namespace orxonox
    4645{
    47   using namespace Ogre;
     46    using namespace Ogre;
    4847
    49   RadarOverlayElement::RadarOverlayElement(const String& name):Ogre::PanelOverlayElement(name){
    50     initialDir = Vector3(0.0, 0.0, 1.0);
    51   }
     48    RadarOverlayElement::RadarOverlayElement(const String& name):Ogre::PanelOverlayElement(name){
     49    }
    5250
    53   RadarOverlayElement::~RadarOverlayElement(){}
     51    RadarOverlayElement::~RadarOverlayElement(){
     52    }
    5453
    55   void RadarOverlayElement::initialise(){
    56     PanelOverlayElement::initialise();
    57   }
    58  
    59   void RadarOverlayElement::initRadarOverlayElement(Real left, Real top, int dim, Ogre::OverlayContainer* container){
     54    void RadarOverlayElement::initialise(){
     55        PanelOverlayElement::initialise();
     56    }
    6057
    61     dirX_ = 0;  // direction of travel
    62     dirY_ = 0;
    63     dirZ_ = 1;
    64    
    65     ortX_ = 0;  // normal of ship
    66     ortY_ = 1;
    67     ortZ_ = 0;
    68    
    69     dX_ = 37;
    70     dY_ = 0;
    71     dZ_ = 0;
    72    
    73     alpha_ = acos((dirX_*dX_+dirY_*dY_+dirZ_*dZ_)/(sqrt(pow(dX_,2)+pow(dY_,2)+pow(dZ_,2))*sqrt(pow(dirX_,2)+pow(dirY_,2)+pow(dirZ_,2))));
    74     beta_ = acos((ortX_*dX_+ortY_*dY_+ortZ_*dZ_)/(sqrt(pow(dX_,2)+pow(dY_,2)+pow(dZ_,2))*sqrt(pow(ortX_,2)+pow(ortY_,2)+pow(ortZ_,2))));
    75     vecX_ = dirY_*ortZ_ - dirZ_*ortY_;
    76     vecY_ = dirZ_*ortX_ - dirX_*ortZ_;
    77     vecZ_ = dirX_*ortY_ - dirY_*ortX_;
    78    
    79     if((vecX_*dX_+vecY_*dY_+vecZ_*dZ_)>0){right_=true;}
    80     else right_=false;
    81    
    82     setMetricsMode(Ogre::GMM_PIXELS);
    83     setPosition(left,top);
    84     setDimensions(dim,dim);
    85     setMaterialName("Orxonox/Radar");
    86    
    87     Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
     58    void RadarOverlayElement::initRadarOverlayElement(Real left, Real top, int dim, Ogre::OverlayContainer* container){
     59        dim_ = dim;
     60        left_ = left;
     61        top_ = top;
     62        count_ = 100;
     63        container_ = container;
    8864
    89     PanelOverlayElement* point = static_cast<PanelOverlayElement*>(overlayManager.createOverlayElement("Panel", "point"));
    90     point->show();
    91    
    92     container->addChild(point);
    93    
    94     if (right_){
    95       point->setPosition(sin(beta_)*alpha_/3.5*dim/2+dim/2+left-2,-cos(beta_)*alpha_/3.5*dim/2+dim/2+top-2);
    96       point->setMaterialName("Orxonox/RedPoint");
    97       point->setDimensions(5,5);
    98       point->setMetricsMode(Ogre::GMM_PIXELS);
     65        shipPos_ = Vector3(0.0, 0.0, 0.0);
     66        targetPos_ = Vector3(42.0, 0.0, 0.0);
     67        initialDir_ = Vector3(1.0, 0.0, 0.0);
     68        currentDir_ = initialDir_;
     69        initialOrth_ = Vector3(0.0, 0.0, 1.0);
     70        currentOrth_ = initialOrth_;
     71     
     72        setMetricsMode(Ogre::GMM_PIXELS);
     73        setPosition(left,top);
     74        setDimensions(dim_,dim_);
     75        setMaterialName("Orxonox/Radar");
     76
     77        om = &Ogre::OverlayManager::getSingleton();
     78        point = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", "point"));
     79        point->show();
     80        container->addChild(point);
     81        point->setMaterialName("Orxonox/RedPoint");
     82        point->setDimensions(5,5);
     83        point->setMetricsMode(Ogre::GMM_PIXELS);
     84
    9985    }
    100  
    101     else {
    102       point->setPosition(-sin(beta_)*alpha_/3.5*dim/2+dim/2+left-2,-cos(beta_)*alpha_/3.5*dim/2+dim/2+top-2);
    103       point->setMaterialName("Orxonox/RedPoint");
    104       point->setDimensions(5,5);
    105       point->setMetricsMode(Ogre::GMM_PIXELS);
     86
     87//    void RadarOverlayElement::setMainShipPosition(int dirX, int dirY, int dirZ, int ortX, int ortY, int ortZ){
     88//        dirX_=dirX;
     89//        dirY_=dirY;
     90//        dirZ_=dirZ;
     91//        ortX_=ortX;
     92//        ortY_=ortY;
     93//        ortZ_=ortZ;
     94//    }
     95
     96    void RadarOverlayElement::update() {
     97        if(count_++ >= 100) {           // for testing purposes
     98                        count_ = 0;
     99                        COUT(3) << "pos:  " << shipPos_ << std::endl;
     100                        COUT(3) << "dir:  " << currentDir_ << std::endl;
     101                        COUT(3) << "orth: " << currentOrth_ << std::endl << std::endl;         
     102        }
     103        shipPos_ = SpaceShip::instance_s->getPosition();
     104        currentDir_ = SpaceShip::instance_s->getOrientation()*initialDir_;              // according to beni....
     105                currentOrth_ = SpaceShip::instance_s->getOrientation()*initialOrth_;
     106               
     107                radius_ = acos((currentDir_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentDir_.length()));
     108        phi_ = acos((currentOrth_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentOrth_.length()));
     109        vec_ = currentDir_.crossProduct(currentOrth_);
     110        if(vec_.dotProduct(targetPos_ - shipPos_) > 0) right_ = true;
     111        else right_=false;
     112       
     113        if (right_){
     114            point->setPosition(sin(phi_)*radius_/3.5*dim_/2+dim_/2+left_-2,-cos(phi_)*radius_/3.5*dim_/2+dim_/2+top_-2);         
     115        }
     116        else {
     117            point->setPosition(-sin(phi_)*radius_/3.5*dim_/2+dim_/2+left_-2,-cos(phi_)*radius_/3.5*dim_/2+dim_/2+top_-2);
     118        }
    106119    }
    107   }
    108    
    109   void RadarOverlayElement::setMainShipPosition(int dirX, int dirY, int dirZ, int ortX, int ortY, int ortZ){
    110     dirX_=dirX;
    111     dirY_=dirY;
    112     dirZ_=dirZ;
    113     ortX_=ortX;
    114     ortY_=ortY;
    115     ortZ_=ortZ;
    116   }
    117  
    118  
    119  
     120
    120121}
    121122
  • code/branches/hud3/src/orxonox/hud/RadarOverlayElement.h

    r1302 r1308  
    5656    Vector3 shipPos_;               //position of ship
    5757    Vector3 vec_;                   //vector product dir X ort
    58     double alpha_;                  //defines the radius in the radar
    59     double beta_;                   //defines the angle in the radar
     58    double radius_;                  //defines the radius in the radar
     59    double phi_;                   //defines the angle in the radar
    6060    float left_, top_;
    6161    bool right_;                    //checks whether the object is on the right side (since cos is not bijective)
  • code/branches/hud3/src/orxonox/objects/SpaceShip.cc

    r1295 r1308  
    432432
    433433    std::string SpaceShip::whereAmI() {
    434         return getConvertedValue<int, std::string>(SpaceShip::instance_s->getPosition().x)
    435         + "  " + getConvertedValue<int, std::string>(SpaceShip::instance_s->getPosition().y)
    436         + "  " + getConvertedValue<int, std::string>(SpaceShip::instance_s->getPosition().z);
     434        return getConvertedValue<float, std::string>(SpaceShip::instance_s->getPosition().x)
     435        + "  " + getConvertedValue<float, std::string>(SpaceShip::instance_s->getPosition().y)
     436        + "  " + getConvertedValue<float, std::string>(SpaceShip::instance_s->getPosition().z);
    437437    }
    438438
Note: See TracChangeset for help on using the changeset viewer.