Merge branch 'master' into HEAD

Conflicts:
	apps/openmw/mwscript/docs/vmformat.txt
	libs/openengine/ogre/renderer.cpp
actorid
Marc Zinnschlag 13 years ago
commit c251fbdf23

@ -37,6 +37,9 @@ option(USE_FFMPEG "use ffmpeg for sound" OFF)
option(USE_AUDIERE "use audiere for sound" OFF) option(USE_AUDIERE "use audiere for sound" OFF)
option(USE_MPG123 "use mpg123 + libsndfile for sound" ON) option(USE_MPG123 "use mpg123 + libsndfile for sound" ON)
# OS X deployment
option(OPENMW_OSX_DEPLOYMENT OFF)
find_program(DPKG_PROGRAM dpkg DOC "dpkg program of Debian-based systems") find_program(DPKG_PROGRAM dpkg DOC "dpkg program of Debian-based systems")
# Location of morrowind data files # Location of morrowind data files
@ -230,22 +233,46 @@ if (APPLE)
${OGRE_Plugin_OctreeSceneManager_LIBRARY_REL} ${OGRE_Plugin_OctreeSceneManager_LIBRARY_REL}
${OGRE_Plugin_CgProgramManager_LIBRARY_REL} ${OGRE_Plugin_CgProgramManager_LIBRARY_REL}
${OGRE_Plugin_ParticleFX_LIBRARY_REL}) ${OGRE_Plugin_ParticleFX_LIBRARY_REL})
if (${OGRE_PLUGIN_DIR_REL}})
set(OGRE_PLUGINS_REL_FOUND TRUE)
endif ()
if (${OGRE_PLUGIN_DIR_DBG})
set(OGRE_PLUGINS_DBG_FOUND TRUE)
endif ()
if (${OGRE_PLUGINS_REL_FOUND})
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_REL})
else ()
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_DBG})
endif ()
#set(OGRE_PLUGIN_DIR "${OGRE_PLUGIN_DIR}/")
configure_file(${OpenMW_SOURCE_DIR}/files/mac/Info.plist
"${APP_BUNDLE_DIR}/Contents/Info.plist")
configure_file(${OpenMW_SOURCE_DIR}/files/mac/openmw.icns
"${APP_BUNDLE_DIR}/Contents/Resources/OpenMW.icns" COPYONLY)
endif (APPLE) endif (APPLE)
# Set up Ogre plugin folder & debug suffix # Set up Ogre plugin folder & debug suffix
set(DEBUG_SUFFIX "") # Ogre on OS X doesn't use "_d" suffix (see Ogre's CMakeLists.txt)
if (DEFINED CMAKE_BUILD_TYPE) if (DEFINED CMAKE_BUILD_TYPE AND CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT APPLE)
if (CMAKE_BUILD_TYPE STREQUAL "Debug") add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="_d")
set(DEBUG_SUFFIX "_d") else()
add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="_d") add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="")
else()
add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="")
endif()
endif() endif()
add_definitions(-DOGRE_PLUGIN_DIR_REL="${OGRE_PLUGIN_DIR_REL}") add_definitions(-DOGRE_PLUGIN_DIR_REL="${OGRE_PLUGIN_DIR_REL}")
add_definitions(-DOGRE_PLUGIN_DIR_DBG="${OGRE_PLUGIN_DIR_DBG}") add_definitions(-DOGRE_PLUGIN_DIR_DBG="${OGRE_PLUGIN_DIR_DBG}")
add_definitions(-DOGRE_PLUGIN_DIR="${OGRE_PLUGIN_DIR}") if (APPLE AND OPENMW_OSX_DEPLOYMENT)
add_definitions(-DOGRE_PLUGIN_DIR="${APP_BUNDLE_NAME}/Contents/Plugins")
else()
add_definitions(-DOGRE_PLUGIN_DIR="${OGRE_PLUGIN_DIR}")
endif()
add_subdirectory(files/) add_subdirectory(files/)
@ -278,35 +305,6 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
"${OpenMW_BINARY_DIR}/openmw.desktop") "${OpenMW_BINARY_DIR}/openmw.desktop")
endif() endif()
if (APPLE)
if (${OGRE_PLUGIN_DIR_REL}})
set(OGRE_PLUGINS_REL_FOUND TRUE)
endif ()
if (${OGRE_PLUGIN_DIR_DBG})
set(OGRE_PLUGINS_DBG_FOUND TRUE)
endif ()
if (${OGRE_PLUGINS_REL_FOUND})
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_REL})
else ()
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_DBG})
endif ()
set(OGRE_PLUGIN_DIR "${OGRE_PLUGIN_DIR}/")
set(OGRE_PLUGIN_DIR_2 ${OGRE_PLUGIN_DIR})
set(OGRE_PLUGIN_DIR "")
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_2})
configure_file(${OpenMW_SOURCE_DIR}/files/mac/Info.plist
"${APP_BUNDLE_DIR}/Contents/Info.plist")
configure_file(${OpenMW_SOURCE_DIR}/files/mac/openmw.icns
"${APP_BUNDLE_DIR}/Contents/Resources/OpenMW.icns" COPYONLY)
endif (APPLE)
# Compiler settings # Compiler settings
if (CMAKE_COMPILER_IS_GNUCC) if (CMAKE_COMPILER_IS_GNUCC)
add_definitions (-Wall -Wextra -Wno-unused-parameter -Wno-reorder) add_definitions (-Wall -Wextra -Wno-unused-parameter -Wno-reorder)

@ -6,6 +6,7 @@
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <components/files/configurationmanager.hpp> #include <components/files/configurationmanager.hpp>
#include <components/files/ogreplugin.hpp>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
#include "graphicspage.hpp" #include "graphicspage.hpp"
@ -115,13 +116,12 @@ bool GraphicsPage::setupOgre()
#endif #endif
} }
std::string glPlugin = std::string(pluginDir) + "/RenderSystem_GL" + OGRE_PLUGIN_DEBUG_SUFFIX; boost::filesystem::path absPluginPath = boost::filesystem::absolute(boost::filesystem::path(pluginDir));
if (boost::filesystem::exists(glPlugin + ".so") || boost::filesystem::exists(glPlugin + ".dll"))
mOgre->loadPlugin (glPlugin);
std::string dxPlugin = std::string(pluginDir) + "/RenderSystem_Direct3D9" + OGRE_PLUGIN_DEBUG_SUFFIX; pluginDir = absPluginPath.string();
if (boost::filesystem::exists(dxPlugin + ".so") || boost::filesystem::exists(dxPlugin + ".dll"))
mOgre->loadPlugin (dxPlugin); Files::loadOgrePlugin(pluginDir, "RenderSystem_GL", *mOgre);
Files::loadOgrePlugin(pluginDir, "RenderSystem_Direct3D9", *mOgre);
#ifdef ENABLE_PLUGIN_GL #ifdef ENABLE_PLUGIN_GL
mGLPlugin = new Ogre::GLPlugin(); mGLPlugin = new Ogre::GLPlugin();

