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/objects
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.