Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 5, 2008, 11:07:16 PM (17 years ago)
Author:
landauf
Message:

loader seems to work now
added function/macro XMLPortObject to load objects as subobjects into another object (like attaching a weapon to a player) + nice debug output with indentation

Location:
code/branches/core/src/orxonox/objects
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core/src/orxonox/objects/WorldEntity.cc

    r853 r856  
    167167    Element& WorldEntity::XMLPort(Element& xmlelement, bool loading)
    168168    {
    169 std::cout << "2_1: " << this->getPosition() << std::endl;
    170169        BaseObject::XMLPort(xmlelement, loading);
    171170
     
    178177        XMLPortParam(WorldEntity, "rotationAxis", setRotationAxis, getRotationAxis, xmlelement, loading);
    179178        XMLPortParam(WorldEntity, "rotationRate", setRotationRate, getRotationRate, xmlelement, loading);
    180 std::cout << "2_2: " << this->getPosition() << std::endl;
     179
     180        XMLPortObject(WorldEntity, WorldEntity, "attached", attachWorldEntity, getAttachedWorldEntity, xmlelement, loading);
    181181
    182182        return xmlelement;
     
    210210      registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA);*/
    211211    }
     212
     213    void WorldEntity::attachWorldEntity(WorldEntity* entity)
     214    {
     215        this->attachedWorldEntities_.push_back(entity);
     216    }
     217
     218    const WorldEntity* WorldEntity::getAttachedWorldEntity(unsigned int index)
     219    {
     220        if (index < this->attachedWorldEntities_.size())
     221            return this->attachedWorldEntities_[index];
     222        else
     223            return 0;
     224    }
    212225}
  • code/branches/core/src/orxonox/objects/WorldEntity.h

    r853 r856  
    2727            virtual Element& XMLPort(Element& xmlelement, bool loading);
    2828            bool create();
     29
     30            void attachWorldEntity(WorldEntity* entity);
     31            const WorldEntity* getAttachedWorldEntity(unsigned int index);
    2932
    3033            inline Ogre::SceneNode* getNode()
     
    156159            Ogre::SceneNode* node_;
    157160            bool bStatic_;
     161            std::vector<WorldEntity*> attachedWorldEntities_;
    158162    };
    159163}
Note: See TracChangeset for help on using the changeset viewer.