@ -39,7 +39,7 @@ add_openmw_dir (mwscript
locals scriptmanager compilercontext interpretercontext cellextensions miscextensions locals scriptmanager compilercontext interpretercontext cellextensions miscextensions
guiextensions soundextensions skyextensions statsextensions containerextensions guiextensions soundextensions skyextensions statsextensions containerextensions
aiextensions controlextensions extensions globalscripts ref dialogueextensions aiextensions controlextensions extensions globalscripts ref dialogueextensions
animationextensions transformationextensions animationextensions transformationextensions consoleextensions userextensions
) )
add_openmw_dir (mwsound add_openmw_dir (mwsound

@ -129,6 +129,7 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
, mCompileAll (false) , mCompileAll (false)
, mScriptContext (0) , mScriptContext (0)
, mFSStrict (false) , mFSStrict (false)
, mScriptConsoleMode (false)
, mCfgMgr(configurationManager) , mCfgMgr(configurationManager)
{ {
std::srand ( std::time(NULL) ); std::srand ( std::time(NULL) );
@ -326,7 +327,8 @@ void OMW::Engine::go()
MWScript::registerExtensions (mExtensions); MWScript::registerExtensions (mExtensions);
mEnvironment.setWindowManager (new MWGui::WindowManager( mEnvironment.setWindowManager (new MWGui::WindowManager(
mExtensions, mFpsLevel, mNewGame, mOgre, mCfgMgr.getLogPath().string() + std::string("/"))); mExtensions, mFpsLevel, mNewGame, mOgre, mCfgMgr.getLogPath().string() + std::string("/"),
mScriptConsoleMode));
// Create sound system // Create sound system
mEnvironment.setSoundManager (new MWSound::SoundManager(mUseSound)); mEnvironment.setSoundManager (new MWSound::SoundManager(mUseSound));
@ -388,6 +390,9 @@ void OMW::Engine::go()
<< std::endl; << std::endl;
} }
if (!mStartupScript.empty())
MWBase::Environment::get().getWindowManager()->executeInConsole (mStartupScript);
// Start the main rendering loop // Start the main rendering loop
mOgre->start(); mOgre->start();
@ -490,3 +495,13 @@ void OMW::Engine::setFallbackValues(std::map<std::string,std::string> fallbackMa
{ {
mFallbackMap = fallbackMap; mFallbackMap = fallbackMap;
} }
void OMW::Engine::setScriptConsoleMode (bool enabled)
{
mScriptConsoleMode = enabled;
}
void OMW::Engine::setStartupScript (const std::string& path)
{
mStartupScript = path;
}

@ -73,6 +73,8 @@ namespace OMW
bool mCompileAll; bool mCompileAll;
std::string mFocusName; std::string mFocusName;
std::map<std::string,std::string> mFallbackMap; std::map<std::string,std::string> mFallbackMap;
bool mScriptConsoleMode;
std::string mStartupScript;
Compiler::Extensions mExtensions; Compiler::Extensions mExtensions;
Compiler::Context *mScriptContext; Compiler::Context *mScriptContext;
@ -158,6 +160,12 @@ namespace OMW
void setFallbackValues(std::map<std::string,std::string> map); void setFallbackValues(std::map<std::string,std::string> map);
/// Enable console-only script functionality
void setScriptConsoleMode (bool enabled);
/// Set path for a script that is run on startup in the console.
void setStartupScript (const std::string& path);
private: private:
Files::ConfigurationManager& mCfgMgr; Files::ConfigurationManager& mCfgMgr;
}; };

@ -124,12 +124,20 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
("script-verbose", bpo::value<bool>()->implicit_value(true) ("script-verbose", bpo::value<bool>()->implicit_value(true)
->default_value(false), "verbose script output") ->default_value(false), "verbose script output")
("new-game", bpo::value<bool>()->implicit_value(true)
->default_value(false), "activate char gen/new game mechanics")
("script-all", bpo::value<bool>()->implicit_value(true) ("script-all", bpo::value<bool>()->implicit_value(true)
->default_value(false), "compile all scripts (excluding dialogue scripts) at startup") ->default_value(false), "compile all scripts (excluding dialogue scripts) at startup")
("script-console", bpo::value<bool>()->implicit_value(true)
->default_value(false), "enable console-only script functionality")
("script-run", bpo::value<std::string>()->default_value(""),
"select a file that is executed in the console on startup\n\n"
"Note: The file contains a list of script lines, but not a complete scripts. "
"That means no begin/end and no variable declarations.")
("new-game", bpo::value<bool>()->implicit_value(true)
->default_value(false), "activate char gen/new game mechanics")
("fs-strict", bpo::value<bool>()->implicit_value(true) ("fs-strict", bpo::value<bool>()->implicit_value(true)
->default_value(false), "strict file system handling (no case folding)") ->default_value(false), "strict file system handling (no case folding)")
@ -249,6 +257,8 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
engine.setCompileAll(variables["script-all"].as<bool>()); engine.setCompileAll(variables["script-all"].as<bool>());
engine.setAnimationVerbose(variables["anim-verbose"].as<bool>()); engine.setAnimationVerbose(variables["anim-verbose"].as<bool>());
engine.setFallbackValues(variables["fallback"].as<FallbackMap>().mMap); engine.setFallbackValues(variables["fallback"].as<FallbackMap>().mMap);
engine.setScriptConsoleMode (variables["script-console"].as<bool>());
engine.setStartupScript (variables["script-run"].as<std::string>());
return true; return true;
} }

@ -2,6 +2,7 @@
#include "console.hpp" #include "console.hpp"
#include <algorithm> #include <algorithm>
#include <fstream>
#include <components/esm_store/reclists.hpp> #include <components/esm_store/reclists.hpp>
#include <components/esm_store/store.hpp> #include <components/esm_store/store.hpp>
@ -105,9 +106,10 @@ namespace MWGui
} }
} }
Console::Console(int w, int h, const Compiler::Extensions& extensions) Console::Console(int w, int h, bool consoleOnlyScripts)
: Layout("openmw_console.layout"), : Layout("openmw_console.layout"),
mCompilerContext (MWScript::CompilerContext::Type_Console) mCompilerContext (MWScript::CompilerContext::Type_Console),
mConsoleOnlyScripts (consoleOnlyScripts)
{ {
setCoord(10,10, w-10, h/2); setCoord(10,10, w-10, h/2);
@ -126,7 +128,8 @@ namespace MWGui
history->setVisibleVScroll(true); history->setVisibleVScroll(true);
// compiler // compiler
mCompilerContext.setExtensions (&extensions); MWScript::registerExtensions (mExtensions, mConsoleOnlyScripts);
mCompilerContext.setExtensions (&mExtensions);
} }
void Console::enable() void Console::enable()
@ -173,6 +176,47 @@ namespace MWGui
print("#FF2222" + msg + "\n"); print("#FF2222" + msg + "\n");
} }
void Console::execute (const std::string& command)
{
// Log the command
print("#FFFFFF> " + command + "\n");
Compiler::Locals locals;
Compiler::Output output (locals);
if (compile (command + "\n", output))
{
try
{
ConsoleInterpreterContext interpreterContext (*this, mPtr);
Interpreter::Interpreter interpreter;
MWScript::installOpcodes (interpreter, mConsoleOnlyScripts);
std::vector<Interpreter::Type_Code> code;
output.getCode (code);
interpreter.run (&code[0], code.size(), interpreterContext);
}
catch (const std::exception& error)
{
printError (std::string ("An exception has been thrown: ") + error.what());
}
}
}
void Console::executeFile (const std::string& path)
{
std::ifstream stream (path.c_str());
if (!stream.is_open())
printError ("failed to open file: " + path);
else
{
std::string line;
while (std::getline (stream, line))
execute (line);
}
}
void Console::keyPress(MyGUI::WidgetPtr _sender, void Console::keyPress(MyGUI::WidgetPtr _sender,
MyGUI::KeyCode key, MyGUI::KeyCode key,
MyGUI::Char _char) MyGUI::Char _char)
@ -234,28 +278,7 @@ namespace MWGui
current = command_history.end(); current = command_history.end();
editString.clear(); editString.clear();
// Log the command execute (cm);
print("#FFFFFF> " + cm + "\n");
Compiler::Locals locals;
Compiler::Output output (locals);
if (compile (cm + "\n", output))
{
try
{
ConsoleInterpreterContext interpreterContext (*this, mPtr);
Interpreter::Interpreter interpreter;
MWScript::installOpcodes (interpreter);
std::vector<Interpreter::Type_Code> code;
output.getCode (code);
interpreter.run (&code[0], code.size(), interpreterContext);
}
catch (const std::exception& error)
{
printError (std::string ("An exception has been thrown: ") + error.what());
}
}
command->setCaption(""); command->setCaption("");
} }

@ -11,6 +11,7 @@
#include <components/compiler/scanner.hpp> #include <components/compiler/scanner.hpp>
#include <components/compiler/locals.hpp> #include <components/compiler/locals.hpp>
#include <components/compiler/output.hpp> #include <components/compiler/output.hpp>
#include <components/compiler/extensions.hpp>
#include <components/interpreter/interpreter.hpp> #include <components/interpreter/interpreter.hpp>
#include "../mwscript/compilercontext.hpp" #include "../mwscript/compilercontext.hpp"
@ -24,8 +25,10 @@ namespace MWGui
{ {
private: private:
Compiler::Extensions mExtensions;
MWScript::CompilerContext mCompilerContext; MWScript::CompilerContext mCompilerContext;
std::vector<std::string> mNames; std::vector<std::string> mNames;
bool mConsoleOnlyScripts;
bool compile (const std::string& cmd, Compiler::Output& output); bool compile (const std::string& cmd, Compiler::Output& output);
@ -62,7 +65,7 @@ namespace MWGui
StringList::iterator current; StringList::iterator current;
std::string editString; std::string editString;
Console(int w, int h, const Compiler::Extensions& extensions); Console(int w, int h, bool consoleOnlyScripts);
void enable(); void enable();
@ -86,6 +89,10 @@ namespace MWGui
/// Error message /// Error message
void printError(const std::string &msg); void printError(const std::string &msg);
void execute (const std::string& command);
void executeFile (const std::string& command);
private: private:
void keyPress(MyGUI::WidgetPtr _sender, void keyPress(MyGUI::WidgetPtr _sender,

@ -75,9 +75,9 @@ namespace
return boost::lexical_cast<std::string>(xaspect) + " : " + boost::lexical_cast<std::string>(yaspect); return boost::lexical_cast<std::string>(xaspect) + " : " + boost::lexical_cast<std::string>(yaspect);
} }
bool hasGLSL () std::string hlslGlsl ()
{ {
return (Ogre::Root::getSingleton ().getRenderSystem ()->getName ().find("OpenGL") != std::string::npos); return (Ogre::Root::getSingleton ().getRenderSystem ()->getName ().find("OpenGL") != std::string::npos) ? "glsl" : "hlsl";
} }
} }
@ -393,12 +393,9 @@ namespace MWGui
std::string val = static_cast<MyGUI::Button*>(_sender)->getCaption(); std::string val = static_cast<MyGUI::Button*>(_sender)->getCaption();
if (val == "off") if (val == "off")
{ {
if (hasGLSL ()) val = hlslGlsl();
val = "glsl";
else
val = "cg";
} }
else if (val == "glsl") else if (val == hlslGlsl())
val = "cg"; val = "cg";
else else
val = "off"; val = "off";
@ -411,6 +408,7 @@ namespace MWGui
// water shader not supported with object shaders off // water shader not supported with object shaders off
mWaterShaderButton->setCaptionWithReplacing("#{sOff}"); mWaterShaderButton->setCaptionWithReplacing("#{sOff}");
mUnderwaterButton->setCaptionWithReplacing("#{sOff}");
mWaterShaderButton->setEnabled(false); mWaterShaderButton->setEnabled(false);
mReflectObjectsButton->setEnabled(false); mReflectObjectsButton->setEnabled(false);
mReflectActorsButton->setEnabled(false); mReflectActorsButton->setEnabled(false);

@ -41,7 +41,7 @@
using namespace MWGui; using namespace MWGui;
WindowManager::WindowManager( WindowManager::WindowManager(
const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const std::string& logpath) const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const std::string& logpath, bool consoleOnlyScripts)
: mGuiManager(NULL) : mGuiManager(NULL)
, mHud(NULL) , mHud(NULL)
, mMap(NULL) , mMap(NULL)
@ -113,7 +113,7 @@ WindowManager::WindowManager(
mMenu = new MainMenu(w,h); mMenu = new MainMenu(w,h);
mMap = new MapWindow(*this); mMap = new MapWindow(*this);
mStatsWindow = new StatsWindow(*this); mStatsWindow = new StatsWindow(*this);
mConsole = new Console(w,h, extensions); mConsole = new Console(w,h, consoleOnlyScripts);
mJournal = new JournalWindow(*this); mJournal = new JournalWindow(*this);
mMessageBoxManager = new MessageBoxManager(this); mMessageBoxManager = new MessageBoxManager(this);
mInventoryWindow = new InventoryWindow(*this,mDragAndDrop); mInventoryWindow = new InventoryWindow(*this,mDragAndDrop);
@ -740,3 +740,8 @@ bool WindowManager::getWorldMouseOver()
{ {
return mHud->getWorldMouseOver(); return mHud->getWorldMouseOver();
} }
void WindowManager::executeInConsole (const std::string& path)
{
mConsole->executeFile (path);
}

@ -94,7 +94,7 @@ namespace MWGui
typedef std::vector<Faction> FactionList; typedef std::vector<Faction> FactionList;
typedef std::vector<int> SkillList; typedef std::vector<int> SkillList;
WindowManager(const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const std::string& logpath); WindowManager(const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const std::string& logpath, bool consoleOnlyScripts);
virtual ~WindowManager(); virtual ~WindowManager();
/** /**
@ -237,6 +237,8 @@ namespace MWGui
void processChangedSettings(const Settings::CategorySettingVector& changed); void processChangedSettings(const Settings::CategorySettingVector& changed);
void executeInConsole (const std::string& path);
private: private:
OEngine::GUI::MyGUIManager *mGuiManager; OEngine::GUI::MyGUIManager *mGuiManager;
HUD *mHud; HUD *mHud;

@ -43,12 +43,14 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
:mRendering(_rend), mObjects(mRendering), mActors(mRendering), mAmbientMode(0), mSunEnabled(0) :mRendering(_rend), mObjects(mRendering), mActors(mRendering), mAmbientMode(0), mSunEnabled(0)
{ {
// select best shader mode // select best shader mode
if (Settings::Manager::getString("shader mode", "General") == "") bool openGL = (Ogre::Root::getSingleton ().getRenderSystem ()->getName().find("OpenGL") != std::string::npos);
// glsl is only supported in opengl mode and hlsl only in direct3d mode.
if (Settings::Manager::getString("shader mode", "General") == ""
|| (openGL && Settings::Manager::getString("shader mode", "General") == "hlsl")
|| (!openGL && Settings::Manager::getString("shader mode", "General") == "glsl"))
{ {
if (Ogre::Root::getSingleton ().getRenderSystem ()->getName().find("OpenGL") == std::string::npos) Settings::Manager::setString("shader mode", "General", openGL ? "glsl" : "hlsl");
Settings::Manager::setString("shader mode", "General", "cg");
else
Settings::Manager::setString("shader mode", "General", "glsl");
} }
mRendering.createScene("PlayerCam", Settings::Manager::getFloat("field of view", "General"), 5); mRendering.createScene("PlayerCam", Settings::Manager::getFloat("field of view", "General"), 5);
@ -74,10 +76,6 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
mFactory->setCurrentLanguage (lang); mFactory->setCurrentLanguage (lang);
mFactory->loadAllFiles(); mFactory->loadAllFiles();
//The fog type must be set before any terrain objects are created as if the
//fog type is set to FOG_NONE then the initially created terrain won't have any fog
configureFog(1, ColourValue(1,1,1));
// Set default mipmap level (NB some APIs ignore this) // Set default mipmap level (NB some APIs ignore this)
TextureManager::getSingleton().setDefaultNumMipmaps(Settings::Manager::getInt("num mipmaps", "General")); TextureManager::getSingleton().setDefaultNumMipmaps(Settings::Manager::getInt("num mipmaps", "General"));

@ -0,0 +1,24 @@
#include "consoleextensions.hpp"
#include <components/compiler/extensions.hpp>
#include <components/interpreter/interpreter.hpp>
#include <components/interpreter/runtime.hpp>
#include <components/interpreter/opcodes.hpp>
namespace MWScript
{
namespace Console
{
void registerExtensions (Compiler::Extensions& extensions)
{
}
void installOpcodes (Interpreter::Interpreter& interpreter)
{
}
}
}

@ -0,0 +1,25 @@
#ifndef GAME_SCRIPT_CONSOLEEXTENSIONS_H
#define GAME_SCRIPT_CONSOLEEXTENSIONS_H
namespace Compiler
{
class Extensions;
}
namespace Interpreter
{
class Interpreter;
}
namespace MWScript
{
/// \brief Script functionality limited to the console
namespace Console
{
void registerExtensions (Compiler::Extensions& extensions);
void installOpcodes (Interpreter::Interpreter& interpreter);
}
}
#endif

@ -173,7 +173,12 @@ op 0x2000168: GetScale
op 0x2000169: GetScale, explicit reference op 0x2000169: GetScale, explicit reference
op 0x200016a: GetAngle op 0x200016a: GetAngle
op 0x200016b: GetAngle, explicit reference op 0x200016b: GetAngle, explicit reference
op 0x200016c: GetStartingAngle op 0x200016c: user1 (console only, requires --script-console switch)
op 0x200016d: GetStartingAngle, explicit reference op 0x200016d: user2 (console only, requires --script-console switch)
opcodes 0x200016e-0x3ffffff unused op 0x200016e: user3, explicit reference (console only, requires --script-console switch)
op 0x200016f: user3 (implicit reference, console only, requires --script-console switch)
op 0x2000170: user4, explicit reference (console only, requires --script-console switch)
op 0x2000171: user4 (implicit reference, console only, requires --script-console switch)
op 0x2000172: GetStartingAngle
op 0x2000173: GetStartingAngle, explicit reference
opcodes 0x2000174-0x3ffffff unused

@ -16,10 +16,12 @@
#include "dialogueextensions.hpp" #include "dialogueextensions.hpp"
#include "animationextensions.hpp" #include "animationextensions.hpp"
#include "transformationextensions.hpp" #include "transformationextensions.hpp"
#include "consoleextensions.hpp"
#include "userextensions.hpp"
namespace MWScript namespace MWScript
{ {
void registerExtensions (Compiler::Extensions& extensions) void registerExtensions (Compiler::Extensions& extensions, bool consoleOnly)
{ {
Cell::registerExtensions (extensions); Cell::registerExtensions (extensions);
Misc::registerExtensions (extensions); Misc::registerExtensions (extensions);
@ -33,9 +35,15 @@ namespace MWScript
Dialogue::registerExtensions (extensions); Dialogue::registerExtensions (extensions);
Animation::registerExtensions (extensions); Animation::registerExtensions (extensions);
Transformation::registerExtensions (extensions); Transformation::registerExtensions (extensions);
if (consoleOnly)
{
Console::registerExtensions (extensions);
User::registerExtensions (extensions);
}
} }
void installOpcodes (Interpreter::Interpreter& interpreter) void installOpcodes (Interpreter::Interpreter& interpreter, bool consoleOnly)
{ {
Interpreter::installOpcodes (interpreter); Interpreter::installOpcodes (interpreter);
Cell::installOpcodes (interpreter); Cell::installOpcodes (interpreter);
@ -50,5 +58,11 @@ namespace MWScript
Dialogue::installOpcodes (interpreter); Dialogue::installOpcodes (interpreter);
Animation::installOpcodes (interpreter); Animation::installOpcodes (interpreter);
Transformation::installOpcodes (interpreter); Transformation::installOpcodes (interpreter);
if (consoleOnly)
{
Console::installOpcodes (interpreter);
User::installOpcodes (interpreter);
}
} }
} }

@ -13,9 +13,11 @@ namespace Interpreter
namespace MWScript namespace MWScript
{ {
void registerExtensions (Compiler::Extensions& extensions); void registerExtensions (Compiler::Extensions& extensions, bool consoleOnly = false);
///< \param consoleOnly include console only extensions
void installOpcodes (Interpreter::Interpreter& interpreter);
void installOpcodes (Interpreter::Interpreter& interpreter, bool consoleOnly = false);
///< \param consoleOnly include console only opcodes
} }
#endif #endif

@ -119,7 +119,7 @@ namespace MWScript
std::string axis = runtime.getStringLiteral (runtime[0].mInteger); std::string axis = runtime.getStringLiteral (runtime[0].mInteger);
runtime.pop(); runtime.pop();
if(axis == "X") if(axis == "X")
{ {
runtime.push(Ogre::Radian(ptr.getCellRef().pos.rot[0]).valueDegrees()); runtime.push(Ogre::Radian(ptr.getCellRef().pos.rot[0]).valueDegrees());
@ -143,8 +143,8 @@ namespace MWScript
const int opcodeGetScaleExplicit = 0x2000169; const int opcodeGetScaleExplicit = 0x2000169;
const int opcodeGetAngle = 0x200016a; const int opcodeGetAngle = 0x200016a;
const int opcodeGetAngleExplicit = 0x200016b; const int opcodeGetAngleExplicit = 0x200016b;
const int opcodeGetStartingAngle = 0x200016c; const int opcodeGetStartingAngle = 0x2000172;
const int opcodeGetStartingAngleExplicit = 0x200016d; const int opcodeGetStartingAngleExplicit = 0x2000173;
void registerExtensions (Compiler::Extensions& extensions) void registerExtensions (Compiler::Extensions& extensions)
{ {

@ -0,0 +1,91 @@
#include "userextensions.hpp"
#include <components/compiler/extensions.hpp>
#include <components/interpreter/interpreter.hpp>
#include <components/interpreter/runtime.hpp>
#include <components/interpreter/opcodes.hpp>
#include <components/interpreter/context.hpp>
#include "ref.hpp"
namespace MWScript
{
/// Temporary script extensions.
///
/// \attention Do not commit changes to this file to a git repository!
namespace User
{
class OpUser1 : public Interpreter::Opcode0
{
public:
virtual void execute (Interpreter::Runtime& runtime)
{
runtime.getContext().report ("user1: not in use");
}
};
class OpUser2 : public Interpreter::Opcode0
{
public:
virtual void execute (Interpreter::Runtime& runtime)
{
runtime.getContext().report ("user2: not in use");
}
};
template<class R>
class OpUser3 : public Interpreter::Opcode0
{
public:
virtual void execute (Interpreter::Runtime& runtime)
{
// MWWorld::Ptr ptr = R()(runtime);
runtime.getContext().report ("user3: not in use");
}
};
template<class R>
class OpUser4 : public Interpreter::Opcode0
{
public:
virtual void execute (Interpreter::Runtime& runtime)
{
// MWWorld::Ptr ptr = R()(runtime);
runtime.getContext().report ("user4: not in use");
}
};
const int opcodeUser1 = 0x200016c;
const int opcodeUser2 = 0x200016d;
const int opcodeUser3 = 0x200016e;
const int opcodeUser3Explicit = 0x200016f;
const int opcodeUser4 = 0x2000170;
const int opcodeUser4Explicit = 0x2000171;
void registerExtensions (Compiler::Extensions& extensions)
{
extensions.registerInstruction ("user1", "", opcodeUser1);
extensions.registerInstruction ("user2", "", opcodeUser2);
extensions.registerInstruction ("user3", "", opcodeUser3, opcodeUser3);
extensions.registerInstruction ("user4", "", opcodeUser4, opcodeUser4);
}
void installOpcodes (Interpreter::Interpreter& interpreter)
{
interpreter.installSegment5 (opcodeUser1, new OpUser1);
interpreter.installSegment5 (opcodeUser2, new OpUser2);
interpreter.installSegment5 (opcodeUser3, new OpUser3<ImplicitRef>);
interpreter.installSegment5 (opcodeUser3Explicit, new OpUser3<ExplicitRef>);
interpreter.installSegment5 (opcodeUser4, new OpUser4<ImplicitRef>);
interpreter.installSegment5 (opcodeUser4Explicit, new OpUser4<ExplicitRef>);
}
}
}

@ -0,0 +1,25 @@
#ifndef GAME_SCRIPT_USEREXTENSIONS_H
#define GAME_SCRIPT_USEREXTENSIONS_H
namespace Compiler
{
class Extensions;
}
namespace Interpreter
{
class Interpreter;
}
namespace MWScript
{
/// \brief Temporaty script functionality limited to the console
namespace User
{
void registerExtensions (Compiler::Extensions& extensions);
void installOpcodes (Interpreter::Interpreter& interpreter);
}
}
#endif

@ -128,9 +128,11 @@ ELSE (WIN32) #Unix
ENDIF (WIN32) ENDIF (WIN32)
#Do some preparation #Do some preparation
SEPARATE_ARGUMENTS(MYGUI_INCLUDE_DIRS) IF (NOT WIN32) # This does not work on Windows for paths with spaces in them
SEPARATE_ARGUMENTS(MYGUI_LIBRARIES) SEPARATE_ARGUMENTS(MYGUI_INCLUDE_DIRS)
SEPARATE_ARGUMENTS(MYGUI_PLATFORM_LIBRARIES) SEPARATE_ARGUMENTS(MYGUI_LIBRARIES)
SEPARATE_ARGUMENTS(MYGUI_PLATFORM_LIBRARIES)
ENDIF (NOT WIN32)
SET(MYGUI_LIBRARIES ${MYGUI_LIBRARIES} ${FREETYPE_LIBRARIES}) SET(MYGUI_LIBRARIES ${MYGUI_LIBRARIES} ${FREETYPE_LIBRARIES})

@ -52,7 +52,7 @@ add_component_dir (misc
add_component_dir (files add_component_dir (files
linuxpath windowspath macospath fixedpath multidircollection collections fileops configurationmanager linuxpath windowspath macospath fixedpath multidircollection collections fileops configurationmanager
filelibrary filelibrary ogreplugin
) )
add_component_dir (compiler add_component_dir (compiler

@ -200,7 +200,7 @@ void BSAFile::readHeader()
input.read(&stringBuf[0], stringBuf.size()); input.read(&stringBuf[0], stringBuf.size());
// Check our position // Check our position
assert(input.tellg() == static_cast<int> (12+dirsize)); assert(input.tellg() == std::streampos(12+dirsize));
// Calculate the offset of the data buffer. All file offsets are // Calculate the offset of the data buffer. All file offsets are
// relative to this. 12 header bytes + directory + hash table // relative to this. 12 header bytes + directory + hash table

@ -0,0 +1,37 @@
#include "ogreplugin.hpp"
#include <OgrePrerequisites.h>
#include <OgreRoot.h>
namespace Files {
bool loadOgrePlugin(const std::string &pluginDir, std::string pluginName, Ogre::Root &ogreRoot) {
pluginName = pluginName + OGRE_PLUGIN_DEBUG_SUFFIX;
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
std::ostringstream verStream;
verStream << "." << OGRE_VERSION_MAJOR << "." << OGRE_VERSION_MINOR << "." << OGRE_VERSION_PATCH;
pluginName = pluginName + verStream.str();
#endif
std::string pluginExt;
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
pluginExt = ".dll";
#endif
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
pluginExt = ".dylib";
#endif
#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
pluginExt = ".so";
#endif
std::string pluginPath = pluginDir + "/" + pluginName + pluginExt;
if (boost::filesystem::exists(pluginPath)) {
ogreRoot.loadPlugin(pluginPath);
return true;
}
else {
return false;
}
}
}

@ -0,0 +1,64 @@
/**
* Open Morrowind - an opensource Elder Scrolls III: Morrowind
* engine implementation.
*
* Copyright (C) 2011 Open Morrowind Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file components/files/ogreplugin.hpp */
#ifndef COMPONENTS_FILES_OGREPLUGIN_H
#define COMPONENTS_FILES_OGREPLUGIN_H
#include <string>
#include <boost/filesystem.hpp>
#include <boost/version.hpp>
namespace Ogre {
class Root;
}
#if (BOOST_VERSION <= 104300)
namespace boost {
namespace filesystem {
inline path absolute(const path& p, const path& base=current_path()) {
// call obsolete version of this function on older boost
return complete(p, base);
}
}
}
#endif /* (BOOST_VERSION <= 104300) */
/**
* \namespace Files
*/
namespace Files {
/**
* \brief Loads Ogre plugin with given name.
*
* \param pluginDir absolute path to plugins
* \param pluginName plugin name, for example "RenderSystem_GL"
* \param ogreRoot Ogre::Root instance
*
* \return whether plugin was located or not
*/
bool loadOgrePlugin(const std::string &pluginDir, std::string pluginName, Ogre::Root &ogreRoot);
}
#endif /* COMPONENTS_FILES_OGREPLUGIN_H */

@ -1,20 +1,20 @@
#if SH_HLSL == 1 #if SH_HLSL == 1 || SH_CG == 1
#error "HLSL is unsupported"
#endif
#if SH_CG == 1
#define shTexture2D sampler2D #define shTexture2D sampler2D
#define shSample(tex, coord) tex2D(tex, coord) #define shSample(tex, coord) tex2D(tex, coord)
#define shCubicSample(tex, coord) texCUBE(tex, coord)
#define shLerp(a, b, t) lerp(a, b, t) #define shLerp(a, b, t) lerp(a, b, t)
#define shSaturate(a) saturate(a) #define shSaturate(a) saturate(a)
#define shSampler2D(name) , uniform sampler2D name : register(s@shCounter(0)) @shUseSampler(name) #define shSampler2D(name) , uniform sampler2D name : register(s@shCounter(0)) @shUseSampler(name)
#define shSamplerCube(name) , uniform samplerCUBE name : register(s@shCounter(0)) @shUseSampler(name)
#define shMatrixMult(m, v) mul(m, v) #define shMatrixMult(m, v) mul(m, v)
#define shUniform(type, name) , uniform type name #define shUniform(type, name) , uniform type name
#define shTangentInput(type) , in type tangent : TANGENT
#define shVertexInput(type, name) , in type name : TEXCOORD@shCounter(1) #define shVertexInput(type, name) , in type name : TEXCOORD@shCounter(1)
#define shInput(type, name) , in type name : TEXCOORD@shCounter(1) #define shInput(type, name) , in type name : TEXCOORD@shCounter(1)
#define shOutput(type, name) , out type name : TEXCOORD@shCounter(2) #define shOutput(type, name) , out type name : TEXCOORD@shCounter(2)
@ -65,9 +65,10 @@
#define float4 vec4 #define float4 vec4
#define int2 ivec2 #define int2 ivec2
#define int3 ivec3 #define int3 ivec3
#define int4 ivec4/ #define int4 ivec4
#define shTexture2D sampler2D #define shTexture2D sampler2D
#define shSample(tex, coord) texture2D(tex, coord) #define shSample(tex, coord) texture2D(tex, coord)
#define shCubicSample(tex, coord) textureCube(tex, coord)
#define shLerp(a, b, t) mix(a, b, t) #define shLerp(a, b, t) mix(a, b, t)
#define shSaturate(a) clamp(a, 0.0, 1.0) #define shSaturate(a) clamp(a, 0.0, 1.0)
@ -75,11 +76,14 @@
#define shSampler2D(name) uniform sampler2D name; @shUseSampler(name) #define shSampler2D(name) uniform sampler2D name; @shUseSampler(name)
#define shSamplerCube(name) uniform samplerCube name; @shUseSampler(name)
#define shMatrixMult(m, v) (m * v) #define shMatrixMult(m, v) (m * v)
#define shOutputPosition gl_Position #define shOutputPosition gl_Position
#define float4x4 mat4 #define float4x4 mat4
#define float3x3 mat3
// GLSL 1.3 // GLSL 1.3
#if 0 #if 0
@ -89,8 +93,8 @@
#define shOutputColour(num) oColor##num #define shOutputColour(num) oColor##num
#define shTangentInput(type) in type tangent;
#define shVertexInput(type, name) in type name;
#define shInput(type, name) in type name; #define shInput(type, name) in type name;
#define shOutput(type, name) out type name; #define shOutput(type, name) out type name;
@ -101,7 +105,7 @@
#ifdef SH_VERTEX_SHADER #ifdef SH_VERTEX_SHADER
#define SH_BEGIN_PROGRAM \ #define SH_BEGIN_PROGRAM \
in float4 shInputPosition; in float4 vertex;
#define SH_START_PROGRAM \ #define SH_START_PROGRAM \
void main(void) void main(void)
@ -126,10 +130,11 @@
#if 1 #if 1
// automatically recognized by ogre when the input name equals this // automatically recognized by ogre when the input name equals this
#define shInputPosition gl_Vertex #define shInputPosition vertex
#define shOutputColour(num) gl_FragData[num] #define shOutputColour(num) gl_FragData[num]
#define shTangentInput(type) attribute type tangent;
#define shVertexInput(type, name) attribute type name; #define shVertexInput(type, name) attribute type name;
#define shInput(type, name) varying type name; #define shInput(type, name) varying type name;
#define shOutput(type, name) varying type name; #define shOutput(type, name) varying type name;
@ -140,8 +145,8 @@
#ifdef SH_VERTEX_SHADER #ifdef SH_VERTEX_SHADER
#define SH_BEGIN_PROGRAM #define SH_BEGIN_PROGRAM \
attribute vec4 vertex;
#define SH_START_PROGRAM \ #define SH_START_PROGRAM \
void main(void) void main(void)

@ -3,7 +3,7 @@ shader_set openmw_objects_vertex
source objects.shader source objects.shader
type vertex type vertex
profiles_cg vs_2_0 vp40 arbvp1 profiles_cg vs_2_0 vp40 arbvp1
profiles_hlsl vs_2_0 profiles_hlsl vs_3_0 vs_2_0
} }
shader_set openmw_objects_fragment shader_set openmw_objects_fragment
@ -11,5 +11,5 @@ shader_set openmw_objects_fragment
source objects.shader source objects.shader
type fragment type fragment
profiles_cg ps_3_0 ps_2_x ps_2_0 fp40 arbfp1 profiles_cg ps_3_0 ps_2_x ps_2_0 fp40 arbfp1
profiles_hlsl ps_2_0 profiles_hlsl ps_3_0 ps_2_0
} }

