Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 661


Ignore:
Timestamp:
Dec 20, 2007, 6:55:17 PM (16 years ago)
Author:
nicolasc
Message:

added a test crosshair — same hack as blinky

Location:
code/branches/FICN
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/Media/materials/scripts/Orxonox.material

    r588 r661  
    403403}
    404404
     405material Orxonox/Crosshair
     406{
     407  technique
     408  {
     409    pass
     410    {
     411      lighting off
     412      scene_blend alpha_blend
     413      depth_check off
     414
     415      texture_unit
     416      {
     417        texture crosshair.png
     418      }
     419    }
     420  }
     421}
  • code/branches/FICN/src/loader/LevelLoader.cc

    r660 r661  
    4949LevelLoader::LevelLoader(string file, string path)
    5050{
    51         valid_ = false;
    52 
    53         // Load XML level file
    54         path.append("/");
    55         path.append(file);
    56 
    57         // Open xml file
    58         doc.LoadFile(path);
    59 
    60         // Check if file was loaded
    61         if (doc.LoadFile())
    62         {
    63                 TiXmlHandle hDoc(&doc);
    64                 TiXmlHandle hRoot(0);
    65                 TiXmlElement* pElem;
    66 
    67                 // Check for root element
    68                 pElem = hDoc.FirstChildElement("orxonoxworld").Element();
    69                 if (pElem)
    70                 {
    71                         // Set root element
    72                         hRoot = TiXmlHandle(pElem);
    73                         rootElement = hRoot.Element();
    74 
    75                         // Set level description
    76                         pElem = hRoot.FirstChild("description").Element();
    77                         if (pElem)
    78                         {
    79                                 description_ = pElem->GetText();
    80                         }
    81 
    82                         // Set level name
    83                         name_ = rootElement->Attribute("name");
    84                         image_ = rootElement->Attribute("image");
    85 
    86                         valid_ = true;
    87                 }
    88                 else
    89                 {
    90                         orxonox::Error("Level file has no valid root node");
    91                 }
    92         }
    93         else
    94         {
    95                 orxonox::Error("Could not load level file ");
    96         }
     51  valid_ = false;
     52
     53  // Load XML level file
     54  path.append("/");
     55  path.append(file);
     56
     57  // Open xml file
     58  doc.LoadFile(path);
     59
     60  // Check if file was loaded
     61  if (doc.LoadFile())
     62  {
     63    TiXmlHandle hDoc(&doc);
     64    TiXmlHandle hRoot(0);
     65    TiXmlElement* pElem;
     66
     67    // Check for root element
     68    pElem = hDoc.FirstChildElement("orxonoxworld").Element();
     69    if (pElem)
     70    {
     71      // Set root element
     72      hRoot = TiXmlHandle(pElem);
     73      rootElement = hRoot.Element();
     74
     75      // Set level description
     76      pElem = hRoot.FirstChild("description").Element();
     77      if (pElem)
     78      {
     79        description_ = pElem->GetText();
     80      }
     81
     82      // Set level name
     83      name_ = rootElement->Attribute("name");
     84      image_ = rootElement->Attribute("image");
     85
     86      valid_ = true;
     87    }
     88    else
     89    {
     90      orxonox::Error("Level file has no valid root node");
     91    }
     92  }
     93  else
     94  {
     95    orxonox::Error("Could not load level file ");
     96  }
    9797}
    9898
    99         void LevelLoader::loadLevel()
    100         {
    101                 if (valid_)
    102                 {
    103                         TiXmlElement* loadElem;
    104                         TiXmlElement* audioElem;
    105                         TiXmlElement* worldElem;
    106                         TiXmlElement* tElem;
    107                         TiXmlNode* tNode;
    108 
    109                         Ogre::OverlayManager& omgr = Ogre::OverlayManager::getSingleton();
    110                         Ogre::Overlay* mLoadOverlay; // FIXME: mey be uninitialized
    111 
    112                         // Set loading screen
    113                         loadElem = rootElement->FirstChildElement("loading");
    114                         if (loadElem)
    115                         {
    116                                 // Set background
    117                                 tElem = loadElem->FirstChildElement("background");
    118                                 if (tElem)
    119                                 {
    120                                         loadingBackgroundColor_ = tElem->Attribute("color");
    121                                         loadingBackgroundImage_ = tElem->Attribute("image");
    122                                 }
    123                                 // Set bar
    124                                 tElem = loadElem->FirstChildElement("bar");
    125                                 if (tElem)
    126                                 {
    127                                         loadingBarImage_ = tElem->Attribute("image");;
    128                                         loadingBarTop_ = tElem->Attribute("top");
    129                                         loadingBarLeft_ = tElem->Attribute("left");
    130                                         loadingBarWidth_ = tElem->Attribute("width");
    131                                         loadingBarHeight_ = tElem->Attribute("height");
    132                                 }
    133 
    134 
    135                     mLoadOverlay = (Ogre::Overlay*)omgr.getByName("Orxonox/LoadingScreenSample");
    136                     mLoadOverlay->show();
    137 
    138                                 COUT(0) << "\n\n\nThis is Orxonox\nthe hottest 3D action shooter ever to exist\n\n\n";
    139                                 COUT(0) << "Level: " << name() << "\nDescription:" << description() << "\nImage:"<<image()<<"\n\n\n";
    140                                 COUT(4) << "Backgroundcolor: " << loadingBackgroundColor_ << "\nBackgroundimage:" << loadingBackgroundImage_ << "\n\n\n";
    141 
    142                         }
    143 
    144                         // Load audio
    145                         audio::AudioManager* auMan = orxonox::Orxonox::getSingleton()->getAudioManagerPointer();
    146                         audioElem = rootElement->FirstChildElement("audio");
    147 
    148                         if (audioElem)
    149                         {
    150                                 audioElem = audioElem->FirstChildElement("ambient");
    151                                 if (audioElem)
    152                                 {
    153                                         tNode = 0;
     99  void LevelLoader::loadLevel()
     100  {
     101    if (valid_)
     102    {
     103      TiXmlElement* loadElem;
     104      TiXmlElement* audioElem;
     105      TiXmlElement* worldElem;
     106      TiXmlElement* tElem;
     107      TiXmlNode* tNode;
     108
     109      Ogre::OverlayManager& omgr = Ogre::OverlayManager::getSingleton();
     110      Ogre::Overlay* mLoadOverlay; // FIXME: mey be uninitialized
     111
     112      // Set loading screen
     113      loadElem = rootElement->FirstChildElement("loading");
     114      if (loadElem)
     115      {
     116        // Set background
     117        tElem = loadElem->FirstChildElement("background");
     118        if (tElem)
     119        {
     120          loadingBackgroundColor_ = tElem->Attribute("color");
     121          loadingBackgroundImage_ = tElem->Attribute("image");
     122        }
     123        // Set bar
     124        tElem = loadElem->FirstChildElement("bar");
     125        if (tElem)
     126        {
     127          loadingBarImage_ = tElem->Attribute("image");;
     128          loadingBarTop_ = tElem->Attribute("top");
     129          loadingBarLeft_ = tElem->Attribute("left");
     130          loadingBarWidth_ = tElem->Attribute("width");
     131          loadingBarHeight_ = tElem->Attribute("height");
     132        }
     133
     134
     135        mLoadOverlay = (Ogre::Overlay*)omgr.getByName("Orxonox/LoadingScreenSample");
     136        mLoadOverlay->show();
     137
     138        COUT(0) << "\n\n\nThis is Orxonox\nthe hottest 3D action shooter ever to exist\n\n\n";
     139        COUT(0) << "Level: " << name() << "\nDescription:" << description() << "\nImage:"<<image()<<"\n\n\n";
     140        COUT(4) << "Backgroundcolor: " << loadingBackgroundColor_ << "\nBackgroundimage:" << loadingBackgroundImage_ << "\n\n\n";
     141
     142      }
     143
     144      // Load audio
     145      audio::AudioManager* auMan = orxonox::Orxonox::getSingleton()->getAudioManagerPointer();
     146      audioElem = rootElement->FirstChildElement("audio");
     147
     148      if (audioElem)
     149      {
     150        audioElem = audioElem->FirstChildElement("ambient");
     151        if (audioElem)
     152        {
     153          tNode = 0;
    154154          //FIXME something is wrong, probably missing ==
    155                                         while( tNode = audioElem->IterateChildren( tNode ) )
    156                                         {
     155          while( tNode = audioElem->IterateChildren( tNode ) )
     156          {
    157157            if (tNode->Type() == TiXmlNode::ELEMENT)
    158158            {
    159159
    160                                                   tElem = tNode->ToElement();
    161                                                   std::string elemVal = tElem->Value();
    162                                                   if (elemVal == "ogg")
    163                                                   {
    164                                 COUT(0) << "Adding sound "<< tElem->Attribute("src") << "\n\n\n";
    165 
    166                                           auMan->ambientAdd(tElem->Attribute("src"));
    167                                                   }
     160              tElem = tNode->ToElement();
     161              std::string elemVal = tElem->Value();
     162              if (elemVal == "ogg")
     163              {
     164        COUT(0) << "Adding sound "<< tElem->Attribute("src") << "\n\n\n";
     165
     166                auMan->ambientAdd(tElem->Attribute("src"));
     167              }
    168168            }
    169                                         }
    170                                         auMan->ambientStart();
    171                                 }
    172                         }
    173 
    174                         // Load world
    175                         worldElem = rootElement->FirstChildElement("world");
    176                         if (worldElem)
    177                         {
    178                                 tNode = 0;
    179                                 while (tNode = worldElem->IterateChildren(tNode))
    180                                 {
     169          }
     170          auMan->ambientStart();
     171        }
     172      }
     173
     174      // Load world
     175      worldElem = rootElement->FirstChildElement("world");
     176      if (worldElem)
     177      {
     178        tNode = 0;
     179        while (tNode = worldElem->IterateChildren(tNode))
     180        {
    181181          if (tNode->Type() == TiXmlNode::ELEMENT)
    182182          {
    183                                           tElem = tNode->ToElement();
    184                                           orxonox::Identifier* id = ID(tElem->Value());
    185                                           if (id)
    186                                           {
     183            tElem = tNode->ToElement();
     184            orxonox::Identifier* id = ID(tElem->Value());
     185            if (id)
     186            {
    187187                          orxonox::BaseObject* obj = id->fabricate();
    188188                          obj->loadParams(tElem);
    189                                           }
    190                                           else
    191                                           {
    192                                               COUT(2) << "Warning: '"<< tElem->Value() <<"' is not a valid classname.\n";
    193                                           }
     189            }
     190            else
     191            {
     192                COUT(2) << "Warning: '"<< tElem->Value() <<"' is not a valid classname.\n";
     193            }
    194194          }
    195                                 }
    196                         }
    197 
    198                         if (loadElem)
    199                         {
    200                                 mLoadOverlay->hide();
    201                         }
    202 
    203 
    204                         COUT(0) << "Loading finished!\n\n\n\n\n";
    205                 }
    206         }
    207 
    208         LevelLoader::~LevelLoader()
    209         {
    210 
    211         }
     195        }
     196      }
     197
     198      if (loadElem)
     199      {
     200        mLoadOverlay->hide();
     201      }
     202
     203
     204      COUT(0) << "Loading finished!\n\n\n\n\n";
     205    }
     206  }
     207
     208  LevelLoader::~LevelLoader()
     209  {
     210
     211  }
    212212
    213213
  • code/branches/FICN/src/orxonox/objects/SpaceShip.cc

    r660 r661  
    165165        // END CREATING BLINKING LIGHTS
    166166
     167        // START of testing crosshair
     168        this->crosshairNear_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1);
     169        this->crosshairFar_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1);
     170
     171        this->chNearNode_ = this->getNode()->createChildSceneNode(this->getName() + "near", Vector3(50.0, 0.0, 0.0));
     172        this->chNearNode_->setInheritScale(false);
     173        this->chFarNode_ = this->getNode()->createChildSceneNode(this->getName() + "far", Vector3(200.0, 0.0, 0.0));
     174        this->chFarNode_->setInheritScale(false);
     175
     176        this->chNearNode_->attachObject(this->crosshairNear_.getBillboardSet());
     177        this->chNearNode_->setScale(0.2, 0.2, 0.2);
     178
     179        this->chFarNode_->attachObject(this->crosshairFar_.getBillboardSet());
     180        this->chFarNode_->setScale(0.4, 0.4, 0.4);
     181
     182        // END of testing crosshair
    167183
    168184/*
  • code/branches/FICN/src/orxonox/objects/SpaceShip.h

    r647 r661  
    5656            Ogre::SceneNode* greenNode_;
    5757            float blinkTime_;
     58
     59            BillboardSet crosshairNear_;
     60            BillboardSet crosshairFar_;
     61            Ogre::SceneNode* chNearNode_;
     62            Ogre::SceneNode* chFarNode_;
    5863
    5964            float timeToReload_;
Note: See TracChangeset for help on using the changeset viewer.