Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 24, 2008, 2:48:43 AM (16 years ago)
Author:
landauf
Message:

many changes, can't remember everything, but these are the most important:

  • attaching entities to other entities works
  • displaying models, lights and shadows works
  • controlling a spectator works
  • removed an update hack in PositionableEntity because I've found a much better solution

and with "works" I mean: it works on client, server and standalone

Location:
code/branches/objecthierarchy/src/orxonox/objects/worldentities
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/ControllableEntity.cc

    r1994 r2006  
    127127    void ControllableEntity::startLocalControl()
    128128    {
    129         std::cout << "###### start local control" << std::endl;
     129        std::cout << this->getObjectID() << " ###### start local control" << std::endl;
    130130        this->camera_ = new Camera();
    131131        this->camera_->requestFocus();
     
    155155        {
    156156            this->velocity_ += (dt * this->acceleration_);
    157             this->node_->translate(dt * this->velocity_, Ogre::Node::TS_PARENT);
     157            this->node_->translate(dt * this->velocity_, Ogre::Node::TS_LOCAL);
    158158
    159159            if (Core::isMaster())
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/ControllableEntity.h

    r1993 r2006  
    115115                { this->hudtemplate_ = name; }
    116116
     117            inline bool isLocallyControlled() const
     118                { return this->bControlled_; }
     119
    117120        private:
    118121            void overwrite();
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/Model.cc

    r1993 r2006  
    5555
    5656        XMLPortParam(Model, "mesh", setMeshSource, getMeshSource, xmlelement, mode);
     57        XMLPortParam(Model, "shadow", setCastShadows, getCastShadows, xmlelement, mode).defaultValues(true);
    5758    }
    5859
    5960    void Model::registerVariables()
    6061    {
    61         REGISTERSTRING(this->meshSrc_, network::direction::toclient, new network::NetworkCallback<Model>(this, &Model::changedMesh));
     62        REGISTERSTRING(this->meshSrc_,    network::direction::toclient, new network::NetworkCallback<Model>(this, &Model::changedMesh));
     63        REGISTERDATA(this->bCastShadows_, network::direction::toclient, new network::NetworkCallback<Model>(this, &Model::changedShadows));
    6264    }
    6365
     
    6870
    6971        this->mesh_.setMeshSource(this->meshSrc_);
     72
    7073        if (this->mesh_.getEntity())
     74        {
    7175            this->getNode()->attachObject(this->mesh_.getEntity());
     76            this->mesh_.getEntity()->setCastShadows(this->bCastShadows_);
     77        }
     78    }
     79
     80    void Model::changedShadows()
     81    {
     82        this->mesh_.setCastShadows(this->bCastShadows_);
    7283    }
    7384
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/Model.h

    r1993 r2006  
    5454                { return this->mesh_; }
    5555
     56            inline void setCastShadows(bool bCastShadows)
     57                { this->bCastShadows_ = bCastShadows; this->changedShadows(); }
     58            inline bool getCastShadows() const
     59                { return this->bCastShadows_; }
     60
    5661        private:
    5762            void changedMesh();
     63            void changedShadows();
    5864
    5965            std::string meshSrc_;
    6066            Mesh mesh_;
     67            bool bCastShadows_;
    6168    };
    6269}
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/PositionableEntity.cc

    r1993 r2006  
    5757        REGISTERDATA(this->getOrientation().z, network::direction::toclient);
    5858    }
    59 
    60     void PositionableEntity::tick(float dt)
    61     {
    62         // I don't know why but this has to be done to update the position if attached to another Entity
    63         this->node_->translate(Vector3::ZERO);
    64         std::cout << this->getWorldPosition() << std::endl;
    65     }
    6659}
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/PositionableEntity.h

    r1993 r2006  
    3232#include "OrxonoxPrereqs.h"
    3333#include "WorldEntity.h"
    34 #include "objects/Tickable.h"
    3534
    3635namespace orxonox
    3736{
    38     class _OrxonoxExport PositionableEntity : public WorldEntity, public Tickable
     37    class _OrxonoxExport PositionableEntity : public WorldEntity
    3938    {
    4039        public:
     
    4342
    4443            void registerVariables();
    45             virtual void tick(float dt);
    4644
    4745            using WorldEntity::setPosition;
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/WorldEntity.cc

    r1993 r2006  
    5151        RegisterObject(WorldEntity);
    5252
    53         this->node_ = GraphicsEngine::getInstance().getLevelSceneManager()->createSceneNode();
     53        this->node_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode();
    5454        this->parent_ = 0;
    5555        this->parentID_ = (unsigned int)-1;
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/pawns/Spectator.cc

    r2001 r2006  
    3131
    3232#include "core/CoreIncludes.h"
     33#include "core/Core.h"
    3334#include "objects/worldentities/Model.h"
     35#include "tools/BillboardSet.h"
    3436
    3537namespace orxonox
     
    5153        this->setDestroyWhenPlayerLeft(true);
    5254
    53         Model* temp = new Model;
    54         temp->setMeshSource("assff.mesh");
    55         this->attach(temp);
     55        // test test test
     56        {
     57            this->testmesh_ = new Mesh();
     58            this->testnode_ = this->getNode()->createChildSceneNode();
     59            this->testmesh_->setMeshSource("assff.mesh");
     60            if (this->testmesh_->getEntity())
     61                this->testnode_->attachObject(this->testmesh_->getEntity());
     62            this->testnode_->pitch(Degree(-90));
     63            this->testnode_->roll(Degree(+90));
     64            this->testnode_->scale(10, 10, 10);
     65        }
     66        // test test test
     67
     68        this->greetingFlare_ = new BillboardSet();
     69        this->greetingFlare_->setBillboardSet("Examples/Flare", ColourValue(1.0, 1.0, 0.8), Vector3(0, 20, 0), 1);
     70        this->getNode()->attachObject(this->greetingFlare_->getBillboardSet());
     71        this->greetingFlare_->setVisible(false);
     72        this->bGreetingFlareVisible_ = false;
     73        this->bGreeting_ = false;
     74
     75        this->registerVariables();
    5676    }
    5777
    5878    Spectator::~Spectator()
    5979    {
     80        if (this->isInitialized())
     81        {
     82            delete this->greetingFlare_;
     83
     84            // test test test
     85            {
     86                delete this->testmesh_;
     87                delete this->testnode_;
     88            }
     89            // test test test
     90        }
     91    }
     92
     93    void Spectator::registerVariables()
     94    {
     95        REGISTERDATA(this->bGreetingFlareVisible_, network::direction::toclient, new network::NetworkCallback<Spectator>(this, &Spectator::changedFlareVisibility));
     96        REGISTERDATA(this->bGreeting_,             network::direction::toserver, new network::NetworkCallback<Spectator>(this, &Spectator::changedGreeting));
     97    }
     98
     99    void Spectator::changedGreeting()
     100    {
     101        this->bGreetingFlareVisible_ = this->bGreeting_;
     102        this->changedFlareVisibility();
     103    }
     104
     105    void Spectator::changedFlareVisibility()
     106    {
     107        this->greetingFlare_->setVisible(this->bGreetingFlareVisible_);
    60108    }
    61109
    62110    void Spectator::tick(float dt)
    63111    {
    64         Vector3 velocity = this->getVelocity();
    65         velocity.normalise();
    66         this->setVelocity(velocity * this->speed_);
     112        if (this->isLocallyControlled())
     113        {
     114            Vector3 velocity = this->getVelocity();
     115            velocity.normalise();
     116            this->setVelocity(velocity * this->speed_);
    67117
    68         // TODO: Check why I have removed *dt (1337)
    69         this->yaw(Radian(this->yaw_ * this->rotationSpeed_));
    70         this->pitch(Radian(this->pitch_ * this->rotationSpeed_));
    71         this->roll(Radian(this->roll_ * this->rotationSpeed_));
     118            this->yaw(Radian(this->yaw_ * this->rotationSpeed_));
     119            this->pitch(Radian(this->pitch_ * this->rotationSpeed_));
     120            this->roll(Radian(this->roll_ * this->rotationSpeed_));
    72121
    73         this->yaw_ = this->pitch_ = this->roll_ = 0;
     122            this->yaw_ = this->pitch_ = this->roll_ = 0;
     123        }
    74124
    75125        SUPER(Spectator, tick, dt);
    76126
    77         this->setVelocity(Vector3::ZERO);
     127        if (this->isLocallyControlled())
     128        {
     129            this->setVelocity(Vector3::ZERO);
     130        }
    78131    }
    79132
     
    82135        ControllableEntity::setPlayer(player);
    83136
    84         this->setObjectMode(network::direction::toclient);
     137//        this->setObjectMode(network::direction::toclient);
     138    }
     139
     140    void Spectator::startLocalControl()
     141    {
     142        ControllableEntity::startLocalControl();
     143        if (this->isLocallyControlled())
     144            this->testmesh_->setVisible(false);
    85145    }
    86146
     
    118178    {
    119179    }
     180
     181    void Spectator::greet()
     182    {
     183        this->bGreeting_ = !this->bGreeting_;
     184
     185        if (Core::isMaster())
     186        {
     187            this->bGreetingFlareVisible_ = this->bGreeting_;
     188            this->changedFlareVisibility();
     189        }
     190    }
    120191}
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/pawns/Spectator.h

    r1993 r2006  
    4242            virtual ~Spectator();
    4343
     44            void registerVariables();
    4445            virtual void tick(float dt);
    4546
    4647            virtual void setPlayer(PlayerInfo* player);
     48            virtual void startLocalControl();
    4749
    4850            virtual void moveFrontBack(float value);
     
    5557
    5658            virtual void fire();
     59            virtual void greet();
    5760
    5861        private:
     62            void changedGreeting();
     63            void changedFlareVisibility();
     64
     65            BillboardSet* greetingFlare_;
     66            bool bGreetingFlareVisible_;
     67            bool bGreeting_;
     68
    5969            float speed_;
    6070            float rotationSpeed_;
     
    6373            float pitch_;
    6474            float roll_;
     75
     76            // test test test
     77            Mesh* testmesh_;
     78            Ogre::SceneNode* testnode_;
     79            // test test test
    6580    };
    6681}
Note: See TracChangeset for help on using the changeset viewer.