@ -3,7 +3,7 @@ shader_set terrain_vertex
source terrain.shader source terrain.shader
type vertex type vertex
profiles_cg vs_2_0 vp40 arbvp1 profiles_cg vs_2_0 vp40 arbvp1
profiles_hlsl vs_2_0 profiles_hlsl vs_3_0 vs_2_0
} }
shader_set terrain_fragment shader_set terrain_fragment
@ -11,5 +11,5 @@ shader_set terrain_fragment
source terrain.shader source terrain.shader
type fragment type fragment
profiles_cg ps_3_0 ps_2_x ps_2_0 fp40 arbfp1 profiles_cg ps_3_0 ps_2_x ps_2_0 fp40 arbfp1
profiles_hlsl ps_2_0 profiles_hlsl ps_3_0 ps_2_0
} }

@ -28,7 +28,7 @@ float3 intercept(float3 lineP,
float3 perturb1(shTexture2D tex, float2 coords, float bend, float2 windDir, float windSpeed, float timer) float3 perturb1(shTexture2D tex, float2 coords, float bend, float2 windDir, float windSpeed, float timer)
{ {
float2 nCoord = float2(0.0); float2 nCoord = float2(0,0);
bend *= WAVE_CHOPPYNESS; bend *= WAVE_CHOPPYNESS;
nCoord = coords * (WAVE_SCALE * 0.05) + windDir * timer * (windSpeed*0.04); nCoord = coords * (WAVE_SCALE * 0.05) + windDir * timer * (windSpeed*0.04);
float3 normal0 = 2.0 * shSample(tex, nCoord + float2(-timer*0.015,-timer*0.05)).rgb - 1.0; float3 normal0 = 2.0 * shSample(tex, nCoord + float2(-timer*0.015,-timer*0.05)).rgb - 1.0;
@ -55,8 +55,8 @@ float3 perturb1(shTexture2D tex, float2 coords, float bend, float2 windDir, floa
float3 perturb(shTexture2D tex, float2 coords, float bend, float2 windDir, float windSpeed, float timer) float3 perturb(shTexture2D tex, float2 coords, float bend, float2 windDir, float windSpeed, float timer)
{ {
bend *= WAVE_CHOPPYNESS; bend *= WAVE_CHOPPYNESS;
float3 col = float3(0.0); float3 col = float3(0,0,0);
float2 nCoord = float2(0.0); //normal coords float2 nCoord = float2(0,0); //normal coords
nCoord = coords * (WAVE_SCALE * 0.025) + windDir * timer * (windSpeed*0.03); nCoord = coords * (WAVE_SCALE * 0.025) + windDir * timer * (windSpeed*0.03);
col += shSample(tex,nCoord + float2(-timer*0.005,-timer*0.01)).rgb*0.20; col += shSample(tex,nCoord + float2(-timer*0.005,-timer*0.01)).rgb*0.20;
@ -102,11 +102,11 @@ float3 getCaustics (shTexture2D causticMap, float3 worldPos, float3 waterEyePos,
/// \todo sunFade /// \todo sunFade
// float3 caustics = clamp(pow(float3(causticR)*5.5,float3(5.5*causticdepth)),0.0,1.0)*NdotL*sunFade*causticdepth; // float3 caustics = clamp(pow(float3(causticR)*5.5,float3(5.5*causticdepth)),0.0,1.0)*NdotL*sunFade*causticdepth;
float3 caustics = clamp(pow(float3(causticR)*5.5,float3(5.5*causticdepth)),0.0,1.0)*NdotL*causticdepth; float3 caustics = clamp(pow(float3(causticR,causticR,causticR)*5.5,float3(5.5*causticdepth,5.5*causticdepth,5.5*causticdepth)),0.0,1.0)*NdotL*causticdepth;
float causticG = 1.0-perturb(causticMap,causticPos.xz+(1.0-causticdepth)*ABBERATION, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).z; float causticG = 1.0-perturb(causticMap,causticPos.xz+(1.0-causticdepth)*ABBERATION, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).z;
float causticB = 1.0-perturb(causticMap,causticPos.xz+(1.0-causticdepth)*ABBERATION*2.0, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).z; float causticB = 1.0-perturb(causticMap,causticPos.xz+(1.0-causticdepth)*ABBERATION*2.0, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).z;
//caustics = shSaturate(pow(float3(causticR,causticG,causticB)*5.5,float3(5.5*causticdepth)))*NdotL*sunFade*causticdepth; //caustics = shSaturate(pow(float3(causticR,causticG,causticB)*5.5,float3(5.5*causticdepth)))*NdotL*sunFade*causticdepth;
caustics = shSaturate(pow(float3(causticR,causticG,causticB)*5.5,float3(5.5*causticdepth)))*NdotL*causticdepth; caustics = shSaturate(pow(float3(causticR,causticG,causticB)*5.5,float3(5.5*causticdepth,5.5*causticdepth,5.5*causticdepth)))*NdotL*causticdepth;
caustics *= 3; caustics *= 3;

@ -198,7 +198,7 @@
float depth = shSample(depthMap, screenCoords).x * far - depthPassthrough; float depth = shSample(depthMap, screenCoords).x * far - depthPassthrough;
float shoreFade = shSaturate(depth / 50.0); float shoreFade = shSaturate(depth / 50.0);
float2 nCoord = float2(0.0); float2 nCoord = float2(0,0);
nCoord = UV * (WAVE_SCALE * 0.05) + WIND_DIR * waterTimer * (WIND_SPEED*0.04); nCoord = UV * (WAVE_SCALE * 0.05) + WIND_DIR * waterTimer * (WIND_SPEED*0.04);
float3 normal0 = 2.0 * shSample(normalMap, nCoord + float2(-waterTimer*0.015,-waterTimer*0.005)).rgb - 1.0; float3 normal0 = 2.0 * shSample(normalMap, nCoord + float2(-waterTimer*0.015,-waterTimer*0.005)).rgb - 1.0;
@ -238,12 +238,12 @@
// sunlight scattering // sunlight scattering
float3 pNormal = float3(0,1,0); float3 pNormal = float3(0,1,0);
vec3 lR = reflect(lVec, lNormal); float3 lR = reflect(lVec, lNormal);
vec3 llR = reflect(lVec, pNormal); float3 llR = reflect(lVec, pNormal);
float s = shSaturate(dot(lR, vVec)*2.0-1.2); float s = shSaturate(dot(lR, vVec)*2.0-1.2);
float lightScatter = shSaturate(dot(-lVec,lNormal)*0.7+0.3) * s * SCATTER_AMOUNT * waterSunFade_sunHeight.x * shSaturate(1.0-exp(-waterSunFade_sunHeight.y)); float lightScatter = shSaturate(dot(-lVec,lNormal)*0.7+0.3) * s * SCATTER_AMOUNT * waterSunFade_sunHeight.x * shSaturate(1.0-exp(-waterSunFade_sunHeight.y));
float3 scatterColour = shLerp(vec3(SCATTER_COLOUR)*vec3(1.0,0.4,0.0), SCATTER_COLOUR, shSaturate(1.0-exp(-waterSunFade_sunHeight.y*SUN_EXT))); float3 scatterColour = shLerp(float3(SCATTER_COLOUR)*float3(1.0,0.4,0.0), SCATTER_COLOUR, shSaturate(1.0-exp(-waterSunFade_sunHeight.y*SUN_EXT)));
// fresnel // fresnel
float ior = (cameraPos.y>0)?(1.333/1.0):(1.0/1.333); //air to water; water to air float ior = (cameraPos.y>0)?(1.333/1.0):(1.0/1.333); //air to water; water to air
@ -284,7 +284,7 @@
waterGradient = clamp((waterGradient*0.5+0.5),0.2,1.0); waterGradient = clamp((waterGradient*0.5+0.5),0.2,1.0);
float3 watercolour = (float3(0.0078, 0.5176, 0.700)+waterSunColour)*waterGradient*2.0; float3 watercolour = (float3(0.0078, 0.5176, 0.700)+waterSunColour)*waterGradient*2.0;
float3 waterext = float3(0.6, 0.9, 1.0);//water extinction float3 waterext = float3(0.6, 0.9, 1.0);//water extinction
watercolour = mix(watercolour*0.3*waterSunFade_sunHeight.x, watercolour, shSaturate(1.0-exp(-waterSunFade_sunHeight.y*SUN_EXT))); watercolour = shLerp(watercolour*0.3*waterSunFade_sunHeight.x, watercolour, shSaturate(1.0-exp(-waterSunFade_sunHeight.y*SUN_EXT)));
float darkness = VISIBILITY*2.0; float darkness = VISIBILITY*2.0;
darkness = clamp((cameraPos.y+darkness)/darkness,0.2,1.0); darkness = clamp((cameraPos.y+darkness)/darkness,0.2,1.0);
@ -299,6 +299,7 @@
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, fogColor, fogValue); shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, fogColor, fogValue);
} }
shOutputColour(0).w = 1;
} }
#endif #endif

@ -3,7 +3,7 @@ shader_set water_vertex
source water.shader source water.shader
type vertex type vertex
profiles_cg vs_2_0 vp40 arbvp1 profiles_cg vs_2_0 vp40 arbvp1
profiles_hlsl vs_2_0 profiles_hlsl vs_3_0 vs_2_0
} }
shader_set water_fragment shader_set water_fragment
@ -11,5 +11,5 @@ shader_set water_fragment
source water.shader source water.shader
type fragment type fragment
profiles_cg ps_2_x ps_2_0 ps fp40 arbfp1 profiles_cg ps_2_x ps_2_0 ps fp40 arbfp1
profiles_hlsl ps_2_0 profiles_hlsl ps_3_0 ps_2_0
} }

