Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 9, 2008, 4:04:23 AM (17 years ago)
Author:
landauf
Message:

cool shit's happening here… it works! wow. I wonder why, but hey, don't ask, just commit. this update might also be helpful for the network guys.

  • fixed a bug in XMLPort
  • fixed a bug in the MultiTypes
  • implemented some XMLPort functions in Model, SpaceShip, Skybox and Ambient (and of course the WorldEntity), but this is just a workaround as all those classes are more or less just temporary solutions
Location:
code/branches/core/src/orxonox
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core/src/orxonox/CMakeLists.txt

    r852 r869  
    66#  SpaceshipSteering.cc
    77#  hud/HUD.cc
    8 #  particle/ParticleInterface.cc
    9 #  tools/BillboardSet.cc
     8  particle/ParticleInterface.cc
     9  tools/BillboardSet.cc
    1010#  tools/Light.cc
    1111  tools/Mesh.cc
    1212  tools/Timer.cc
    13 #  objects/Ambient.cc
     13  objects/Ambient.cc
    1414#  objects/Camera.cc
    15 #  objects/Explosion.cc
     15  objects/Explosion.cc
    1616#  objects/Fighter.cc
    1717  objects/Model.cc
    1818#  objects/NPC.cc
    19 #  objects/Projectile.cc
    20 #  objects/Skybox.cc
    21 #  objects/SpaceShip.cc
     19  objects/Projectile.cc
     20  objects/Skybox.cc
     21  objects/SpaceShip.cc
    2222#  objects/SpaceshipSteeringObject.cc
    2323  objects/test1.cc
  • code/branches/core/src/orxonox/Orxonox.cc

    r852 r869  
    209209  {
    210210    //TODO: start modules
    211 //    ogre_->startRender();
     211    ogre_->startRender();
    212212    //TODO: run engine
    213213    Factory::createClassHierarchy();
    214 //    createScene();
    215 //    setupScene();
    216 //    setupInputSystem();
     214    createScene();
     215    setupScene();
     216    setupInputSystem();
    217217    if(mode_!=CLIENT){ // remove this in future ---- presentation hack
    218218    }
     
    11461146        std::cout << "2\n";
    11471147
    1148 //    startRenderLoop();
     1148    startRenderLoop();
    11491149  }
    11501150
  • code/branches/core/src/orxonox/core/XMLPort.cc

    r856 r869  
    2828#include "XMLPort.h"
    2929#include "Language.h"
     30#include "Loader.h"
    3031
    3132namespace orxonox
     
    8283        return GetLocalisation(this->description_);
    8384    }
     85
     86    bool XMLPortObjectContainer::identifierIsIncludedInLoaderMask(const Identifier* identifier)
     87    {
     88        return Loader::currentMask_s.isIncluded(identifier);
     89    }
    8490}
  • code/branches/core/src/orxonox/core/XMLPort.h

    r858 r869  
    3737#include "CoreIncludes.h"
    3838#include "BaseObject.h"
    39 #include "Loader.h"
    4039
    4140#include "CorePrereqs.h"
     
    142141                                {
    143142                                    COUT(5) << tokens.size() << " parameter (using MultiTypeMath)." << std::endl;
    144                                     MultiTypeMath param1, param2, param3, param4, param5;
     143                                    MultiTypeMath param1 = MT_null, param2 = MT_null, param3 = MT_null, param4 = MT_null, param5 = MT_null;
    145144                                    if (tokens.size() >= 1) param1 = tokens[0];
    146                                     if (tokens.size() >= 2) param1 = tokens[1];
    147                                     if (tokens.size() >= 3) param1 = tokens[2];
    148                                     if (tokens.size() >= 4) param1 = tokens[3];
    149                                     if (tokens.size() >= 5) param1 = tokens[4];
     145                                    if (tokens.size() >= 2) param2 = tokens[1];
     146                                    if (tokens.size() >= 3) param3 = tokens[2];
     147                                    if (tokens.size() >= 4) param4 = tokens[3];
     148                                    if (tokens.size() >= 5) param5 = tokens[4];
    150149                                    COUT(5) << object->getLoaderIndentation() << "  " << attribute << std::endl;
    151                                     COUT(5) << object->getLoaderIndentation() << "  " << tokens[0] << " -> " << param1 << ", " << tokens[1] << " -> " << param2 << ", " << tokens[2] << " -> " << param3 << ", " << tokens[3] << " -> " << param4 << ", " << tokens[4] << " -> " << param5 << std::endl;
     150                                    COUT(5) << object->getLoaderIndentation() << "  " << param1 << ", " << param2 << ", " << param3 << ", " << param4 << ", " << param5 << std::endl;
    152151
    153152                                    (*this->loadfunction_)(object, param1, param2, param3, param4, param5);
     
    197196            XMLPortObjectContainer& description(const std::string description);
    198197            const std::string& getDescription();
     198            static bool identifierIsIncludedInLoaderMask(const Identifier* identifier);
    199199
    200200        protected:
     
    236236                                    if (identifier->isA(Class(O)))
    237237                                    {
    238                                         if (Loader::currentMask_s.isIncluded(identifier))
     238                                        if (this->identifierIsIncludedInLoaderMask(identifier))
    239239                                        {
    240240                                            COUT(4) << object->getLoaderIndentation() << "fabricating " << child->Value() << "..." << std::endl;
  • code/branches/core/src/orxonox/objects/Ambient.cc

    r845 r869  
    4040#include "../core/CoreIncludes.h"
    4141#include "../Orxonox.h"
     42#include "core/XMLPort.h"
    4243
    4344#include "Ambient.h"
     
    5859    void Ambient::loadParams(TiXmlElement* xmlElem)
    5960    {
    60         Ogre::SceneManager* mgr = orxonox::Orxonox::getSingleton()->getSceneManager();
    61 
    6261        if (xmlElem->Attribute("colourvalue"))
    6362        {
     
    6968                String2Number<float>(b, colourvalues[2]);
    7069
    71                 mgr->setAmbientLight(ColourValue(r,g,b));
     70                this->setAmbientLight(ColourValue(r, g, b));
    7271
    7372                COUT(4) << "Loader: Set ambient light: "<<r<<" " << g << " " << b  << std::endl << std::endl;
    7473        }
    7574   }
     75
     76   void Ambient::setAmbientLight(const ColourValue& colour)
     77   {
     78        Orxonox::getSingleton()->getSceneManager()->setAmbientLight(colour);
     79   }
     80
     81    /**
     82        @brief XML loading and saving.
     83        @param xmlelement The XML-element
     84        @param loading Loading (true) or saving (false)
     85        @return The XML-element
     86    */
     87    Element& Ambient::XMLPort(Element& xmlelement, bool loading)
     88    {
     89        BaseObject::XMLPort(xmlelement, loading);
     90
     91        XMLPortParamLoadOnly(Ambient, "colourvalue", setAmbientLight, xmlelement, loading);
     92
     93        return xmlelement;
     94    }
    7695}
  • code/branches/core/src/orxonox/objects/Ambient.h

    r845 r869  
    1414            virtual ~Ambient();
    1515
    16 
    1716            void loadParams(TiXmlElement* xmlElem);
     17            virtual Element& XMLPort(Element& xmlelement, bool loading);
     18            void setAmbientLight(const ColourValue& colour);
    1819
    1920        private:
  • code/branches/core/src/orxonox/objects/Model.cc

    r793 r869  
    3333#include "../core/CoreIncludes.h"
    3434#include "../Orxonox.h"
     35#include "core/XMLPort.h"
    3536
    3637#include "Model.h"
     
    6061    }
    6162
     63    /**
     64        @brief XML loading and saving.
     65        @param xmlelement The XML-element
     66        @param loading Loading (true) or saving (false)
     67        @return The XML-element
     68    */
     69    Element& Model::XMLPort(Element& xmlelement, bool loading)
     70    {
     71        WorldEntity::XMLPort(xmlelement, loading);
     72
     73        XMLPortParamLoadOnly(Model, "mesh", setMesh, xmlelement, loading);
     74
     75        create();
     76
     77        return xmlelement;
     78    }
     79
     80    void Model::setMesh(const std::string& meshname)
     81    {
     82        this->meshSrc_ = meshname;
     83    }
     84
    6285    bool Model::create(){
    6386      if(meshSrc_.compare("")!=0){
  • code/branches/core/src/orxonox/objects/Model.h

    r845 r869  
    1818            virtual ~Model();
    1919            virtual void loadParams(TiXmlElement* xmlElem);
     20            virtual Element& XMLPort(Element& xmlelement, bool loading);
     21            void setMesh(const std::string& meshname);
    2022            bool create();
    2123
  • code/branches/core/src/orxonox/objects/Skybox.cc

    r790 r869  
    3838#include "../core/CoreIncludes.h"
    3939#include "../core/Debug.h"
     40#include "core/XMLPort.h"
    4041
    4142#include "Skybox.h"
     
    5657    void Skybox::loadParams(TiXmlElement* xmlElem)
    5758    {
    58         Ogre::SceneManager* mgr = orxonox::Orxonox::getSingleton()->getSceneManager();
    59 
    6059        if (xmlElem->Attribute("src"))
    6160        {
    6261                std::string skyboxSrc = xmlElem->Attribute("src");
    63                 mgr->setSkyBox(true, skyboxSrc);
     62                this->setSkybox(skyboxSrc);
    6463
    6564                COUT(4) << "Loader: Set skybox: "<< skyboxSrc << std::endl << std::endl;
    6665        }
    6766   }
     67
     68   void Skybox::setSkybox(const std::string& skyboxname)
     69   {
     70        Orxonox::getSingleton()->getSceneManager()->setSkyBox(true, skyboxname);
     71   }
     72
     73    /**
     74        @brief XML loading and saving.
     75        @param xmlelement The XML-element
     76        @param loading Loading (true) or saving (false)
     77        @return The XML-element
     78    */
     79    Element& Skybox::XMLPort(Element& xmlelement, bool loading)
     80    {
     81        BaseObject::XMLPort(xmlelement, loading);
     82
     83        XMLPortParamLoadOnly(Skybox, "src", setSkybox, xmlelement, loading);
     84
     85        return xmlelement;
     86    }
    6887}
  • code/branches/core/src/orxonox/objects/Skybox.h

    r845 r869  
    1616            virtual ~Skybox();
    1717
    18 
    1918            void loadParams(TiXmlElement* xmlElem);
     19            virtual Element& XMLPort(Element& xmlelement, bool loading);
     20            void setSkybox(const std::string& skyboxname);
    2021
    2122        private:
  • code/branches/core/src/orxonox/objects/SpaceShip.cc

    r790 r869  
    4444#include "../particle/ParticleInterface.h"
    4545#include "Projectile.h"
     46#include "core/XMLPort.h"
    4647
    4748#include "SpaceShip.h"
     
    123124        this->brakeLoop(loop);
    124125*/
     126        this->init();
     127
    125128        COUT(3) << "Info: SpaceShip was loaded" << std::endl;
    126129    }
     
    132135    }
    133136
    134     void SpaceShip::setConfigValues()
    135     {
    136         SetConfigValue(bInvertYAxis_, false).description("Set this to true for joystick-like mouse behaviour (mouse up = ship down).");
    137         SetConfigValue(reloadTime_, 0.125).description("The reload time of the weapon in seconds");
    138         SetConfigValue(testvector_, Vector3()).description("asdfblah");
    139     }
    140 
    141     void SpaceShip::loadParams(TiXmlElement* xmlElem)
    142     {
    143         Model::loadParams(xmlElem);
    144 
    145 
     137    void SpaceShip::init()
     138    {
    146139        // START CREATING THRUSTER
    147140        this->tt_ = new ParticleInterface(Orxonox::getSingleton()->getSceneManager(),"twinthruster" + this->getName(),"Orxonox/engineglow");
     
    197190
    198191        // END of testing crosshair
    199 
     192    }
     193
     194    void SpaceShip::setConfigValues()
     195    {
     196        SetConfigValue(bInvertYAxis_, false).description("Set this to true for joystick-like mouse behaviour (mouse up = ship down).");
     197        SetConfigValue(reloadTime_, 0.125).description("The reload time of the weapon in seconds");
     198        SetConfigValue(testvector_, Vector3()).description("asdfblah");
     199    }
     200
     201    void SpaceShip::loadParams(TiXmlElement* xmlElem)
     202    {
     203        Model::loadParams(xmlElem);
    200204/*
    201205        if (xmlElem->Attribute("forward") && xmlElem->Attribute("rotateupdown") && xmlElem->Attribute("rotaterightleft") && xmlElem->Attribute("looprightleft"))
     
    242246        if (xmlElem->Attribute("camera"))
    243247        {
    244             Ogre::Camera *cam = Orxonox::getSingleton()->getSceneManager()->createCamera("ShipCam");
    245             this->camNode_ = this->getNode()->createChildSceneNode("CamNode");
    246 /*
    247 //            node->setInheritOrientation(false);
    248             cam->setPosition(Vector3(0,50,-150));
    249             cam->lookAt(Vector3(0,20,0));
    250             cam->roll(Degree(0));
    251 */
    252 
    253             cam->setPosition(Vector3(-200,0,35));
    254 //            cam->setPosition(Vector3(0,-350,0));
    255             cam->lookAt(Vector3(0,0,35));
    256             cam->roll(Degree(-90));
    257 
    258             this->camNode_->attachObject(cam);
    259             Orxonox::getSingleton()->getOgrePointer()->getRoot()->getAutoCreatedWindow()->addViewport(cam);
     248            this->setCamera();
    260249        }
     250    }
     251
     252    void SpaceShip::setCamera(const std::string& camera)
     253    {
     254        Ogre::Camera *cam = Orxonox::getSingleton()->getSceneManager()->createCamera("ShipCam");
     255        this->camNode_ = this->getNode()->createChildSceneNode("CamNode");
     256/*
     257//        node->setInheritOrientation(false);
     258        cam->setPosition(Vector3(0,50,-150));
     259        cam->lookAt(Vector3(0,20,0));
     260        cam->roll(Degree(0));
     261*/
     262
     263        cam->setPosition(Vector3(-200,0,35));
     264//        cam->setPosition(Vector3(0,-350,0));
     265        cam->lookAt(Vector3(0,0,35));
     266        cam->roll(Degree(-90));
     267
     268        this->camNode_->attachObject(cam);
     269        Orxonox::getSingleton()->getOgrePointer()->getRoot()->getAutoCreatedWindow()->addViewport(cam);
     270    }
     271
     272    void SpaceShip::setMaxSpeed(float value)
     273    { this->maxSpeed_ = value; }
     274    void SpaceShip::setMaxSideAndBackSpeed(float value)
     275    { this->maxSideAndBackSpeed_ = value; }
     276    void SpaceShip::setMaxRotation(float value)
     277    { this->maxRotation_ = value; this->maxRotationRadian_ = Radian(value); }
     278    void SpaceShip::setTransAcc(float value)
     279    { this->translationAcceleration_ = value; }
     280    void SpaceShip::setRotAcc(float value)
     281    { this->rotationAcceleration_ = value; this->rotationAccelerationRadian_ = Radian(value); }
     282    void SpaceShip::setTransDamp(float value)
     283    { this->translationDamping_ = value; }
     284    void SpaceShip::setRotDamp(float value)
     285    { this->rotationDamping_ = value; this->rotationDampingRadian_ = Radian(value); }
     286
     287    /**
     288        @brief XML loading and saving.
     289        @param xmlelement The XML-element
     290        @param loading Loading (true) or saving (false)
     291        @return The XML-element
     292    */
     293    Element& SpaceShip::XMLPort(Element& xmlelement, bool loading)
     294    {
     295        Model::XMLPort(xmlelement, loading);
     296
     297        XMLPortParamLoadOnly(SpaceShip, "camera", setCamera, xmlelement, loading);
     298        XMLPortParamLoadOnly(SpaceShip, "maxSpeed", setMaxSpeed, xmlelement, loading);
     299        XMLPortParamLoadOnly(SpaceShip, "maxSideAndBackSpeed", setMaxSideAndBackSpeed, xmlelement, loading);
     300        XMLPortParamLoadOnly(SpaceShip, "maxRotation", setMaxRotation, xmlelement, loading);
     301        XMLPortParamLoadOnly(SpaceShip, "transAcc", setTransAcc, xmlelement, loading);
     302        XMLPortParamLoadOnly(SpaceShip, "rotAcc", setRotAcc, xmlelement, loading);
     303        XMLPortParamLoadOnly(SpaceShip, "transDamp", setTransDamp, xmlelement, loading);
     304        XMLPortParamLoadOnly(SpaceShip, "rotDamp", setRotDamp, xmlelement, loading);
     305
     306        return xmlelement;
    261307    }
    262308
  • code/branches/core/src/orxonox/objects/SpaceShip.h

    r845 r869  
    2121            SpaceShip();
    2222            ~SpaceShip();
     23            void init();
    2324            void setConfigValues();
    2425            virtual void loadParams(TiXmlElement* xmlElem);
     26            virtual Element& XMLPort(Element& xmlelement, bool loading);
    2527            virtual void tick(float dt);
     28
     29            void setCamera(const std::string& camera = "");
     30            void setMaxSpeed(float value);
     31            void setMaxSideAndBackSpeed(float value);
     32            void setMaxRotation(float value);
     33            void setTransAcc(float value);
     34            void setRotAcc(float value);
     35            void setTransDamp(float value);
     36            void setRotDamp(float value);
    2637
    2738            bool mouseMoved(const OIS::MouseEvent &e);
  • code/branches/core/src/orxonox/objects/WorldEntity.cc

    r856 r869  
    158158    }
    159159
     160    void WorldEntity::setYawPitchRoll(const Degree& yaw, const Degree& pitch, const Degree& roll)
     161    {
     162        this->yaw(yaw);
     163        this->pitch(pitch);
     164        this->roll(roll);
     165    }
    160166
    161167    /**
     
    169175        BaseObject::XMLPort(xmlelement, loading);
    170176
    171         XMLPortParam(WorldEntity, "position", setPosition, getPosition, xmlelement, loading);
    172 //        XMLPortParam(WorldEntity, "direction", setDirection, getDirection, xmlelement, loading);
    173         XMLPortParamLoadOnly(WorldEntity, "yaw", setYaw, xmlelement, loading);
    174         XMLPortParamLoadOnly(WorldEntity, "pitch", setPitch, xmlelement, loading);
    175         XMLPortParamLoadOnly(WorldEntity, "roll", setRoll, xmlelement, loading);
     177        XMLPortParam(WorldEntity, "position", setPositionLoader2, getPosition, xmlelement, loading);
     178        XMLPortParamLoadOnly(WorldEntity, "direction", setDirectionLoader, xmlelement, loading);
     179        XMLPortParamLoadOnly(WorldEntity, "yawpitchroll", setYawPitchRoll, xmlelement, loading);
    176180        XMLPortParam(WorldEntity, "scale", setTotalScale, getScale, xmlelement, loading);
    177         XMLPortParam(WorldEntity, "rotationAxis", setRotationAxis, getRotationAxis, xmlelement, loading);
     181        XMLPortParam(WorldEntity, "rotationAxis", setRotationAxisLoader, getRotationAxis, xmlelement, loading);
    178182        XMLPortParam(WorldEntity, "rotationRate", setRotationRate, getRotationRate, xmlelement, loading);
    179183
  • code/branches/core/src/orxonox/objects/WorldEntity.h

    r856 r869  
    3939            inline void setPosition(const Vector3& pos)
    4040                { this->node_->setPosition(pos); }
    41 //            inline void setPosition(Real x, Real y, Real z)
    42 //                { this->node_->setPosition(x, y, z); }
     41            inline void setPositionLoader1(const Vector3& pos)
     42                { this->node_->setPosition(pos); }
     43            inline void setPositionLoader2(Real x, Real y, Real z)
     44                { this->node_->setPosition(x, y, z); }
     45            inline void setPosition(Real x, Real y, Real z)
     46                { this->node_->setPosition(x, y, z); }
    4347            inline const Vector3& getPosition() const
    4448                { return this->node_->getPosition(); }
     
    5963            inline void roll(const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL)
    6064                { this->node_->roll(angle, relativeTo); }
     65            void setYawPitchRoll(const Degree& yaw, const Degree& pitch, const Degree& roll);
    6166
    6267            inline void setYaw(const Degree &angle)
     
    7378            inline void rotate(const Vector3 &axis, const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL)
    7479              { this->node_->rotate(axis, angle, relativeTo); }
     80            inline void setDirectionLoader(Real x, Real y, Real z)
     81              { this->setDirection(x, y, z); }
    7582            inline void setDirection(Real x, Real y, Real z, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z)
    7683              { this->node_->setDirection(x, y, z, relativeTo, localDirectionVector); }
     
    120127                { return this->acceleration_; }
    121128
     129            inline void setRotationAxisLoader(const Vector3& axis)
     130                { this->rotationAxis_ = axis; }
    122131            inline void setRotationAxis(const Vector3& axis)
    123132                { this->rotationAxis_ = axis; }
    124 //            inline void setRotationAxis(Real x, Real y, Real z)
    125 //                { this->rotationAxis_.x = x; this->rotationAxis_.y = y; this->rotationAxis_.z = z; }
     133            inline void setRotationAxis(Real x, Real y, Real z)
     134                { this->rotationAxis_.x = x; this->rotationAxis_.y = y; this->rotationAxis_.z = z; }
    126135            inline const Vector3& getRotationAxis() const
    127136                { return this->rotationAxis_; }
     
    130139//                { this->rotationRate_ = angle; }
    131140            inline void setRotationRate(const Degree& angle)
    132                 { this->rotationRate_ = angle; }
     141                { this->rotationRate_ = angle; this->setStatic(angle == Degree(0)); }
    133142            inline const Radian& getRotationRate() const
    134143                { return this->rotationRate_; }
Note: See TracChangeset for help on using the changeset viewer.