Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 507


Ignore:
Timestamp:
Dec 12, 2007, 11:34:58 PM (16 years ago)
Author:
nicolape
Message:
  • Skybox and ambient light load now from level file sample.oxw. Added objects to and methods to parse this tags. Added a tokenizer function to split strings into smaller strings (for reading out the light colours for examle). Moved Tokenizer and String2number into misc directory. deleted old unised xml class
Location:
code/branches/FICN/src
Files:
6 added
5 deleted
5 edited
1 copied

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/src/loader/LevelLoader.cc

    r496 r507  
    1 #include <string.h>
     1#include <string>
     2#include <vector>
    23#include <iostream>
     4#include <algorithm>
     5#include <iterator>
    36
    47#include "LevelLoader.h"
     
    127130        }
    128131       
    129        
    130         //orxonox::BaseObject* bla = orxonox::ID("classname")->fabricate();
    131         //bla->loadParams();
     132        LevelLoader::~LevelLoader()
     133        {
     134
     135        }
    132136       
    133137       
    134         /*
    135         rootNode = XMLNode::openFileHelper(dir.c_str(),"orxonoxworld");
    136         // TODO: Error handling
    137 
    138         // Assing general level infos to class variables
     138        string LevelLoader::name()
     139        {
     140                return this->name_;
     141        }
    139142       
    140         this->name_ = rootNode.getAttribute("name");
    141         this->image_ = rootNode.getAttribute("image");
    142         this->description_ = rootNode.getChildNode("description").getText();
    143  
    144         loadingScreenNode = rootNode.getChildNode("loading");
    145         if (!loadingScreenNode.isEmpty())
    146         {
    147                 this->showLoadingScreen();
    148         }
    149 
    150         worldNode = rootNode.getChildNode("world");
    151         if (!worldNode.isEmpty())
    152         {
    153                
    154         }
    155         */
    156 
    157  
    158   /*
    159   // Assign sub-nodes
    160   if (rootNode.nChildNode("LightManager")==1)
    161   {
    162         // Init Luightmanager...
    163   }*/
    164  
    165   /*
    166  
    167         worldNode = rootNode.getChildNode("WorldEntities");
    168         scriptNode = rootNode.getChildNode("ScriptManager");
    169         cameraNode = rootNode.getChildNode("CameraMan");
    170         lightNode = rootNode.getChildNode("LightManager");
    171 */
    172 
    173 
    174 
    175 LevelLoader::~LevelLoader()
    176 {
     143        string LevelLoader::description()
     144        {
     145                return this->description_;
     146        }
     147       
     148        string LevelLoader::image()
     149        {
     150                return this->image_;
     151        }
    177152
    178153
    179154}
    180155
    181 
    182 string LevelLoader::name()
    183 {
    184         return this->name_;
    185 }
    186 
    187 string LevelLoader::description()
    188 {
    189         return this->description_;
    190 }
    191 
    192 string LevelLoader::image()
    193 {
    194         return this->image_;
    195 }
    196 
    197 
    198 /*
    199 
    200 
    201 void LevelLoader::loadWorld(WorldManager* wm)
    202 {
    203         if (!worldNode.getChildNode("lights").isEmpty())
    204         {
    205                
    206                
    207         }
    208 }
    209 
    210 
    211 void LevelLoader::loadLights(LightManager* lm)
    212 {
    213         if (!lightNode.getChildNode("lights").isEmpty())
    214         {
    215                 int nLights = lightNode.getChildNode("lights").nChildNode("light");
    216                 for (int i=0; i<nLights;i++)
    217                 {
    218                         XMLNode t = lightNode.getChildNode("lights").getChildNode("light",i);
    219                         const char* diffuse = t.getAttribute("diffuse-color");
    220                         const char* coor = t.getAttribute("abs-coor");
    221                         lm->addLight(diffuse,coor);     
    222                 }
    223         }
    224         lm->setAmbient(lightNode.getChildNode("ambient").getAttribute("color"));       
    225 }
    226 
    227 void LevelLoader::loadCameras(CameraManager* cm)
    228 {
    229         if (!cameraNode.getChildNode("cameras").isEmpty())
    230         {
    231                 int nCameras = cameraNode.getChildNode("cameras").nChildNode("camera");
    232                 for (int i=0; i<nCameras;i++)
    233                 {
    234                         XMLNode t = cameraNode.getChildNode("cameras").getChildNode("camera",i);
    235                        
    236                        
    237                         cm->addCamera();
    238                 }
    239         }
    240 }
    241 
    242 
    243 void LevelLoader::loadScripts(ScriptManager* sm)
    244 {
    245         if (!scriptNode.getChildNode("scripts").isEmpty())
    246         {
    247                 int nScripts = scriptNode.getChildNode("scripts").nChildNode("script");
    248                 for (int i=0; i<nScripts;i++)
    249                 {
    250                         XMLNode t = scriptNode.getChildNode("scripts").getChildNode("script",i);
    251                         sm->addScript(t.getAttribute("file"));
    252                 }
    253        
    254         }
    255 }
    256 */
    257 
    258 
    259 }
    260 
  • code/branches/FICN/src/loader/LevelLoader.h

    r480 r507  
    77
    88#include <string>
     9#include <vector>
    910#include <iostream>
    1011
     
    2324        class _LoaderExport LevelLoader
    2425        {
     26        public:
     27                // Constructors, loads the level file and some information data
     28                LevelLoader(string file, string dir="levels");
     29                // Destructor
     30                ~LevelLoader();
     31                // Shows a simple loading screen
     32                void showLoadingScreen();
     33                // Loads all level data
     34                void loadLevel();
     35       
     36                // Getters
     37                string name();
     38                string description();
     39                string image();         
    2540        private:
    2641                // Level information
     
    3651                std::string loadingBarHeight_;
    3752               
     53                // Set to true if it was possible to load the level file
    3854                bool valid_;
    3955                       
     56                // Xml-Stuff
    4057                TiXmlDocument doc;
    4158                TiXmlElement* rootElement;     
    42         public:
    4359
    44                 // Constructors
    45                 LevelLoader(string file, string dir="levels");
    46                 ~LevelLoader();
    47                
    48                 void showLoadingScreen();
    49                 void loadLevel();
    50                
    51                 // Getters
    52                 string name();
    53                 string description();
    54                 string image();         
    55                
    56                 // Managers
    57                
    5860                       
    5961        };     
  • code/branches/FICN/src/misc/String2Number.h

    r487 r507  
    3232        * should be one of std::hex, std::dec or std::oct (dec is default value)
    3333        */
    34         String2Number(T& t, const std::string& s, std::ios_base& (*f)(std::ios_base&) =  std::dec, int haltOnError=1)
     34        inline String2Number(T& t, const std::string& s, std::ios_base& (*f)(std::ios_base&) =  std::dec, int haltOnError=1)
    3535        {
    3636          std::istringstream iss(s);
  • code/branches/FICN/src/orxonox/objects/CMakeLists.txt

    r496 r507  
    77  test2.cc
    88  test3.cc
     9  Ambient.cc
     10  Skybox.cc
    911)
    1012
  • code/branches/FICN/src/orxonox/objects/test1.cc

    r482 r507  
    7272    void Test1::loadParams(TiXmlElement* xmlElem)
    7373    {
    74         Ogre::SceneManager* mgr = orxonox::Orxonox::getSingleton()->getSceneManager();
    75        
    76         mgr->setAmbientLight(ColourValue(1,0,0));
    77        
    78        
    79        
    80         std::cout<< xmlElem->GetText()<<std::endl;
     74
    8175       
    8276       
  • code/branches/FICN/src/orxonox/orxonox.cc

    r505 r507  
    5656#include "core/Factory.h"
    5757
    58 #include "../xml/xmlParser.h"
    5958#include "../loader/LevelLoader.h"
    6059#include "../audio/AudioManager.h"
     
    360359  {
    361360    SceneManager *mgr = ogre_->getSceneManager();
     361   
    362362    Camera *cam = mgr->createCamera("Camera");
    363363    cam->setPosition(Vector3(0,0,-250));
     
    370370    node->attachObject(head);
    371371    node->attachObject(cam);
    372     mgr->setSkyBox(true, "Examples/SceneSkyBox2");
     372   
     373   
    373374
    374375    Entity* head1 = mgr->createEntity("head1", "ogrehead.mesh");
Note: See TracChangeset for help on using the changeset viewer.