Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2212 for code/branches


Ignore:
Timestamp:
Nov 16, 2008, 7:10:28 PM (16 years ago)
Author:
landauf
Message:

maybe fixed backlight crash

Location:
code/branches/objecthierarchy2/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy2/src/core/Super.h

    r2171 r2212  
    233233    #define SUPER_processEvent(classname, functionname, ...) \
    234234        SUPER_ARGS(classname, functionname, __VA_ARGS__)
     235
     236    #define SUPER_changedScale(classname, functionname, ...) \
     237        SUPER_NOARGS(classname, functionname)
    235238    // (1/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
    236239
     
    441444            (event)
    442445        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
     446
     447        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(5, changedScale, false)
     448            ()
     449        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
    443450        // (2/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
    444451
     
    488495    SUPER_INTRUSIVE_DECLARATION(changedVisibility);
    489496    SUPER_INTRUSIVE_DECLARATION(processEvent);
     497    SUPER_INTRUSIVE_DECLARATION(changedScale);
    490498    // (3/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
    491499
  • code/branches/objecthierarchy2/src/orxonox/gamestates/GSDedicated.cc

    r2175 r2212  
    4949    {
    5050        RegisterObject(GSDedicated);
    51        
     51
    5252        this->setConfigValues();
    5353    }
     
    8282    {
    8383        static int timeSinceLastTick = 0; // in microseconds
    84         const int tickPeriod = 1000000. / this->tickrate_; // in microseconds
    85        
     84        const int tickPeriod = (int)(1000000.0f / this->tickrate_); // in microseconds
     85
    8686        GSLevel::ticked(time);
    87        
     87
    8888        timeSinceLastTick += time.getDeltaTimeMicroseconds();
    8989        if ( timeSinceLastTick >= tickPeriod )
     
    9696        {
    9797            unsigned int sleepTime;
    98            
     98
    9999#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
    100100            if ( tickPeriod-timeSinceLastTick < MIN_WIN32_SLEEP_TIME )
    101                 sleepTime = MIN_WIN32_SLEEP_TIME*1000000;
     101                sleepTime = (unsigned int)(MIN_WIN32_SLEEP_TIME * 1000000);
    102102            else
    103103                sleepTime = tickPeriod - timeSinceLastTick;
    104104            msleep( sleepTime / 1000 );
    105            
     105
    106106#else /* unix */
    107107            sleepTime = tickPeriod - timeSinceLastTick;
    108108            usleep( sleepTime );
    109109#endif
    110            
     110
    111111        }
    112        
     112
    113113        this->tickChild(time);
    114114    }
    115    
     115
    116116    void GSDedicated::setConfigValues()
    117117    {
  • code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Backlight.cc

    r2207 r2212  
    6666
    6767            this->ribbonTrail_ = this->getScene()->getSceneManager()->createRibbonTrail(this->getNode()->getName());
    68             this->ribbonTrail_->addNode(this->getNode());
     68
    6969            this->ribbonTrailNode_ = this->getScene()->getRootSceneNode()->createChildSceneNode();
    7070            this->ribbonTrailNode_->attachObject(this->ribbonTrail_);
     71
     72            this->ribbonTrail_->setMaxChainElements(this->maxelements_);
     73            this->ribbonTrail_->setTrailLength(this->length_);
    7174            this->ribbonTrail_->setInitialWidth(0, 0);
    7275        }
     
    123126    {
    124127        if (this->ribbonTrail_ && this->tickcount_ >= 2)
    125             this->ribbonTrail_->setInitialWidth(0, this->width_);
     128            this->ribbonTrail_->setInitialWidth(0, this->width_ * this->getWorldScale());
    126129        this->update_lifetime();
    127130    }
     
    131134        if (this->ribbonTrail_ && this->tickcount_ >= 2)
    132135        {
    133             this->ribbonTrail_->setWidthChange(0, this->width_ / this->lifetime_/* * Backlight::timeFactor_s*/);
     136            this->ribbonTrail_->setWidthChange(0, this->width_ * this->getWorldScale() / this->lifetime_/* * Backlight::timeFactor_s*/);
    134137            this->ribbonTrail_->setColourChange(0, 0, 0, 0, 1.0f / this->lifetime_/* * Backlight::timeFactor_s*/);
    135138        }
     
    139142    {
    140143        if (this->ribbonTrail_ && this->tickcount_ >= 2)
    141             this->ribbonTrail_->setTrailLength(this->length_);
     144            this->ribbonTrail_->setTrailLength(this->length_ * this->getWorldScale());
    142145    }
    143146
     
    176179            }
    177180        }
     181    }
     182
     183    void Backlight::changedScale()
     184    {
     185        SUPER(Backlight, changedScale);
     186
     187        this->update_width();
     188        this->update_length();
    178189    }
    179190
     
    196207                this->update_maxelements();
    197208                this->update_trailmaterial();
     209                if (this->ribbonTrail_)
     210                    this->ribbonTrail_->addNode(this->getNode());
    198211            }
    199212        }
     
    204217        }
    205218    }
    206 
    207 //------------------------------------------------------------------------------------
    208 /*
    209     float Backlight::timeFactor_s = 1.0;
    210 
    211     Backlight::Backlight(float maxspeed, float brakingtime, float scale)
    212     {
    213         RegisterObject(Backlight);
    214 
    215         this->setConfigValues();
    216         this->traillength_ = 1;
    217         this->colour_ = ColourValue::White;
    218 
    219         this->configure(maxspeed, brakingtime, scale);
    220     }
    221 
    222     bool Backlight::create(){
    223       if(!WorldEntity::create())
    224         return false;
    225 
    226       this->getNode()->setInheritScale(false);
    227 
    228       this->billboard_.setBillboardSet("Flares/backlightflare");
    229       this->attachObject(this->billboard_.getBillboardSet());
    230 
    231       this->ribbonTrail_ = GraphicsEngine::getInstance().getLevelSceneManager()->createRibbonTrail(this->getName() + "RibbonTrail");
    232       this->ribbonTrailNode_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName() + "RibbonTrailNode");
    233       this->ribbonTrailNode_->attachObject(this->ribbonTrail_);
    234       this->ribbonTrail_->addNode(this->getNode());
    235 
    236 
    237       this->ribbonTrail_->setTrailLength(this->maxTraillength_);
    238       this->ribbonTrail_->setMaterialName("Trail/backlighttrail");
    239 
    240         //this->setTimeFactor(Orxonox::getInstance().getTimeFactor());
    241       this->setTimeFactor(1.0f);
    242 
    243       this->ribbonTrail_->setMaxChainElements(this->maxTrailsegments_);
    244       this->ribbonTrail_->setTrailLength(this->traillength_ = 2 * this->maxTrailsegments_);
    245       this->ribbonTrail_->setInitialWidth(0, this->width_ * this->getScale());
    246       this->ribbonTrail_->setWidthChange(0, this->width_ * this->getScale() / this->maxLifeTime_ * Backlight::timeFactor_s);
    247       return true;
    248     }
    249 
    250     Backlight::~Backlight()
    251     {
    252         if (this->isInitialized())
    253         {
    254             this->detachObject(this->billboard_.getBillboardSet());
    255             GraphicsEngine::getInstance().getLevelSceneManager()->destroySceneNode(this->getName() + "RibbonTrailNode");
    256             GraphicsEngine::getInstance().getLevelSceneManager()->destroyRibbonTrail(this->ribbonTrail_);
    257         }
    258     }
    259 
    260     void Backlight::setConfigValues()
    261     {
    262         SetConfigValue(maxLifeTime_, 4.0).description("The maximal amount of seconds the trail behind a SpaceShip stays visible");
    263         SetConfigValue(trailSegmentLength_, 50).description("The length of one segment of the trail behind a SpaceShip (lower values make it more smooth)");
    264         SetConfigValue(width_, 7.0).description("The width of the trail");
    265     }
    266 
    267     void Backlight::setTimeFactor(float factor)
    268     {
    269         Backlight::timeFactor_s = factor;
    270         float change = Backlight::timeFactor_s / this->maxLifeTime_;
    271         this->ribbonTrail_->setWidthChange(0, this->width_ * change);
    272         this->updateColourChange();
    273     }
    274 
    275     void Backlight::updateColourChange()
    276     {
    277         this->ribbonTrail_->setColourChange(0, ColourValue(0, 0, 0, this->maxTraillength_ / this->traillength_ / this->maxLifeTime_ * Backlight::timeFactor_s));
    278     }
    279 
    280     void Backlight::tick(float dt)
    281     {
    282         SUPER(Backlight, tick, dt);
    283 
    284         if (this->isActive())
    285         {
    286             if (this->traillength_ < this->maxTraillength_)
    287             {
    288                 this->traillength_ = min<float>(this->maxTraillength_, this->traillength_ + dt * this->maxTraillength_ / this->maxLifeTime_);
    289                 this->updateColourChange();
    290             }
    291         }
    292         else
    293         {
    294             if (this->traillength_ > 1)
    295             {
    296                 this->traillength_ = max<float>(1, this->traillength_ - this->brakefactor_ * dt * this->maxTraillength_ / this->maxLifeTime_);
    297                 this->updateColourChange();
    298             }
    299         }
    300 
    301         this->ribbonTrail_->setTrailLength(this->traillength_);
    302     }
    303 
    304     void Backlight::configure(float maxspeed, float brakingtime, float scale)
    305     {
    306         this->maxTraillength_ = this->maxLifeTime_ * maxspeed;
    307         this->maxTrailsegments_ = (size_t)(this->maxTraillength_ / this->trailSegmentLength_);
    308 
    309         this->brakefactor_ = this->maxLifeTime_ / brakingtime;
    310 
    311         this->scale(scale);
    312     }
    313 
    314     void Backlight::changedVisibility()
    315     {
    316         SUPER(Backlight, changedVisibility);
    317 
    318         this->billboard_.setVisible(this->isVisible());
    319         this->ribbonTrail_->setVisible(this->isVisible());
    320     }
    321 */
    322219}
  • code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Backlight.h

    r2207 r2212  
    8080                { return this->trailmaterial_; }
    8181
     82            virtual void changedScale();
     83
    8284        private:
    8385            void stopturnoff();
     
    101103            Timer<Backlight> turnofftimer_;
    102104    };
    103 
    104 
    105 /*
    106         public:
    107             Backlight(float maxspeed = 1.0, float brakingtime = 1.0, float scale = 1.0);
    108             virtual ~Backlight();
    109 
    110             void setConfigValues();
    111             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    112             virtual void tick(float dt);
    113             virtual void changedVisibility();
    114             virtual bool create();
    115 
    116 
    117             void setTimeFactor(float factor);
    118 
    119         private:
    120             void configure(float maxspeed, float brakingtime, float scale = 1);
    121             void updateColourChange();
    122 
    123             static float timeFactor_s;
    124             BillboardSet billboard_;
    125             Ogre::SceneNode* ribbonTrailNode_;
    126             Ogre::RibbonTrail* ribbonTrail_;
    127 
    128 
    129             float maxLifeTime_;
    130             float trailSegmentLength_;
    131             float width_;
    132 
    133             float brakefactor_;
    134 
    135             float maxTraillength_;
    136             float traillength_;
    137 
    138             size_t maxTrailsegments_;
    139     };
    140 */
    141105}
    142106
  • code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Billboard.cc

    r2207 r2212  
    5353        {
    5454            if (this->isInitialized() && this->billboard_.getBillboardSet())
    55                 this->getNode()->detachObject(this->billboard_.getName());
     55                this->getNode()->detachObject(this->billboard_.getBillboardSet());
    5656        }
    5757    }
  • code/branches/objecthierarchy2/src/orxonox/objects/worldentities/WorldEntity.h

    r2207 r2212  
    107107
    108108            inline void setScale3D(const Vector3& scale)
    109                 { this->node_->setScale(scale); }
     109                { this->node_->setScale(scale); this->changedScale(); }
    110110            inline void setScale3D(float x, float y, float z)
    111                 { this->node_->setScale(x, y, z); }
    112             inline const Vector3& getScale3D(void) const
     111                { this->node_->setScale(x, y, z); this->changedScale(); }
     112            inline const Vector3& getScale3D() const
    113113                { return this->node_->getScale(); }
     114            inline const Vector3& getWorldScale3D() const
     115                { return this->node_->_getDerivedScale(); }
    114116
    115117            inline void setScale(float scale)
    116                 { this->node_->setScale(scale, scale, scale); }
     118                { this->node_->setScale(scale, scale, scale); this->changedScale(); }
    117119            inline float getScale() const
    118120                { Vector3 scale = this->getScale3D(); return (scale.x == scale.y && scale.x == scale.z) ? scale.x : 1; }
     121            inline float getWorldScale() const
     122                { Vector3 scale = this->getWorldScale3D(); return (scale.x == scale.y && scale.x == scale.z) ? scale.x : 1; }
    119123
    120124            inline void scale3D(const Vector3& scale)
    121                 { this->node_->scale(scale); }
     125                { this->node_->scale(scale); this->changedScale(); }
    122126            inline void scale3D(float x, float y, float z)
    123                 { this->node_->scale(x, y, z); }
     127                { this->node_->scale(x, y, z); this->changedScale(); }
    124128            inline void scale(float scale)
    125129                { this->node_->scale(scale, scale, scale); }
     130
     131            virtual void changedScale() {}
    126132
    127133            void attach(WorldEntity* object);
     
    159165            std::set<WorldEntity*> children_;
    160166    };
     167
     168    SUPER_FUNCTION(5, WorldEntity, changedScale, false);
    161169}
    162170
Note: See TracChangeset for help on using the changeset viewer.