@ -11,6 +11,8 @@
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <components/files/ogreplugin.hpp>
#include <cassert> #include <cassert>
#include <cstdlib> #include <cstdlib>
#include <stdexcept> #include <stdexcept>
@ -110,20 +112,14 @@ void OgreRenderer::configure(const std::string &logPath,
pluginDir = OGRE_PLUGIN_DIR_REL; pluginDir = OGRE_PLUGIN_DIR_REL;
#endif #endif
} }
#ifndef OGRE_PLUGIN_DEBUG_SUFFIX
#define OGRE_PLUGIN_DEBUG_SUFFIX ""
#endif
std::string glPlugin = std::string(pluginDir) + "/RenderSystem_GL" + OGRE_PLUGIN_DEBUG_SUFFIX;
if (boost::filesystem::exists(glPlugin + ".so") || boost::filesystem::exists(glPlugin + ".dll"))
mRoot->loadPlugin (glPlugin);
std::string dxPlugin = std::string(pluginDir) + "/RenderSystem_Direct3D9" + OGRE_PLUGIN_DEBUG_SUFFIX; boost::filesystem::path absPluginPath = boost::filesystem::absolute(boost::filesystem::path(pluginDir));
if (boost::filesystem::exists(dxPlugin + ".so") || boost::filesystem::exists(dxPlugin + ".dll"))
mRoot->loadPlugin (dxPlugin); pluginDir = absPluginPath.string();
std::string cgPlugin = std::string(pluginDir) + "/Plugin_CgProgramManager" + OGRE_PLUGIN_DEBUG_SUFFIX; Files::loadOgrePlugin(pluginDir, "RenderSystem_GL", *mRoot);
if (boost::filesystem::exists(cgPlugin + ".so") || boost::filesystem::exists(cgPlugin + ".dll")) Files::loadOgrePlugin(pluginDir, "RenderSystem_Direct3D9", *mRoot);
mRoot->loadPlugin (cgPlugin); Files::loadOgrePlugin(pluginDir, "Plugin_CgProgramManager", *mRoot);
RenderSystem* rs = mRoot->getRenderSystemByName(renderSystem); RenderSystem* rs = mRoot->getRenderSystemByName(renderSystem);
if (rs == 0) if (rs == 0)
@ -145,7 +141,7 @@ void OgreRenderer::createWindow(const std::string &title, const WindowSettings&
// create the semi-transparent black background texture used by the GUI. // create the semi-transparent black background texture used by the GUI.
// has to be created in code with TU_DYNAMIC_WRITE_ONLY_DISCARDABLE param // has to be created in code with TU_DYNAMIC_WRITE_ONLY_DISCARDABLE param
// so that it can be modified at runtime. // so that it can be modified at runtime.
Ogre::TextureManager::getSingleton().createManual( Ogre::TextureManager::getSingleton().createManual(
"transparent.png", "transparent.png",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,

@ -66,9 +66,16 @@ Allowed options:
--debug [=arg(=1)] (=0) debug mode --debug [=arg(=1)] (=0) debug mode
--nosound [=arg(=1)] (=0) disable all sounds --nosound [=arg(=1)] (=0) disable all sounds
--script-verbose [=arg(=1)] (=0) verbose script output --script-verbose [=arg(=1)] (=0) verbose script output
--new-game [=arg(=1)] (=0) activate char gen/new game mechanics
--script-all [=arg(=1)] (=0) compile all scripts (excluding dialogue scri --script-all [=arg(=1)] (=0) compile all scripts (excluding dialogue scri
pts) at startup pts) at startup
--script-console [=arg(=1)] (=0) enable console-only script functionality
--script-run arg select a file that is executed in the consol
e on startup
Note: The file contains a list of script
lines, but not a complete scripts. That mean
s no begin/end and no variable declarations.
--new-game [=arg(=1)] (=0) activate char gen/new game mechanics
--fs-strict [=arg(=1)] (=0) strict file system handling (no case folding --fs-strict [=arg(=1)] (=0) strict file system handling (no case folding
) )
--encoding arg (=win1252) Character encoding used in OpenMW game messa --encoding arg (=win1252) Character encoding used in OpenMW game messa

Loading…
Cancel
Save