Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 21, 2008, 4:56:41 PM (16 years ago)
Author:
landauf
Message:
  • added ControllableEntity, the baseclass of all players, vehicles and ships.
  • moved Template to core
  • some changes in Camera
  • added 6 constants to WorldEntity to identify relative directions
  • changed vom Radian to Degree as default angle unit
Location:
code/branches/objecthierarchy/src/core
Files:
5 edited
2 moved

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/core/BaseObject.cc

    r1625 r1989  
    3737#include "XMLPort.h"
    3838#include "Level.h"
     39#include "Template.h"
    3940
    4041namespace orxonox
     
    7677        XMLPortParam(BaseObject, "visible", setVisible, isVisible, xmlelement, mode);
    7778        XMLPortParam(BaseObject, "active", setActive, isActive, xmlelement, mode);
     79
     80        XMLPortObjectTemplate(BaseObject, Template, "templates", addTemplate, getTemplate, xmlelement, mode, const std::string&);
    7881    }
    7982
     
    8689        return this->level_->getFile();
    8790    }
     91
     92    /**
     93        @brief Adds a Template to the object.
     94        @param name The name of the Template
     95    */
     96    void BaseObject::addTemplate(const std::string& name)
     97    {
     98        Template* temp = Template::getTemplate(name);
     99        if (temp)
     100            this->addTemplate(temp);
     101        else
     102            COUT(1) << "Error: \"" << name << "\" is not a valid Template name (in class: " << this->getIdentifier()->getName() << ", name: " << this->getName() << ")." << std::endl;
     103    }
     104
     105    /**
     106        @brief Adds a Template to the object.
     107        @param temp The Template
     108    */
     109    void BaseObject::addTemplate(Template* temp)
     110    {
     111        this->templates_.insert(temp);
     112        temp->applyOn(this);
     113    }
     114
     115    /**
     116        @brief Returns the Template with the given index.
     117        @param index The index
     118    */
     119    Template* BaseObject::getTemplate(unsigned int index) const
     120    {
     121        unsigned int i = 0;
     122        for (std::set<Template*>::const_iterator it = this->templates_.begin(); it != this->templates_.end(); ++it)
     123        {
     124            if (i == index)
     125                return (*it);
     126            i++;
     127        }
     128        return 0;
     129    }
    88130}
  • code/branches/objecthierarchy/src/core/BaseObject.h

    r1950 r1989  
    8787            const std::string& getLevelfile() const;
    8888
     89            void addTemplate(const std::string& name);
     90            void addTemplate(Template* temp);
     91            /** @brief Returns the set of all aplied templates. */
     92            inline const std::set<Template*>& getTemplates() const
     93                { return this->templates_; }
     94
    8995            virtual inline void setNamespace(Namespace* ns) { this->namespace_ = ns; }
    9096            inline Namespace* getNamespace() const { return this->namespace_; }
     
    102108
    103109        private:
     110            Template* getTemplate(unsigned int index) const;
     111
    104112            bool bInitialized_;                         //!< True if the object was initialized (passed the object registration)
    105113            const Level* level_;                        //!< The level that loaded this object
    106114            std::string loaderIndentation_;             //!< Indentation of the debug output in the Loader
    107115            Namespace* namespace_;
     116            std::set<Template*> templates_;
    108117    };
    109118
  • code/branches/objecthierarchy/src/core/CMakeLists.txt

    r1961 r1989  
    3131  Namespace.cc
    3232  NamespaceNode.cc
     33  Template.cc
    3334  XMLPort.cc
    3435
  • code/branches/objecthierarchy/src/core/CorePrereqs.h

    r1757 r1989  
    153153  struct TclInterpreterBundle;
    154154  class TclThreadManager;
     155  class Template;
    155156  class Tickable;
    156157  template <class T, class O>
  • code/branches/objecthierarchy/src/core/Template.cc

    • Property svn:mergeinfo set to (toggle deleted branches)
      /code/branches/ceguilua/src/orxonox/objects/Template.cc1802-1808
      /code/branches/core3/src/orxonox/objects/Template.cc1572-1739
      /code/branches/gcc43/src/orxonox/objects/Template.cc1580
      /code/branches/gui/src/orxonox/objects/Template.cc1635-1723
      /code/branches/input/src/orxonox/objects/Template.cc1629-1636
      /code/branches/script_trigger/src/orxonox/objects/Template.cc1295-1953,​1955
    r1971 r1989  
    4949    Template::~Template()
    5050    {
     51        Template::getTemplateMap().erase(this->getName());
    5152    }
    5253
     
    5960
    6061        this->setXMLElement(*xmlelement.FirstChildElement(false));
     62    }
     63
     64    void Template::changedName()
     65    {
     66        if (this->getName() != "")
     67        {
     68            std::map<std::string, Template*>::iterator it;
     69            it = Template::getTemplateMap().find(this->getOldName());
     70            if (it != Template::getTemplateMap().end())
     71                Template::getTemplateMap().erase(it);
     72
     73            it = Template::getTemplateMap().find(this->getName());
     74            if (it != Template::getTemplateMap().end())
     75                COUT(2) << "Warning: Template with name \"" << this->getName() << "\" already exists." << std::endl;
     76            else
     77                Template::getTemplateMap()[this->getName()] = this;
     78        }
    6179    }
    6280
  • code/branches/objecthierarchy/src/core/Template.h

    • Property svn:mergeinfo set to (toggle deleted branches)
      /code/branches/ceguilua/src/orxonox/objects/Template.h1802-1808
      /code/branches/core3/src/orxonox/objects/Template.h1572-1739
      /code/branches/gcc43/src/orxonox/objects/Template.h1580
      /code/branches/gui/src/orxonox/objects/Template.h1635-1723
      /code/branches/input/src/orxonox/objects/Template.h1629-1636
      /code/branches/script_trigger/src/orxonox/objects/Template.h1295-1953,​1955
    r1971 r1989  
    3232#include <map>
    3333
    34 #include "OrxonoxPrereqs.h"
    35 #include "core/BaseObject.h"
     34#include "CorePrereqs.h"
     35
     36#include "BaseObject.h"
    3637#include "tinyxml/ticpp.h"
    3738
    3839namespace orxonox
    3940{
    40     class _OrxonoxExport Template : public BaseObject
     41    class _CoreExport Template : public BaseObject
    4142    {
    4243        public:
     
    4546
    4647            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     48            virtual void changedName();
    4749
    4850            inline void setLink(const std::string& link)
  • code/branches/objecthierarchy/src/core/XMLPort.h

    r1940 r1989  
    219219*/
    220220#define XMLPortObjectExtendedTemplate(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore, ...) \
    221     XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, orxonox::createExecutor(orxonox::createFunctor< __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode, bApplyLoaderMask, bLoadBefore)
     221    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode, bApplyLoaderMask, bLoadBefore)
    222222
    223223// -------------
     
    233233*/
    234234#define XMLPortObjectTemplate(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, ...) \
    235     XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, orxonox::createExecutor(orxonox::createFunctor< __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode, false, true)
     235    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode, false, true)
    236236
    237237// --------------------
Note: See TracChangeset for help on using the changeset viewer.