Revision: 1633
http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=1633&view=rev
Author: rorthomas
Date: 2011-02-02 15:05:35 +0000 (Wed, 02 Feb 2011)
Log Message:
-----------
updated DOF integration, also moved it to separate directory
fixed RoR compilation when no curl is used
removed DOF debug mode
Modified Paths:
--------------
trunk/source/main/CMakeLists.txt
trunk/source/main/RoR.list
trunk/source/main/RoRFrameListener.cpp
trunk/source/main/RoRFrameListener.h
trunk/source/main/RoRPrerequisites.h
trunk/source/main/ScriptEngine.cpp
Removed Paths:
-------------
trunk/source/main/DepthOfFieldEffect.cpp
trunk/source/main/DepthOfFieldEffect.h
trunk/source/main/Lens.cpp
trunk/source/main/Lens.h
Modified: trunk/source/main/CMakeLists.txt
===================================================================
--- trunk/source/main/CMakeLists.txt 2011-02-02 13:41:17 UTC (rev 1632)
+++ trunk/source/main/CMakeLists.txt 2011-02-02 15:05:35 UTC (rev 1633)
@@ -88,6 +88,9 @@
add_executable(RoR ${HEADER_FILES} ${SOURCE_FILES})
ENDIF(WIN32)
+#additional include dirs
+include_directories(.)
+include_directories(dof)
target_link_libraries(RoR ${Ogre_LIBRARIES} ${Ogre_Terrain_LIBRARIES}
${Ogre_Paging_LIBRARIES} ${Ogre_RTShader_LIBRARIES} ${Ois_LIBRARIES} ${OS_LIBS}
${optional_libs})
Deleted: trunk/source/main/DepthOfFieldEffect.cpp
===================================================================
--- trunk/source/main/DepthOfFieldEffect.cpp 2011-02-02 13:41:17 UTC (rev
1632)
+++ trunk/source/main/DepthOfFieldEffect.cpp 2011-02-02 15:05:35 UTC (rev
1633)
@@ -1,462 +0,0 @@
-// "Depth of Field" demo for Ogre
-// Copyright (C) 2006 Christian Lindequist Larsen
-//
-// This code is in the public domain. You may do whatever you want with it.
-
-#include "DepthOfFieldEffect.h"
-#include "Ogre.h"
-#include "Lens.h"
-
-using namespace Ogre;
-
-const int DepthOfFieldEffect::BLUR_DIVISOR = 4;
-
-DepthOfFieldEffect::DepthOfFieldEffect(Viewport* viewport)
- : mViewport(viewport)
- , mNearDepth(10.0)
- , mFocalDepth(100.0)
- , mFarDepth(190.0)
- , mFarBlurCutoff(1.0)
-{
- createDepthRenderTexture();
- createCompositor();
- addCompositor();
-}
-
-DepthOfFieldEffect::~DepthOfFieldEffect()
-{
- removeCompositor();
- destroyCompositor();
- destroyDepthRenderTexture();
-}
-
-void DepthOfFieldEffect::setFocalDepths(float nearDepth, float focalDepth,
float farDepth)
-{
- mNearDepth = nearDepth;
- mFocalDepth = focalDepth;
- mFarDepth = farDepth;
-}
-
-void DepthOfFieldEffect::setFarBlurCutoff(float cutoff)
-{
- mFarBlurCutoff = cutoff;
-}
-
-bool DepthOfFieldEffect::getEnabled() const
-{
- if(!mCompositor) return false;
- return mCompositor->getEnabled();
-}
-
-void DepthOfFieldEffect::setEnabled(bool value)
-{
- if(mCompositor)
- mCompositor->setEnabled(value);
-}
-
-void DepthOfFieldEffect::createDepthRenderTexture()
-{
- // Create the depth render texture
- TexturePtr depthTexture = TextureManager::getSingleton().createManual(
- "DoF_Depth", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
- TEX_TYPE_2D, mViewport->getActualWidth(),
mViewport->getActualHeight(),
- 0, PF_L8, TU_RENDERTARGET);
-
- // Get its render target and add a viewport to it
- RenderTexture* depthTarget =
depthTexture->getBuffer()->getRenderTarget();
- Viewport* depthViewport =
depthTarget->addViewport(mViewport->getCamera());
-
- // Register 'this' as a render target listener
- depthTarget->addListener(this);
-
- // Get the technique to use when rendering the depth render texture
- mDepthMaterial = MaterialManager::getSingleton().getByName("DoF_Depth");
- mDepthMaterial->load(); // needs to be loaded manually
- mDepthTechnique = mDepthMaterial->getBestTechnique();
-
- // Create a custom render queue invocation sequence for the depth
render texture
- RenderQueueInvocationSequence* invocationSequence =
-
Root::getSingleton().createRenderQueueInvocationSequence("DoF_Depth");
-
- // Add a render queue invocation to the sequence, and disable shadows
for it
- RenderQueueInvocation* invocation =
invocationSequence->add(RENDER_QUEUE_MAIN, "main");
- invocation->setSuppressShadows(true);
-
- // Set the render queue invocation sequence for the depth render
texture viewport
- depthViewport->setRenderQueueInvocationSequenceName("DoF_Depth");
-
- // update debug texture
- MaterialPtr mat =
MaterialManager::getSingleton().getByName("DoF_DepthDebug");
-
mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName("DoF_Depth");
-
-}
-
-void DepthOfFieldEffect::destroyDepthRenderTexture()
-{
- TextureManager::getSingleton().remove("DoF_Depth");
-}
-
-void DepthOfFieldEffect::createCompositor()
-{
- // Create compositor
- CompositorPtr compositor = CompositorManager::getSingleton().create(
- "DoF_Compositor",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
- {
- // Create technique
- CompositionTechnique* technique = compositor->createTechnique();
- {
- // Create texture definition 'scene'
- CompositionTechnique::TextureDefinition* definition =
technique->createTextureDefinition("scene");
- definition->width = 0; // target width
- definition->height = 0; // target height
-#if OGRE_VERSION>0x010602
- definition->formatList.push_back(PF_X8R8G8B8);
-#else
- definition->format = PF_X8R8G8B8;
-#endif //OGRE_VERSION
- }
- {
- // Create texture definition 'blur'
- CompositionTechnique::TextureDefinition* definition =
technique->createTextureDefinition("blur");
- definition->width = mViewport->getActualWidth() /
BLUR_DIVISOR;
- definition->height = mViewport->getActualHeight() /
BLUR_DIVISOR;
-#if OGRE_VERSION>0x010602
- definition->formatList.push_back(PF_X8R8G8B8);
-#else
- definition->format = PF_X8R8G8B8;
-#endif //OGRE_VERSION
- }
- {
- // Create target pass 'scene'
- CompositionTargetPass* target =
technique->createTargetPass();
- target->setOutputName("scene");
-
target->setInputMode(CompositionTargetPass::IM_PREVIOUS);
- }
- {
- // Create target pass 'blur'
- CompositionTargetPass* target =
technique->createTargetPass();
- target->setOutputName("blur");
- {
- // Create a composition pass
- CompositionPass* pass = target->createPass();
- pass->setIdentifier(BlurPass);
- pass->setMaterialName("DoF_Gaussian3x3");
- pass->setInput(0, "scene");
- }
- }
- {
- // Build the output target pass
- CompositionTargetPass* output =
technique->getOutputTargetPass();
- {
- // Create a composition pass
- CompositionPass* pass = output->createPass();
- pass->setIdentifier(OutputPass);
- pass->setMaterialName("DoF_DepthOfField");
- pass->setInput(0, "scene");
- //pass->setInput(1, "depth"); // render texture
- pass->setInput(2, "blur");
- }
- }
- }
-}
-
-void DepthOfFieldEffect::destroyCompositor()
-{
- CompositorManager::getSingleton().remove("DoF_Compositor");
-}
-
-void DepthOfFieldEffect::addCompositor()
-{
- // Add the compositor to the viewport
- mCompositor = CompositorManager::getSingleton().addCompositor(
- mViewport, "DoF_Compositor_test");
-
- //TODO: throw error and exit if not found
- // Register 'this' as a listener
- if(mCompositor)
- mCompositor->addListener(this);
-}
-
-void DepthOfFieldEffect::removeCompositor()
-{
- CompositorManager::getSingleton().removeCompositor(mViewport,
"DoF_Compositor_test");
-}
-
-void DepthOfFieldEffect::notifyMaterialSetup(unsigned int passId, MaterialPtr&
material)
-{
- switch (passId)
- {
- case BlurPass:
- {
- //float pixelSize[2] = {
- // 1.0f / (mViewport->getActualWidth() /
BLUR_DIVISOR),
- // 1.0f / (mViewport->getActualHeight() /
BLUR_DIVISOR)};
-
- // Adjust fragment program parameters
- Ogre::Vector3 pixelSize = Ogre::Vector3(1.0f /
(mViewport->getActualWidth() / BLUR_DIVISOR),1.0f /
(mViewport->getActualHeight() / BLUR_DIVISOR), 1.0f);
- GpuProgramParametersSharedPtr fragParams =
material->getBestTechnique()->getPass(0)->getFragmentProgramParameters();
- fragParams->setNamedConstant("pixelSize", pixelSize);
-
- break;
- }
-
- case OutputPass:
- {
- float pixelSizeScene[2] = {
- 1.0f / mViewport->getActualWidth(),
- 1.0f / mViewport->getActualHeight()};
-
- float pixelSizeBlur[2] = {
- 1.0f / (mViewport->getActualWidth() /
BLUR_DIVISOR),
- 1.0f / (mViewport->getActualHeight() /
BLUR_DIVISOR)};
-
- // Adjust fragment program parameters
- GpuProgramParametersSharedPtr fragParams =
-
material->getBestTechnique()->getPass(0)->getFragmentProgramParameters();
- fragParams->setNamedConstant("pixelSizeScene",
pixelSizeScene,
-
sizeof(pixelSizeScene)/sizeof(pixelSizeScene[0]));
- fragParams->setNamedConstant("pixelSizeBlur",
pixelSizeBlur,
- sizeof(pixelSizeBlur)/sizeof(pixelSizeBlur[0]));
-
- break;
- }
- }
-}
-
-void DepthOfFieldEffect::preViewportUpdate(const
Ogre::RenderTargetViewportEvent& evt)
-{
- float dofParams[4] = {mNearDepth, mFocalDepth, mFarDepth,
mFarBlurCutoff};
-
- // Adjust fragment program parameters for depth pass
- GpuProgramParametersSharedPtr fragParams =
- mDepthTechnique->getPass(0)->getFragmentProgramParameters();
- fragParams->setNamedConstant("dofParams", dofParams,
- sizeof(dofParams)/sizeof(dofParams[0]));
-
- // Add 'this' as a RenderableListener to replace the technique for all
renderables
- RenderQueue* queue =
evt.source->getCamera()->getSceneManager()->getRenderQueue();
- queue->setRenderableListener(this);
-}
-
-void DepthOfFieldEffect::postViewportUpdate(const
Ogre::RenderTargetViewportEvent& evt)
-{
- // Reset the RenderableListener
- RenderQueue* queue =
evt.source->getCamera()->getSceneManager()->getRenderQueue();
- queue->setRenderableListener(0);
-}
-
-#if OGRE_VERSION>0x010602
-bool DepthOfFieldEffect::renderableQueued(Renderable* rend, Ogre::uint8
groupID, Ogre::ushort priority, Technique** ppTech, Ogre::RenderQueue* pQueue)
-#else
-bool DepthOfFieldEffect::renderableQueued(Renderable* rend, Ogre::uint8
groupID, Ogre::ushort priority, Technique** ppTech)
-#endif //OGRE_VERSION
-{
- // Replace the technique of all renderables
- *ppTech = mDepthTechnique;
- return true;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////
-// DOFManager below
-const char* DOFManager::FOCUS_MODES[3] = {"auto", "manual", "pinhole"};
-
-DOFManager::DOFManager(Ogre::Root *mRoot, Camera* camera, SceneManager*
sceneManager) : mSceneManager(sceneManager), mFocusMode(Manual), mRoot(mRoot),
debugEnabled(false), mCamera(camera)
-{
- mDepthOfFieldEffect = new DepthOfFieldEffect(mCamera->getViewport());
- mLens = new Lens(mCamera->getFOVy(), 1.5);
- mLens->setFocalDistance(171.5);
- //mLens->setFStop(3);
- mDepthOfFieldEffect->setEnabled(false);
- mRoot->addFrameListener(this);
-
- // Do not Show overlays - only crash if the overlays are missing ;)
- OverlayManager::getSingleton().getByName("DoF_SettingsOverlay")->hide();
-
OverlayManager::getSingleton().getByName("DoF_FocusAreaOverlay")->hide();
-
OverlayManager::getSingleton().getByName("DoF_DepthDebugOverlay")->hide();
-
- // Initialise and show debug depth overlay
- MaterialPtr material =
MaterialManager::getSingleton().getByName("DoF_DepthDebug");
-
material->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName("DoF_Depth");
-
- // debug overlays
- OverlayManager& om = OverlayManager::getSingleton();
- mFocalLengthText = om.getOverlayElement("DoF_FocalLength");
- mFStopKey = om.getOverlayElement("DoF_FStopKey");
- mFStopText = om.getOverlayElement("DoF_FStop");
- mFocusModeText = om.getOverlayElement("DoF_FocusMode");
- mFocalDistanceKey = om.getOverlayElement("DoF_FocalDistanceKey");
- mFocalDistanceText = om.getOverlayElement("DoF_FocalDistance");
-}
-
-void DOFManager::setEnabled(bool enabled)
-{
- mDepthOfFieldEffect->setEnabled(enabled);
- /*
- // crashes for some reason
- if(enabled && !mDepthOfFieldEffect->getEnabled())
- {
- // turn on
- mDepthOfFieldEffect->setEnabled(true);
- mRoot->addFrameListener(this);
- } else if(!enabled && mDepthOfFieldEffect->getEnabled())
- {
- // turn off
- mDepthOfFieldEffect->setEnabled(false);
- mRoot->removeFrameListener(this);
- }
- */
-}
-
-void DOFManager::setDebugEnabled(bool enabled)
-{
- debugEnabled = enabled;
- if(debugEnabled)
- {
-
OverlayManager::getSingleton().getByName("DoF_SettingsOverlay")->show();
-
OverlayManager::getSingleton().getByName("DoF_FocusAreaOverlay")->show();
-
OverlayManager::getSingleton().getByName("DoF_DepthDebugOverlay")->show();
- } else
- {
-
OverlayManager::getSingleton().getByName("DoF_SettingsOverlay")->hide();
-
OverlayManager::getSingleton().getByName("DoF_FocusAreaOverlay")->hide();
-
OverlayManager::getSingleton().getByName("DoF_DepthDebugOverlay")->hide();
- }
-}
-
-bool DOFManager::getDebugEnabled()
-{
- return debugEnabled;
-}
-
-bool DOFManager::getEnabled()
-{
- return mDepthOfFieldEffect->getEnabled();
-}
-
-void DOFManager::toggleFocusMode()
-{
- mFocusMode = static_cast<FocusMode>((mFocusMode + 1) % 3);
-}
-
-void DOFManager::zoomView(float delta)
-{
- Real fieldOfView = mLens->getFieldOfView().valueRadians();
- fieldOfView += delta;
- fieldOfView = std::max<Real>(0.1, std::min<Real>(fieldOfView, 2.0));
- mLens->setFieldOfView(Radian(fieldOfView));
- mCamera->setFOVy(Radian(fieldOfView));
-}
-
-void DOFManager::setAperture(float delta)
-{
- if (mFocusMode == Pinhole)
- return;
- Real fStop = mLens->getFStop();
- fStop += delta;
- fStop = std::max<Real>(0.5, std::min<Real>(fStop, 12.0));
- mLens->setFStop(fStop);
-}
-
-void DOFManager::moveFocus(float delta)
-{
- mLens->setFocalDistance(mLens->getFocalDistance() + delta);
-}
-
-bool DOFManager::frameStarted(const FrameEvent& evt)
-{
- // Focusing
- switch (mFocusMode)
- {
- case Auto:
- {
- // TODO: Replace with accurate ray/triangle collision
detection
-
- // TODO: Continous AF / triggered
-
- Real currentFocalDistance = mLens->getFocalDistance();
- Real targetFocalDistance = currentFocalDistance;
-
- // Ryan Booker's (eyevee99) ray scene query auto focus
- Ray focusRay;
- focusRay.setOrigin(mCamera->getDerivedPosition());
- focusRay.setDirection(mCamera->getDerivedDirection());
-
- RaySceneQuery* query = 0;
- query = mSceneManager->createRayQuery(focusRay);
- query->setRay(focusRay);
- RaySceneQueryResult& queryResult = query->execute();
- RaySceneQueryResult::iterator i = queryResult.begin();
- if (i != queryResult.end())
- targetFocalDistance = i->distance;
- //else
- // mLens->setFocalDistance(Math::POS_INFINITY);
- mSceneManager->destroyQuery(query);
-
- // Slowly adjust the focal distance (emulate auto focus
motor)
- if (currentFocalDistance < targetFocalDistance)
- {
- mLens->setFocalDistance(
- std::min<Real>(currentFocalDistance +
240.0 * evt.timeSinceLastFrame, targetFocalDistance));
- }
- else if (currentFocalDistance > targetFocalDistance)
- {
- mLens->setFocalDistance(
- std::max<Real>(currentFocalDistance -
240.0 * evt.timeSinceLastFrame, targetFocalDistance));
- }
-
- break;
- }
-
- case Manual:
- //we set the values elsewhere
- break;
- }
-
- // Update Depth of Field effect
- if (mFocusMode != Pinhole)
- {
- mDepthOfFieldEffect->setEnabled(true);
-
- // Calculate and set depth of field using lens
- float nearDepth, focalDepth, farDepth;
- mLens->recalculateDepthOfField(nearDepth, focalDepth, farDepth);
- mDepthOfFieldEffect->setFocalDepths(nearDepth, focalDepth,
farDepth);
- }
- else
- {
- mDepthOfFieldEffect->setEnabled(false);
- }
-
- // Update overlay
- updateOverlay();
-
- return true;
-}
-
-void DOFManager::updateOverlay()
-{
- if(!debugEnabled) return;
-
- mFocalLengthText->setCaption(
- StringConverter::toString(mLens->getFocalLength(), 1, 0, 32,
std::ios::fixed) + " (" +
-
StringConverter::toString(mLens->getFieldOfView().valueDegrees(), 1, 0, 32,
std::ios::fixed) + ")");
- mFocusModeText->setCaption(FOCUS_MODES[mFocusMode]);
-
- if (mFocusMode != Pinhole)
- {
- mFStopKey->setCaption("[1,2]");
-
mFStopText->setCaption(StringConverter::toString(mLens->getFStop(), 1, 0, 32,
std::ios::fixed));
- if (mFocusMode == Manual)
- mFocalDistanceKey->setCaption("[Wheel]");
- else
- mFocalDistanceKey->setCaption("[]");
-
mFocalDistanceText->setCaption(StringConverter::toString(mLens->getFocalDistance(),
1, 0, 32, std::ios::fixed));
- }
- else
- {
- mFStopKey->setCaption("[]");
- mFStopText->setCaption("N/A");
- mFocalDistanceKey->setCaption("[]");
- mFocalDistanceText->setCaption("N/A");
- }
-}
Deleted: trunk/source/main/DepthOfFieldEffect.h
===================================================================
--- trunk/source/main/DepthOfFieldEffect.h 2011-02-02 13:41:17 UTC (rev
1632)
+++ trunk/source/main/DepthOfFieldEffect.h 2011-02-02 15:05:35 UTC (rev
1633)
@@ -1,114 +0,0 @@
-// "Depth of Field" demo for Ogre
-// Copyright (C) 2006 Christian Lindequist Larsen
-//
-// This code is in the public domain. You may do whatever you want with it.
-
-#ifndef __DepthOfFieldEffect_H__
-#define __DepthOfFieldEffect_H__
-
-#include "OgrePrerequisites.h"
-#include "OgreCompositorInstance.h"
-#include "OgreRenderTargetListener.h"
-#include "OgreFrameListener.h"
-#include "OgreRenderQueue.h"
-
-
-class Lens;
-
-class DepthOfFieldEffect : public Ogre::CompositorInstance::Listener,
- public
Ogre::RenderTargetListener,
- public
Ogre::RenderQueue::RenderableListener
-{
-public:
- DepthOfFieldEffect(Ogre::Viewport* viewport);
- ~DepthOfFieldEffect();
-
- float getNearDepth() const {return mNearDepth; }
- float getFocalDepth() const {return mFocalDepth; }
- float getFarDepth() const {return mFarDepth; }
- void setFocalDepths(float nearDepth, float focalDepth, float farDepth);
- float getFarBlurCutoff() const {return mFarBlurCutoff; }
- void setFarBlurCutoff(float cutoff);
- bool getEnabled() const;
- void setEnabled(bool value);
-
-private:
- static const int BLUR_DIVISOR;
-
- enum PassId
- {
- BlurPass,
- OutputPass
- };
-
- Ogre::Viewport* mViewport;
- Ogre::MaterialPtr mDepthMaterial;
- Ogre::Technique* mDepthTechnique;
- Ogre::CompositorInstance* mCompositor;
- float mNearDepth;
- float mFocalDepth;
- float mFarDepth;
- float mFarBlurCutoff;
-
- void createDepthRenderTexture();
- void destroyDepthRenderTexture();
- void createCompositor();
- void destroyCompositor();
- void addCompositor();
- void removeCompositor();
-
- // Implementation of Ogre::CompositorInstance::Listener
- virtual void notifyMaterialSetup(Ogre::uint32 passId,
Ogre::MaterialPtr& material);
-
- // Implementation of Ogre::RenderTargetListener
- virtual void preViewportUpdate(const Ogre::RenderTargetViewportEvent&
evt);
- virtual void postViewportUpdate(const Ogre::RenderTargetViewportEvent&
evt);
-
- // Implementation of Ogre::RenderQueue::RenderableListener
-#if OGRE_VERSION>0x010602
- virtual bool renderableQueued(Ogre::Renderable* rend, Ogre::uint8
groupID, Ogre::ushort priority, Ogre::Technique** ppTech, Ogre::RenderQueue*
pQueue);
-#else
- virtual bool renderableQueued(Ogre::Renderable* rend, Ogre::uint8
groupID, Ogre::ushort priority, Ogre::Technique** ppTech);
-#endif //OGRE_VERSION
-
-};
-
-class DOFManager : public Ogre::FrameListener
-{
-public:
- DOFManager(Ogre::Root *mRoot, Ogre::Camera* camera, Ogre::SceneManager*
sceneManager);
-
- void setEnabled(bool enabled);
- bool getEnabled();
-
- void setDebugEnabled(bool enabled);
- bool getDebugEnabled();
-
- // controls
- void toggleFocusMode();
- void zoomView(float delta);
- void setAperture(float delta);
- void moveFocus(float delta);
-
-protected:
- Ogre::Root *mRoot;
- Ogre::SceneManager* mSceneManager;
- Ogre::Camera *mCamera;
- DepthOfFieldEffect* mDepthOfFieldEffect;
- Lens* mLens;
- bool debugEnabled;
- enum FocusMode {Auto, Manual, Pinhole};
- static const char* FOCUS_MODES[3];
- FocusMode mFocusMode;
- Ogre::OverlayElement* mFocalLengthText;
- Ogre::OverlayElement* mFStopKey;
- Ogre::OverlayElement* mFStopText;
- Ogre::OverlayElement* mFocusModeText;
- Ogre::OverlayElement* mFocalDistanceKey;
- Ogre::OverlayElement* mFocalDistanceText;
-
- virtual bool frameStarted(const Ogre::FrameEvent& evt);
- void updateOverlay();
-};
-
-#endif // __DepthOfFieldEffect_H__
Deleted: trunk/source/main/Lens.cpp
===================================================================
--- trunk/source/main/Lens.cpp 2011-02-02 13:41:17 UTC (rev 1632)
+++ trunk/source/main/Lens.cpp 2011-02-02 15:05:35 UTC (rev 1633)
@@ -1,128 +0,0 @@
-// "Depth of Field" demo for Ogre
-// Copyright (C) 2006 Christian Lindequist Larsen
-//
-// This code is in the public domain. You may do whatever you want with it.
-//
-// Author: Ryan Booker (eyevee99)
-
-#include "Lens.h"
-#include "Ogre.h"
-
-using namespace Ogre;
-
-#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
-#undef min
-#undef max
-#endif
-
-template<class T>
-const T& min(const T& a, const T& b) {
- return (a < b) ? a : b;
-};
-
-
-template<class T>
-const T& max(const T& a, const T& b) {
- return (a > b) ? a : b;
-};
-
-
-Lens::Lens(const Real& _focalLength, const Real& _fStop, const Real&
_frameSize, const Real& _circleOfConfusion) {
- init(_focalLength, _fStop, _frameSize, _circleOfConfusion);
-}
-
-
-Lens::Lens(const Radian& _fieldOfView, const Real& _fStop, const Real&
_frameSize, const Real& _circleOfConfusion) {
- init(_fieldOfView, _fStop, _frameSize, _circleOfConfusion);
-}
-
-
-void Lens::init(const Real& _focalLength, const Real& _fStop, const Real&
_frameSize, const Real& _circleOfConfusion) {
- mFocalLength = _focalLength;
- mFStop = _fStop;
- mFrameSize = _frameSize;
- mCircleOfConfusion = _circleOfConfusion;
- recalculateFieldOfView();
-}
-
-
-void Lens::init(const Radian& _fieldOfView, const Real& _fStop, const Real&
_frameSize, const Real& _circleOfConfusion) {
- mFieldOfView = _fieldOfView;
- mFStop = _fStop;
- mFrameSize = _frameSize;
- mCircleOfConfusion = _circleOfConfusion;
- recalculateFocalLength();
-}
-
-
-void Lens::setFrameSize(const Real& _frameSize) {
- mFrameSize = _frameSize;
- recalculateFieldOfView();
-}
-
-
-void Lens::setFocalDistance(const Real& _focalDistance) {
- mFocalDistance = max(_focalDistance, Real(0));
-}
-
-
-void Lens::setFocalLength(const Real& _focalLength) {
- mFocalLength = max(_focalLength, Real(0.3));
- recalculateFieldOfView();
-}
-
-
-void Lens::setFieldOfView(const Radian& _fieldOfView) {
- mFieldOfView = min(_fieldOfView, Radian(2.8));
- recalculateFocalLength();
-}
-
-
-void Lens::setFStop(const Real& _fStop) {
- mFStop = max(_fStop, Real(0));
-}
-
-
-void Lens::recalculateFocalLength(void) {
- mFocalLength = (mFrameSize / Math::Tan(mFieldOfView / 2.0)) / 2.0;
-}
-
-
-void Lens::recalculateFieldOfView(void) {
- mFieldOfView = 2.0 * Math::ATan(mFrameSize / (2.0 * mFocalLength));
-}
-
-
-void Lens::recalculateHyperfocalLength(void) {
- mHyperfocalLength = (mFocalLength * mFocalLength) / (mFStop *
mCircleOfConfusion) + mFocalLength;
-}
-
-
-void Lens::recalculateDepthOfField(Real& _nearDepth, Real& _focalDepth, Real&
_farDepth) {
- // Set focalDepth to the current focalDistance
- _focalDepth = mFocalDistance;
-
- // Recalculate the Hyperfocal length
- recalculateHyperfocalLength();
-
- // Calculate the numerator of the optics equations
- Real numerator = (mFocalDistance * (mHyperfocalLength - mFocalLength));
-
- Real nearClear = numerator / (mHyperfocalLength + mFocalDistance - (2.0 *
mFocalLength));
-
- // Adjust the nearDepth relative to the aperture. This is an approximation.
- _nearDepth = min(nearClear - nearClear * mFStop, (Real)0);
-
- if(mFocalDistance < mHyperfocalLength)
- {
- // Calculate the far clear plane
- Real farClear = numerator / (mHyperfocalLength - mFocalDistance);
-
- // Adjust the farDepth relative to the aperture. This is an approximation.
- _farDepth = farClear + farClear * mFStop;
- }
-
- // Far depth of field should be infinite
- else
- _farDepth = Math::POS_INFINITY;
-}
Deleted: trunk/source/main/Lens.h
===================================================================
--- trunk/source/main/Lens.h 2011-02-02 13:41:17 UTC (rev 1632)
+++ trunk/source/main/Lens.h 2011-02-02 15:05:35 UTC (rev 1633)
@@ -1,62 +0,0 @@
-// "Depth of Field" demo for Ogre
-// Copyright (C) 2006 Christian Lindequist Larsen
-//
-// This code is in the public domain. You may do whatever you want with it.
-//
-// Author: Ryan Booker (eyevee99)
-
-#ifndef __Lens_H__
-#define __Lens_H__
-
-#include "OgrePrerequisites.h"
-#include "OgreMath.h"
-
-
-class Lens
-{
-public:
- Lens(void) {};
- Lens(const Ogre::Real& _focalLength, const Ogre::Real& _fStop, const
Ogre::Real& _frameSize = 3.5, const Ogre::Real& _circleOfConfusion = 0.003);
- Lens(const Ogre::Radian& _fieldOfView, const Ogre::Real& _fStop, const
Ogre::Real& _frameSize = 3.5, const Ogre::Real& _circleOfConfusion = 0.003);
- ~Lens(void) {};
-
- void init(const Ogre::Real& _focalLength, const Ogre::Real& _fStop, const
Ogre::Real& _frameSize = 3.5, const Ogre::Real& _circleOfConfusion = 0.003);
- void init(const Ogre::Radian& _fieldOfView, const Ogre::Real& _fStop, const
Ogre::Real& _frameSize = 3.5, const Ogre::Real& _circleOfConfusion = 0.003);
-
- void setFrameSize(const Ogre::Real& _frameSize);
- void setFocalDistance(const Ogre::Real& _focalDistance);
- void setFocalLength(const Ogre::Real& _focalLength);
- void setFieldOfView(const Ogre::Radian& _fieldOfView);
- void setFStop(const Ogre::Real& _fStop);
-
- const Ogre::Real& getFrameSize(void) { return mFrameSize; }
- const Ogre::Real& getFocalDistance(void) { return mFocalDistance; }
- const Ogre::Real& getFocalLength(void) { return mFocalLength; }
- const Ogre::Radian& getFieldOfView(void) { return mFieldOfView; }
- const Ogre::Real& getFStop(void) { return mFStop; }
- const Ogre::Real& getHyperfocalLength(void) { return mHyperfocalLength; }
-
- void recalculateDepthOfField(Ogre::Real& _nearDepth, Ogre::Real&
_focalDepth, Ogre::Real& _farDepth);
-
-
-protected:
- // NOTE: All units must be the same, eg mm, cm or m etc
- // Primary attributes
- Ogre::Real mFrameSize; // Film stock/sensor size, arbitrarily
selected to help mimic the properties of film, eg 35mm, 3.5cm, 0.035m etc
- Ogre::Real mCircleOfConfusion; // The area within which the depth of
field is clear, it's tied to frame size, eg 0.03mm, 0.003cm, 0.0003m etc
- Ogre::Real mFocalDistance; // The distance to the object we are
focusing on
- Ogre::Real mFocalLength; // Focal length of the lens, this
directly effects field of view, we can do anything from wide angle to telephoto
as we don't have the limitations of physical lenses. Focal length is the
distance from the optical centre of the lens to the film stock/sensor etc
- Ogre::Real mFStop; // FStop number, ie aperture, changing
the aperture of a lens has an effect of depth of field, the narrower the
aperture/higher the fstop number, the greater the depth of field/clearer the
picture is.
-
- // Secondary attributes
- Ogre::Real mHyperfocalLength; // The hyperfocal length is the point
at which far depth of field is infinite, ie if mFocalDistance is >= to this
value everythig will be clear to infinity
- Ogre::Radian mFieldOfView; // Field of view of the lens, directly
related to focal length
-
-
-private:
- void recalculateHyperfocalLength(void);
- void recalculateFieldOfView(void);
- void recalculateFocalLength(void);
-};
-
-#endif
Modified: trunk/source/main/RoR.list
===================================================================
--- trunk/source/main/RoR.list 2011-02-02 13:41:17 UTC (rev 1632)
+++ trunk/source/main/RoR.list 2011-02-02 15:05:35 UTC (rev 1633)
@@ -17,7 +17,7 @@
ColoredTextAreaOverlayElementFactory.h
dashboard.h
IngameConsole.h
- DepthOfFieldEffect.h
+ dof/DepthOfFieldEffect.h
DustManager.h
DustPool.h
DynamicLines.h
@@ -26,7 +26,7 @@
hdrlistener.h
Heathaze.h
HydraxWater.h
- Lens.h
+ dof/Lens.h
MovableText.h
OgreLineStreamOverlayElement.h
RandomTreeLoader.h
@@ -130,7 +130,7 @@
ColoredTextAreaOverlayElement.cpp
dashboard.cpp
IngameConsole.cpp
- DepthOfFieldEffect.cpp
+ dof/DepthOfFieldEffect.cpp
DustManager.cpp
DustPool.cpp
DynamicLines.cpp
@@ -139,7 +139,7 @@
hdrlistener.cpp
Heathaze.cpp
HydraxWater.cpp
- Lens.cpp
+ dof/Lens.cpp
MovableText.cpp
OgreLineStreamOverlayElement.cpp
Skidmark.cpp
@@ -269,8 +269,8 @@
OverlayWrapper.h
)
SOURCE_GROUP("GFX" FILES
- DepthOfFieldEffect.cpp
- DepthOfFieldEffect.h
+ dof/DepthOfFieldEffect.cpp
+ dof/DepthOfFieldEffect.h
DustManager.cpp
DustManager.h
DustPool.cpp
@@ -291,8 +291,8 @@
Heathaze.h
HydraxWater.cpp
HydraxWater.h
- Lens.cpp
- Lens.h
+ dof/Lens.cpp
+ dof/Lens.h
MovableText.cpp
MovableText.h
OgreLineStreamOverlayElement.cpp
Modified: trunk/source/main/RoRFrameListener.cpp
===================================================================
--- trunk/source/main/RoRFrameListener.cpp 2011-02-02 13:41:17 UTC (rev
1632)
+++ trunk/source/main/RoRFrameListener.cpp 2011-02-02 15:05:35 UTC (rev
1633)
@@ -788,7 +788,6 @@
netPointToUID=-1;
netcheckGUITimer=0;
mDOF=0;
- mDOFDebug=false;
mouseGrabForce=100000.0f;
eflsingleton=this;
forcefeedback=0;
@@ -2380,24 +2379,6 @@
#endif // MYGUI
-
- if (INPUTENGINE.getEventBoolValueBounce(EV_DOF_TOGGLE, 0.5f) && mDOF)
- {
- bool enabled = !mDOF->getEnabled();
- if(!enabled && mDOFDebug)
- {
- // turn off debug if on
- mDOFDebug = false;
- mDOF->setDebugEnabled(mDOFDebug);
- }
- mDOF->setEnabled(enabled);
- }
- if (INPUTENGINE.getEventBoolValueBounce(EV_DOF_DEBUG, 0.5f) && mDOF)
- {
- mDOFDebug = !mDOFDebug;
- mDOF->setDebugEnabled(mDOFDebug);
- }
-
/*
if (INPUTENGINE.getEventBoolValueBounce(EV_TOGGLESHADERS, 0.5f))
{
@@ -2520,37 +2501,6 @@
return true;
}
-
- // special keys for the debug mode
- if(mDOF && mDOFDebug)
- {
-
if(INPUTENGINE.getEventBoolValueBounce(EV_DOF_DEBUG_TOGGLE_FOCUS_MODE, 1.0f))
- mDOF->toggleFocusMode();
-
- // zoom
- if(INPUTENGINE.getEventBoolValue(EV_DOF_DEBUG_ZOOM_IN))
- mDOF->zoomView(-dt);
- else if(INPUTENGINE.getEventBoolValue(EV_DOF_DEBUG_ZOOM_OUT))
- mDOF->zoomView(dt);
-
- // aperture
- if(INPUTENGINE.getEventBoolValue(EV_DOF_DEBUG_APERTURE_MORE))
- mDOF->setAperture(-5*dt);
- else
if(INPUTENGINE.getEventBoolValue(EV_DOF_DEBUG_APERTURE_LESS))
- mDOF->setAperture(5*dt);
-
- // focus
- const OIS::MouseState mstate = INPUTENGINE.getMouseState();
- Real offset = 0.05f * mstate.Z.rel;
- if(INPUTENGINE.getEventBoolValue(EV_DOF_DEBUG_FOCUS_IN))
- offset -= 120.0 * dt;
- else if(INPUTENGINE.getEventBoolValue(EV_DOF_DEBUG_FOCUS_OUT))
- offset += 120.0 * dt;
- mDOF->moveFocus(offset);
-
- // if in DOF debug, we wont process any other events
- return true;
- }
/* -- disabled for now ... why we should check for this if it does not call
anything?
-- enable this again when truckToolGUI is available again
@@ -5358,10 +5308,8 @@
bool useDOF = (SETTINGS.getSetting("DOF") == "Yes");
if(useDOF)
{
- mDOF = new DOFManager(mRoot, mCamera, mSceneMgr);
+ mDOF = new DepthOfFieldEffect(mCamera->getViewport());
mDOF->setEnabled(true);
- // debug enabled via event
- mDOF->setDebugEnabled(false);
}
Modified: trunk/source/main/RoRFrameListener.h
===================================================================
--- trunk/source/main/RoRFrameListener.h 2011-02-02 13:41:17 UTC (rev
1632)
+++ trunk/source/main/RoRFrameListener.h 2011-02-02 15:05:35 UTC (rev
1633)
@@ -185,7 +185,7 @@
} animated_object_t;
class RoRFrameListener;
-class DOFManager;
+class DepthOfFieldEffect;
class SelectorWindow;
@@ -222,8 +222,7 @@
std::map< std::string, Ogre::SceneNode *> loadedObjects;
- DOFManager *mDOF;
- bool mDOFDebug;
+ DepthOfFieldEffect *mDOF;
int mouseX;
int mouseY;
int shaderSchemeMode;
Modified: trunk/source/main/RoRPrerequisites.h
===================================================================
--- trunk/source/main/RoRPrerequisites.h 2011-02-02 13:41:17 UTC (rev
1632)
+++ trunk/source/main/RoRPrerequisites.h 2011-02-02 15:05:35 UTC (rev
1633)
@@ -21,6 +21,9 @@
// created on 30th of April 2010 by Thomas Fischer
// macro that checks for the correct ogre version and aborts compilation if
not correct
+
+#include <OgrePrerequisites.h>
+
#if OGRE_VERSION < 0x010701
#error You need at least Ogre version 1.7.1, older versions are not supported
#endif
Modified: trunk/source/main/ScriptEngine.cpp
===================================================================
--- trunk/source/main/ScriptEngine.cpp 2011-02-02 13:41:17 UTC (rev 1632)
+++ trunk/source/main/ScriptEngine.cpp 2011-02-02 15:05:35 UTC (rev 1633)
@@ -1154,7 +1154,7 @@
return 0;
}
-//#ifdef USE_CURL
+#ifdef USE_CURL
//hacky hack to fill memory with data for curl
// from: http://curl.haxx.se/libcurl/c/getinmemory.html
static size_t curlWriteMemoryCallback(void *ptr, size_t size, size_t nmemb,
void *data)
@@ -1175,11 +1175,11 @@
return realsize;
}
-//#endif //USE_CURL
+#endif //USE_CURL
int GameScript::useOnlineAPI(const std::string &apiquery, const
AngelScript::CScriptDictionary &d, std::string &result)
{
-//#ifdef USE_CURL
+#ifdef USE_CURL
struct curlMemoryStruct chunk;
chunk.memory = (char *)malloc(1); /* will be grown as needed by the
realloc above */
@@ -1318,7 +1318,8 @@
}
return 0;
-//#endif //USE_CURL
+#endif //USE_CURL
+ return 1;
}
///////////////////////////////////////////////////////////////////////////////
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel