Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 12, 2008, 4:32:10 AM (16 years ago)
Author:
landauf
Message:
  • Some small changes in XMLPortParam: It's now possible to add functions of another class. an example is setPosition and getPosition that are directly referred to Ogre::Node. Use XMLPortParamExtern if you need this. It takes the object to call the functions on as an additional argument (in our example: this→node_).
  • Removed loadParams functions and reduced the usage of XMLPortParamLoadOnly in several classes
Location:
code/branches/core3/src/orxonox/objects
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core3/src/orxonox/objects/Ambient.cc

    r1586 r1592  
    6464    }
    6565
    66     bool Ambient::create(){
    67       GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(ambientLight_);
    68       return Synchronisable::create();
     66    bool Ambient::create()
     67    {
     68        GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(ambientLight_);
     69        return Synchronisable::create();
    6970    }
    7071
    71     void Ambient::registerAllVariables(){
    72       registerVar(&ambientLight_, sizeof(ColourValue), network::DATA);
    73 
     72    void Ambient::registerAllVariables()
     73    {
     74        registerVar(&ambientLight_, sizeof(ColourValue), network::DATA);
    7475    }
    7576
    76     void Ambient::loadParams(TiXmlElement* xmlElem)
     77    void Ambient::setAmbientLight(const ColourValue& colour)
    7778    {
    78         if (xmlElem->Attribute("colourvalue"))
    79         {
    80         SubString colourvalues(xmlElem->Attribute("colourvalue"), ',');
    81 
    82                 float r, g, b;
    83         convertValue<std::string, float>(&r, colourvalues[0]);
    84         convertValue<std::string, float>(&g, colourvalues[1]);
    85         convertValue<std::string, float>(&b, colourvalues[2]);
    86 
    87                 this->setAmbientLight(ColourValue(r, g, b));
    88 
    89                 COUT(4) << "Loader: Set ambient light: "<<r<<" " << g << " " << b  << std::endl << std::endl;
    90         }
    91    }
    92 
    93    void Ambient::setAmbientLight(const ColourValue& colour)
    94    {
    95         GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(colour);
    96       ambientLight_=colour;
    97    }
     79        GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(colour);
     80        ambientLight_=colour;
     81    }
    9882
    9983    /**
     
    10791        BaseObject::XMLPort(xmlelement, mode);
    10892
    109         XMLPortParamLoadOnly(Ambient, "colourvalue", setAmbientLight, xmlelement, mode);
     93        XMLPortParam(Ambient, "colourvalue", setAmbientLight, getAmbienetLight, xmlelement, mode);
    11094        create();
    11195    }
  • code/branches/core3/src/orxonox/objects/Ambient.h

    r1505 r1592  
    4444            virtual ~Ambient();
    4545
    46             void loadParams(TiXmlElement* xmlElem);
    4746            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    48             void setAmbientLight(const ColourValue& colour);
    4947            virtual bool create();
    5048            void registerAllVariables();
     49
     50            void setAmbientLight(const ColourValue& colour);
     51            inline const ColourValue& getAmbienetLight() const
     52                { return this->ambientLight_; }
    5153
    5254            static void setAmbientLightTest(const ColourValue& colour)
  • code/branches/core3/src/orxonox/objects/Model.cc

    r1559 r1592  
    6868        WorldEntity::XMLPort(xmlelement, mode);
    6969
    70         XMLPortParamLoadOnly(Model, "mesh", setMesh, xmlelement, mode);
     70        XMLPortParam(Model, "mesh", setMesh, getMesh, xmlelement, mode);
    7171
    7272        Model::create();
    73     }
    74 
    75     void Model::setMesh(const std::string& meshname)
    76     {
    77         this->meshSrc_ = meshname;
    7873    }
    7974
  • code/branches/core3/src/orxonox/objects/Model.h

    r1558 r1592  
    4545            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4646            virtual void changedVisibility();
    47             void setMesh(const std::string& meshname);
     47            inline void setMesh(const std::string& meshname)
     48                { this->meshSrc_ = meshname; }
     49            inline const std::string& getMesh() const
     50                { return this->meshSrc_; }
    4851            virtual bool create();
    4952
  • code/branches/core3/src/orxonox/objects/NPC.cc

    r1591 r1592  
    4646  NPC::~NPC()
    4747  {
    48   }
    49 
    50   void NPC::loadParams(TiXmlElement* xmlElem)
    51   {
    52     Model::loadParams(xmlElem);
    5348  }
    5449
  • code/branches/core3/src/orxonox/objects/NPC.h

    r1505 r1592  
    4848      NPC();
    4949      virtual ~NPC();
    50       virtual void loadParams(TiXmlElement* xmlElem);
    5150      void tick(float dt);
    5251      void update();
  • code/branches/core3/src/orxonox/objects/Projectile.cc

    r1591 r1592  
    9292            if ((*it) != this->owner_)
    9393            {
    94                 radius = it->getScale().x * 3.0;
     94                radius = it->getScale3D().x * 3.0;
    9595
    9696                if (this->getPosition().squaredDistance(it->getPosition()) <= (radius*radius))
  • code/branches/core3/src/orxonox/objects/Skybox.cc

    r1586 r1592  
    5959    }
    6060
    61     void Skybox::setSkyboxSrc(const std::string& src)
    62     {
    63         this->skyboxSrc_ = src;
    64     }
    65 
    6661    /**
    6762        @brief XML loading and saving.
     
    7469        BaseObject::XMLPort(xmlelement, mode);
    7570
    76         XMLPortParamLoadOnly(Skybox, "src", setSkyboxSrc, xmlelement, mode);
     71        XMLPortParam(Skybox, "src", setSkyboxSrc, getSkyboxSrc, xmlelement, mode);
    7772        create();
    7873    }
  • code/branches/core3/src/orxonox/objects/Skybox.h

    r1558 r1592  
    4949            virtual bool create();
    5050            void registerAllVariables();
    51             void setSkyboxSrc(const std::string &src);
     51
     52            inline void setSkyboxSrc(const std::string &src)
     53                { this->skyboxSrc_ = src; }
     54            inline const std::string& getSkyboxSrc() const
     55                { return this->skyboxSrc_; }
    5256
    5357        private:
  • code/branches/core3/src/orxonox/objects/SpaceShip.cc

    r1591 r1592  
    347347        Model::XMLPort(xmlelement, mode);
    348348
    349         XMLPortParamLoadOnly(SpaceShip, "camera", setCamera, xmlelement, mode);
    350         XMLPortParamLoadOnly(SpaceShip, "maxSpeed", setMaxSpeed, xmlelement, mode);
    351         XMLPortParamLoadOnly(SpaceShip, "maxSideAndBackSpeed", setMaxSideAndBackSpeed, xmlelement, mode);
    352         XMLPortParamLoadOnly(SpaceShip, "maxRotation", setMaxRotation, xmlelement, mode);
    353         XMLPortParamLoadOnly(SpaceShip, "transAcc", setTransAcc, xmlelement, mode);
    354         XMLPortParamLoadOnly(SpaceShip, "rotAcc", setRotAcc, xmlelement, mode);
    355         XMLPortParamLoadOnly(SpaceShip, "transDamp", setTransDamp, xmlelement, mode);
    356         XMLPortParamLoadOnly(SpaceShip, "rotDamp", setRotDamp, xmlelement, mode);
     349        XMLPortParam(SpaceShip, "camera", setCamera, getCamera, xmlelement, mode);
     350        XMLPortParam(SpaceShip, "maxSpeed", setMaxSpeed, getMaxSpeed, xmlelement, mode);
     351        XMLPortParam(SpaceShip, "maxSideAndBackSpeed", setMaxSideAndBackSpeed, getMaxSideAndBackSpeed, xmlelement, mode);
     352        XMLPortParam(SpaceShip, "maxRotation", setMaxRotation, getMaxRotation, xmlelement, mode);
     353        XMLPortParam(SpaceShip, "transAcc", setTransAcc, getTransAcc, xmlelement, mode);
     354        XMLPortParam(SpaceShip, "rotAcc", setRotAcc, getRotAcc, xmlelement, mode);
     355        XMLPortParam(SpaceShip, "transDamp", setTransDamp, getTransDamp, xmlelement, mode);
     356        XMLPortParam(SpaceShip, "rotDamp", setRotDamp, getRotDamp, xmlelement, mode);
    357357
    358358        SpaceShip::create();
  • code/branches/core3/src/orxonox/objects/WorldEntity.cc

    r1559 r1592  
    9595    }
    9696
    97     void WorldEntity::loadParams(TiXmlElement* xmlElem)
    98     {
    99 
    100         BaseObject::loadParams(xmlElem);
    101         create();
    102     }
    103 
    104 
    10597    void WorldEntity::setYawPitchRoll(const Degree& yaw, const Degree& pitch, const Degree& roll)
    10698    {
     
    120112        BaseObject::XMLPort(xmlelement, mode);
    121113
    122         XMLPortParam(WorldEntity, "position", setPositionLoader2, getPosition, xmlelement, mode);
    123         XMLPortParamLoadOnly(WorldEntity, "direction", setDirectionLoader, xmlelement, mode);
     114        XMLPortParamExternTemplate(Ogre::Node, this->node_, "position", setPosition, getPosition, xmlelement, mode, Ogre::Node, const Vector3&);
     115        XMLPortParamLoadOnly(WorldEntity, "direction", setDirectionSimple, xmlelement, mode);
    124116        XMLPortParamLoadOnly(WorldEntity, "yawpitchroll", setYawPitchRoll, xmlelement, mode);
    125         XMLPortParam(WorldEntity, "scale", setTotalScale, getScale, xmlelement, mode);
    126         XMLPortParam(WorldEntity, "rotationAxis", setRotationAxisLoader, getRotationAxis, xmlelement, mode);
     117        XMLPortParam(WorldEntity, "scale", setScale, getScale, xmlelement, mode);
     118        XMLPortParamTemplate(WorldEntity, "rotationAxis", setRotationAxis, getRotationAxis, xmlelement, mode, WorldEntity, const Vector3&);
    127119        XMLPortParam(WorldEntity, "rotationRate", setRotationRate, getRotationRate, xmlelement, mode);
    128120
     
    157149      registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA, 0x3);
    158150      // register scale of node
    159       registerVar( (void*) &(this->getScale().x), sizeof(this->getScale().x), network::DATA, 0x3);
    160       registerVar( (void*) &(this->getScale().y), sizeof(this->getScale().y), network::DATA, 0x3);
    161       registerVar( (void*) &(this->getScale().z), sizeof(this->getScale().z), network::DATA, 0x3);
     151      registerVar( (void*) &(this->getScale3D().x), sizeof(this->getScale3D().x), network::DATA, 0x3);
     152      registerVar( (void*) &(this->getScale3D().y), sizeof(this->getScale3D().y), network::DATA, 0x3);
     153      registerVar( (void*) &(this->getScale3D().z), sizeof(this->getScale3D().z), network::DATA, 0x3);
    162154      //register staticity
    163155      registerVar( (void*) &(this->bStatic_), sizeof(this->bStatic_), network::DATA, 0x3);
  • code/branches/core3/src/orxonox/objects/WorldEntity.h

    r1535 r1592  
    5151
    5252            virtual void tick(float dt);
    53             virtual void loadParams(TiXmlElement* xmlElem);
    5453            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5554            virtual inline bool create(){ return Synchronisable::create(); }
     
    6665            inline void setPosition(const Vector3& pos)
    6766                { this->node_->setPosition(pos); }
    68             inline void setPositionLoader1(const Vector3& pos)
    69                 { this->node_->setPosition(pos); }
    70             inline void setPositionLoader2(Real x, Real y, Real z)
    71                 { this->node_->setPosition(x, y, z); }
    7267            inline void setPosition(Real x, Real y, Real z)
    7368                { this->node_->setPosition(x, y, z); }
     
    105100            inline void rotate(const Vector3 &axis, const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL)
    106101              { this->node_->rotate(axis, angle, relativeTo); }
    107             inline void setDirectionLoader(Real x, Real y, Real z)
     102            inline void setDirectionSimple(Real x, Real y, Real z)
    108103              { this->setDirection(x, y, z); }
    109104            inline void setDirection(Real x, Real y, Real z, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z)
     
    114109              { this->node_->lookAt(targetPoint, relativeTo, localDirectionVector); }
    115110
    116             inline void setScale(const Vector3 &scale)
     111            inline void setScale3D(const Vector3 &scale)
    117112              { this->node_->setScale(scale); }
    118             inline void setScale(Real x, Real y, Real z)
     113            inline void setScale3D(Real x, Real y, Real z)
    119114              { this->node_->setScale(x, y, z); }
    120             inline void setScale(Real scale)
     115            inline const Vector3& getScale3D(void) const
     116              { return this->node_->getScale(); }
     117            inline void setScale(float scale)
    121118              { this->node_->setScale(scale, scale, scale); }
    122             inline void setTotalScale(Real scale)
    123               { this->node_->setScale(scale, scale, scale); }
    124             inline const Vector3& getScale(void) const
    125               { return this->node_->getScale(); }
    126             inline void scale(const Vector3 &scale)
     119            inline float getScale() const
     120              { Vector3 scale = this->getScale3D(); return (scale.x == scale.y && scale.x == scale.z) ? scale.x : 1; }
     121            inline void scale3D(const Vector3 &scale)
    127122              { this->node_->scale(scale); }
    128             inline void scale(Real x, Real y, Real z)
     123            inline void scale3D(Real x, Real y, Real z)
    129124              { this->node_->scale(x, y, z); }
    130125            inline void scale(Real scale)
     
    154149                { return this->acceleration_; }
    155150
    156             inline void setRotationAxisLoader(const Vector3& axis)
    157                 { this->rotationAxis_ = axis; rotationAxis_.normalise(); }
    158151            inline void setRotationAxis(const Vector3& axis)
    159                 { this->rotationAxis_ = axis; rotationAxis_.normalise(); }
     152                { this->rotationAxis_ = axis; this->rotationAxis_.normalise(); }
    160153            inline void setRotationAxis(Real x, Real y, Real z)
    161154                { this->rotationAxis_.x = x; this->rotationAxis_.y = y; this->rotationAxis_.z = z; rotationAxis_.normalise(); }
Note: See TracChangeset for help on using the changeset viewer.