Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 7, 2008, 4:18:11 AM (16 years ago)
Author:
landauf
Message:
  • Added support for postprocessing shaders (bloom, motion blur, …). Shaders are only visible if Plugin_CgProgramManager is included in bin/Plugins.cfg.
  • Added class GlobalShader which is visible on all clients and can be activated or deactivated by triggers or other events.
  • Added RadialBlur shader to the SpaceShip's engine. The strength of the RadialBlur depends on the SpaceShip's velocity.
Location:
code/branches/objecthierarchy2/src/orxonox
Files:
4 added
11 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy2/src/orxonox/GraphicsEngine.cc

    r2087 r2350  
    7777        singletonRef_s = this;
    7878
     79        this->viewport_ = 0;
     80
    7981        this->detailLevelParticle_ = 0;
    8082
  • code/branches/objecthierarchy2/src/orxonox/GraphicsEngine.h

    r2087 r2350  
    7272        static GraphicsEngine* getInstancePtr() { return singletonRef_s; }
    7373
     74        inline void setViewport(Ogre::Viewport* viewport)
     75            { this->viewport_ = viewport; }
     76        inline Ogre::Viewport* getViewport() const
     77            { return this->viewport_; }
     78
    7479    private:
    7580        // don't mess with singletons
    7681        GraphicsEngine(GraphicsEngine&);
     82
     83        Ogre::Viewport*     viewport_;              //!< default full size viewport
    7784
    7885        // stats
  • code/branches/objecthierarchy2/src/orxonox/OrxonoxPrereqs.h

    r2254 r2350  
    114114    class BlinkingBillboard;
    115115    class FadingBillboard;
     116    class GlobalShader;
    116117    class Light;
    117118    class Backlight;
     
    162163    class Mesh;
    163164    class ParticleInterface;
     165    class Shader;
    164166    template <class T>
    165167    class Timer;
  • code/branches/objecthierarchy2/src/orxonox/gamestates/GSGraphics.cc

    r2344 r2350  
    3131
    3232#include <fstream>
     33#include <OgreCompositorManager.h>
    3334#include <OgreConfigFile.h>
    3435#include <OgreFrameListener.h>
     
    188189        delete this->debugOverlay_;
    189190
     191        // unload all compositors
     192        Ogre::CompositorManager::getSingleton().removeAll();
     193
    190194        // destroy render window
    191195        RenderSystem* renderer = this->ogreRoot_->getRenderSystem();
     
    433437        // create a full screen default viewport
    434438        this->viewport_ = this->renderWindow_->addViewport(0, 0);
     439
     440        if (this->graphicsEngine_)
     441            this->graphicsEngine_->setViewport(this->viewport_);
    435442    }
    436443
  • code/branches/objecthierarchy2/src/orxonox/gamestates/GSLevel.cc

    r2344 r2350  
    6565    {
    6666        RegisterObject(GSLevel);
     67
     68        this->ccKeybind_ = 0;
     69        this->ccTkeybind_ = 0;
     70        this->ccSetTimeFactor_ = 0;
     71
    6772        setConfigValues();
    6873    }
     
    142147    {
    143148        // destroy console commands
    144         delete this->ccKeybind_;
    145         delete this->ccSetTimeFactor_;
    146         delete this->ccTkeybind_;
     149        if (this->ccKeybind_)
     150        {
     151            delete this->ccKeybind_;
     152            this->ccKeybind_ = 0;
     153        }
     154        if (this->ccSetTimeFactor_)
     155        {
     156            delete this->ccSetTimeFactor_;
     157            this->ccSetTimeFactor_ = 0;
     158        }
     159        if (this->ccTkeybind_)
     160        {
     161            delete this->ccTkeybind_;
     162            this->ccTkeybind_ = 0;
     163        }
    147164
    148165        // this call will delete every BaseObject!
     
    159176
    160177        if (this->radar_)
     178        {
    161179            delete this->radar_;
     180            this->radar_ = 0;
     181        }
    162182
    163183        if (this->cameraManager_)
     184        {
    164185            delete this->cameraManager_;
     186            this->cameraManager_ = 0;
     187        }
    165188
    166189        if (this->levelManager_)
     190        {
    167191            delete this->levelManager_;
     192            this->levelManager_ = 0;
     193        }
    168194
    169195        if (this->playerManager_)
     196        {
    170197            delete this->playerManager_;
     198            this->playerManager_ = 0;
     199        }
    171200
    172201        if (Core::showsGraphics())
     
    175204            InputManager::getInstance().requestDestroyState("game");
    176205            if (this->keyBinder_)
     206            {
    177207                delete this->keyBinder_;
     208                this->keyBinder_ = 0;
     209            }
    178210        }
    179211    }
  • code/branches/objecthierarchy2/src/orxonox/objects/CMakeLists.txt

    r2254 r2350  
    33  EventDispatcher.cc
    44  EventTarget.cc
     5  GlobalShader.cc
    56  Level.cc
    67  Radar.cc
  • code/branches/objecthierarchy2/src/orxonox/objects/items/Engine.cc

    r2256 r2350  
    3232#include "core/CoreIncludes.h"
    3333#include "core/XMLPort.h"
     34#include "objects/Scene.h"
    3435#include "objects/worldentities/pawns/SpaceShip.h"
     36#include "tools/Shader.h"
    3537
    3638namespace orxonox
     
    5961        this->accelerationUpDown_ = 0.0;
    6062
     63        this->boostBlur_ = 0;
     64
    6165        this->registerVariables();
    6266    }
     
    6569    {
    6670        if (this->isInitialized() && this->ship_)
     71        {
    6772            this->ship_->setEngine(0);
     73
     74            if (this->boostBlur_)
     75                delete this->boostBlur_;
     76        }
    6877    }
    6978
     
    178187        this->ship_->setBoost(false);
    179188        this->ship_->setSteeringDirection(Vector3::ZERO);
     189
     190        if (!this->boostBlur_ && this->ship_->hasLocalController() && this->ship_->hasHumanController())
     191        {
     192            this->boostBlur_ = new Shader(this->ship_->getScene()->getSceneManager());
     193            this->boostBlur_->setCompositor("Radial Blur");
     194        }
     195
     196        if (this->boostBlur_ && this->maxSpeedFront_ != 0 && this->boostFactor_ != 1)
     197            this->boostBlur_->setParameter("Ogre/Compositor/Radial_Blur", 0, 0, "sampleStrength", 5.0f * clamp((-velocity.z - this->maxSpeedFront_) / ((this->boostFactor_ - 1) * this->maxSpeedFront_), 0.0f, 1.0f));
     198    }
     199
     200    void Engine::changedActivity()
     201    {
     202        SUPER(Engine, changedActivity);
     203
     204        if (this->boostBlur_)
     205            this->boostBlur_->setVisible(this->isVisible());
    180206    }
    181207
     
    188214            if (ship->getEngine() != this)
    189215                ship->setEngine(this);
     216
     217            if (this->boostBlur_)
     218            {
     219                delete this->boostBlur_;
     220                this->boostBlur_ = 0;
     221            }
    190222        }
    191223    }
  • code/branches/objecthierarchy2/src/orxonox/objects/items/Engine.h

    r2256 r2350  
    4848
    4949            virtual void tick(float dt);
     50            virtual void changedActivity();
    5051
    5152            virtual void addToSpaceShip(SpaceShip* ship);
     
    124125            float accelerationLeftRight_;
    125126            float accelerationUpDown_;
     127
     128            Shader* boostBlur_;
    126129    };
    127130}
  • code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Backlight.cc

    r2254 r2350  
    3838#include "core/XMLPort.h"
    3939#include "objects/Scene.h"
     40#include "util/Exception.h"
    4041
    4142namespace orxonox
     
    5960        if (Core::showsGraphics())
    6061        {
    61             assert(this->getScene());
    62             assert(this->getScene()->getSceneManager());
    63             assert(this->getScene()->getRootSceneNode());
     62            if (!this->getScene())
     63                ThrowException(AbortLoading, "Can't create Camera, no scene given.");
     64            if (!this->getScene()->getSceneManager())
     65                ThrowException(AbortLoading, "Can't create Camera, no scene manager given.");
     66            if (!this->getScene()->getRootSceneNode())
     67                ThrowException(AbortLoading, "Can't create Camera, no root scene node given.");
    6468
    6569            this->ribbonTrail_ = this->getScene()->getSceneManager()->createRibbonTrail(this->getNode()->getName());
  • code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Camera.cc

    r2171 r2350  
    3737#include <OgreSceneNode.h>
    3838#include <OgreViewport.h>
     39#include <OgreCompositorManager.h>
     40#include <OgreResource.h>
    3941
    4042#include "util/Exception.h"
     
    4244#include "core/ConfigValueIncludes.h"
    4345#include "objects/Scene.h"
     46#include "tools/Shader.h"
    4447#include "CameraManager.h"
    4548
     
    7578        {
    7679            this->releaseFocus();
     80            this->getScene()->getSceneManager()->destroyCamera(this->camera_);
    7781        }
    7882    }
     
    122126    void Camera::setFocus(Ogre::Viewport* viewport)
    123127    {
     128        // This workaround is needed to avoid weird behaviour with active compositors while
     129        // switching the camera (like freezing the image)
     130        //
     131        // Last known Ogre version needing this workaround:
     132        // 1.4.8
     133
     134        // deactivate all compositors
     135        {
     136            Ogre::ResourceManager::ResourceMapIterator iterator = Ogre::CompositorManager::getSingleton().getResourceIterator();
     137            while (iterator.hasMoreElements())
     138                Ogre::CompositorManager::getSingleton().setCompositorEnabled(viewport, iterator.getNext()->getName(), false);
     139        }
     140
    124141        this->bHasFocus_ = true;
    125142        viewport->setCamera(this->camera_);
     143
     144        // reactivate all visible compositors
     145        {
     146            for (ObjectList<Shader>::iterator it = ObjectList<Shader>::begin(); it != ObjectList<Shader>::end(); ++it)
     147                it->updateVisibility();
     148        }
    126149    }
    127150}
  • code/branches/objecthierarchy2/src/orxonox/tools/CMakeLists.txt

    r2131 r2350  
    33  Mesh.cc
    44  ParticleInterface.cc
     5  Shader.cc
    56  TextureGenerator.cc
    67  Timer.cc
Note: See TracChangeset for help on using the changeset viewer.