diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c702be2e..57f950612 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,6 +96,7 @@ source_group(libs\\mangle FILES ${MANGLE_ALL}) set(OENGINE_OGRE ${LIBDIR}/openengine/ogre/renderer.cpp ${LIBDIR}/openengine/ogre/mouselook.cpp + ${LIBDIR}/openengine/ogre/fader.cpp ) set(OENGINE_GUI ${LIBDIR}/openengine/gui/events.cpp diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 6130e21f9..09b3cc9ed 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -75,6 +75,11 @@ MWRender::Player& RenderingManager::getPlayer(){ return (*mPlayer); } +OEngine::Render::Fader* RenderingManager::getFader() +{ + return mRendering.getFader(); +} + void RenderingManager::removeCell (MWWorld::Ptr::CellStore *store){ mObjects.removeCell(store); mActors.removeCell(store); @@ -123,6 +128,8 @@ void RenderingManager::moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Ve void RenderingManager::update (float duration){ mActors.update (duration); + + mRendering.update(duration); } void RenderingManager::skyEnable () @@ -165,8 +172,24 @@ void RenderingManager::skySetMoonColour (bool red){ if(mSkyManager) mSkyManager->setMoonColour(red); } -bool RenderingManager::toggleRenderMode(int mode){ - return mDebugging.toggleRenderMode(mode); + +bool RenderingManager::toggleRenderMode(int mode) +{ + if (mode == MWWorld::World::Render_CollisionDebug) + return mDebugging.toggleRenderMode(mode); + else // if (mode == MWWorld::World::Render_Wireframe) + { + if (mRendering.getCamera()->getPolygonMode() == PM_SOLID) + { + mRendering.getCamera()->setPolygonMode(PM_WIREFRAME); + return true; + } + else + { + mRendering.getCamera()->setPolygonMode(PM_SOLID); + return false; + } + } } void RenderingManager::configureFog(ESMS::CellStore &mCell) diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index ca5d95a3f..0a84aea66 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -63,6 +64,8 @@ class RenderingManager: private RenderingInterface { void toggleLight(); bool toggleRenderMode(int mode); + + OEngine::Render::Fader* getFader(); void removeCell (MWWorld::Ptr::CellStore *store); diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index 183605328..b1c5acb96 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -115,4 +115,8 @@ op 0x2000136: GetPCCell op 0x2000137: GetButtonPressed op 0x2000138: SkipAnim op 0x2000139: SkipAnim, expplicit reference -opcodes 0x200013a-0x3ffffff unused +op 0x200013b: twf +op 0x200013c: FadeIn +op 0x200013d: FadeOut +op 0x200013e: FadeTo +opcodes 0x200013f-0x3ffffff unused diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index d8dfbdde4..5bfffd3a2 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -103,7 +103,75 @@ namespace MWScript context.getWorld().toggleRenderMode (MWWorld::World::Render_CollisionDebug); context.report (enabled ? - "Collsion Mesh Rendering -> On" : "Collision Mesh Rendering -> Off"); + "Collision Mesh Rendering -> On" : "Collision Mesh Rendering -> Off"); + } + }; + + class OpToggleWireframe : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + InterpreterContext& context = + static_cast (runtime.getContext()); + + bool enabled = + context.getWorld().toggleRenderMode (MWWorld::World::Render_Wireframe); + + context.report (enabled ? + "Wireframe Rendering -> On" : "Wireframe Rendering -> Off"); + } + }; + + class OpFadeIn : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + InterpreterContext& context = + static_cast (runtime.getContext()); + + Interpreter::Type_Float time = runtime[0].mFloat; + runtime.pop(); + + context.getWorld().getFader()->fadeIn(time); + } + }; + + class OpFadeOut : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + InterpreterContext& context = + static_cast (runtime.getContext()); + + Interpreter::Type_Float time = runtime[0].mFloat; + runtime.pop(); + + context.getWorld().getFader()->fadeOut(time); + } + }; + + class OpFadeTo : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + InterpreterContext& context = + static_cast (runtime.getContext()); + + Interpreter::Type_Float alpha = runtime[0].mFloat; + runtime.pop(); + + Interpreter::Type_Float time = runtime[0].mFloat; + runtime.pop(); + + context.getWorld().getFader()->fadeTo(alpha, time); } }; @@ -115,6 +183,10 @@ namespace MWScript const int opcodeUnlock = 0x200008c; const int opcodeUnlockExplicit = 0x200008d; const int opcodeToggleCollisionDebug = 0x2000132; + const int opcodeToggleWireframe = 0x200013b; + const int opcodeFadeIn = 0x200013c; + const int opcodeFadeOut = 0x200013d; + const int opcodeFadeTo = 0x200013e; void registerExtensions (Compiler::Extensions& extensions) { @@ -127,6 +199,11 @@ namespace MWScript extensions.registerInstruction ("togglecollisiongrid", "", opcodeToggleCollisionDebug); extensions.registerInstruction ("tcb", "", opcodeToggleCollisionDebug); extensions.registerInstruction ("tcg", "", opcodeToggleCollisionDebug); + extensions.registerInstruction ("twf", "", opcodeToggleWireframe); + extensions.registerInstruction ("togglewireframe", "", opcodeToggleWireframe); + extensions.registerInstruction ("fadein", "f", opcodeFadeIn); + extensions.registerInstruction ("fadeout", "f", opcodeFadeOut); + extensions.registerInstruction ("fadeto", "ff", opcodeFadeTo); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -139,6 +216,10 @@ namespace MWScript interpreter.installSegment5 (opcodeUnlock, new OpUnlock); interpreter.installSegment5 (opcodeUnlockExplicit, new OpUnlock); interpreter.installSegment5 (opcodeToggleCollisionDebug, new OpToggleCollisionDebug); + interpreter.installSegment5 (opcodeToggleWireframe, new OpToggleWireframe); + interpreter.installSegment5 (opcodeFadeIn, new OpFadeIn); + interpreter.installSegment5 (opcodeFadeOut, new OpFadeOut); + interpreter.installSegment5 (opcodeFadeTo, new OpFadeTo); } } } diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 0ce84ebf5..f9e108f4c 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -689,4 +689,9 @@ namespace MWWorld { mWorldScene->update (duration); } + + OEngine::Render::Fader* World::getFader() + { + return mRendering->getFader(); + } } diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index a96d1ef35..a6e917961 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -20,6 +20,7 @@ #include "localscripts.hpp" #include +#include namespace Ogre { @@ -60,7 +61,8 @@ namespace MWWorld enum RenderMode { - Render_CollisionDebug + Render_CollisionDebug, + Render_Wireframe }; private: @@ -101,6 +103,8 @@ namespace MWWorld Environment& environment, const std::string& encoding); ~World(); + + OEngine::Render::Fader* getFader(); Ptr::CellStore *getExterior (int x, int y); diff --git a/libs/openengine b/libs/openengine index 4a188f282..420e611a4 160000 --- a/libs/openengine +++ b/libs/openengine @@ -1 +1 @@ -Subproject commit 4a188f2820c037ca4ad8ef35492d3857ea8d7df8 +Subproject commit 420e611a4beb2d45fef1f4b93618b22269fc89e6