forked from mirror/openmw-tes3mp
factored world class out of main engine class
This commit is contained in:
parent
60fb817e89
commit
ce37666dbc
6 changed files with 29 additions and 70 deletions
|
@ -10,10 +10,12 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/)
|
||||||
|
|
||||||
set(GAME
|
set(GAME
|
||||||
apps/openmw/main.cpp
|
apps/openmw/main.cpp
|
||||||
apps/openmw/engine.cpp)
|
apps/openmw/engine.cpp
|
||||||
|
apps/openmw/world.cpp)
|
||||||
set(GAME_HEADER
|
set(GAME_HEADER
|
||||||
apps/openmw/mwinput/inputmanager.hpp
|
apps/openmw/mwinput/inputmanager.hpp
|
||||||
apps/openmw/engine.hpp)
|
apps/openmw/engine.hpp
|
||||||
|
apps/openmw/world.hpp)
|
||||||
source_group(game FILES ${GAME} ${GAME_HEADER})
|
source_group(game FILES ${GAME} ${GAME_HEADER})
|
||||||
|
|
||||||
set(GAMEREND
|
set(GAMEREND
|
||||||
|
|
|
@ -4,19 +4,14 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "components/esm_store/cell_store.hpp"
|
|
||||||
#include "components/bsa/bsa_archive.hpp"
|
|
||||||
#include "components/engine/ogre/renderer.hpp"
|
|
||||||
#include "components/misc/fileops.hpp"
|
#include "components/misc/fileops.hpp"
|
||||||
|
#include "components/bsa/bsa_archive.hpp"
|
||||||
|
|
||||||
#include "apps/openmw/mwrender/interior.hpp"
|
|
||||||
#include "mwinput/inputmanager.hpp"
|
#include "mwinput/inputmanager.hpp"
|
||||||
#include "apps/openmw/mwrender/playerpos.hpp"
|
|
||||||
#include "apps/openmw/mwrender/sky.hpp"
|
#include "world.hpp"
|
||||||
|
|
||||||
OMW::Engine::Engine()
|
OMW::Engine::Engine()
|
||||||
: mEnableSky (false)
|
|
||||||
, mpSkyManager (NULL)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,17 +71,11 @@ void OMW::Engine::addMaster (const std::string& master)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enables sky rendering
|
|
||||||
//
|
|
||||||
void OMW::Engine::enableSky (bool bEnable)
|
|
||||||
{
|
|
||||||
mEnableSky = bEnable;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialise and enter main loop.
|
// Initialise and enter main loop.
|
||||||
|
|
||||||
void OMW::Engine::go()
|
void OMW::Engine::go()
|
||||||
{
|
{
|
||||||
|
assert (!mWorld);
|
||||||
assert (!mDataDir.empty());
|
assert (!mDataDir.empty());
|
||||||
assert (!mCellName.empty());
|
assert (!mCellName.empty());
|
||||||
assert (!mMaster.empty());
|
assert (!mMaster.empty());
|
||||||
|
@ -104,55 +93,29 @@ void OMW::Engine::go()
|
||||||
addResourcesDirectory (mDataDir / "Meshes");
|
addResourcesDirectory (mDataDir / "Meshes");
|
||||||
addResourcesDirectory (mDataDir / "Textures");
|
addResourcesDirectory (mDataDir / "Textures");
|
||||||
|
|
||||||
loadBSA();
|
|
||||||
|
|
||||||
boost::filesystem::path masterPath (mDataDir);
|
|
||||||
masterPath /= mMaster;
|
|
||||||
|
|
||||||
std::cout << "Loading ESM " << masterPath.string() << "\n";
|
|
||||||
ESM::ESMReader esm;
|
|
||||||
ESMS::ESMStore store;
|
|
||||||
ESMS::CellStore cell;
|
|
||||||
|
|
||||||
// This parses the ESM file and loads a sample cell
|
|
||||||
esm.open(masterPath.file_string());
|
|
||||||
store.load(esm);
|
|
||||||
|
|
||||||
cell.loadInt(mCellName, store, esm);
|
|
||||||
|
|
||||||
// Create the window
|
// Create the window
|
||||||
mOgre.createWindow("OpenMW");
|
mOgre.createWindow("OpenMW");
|
||||||
|
|
||||||
std::cout << "\nSetting up cell rendering\n";
|
loadBSA();
|
||||||
|
|
||||||
// Sets up camera, scene manager, and viewport.
|
// Create the world
|
||||||
MWRender::MWScene scene(mOgre);
|
mWorld = new World (mOgre, mDataDir, mMaster, mCellName);
|
||||||
|
|
||||||
// Used to control the player camera and position
|
|
||||||
MWRender::PlayerPos player(scene.getCamera());
|
|
||||||
|
|
||||||
// This connects the cell data with the rendering scene.
|
|
||||||
MWRender::InteriorCellRender rend(cell, scene);
|
|
||||||
|
|
||||||
// Load the cell and insert it into the renderer
|
|
||||||
rend.show();
|
|
||||||
|
|
||||||
// Optionally enable the sky
|
|
||||||
if (mEnableSky)
|
|
||||||
mpSkyManager = MWRender::SkyManager::create(mOgre.getWindow(), scene.getCamera());
|
|
||||||
|
|
||||||
std::cout << "Setting up input system\n";
|
std::cout << "Setting up input system\n";
|
||||||
|
|
||||||
// Sets up the input system
|
// Sets up the input system
|
||||||
MWInput::MWInputManager input(mOgre, player);
|
MWInput::MWInputManager input(mOgre, mWorld->getPlayerPos());
|
||||||
|
|
||||||
std::cout << "\nStart! Press Q/ESC or close window to exit.\n";
|
std::cout << "\nStart! Press Q/ESC or close window to exit.\n";
|
||||||
|
|
||||||
// Start the main rendering loop
|
// Start the main rendering loop
|
||||||
mOgre.start();
|
mOgre.start();
|
||||||
|
|
||||||
delete mpSkyManager;
|
|
||||||
|
|
||||||
std::cout << "\nThat's all for now!\n";
|
std::cout << "\nThat's all for now!\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OMW::Engine::~Engine()
|
||||||
|
{
|
||||||
|
delete mWorld;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,15 +5,12 @@
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
#include "apps/openmw/mwrender/mwscene.hpp"
|
#include "components/engine/ogre/renderer.hpp"
|
||||||
|
|
||||||
namespace MWRender
|
|
||||||
{
|
|
||||||
class SkyManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace OMW
|
namespace OMW
|
||||||
{
|
{
|
||||||
|
class World;
|
||||||
|
|
||||||
/// \brief Main engine class, that brings together all the components of OpenMW
|
/// \brief Main engine class, that brings together all the components of OpenMW
|
||||||
|
|
||||||
class Engine
|
class Engine
|
||||||
|
@ -22,9 +19,7 @@ namespace OMW
|
||||||
Render::OgreRenderer mOgre;
|
Render::OgreRenderer mOgre;
|
||||||
std::string mCellName;
|
std::string mCellName;
|
||||||
std::string mMaster;
|
std::string mMaster;
|
||||||
|
World *mWorld;
|
||||||
bool mEnableSky;
|
|
||||||
MWRender::SkyManager* mpSkyManager;
|
|
||||||
|
|
||||||
// not implemented
|
// not implemented
|
||||||
Engine (const Engine&);
|
Engine (const Engine&);
|
||||||
|
@ -41,6 +36,8 @@ namespace OMW
|
||||||
|
|
||||||
Engine();
|
Engine();
|
||||||
|
|
||||||
|
~Engine();
|
||||||
|
|
||||||
/// Set data dir
|
/// Set data dir
|
||||||
void setDataDir (const boost::filesystem::path& dataDir);
|
void setDataDir (const boost::filesystem::path& dataDir);
|
||||||
|
|
||||||
|
@ -52,9 +49,6 @@ namespace OMW
|
||||||
/// - Currently OpenMW only supports one master at the same time.
|
/// - Currently OpenMW only supports one master at the same time.
|
||||||
void addMaster (const std::string& master);
|
void addMaster (const std::string& master);
|
||||||
|
|
||||||
/// Enables rendering of the sky (off by default).
|
|
||||||
void enableSky (bool bEnable);
|
|
||||||
|
|
||||||
/// Initialise and enter main loop.
|
/// Initialise and enter main loop.
|
||||||
void go();
|
void go();
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,7 +29,6 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine)
|
||||||
"set initial cell (only interior cells supported at the moment")
|
"set initial cell (only interior cells supported at the moment")
|
||||||
("master", bpo::value<std::string>()->default_value ("Morrowind"),
|
("master", bpo::value<std::string>()->default_value ("Morrowind"),
|
||||||
"master file")
|
"master file")
|
||||||
("enablesky", "enable rendering of the sky")
|
|
||||||
;
|
;
|
||||||
|
|
||||||
bpo::variables_map variables;
|
bpo::variables_map variables;
|
||||||
|
@ -48,8 +47,6 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
engine.enableSky(!!variables.count("enablesky"));
|
|
||||||
|
|
||||||
engine.setDataDir (variables["data"].as<std::string>());
|
engine.setDataDir (variables["data"].as<std::string>());
|
||||||
engine.setCell (variables["start"].as<std::string>());
|
engine.setCell (variables["start"].as<std::string>());
|
||||||
engine.addMaster (variables["master"].as<std::string>());
|
engine.addMaster (variables["master"].as<std::string>());
|
||||||
|
|
|
@ -37,6 +37,9 @@ namespace MWRender
|
||||||
virtual std::string insertEnd() = 0;
|
virtual std::string insertEnd() = 0;
|
||||||
|
|
||||||
void insertCell(const ESMS::CellStore &cell);
|
void insertCell(const ESMS::CellStore &cell);
|
||||||
|
|
||||||
|
/// placeholder function -> need to do some heavy refactoring on the whole cell stuff
|
||||||
|
virtual void show() = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace MWRender
|
||||||
TODO FIXME: Doesn't do full cleanup yet.
|
TODO FIXME: Doesn't do full cleanup yet.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class InteriorCellRender : private CellRender
|
class InteriorCellRender : public CellRender
|
||||||
{
|
{
|
||||||
|
|
||||||
static bool lightConst;
|
static bool lightConst;
|
||||||
|
@ -83,7 +83,7 @@ namespace MWRender
|
||||||
virtual ~InteriorCellRender() { destroy(); }
|
virtual ~InteriorCellRender() { destroy(); }
|
||||||
|
|
||||||
/// Make the cell visible. Load the cell if necessary.
|
/// Make the cell visible. Load the cell if necessary.
|
||||||
void show();
|
virtual void show();
|
||||||
|
|
||||||
/// Remove the cell from rendering, but don't remove it from
|
/// Remove the cell from rendering, but don't remove it from
|
||||||
/// memory.
|
/// memory.
|
||||||
|
|
Loading…
Reference in a new issue