mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:53:51 +00:00
Merge branch 'master' of http://github.com/zinnschlag/openmw
This commit is contained in:
commit
af7c87e8dc
6 changed files with 246 additions and 99 deletions
|
@ -30,8 +30,8 @@ set(OGRE_HEADER ogre/renderer.hpp)
|
||||||
set(INPUT input/oismanager.cpp)
|
set(INPUT input/oismanager.cpp)
|
||||||
set(INPUT_HEADER input/oismanager.hpp input/listener.hpp input/func_binder.hpp input/dispatch_map.hpp input/dispatcher.hpp)
|
set(INPUT_HEADER input/oismanager.hpp input/listener.hpp input/func_binder.hpp input/dispatch_map.hpp input/dispatcher.hpp)
|
||||||
|
|
||||||
set(GAME game/main.cpp)
|
set(GAME game/main.cpp game/engine.cpp)
|
||||||
set(GAME_HEADER game/mwinput/inputmanager.hpp)
|
set(GAME_HEADER game/mwinput/inputmanager.hpp game/engine.hpp)
|
||||||
|
|
||||||
set(ESM_STORE esm_store/store.cpp esm_store/cell_store.cpp)
|
set(ESM_STORE esm_store/store.cpp esm_store/cell_store.cpp)
|
||||||
set(ESM_STORE_HEADER esm_store/cell_store.hpp esm_store/reclists.hpp esm_store/store.hpp)
|
set(ESM_STORE_HEADER esm_store/cell_store.hpp esm_store/reclists.hpp esm_store/store.hpp)
|
||||||
|
|
|
@ -26,7 +26,7 @@ struct Potion
|
||||||
void load(ESMReader &esm)
|
void load(ESMReader &esm)
|
||||||
{
|
{
|
||||||
model = esm.getHNString("MODL");
|
model = esm.getHNString("MODL");
|
||||||
icon = esm.getHNString("TEXT"); // not ITEX here for some reason
|
icon = esm.getHNOString("TEXT"); // not ITEX here for some reason
|
||||||
script = esm.getHNOString("SCRI");
|
script = esm.getHNOString("SCRI");
|
||||||
name = esm.getHNOString("FNAM");
|
name = esm.getHNOString("FNAM");
|
||||||
esm.getHNT(data, "ALDT", 12);
|
esm.getHNT(data, "ALDT", 12);
|
||||||
|
|
142
game/engine.cpp
Normal file
142
game/engine.cpp
Normal file
|
@ -0,0 +1,142 @@
|
||||||
|
#include "engine.hpp"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "esm_store/cell_store.hpp"
|
||||||
|
#include "bsa/bsa_archive.hpp"
|
||||||
|
#include "ogre/renderer.hpp"
|
||||||
|
#include "tools/fileops.hpp"
|
||||||
|
|
||||||
|
#include "mwrender/interior.hpp"
|
||||||
|
#include "mwinput/inputmanager.hpp"
|
||||||
|
|
||||||
|
OMW::Engine::Engine() {}
|
||||||
|
|
||||||
|
// adjust name and load bsa
|
||||||
|
|
||||||
|
void OMW::Engine::prepareMaster()
|
||||||
|
{
|
||||||
|
std::string::size_type sep = mMaster.find_last_of (".");
|
||||||
|
|
||||||
|
if (sep==std::string::npos)
|
||||||
|
{
|
||||||
|
mMaster += ".esm";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load all BSA files in data directory.
|
||||||
|
|
||||||
|
void OMW::Engine::loadBSA()
|
||||||
|
{
|
||||||
|
boost::filesystem::directory_iterator end;
|
||||||
|
|
||||||
|
for (boost::filesystem::directory_iterator iter (mDataDir); iter!=end; ++iter)
|
||||||
|
{
|
||||||
|
if (boost::filesystem::extension (iter->path())==".bsa")
|
||||||
|
{
|
||||||
|
std::cout << "Adding " << iter->path().string() << std::endl;
|
||||||
|
addBSA(iter->path().file_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add resources directory
|
||||||
|
// \note This function works recursively.
|
||||||
|
|
||||||
|
void OMW::Engine::addResourcesDirectory (const boost::filesystem::path& path)
|
||||||
|
{
|
||||||
|
mOgre.getRoot()->addResourceLocation (path.file_string(), "FileSystem",
|
||||||
|
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set data dir
|
||||||
|
|
||||||
|
void OMW::Engine::setDataDir (const boost::filesystem::path& dataDir)
|
||||||
|
{
|
||||||
|
mDataDir = boost::filesystem::system_complete (dataDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set start cell name (only interiors for now)
|
||||||
|
|
||||||
|
void OMW::Engine::setCell (const std::string& cellName)
|
||||||
|
{
|
||||||
|
mCellName = cellName;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set master file (esm)
|
||||||
|
// - If the given name does not have an extension, ".esm" is added automatically
|
||||||
|
// - Currently OpenMW only supports one master at the same time.
|
||||||
|
|
||||||
|
void OMW::Engine::addMaster (const std::string& master)
|
||||||
|
{
|
||||||
|
assert (mMaster.empty());
|
||||||
|
mMaster = master;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialise and enter main loop.
|
||||||
|
|
||||||
|
void OMW::Engine::go()
|
||||||
|
{
|
||||||
|
assert (!mDataDir.empty());
|
||||||
|
assert (!mCellName.empty());
|
||||||
|
assert (!mMaster.empty());
|
||||||
|
|
||||||
|
std::cout << "Hello, fellow traveler!\n";
|
||||||
|
|
||||||
|
std::cout << "Your data directory for today is: " << mDataDir << "\n";
|
||||||
|
|
||||||
|
std::cout << "Initializing OGRE\n";
|
||||||
|
|
||||||
|
const char* plugCfg = "plugins.cfg";
|
||||||
|
|
||||||
|
mOgre.configure(!isFile("ogre.cfg"), plugCfg, false);
|
||||||
|
|
||||||
|
addResourcesDirectory (mDataDir / "Meshes");
|
||||||
|
addResourcesDirectory (mDataDir / "Textures");
|
||||||
|
|
||||||
|
prepareMaster();
|
||||||
|
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
|
||||||
|
mOgre.createWindow("OpenMW");
|
||||||
|
|
||||||
|
std::cout << "\nSetting up cell rendering\n";
|
||||||
|
|
||||||
|
// Sets up camera, scene manager etc
|
||||||
|
MWRender::MWScene scene(mOgre);
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
|
||||||
|
std::cout << "Setting up input system\n";
|
||||||
|
|
||||||
|
// Sets up the input system
|
||||||
|
MWInput::MWInputManager input(mOgre);
|
||||||
|
|
||||||
|
std::cout << "\nStart! Press Q/ESC or close window to exit.\n";
|
||||||
|
|
||||||
|
// Start the main rendering loop
|
||||||
|
mOgre.start();
|
||||||
|
|
||||||
|
std::cout << "\nThat's all for now!\n";
|
||||||
|
}
|
||||||
|
|
55
game/engine.hpp
Normal file
55
game/engine.hpp
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
#ifndef ENGINE_H
|
||||||
|
#define ENGINE_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
|
#include "mwrender/mwscene.hpp"
|
||||||
|
|
||||||
|
namespace OMW
|
||||||
|
{
|
||||||
|
/// \brief Main engine class, that brings together all the components of OpenMW
|
||||||
|
|
||||||
|
class Engine
|
||||||
|
{
|
||||||
|
boost::filesystem::path mDataDir;
|
||||||
|
Render::OgreRenderer mOgre;
|
||||||
|
std::string mCellName;
|
||||||
|
std::string mMaster;
|
||||||
|
|
||||||
|
// not implemented
|
||||||
|
Engine (const Engine&);
|
||||||
|
Engine& operator= (const Engine&);
|
||||||
|
|
||||||
|
/// adjust name and load bsa
|
||||||
|
void prepareMaster();
|
||||||
|
|
||||||
|
/// add resources directory
|
||||||
|
/// \note This function works recursively.
|
||||||
|
void addResourcesDirectory (const boost::filesystem::path& path);
|
||||||
|
|
||||||
|
/// Load all BSA files in data directory.
|
||||||
|
void loadBSA();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Engine();
|
||||||
|
|
||||||
|
/// Set data dir
|
||||||
|
void setDataDir (const boost::filesystem::path& dataDir);
|
||||||
|
|
||||||
|
/// Set start cell name (only interiors for now)
|
||||||
|
void setCell (const std::string& cellName);
|
||||||
|
|
||||||
|
/// Set master file (esm)
|
||||||
|
/// - If the given name does not have an extension, ".esm" is added automatically
|
||||||
|
/// - Currently OpenMW only supports one master at the same time.
|
||||||
|
void addMaster (const std::string& master);
|
||||||
|
|
||||||
|
/// Initialise and enter main loop.
|
||||||
|
void go();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
100
game/main.cpp
100
game/main.cpp
|
@ -3,84 +3,18 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#include "boost/program_options.hpp"
|
#include <boost/program_options.hpp>
|
||||||
|
|
||||||
#include "esm_store/cell_store.hpp"
|
#include "engine.hpp"
|
||||||
#include "bsa/bsa_archive.hpp"
|
|
||||||
#include "ogre/renderer.hpp"
|
|
||||||
#include "tools/fileops.hpp"
|
|
||||||
|
|
||||||
#include "mwrender/interior.hpp"
|
|
||||||
#include "mwrender/mwscene.hpp"
|
|
||||||
#include "mwinput/inputmanager.hpp"
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void maintest (std::string dataDir, const std::string& cellName)
|
/// Parse command line options and openmw.cfg file (if one exists). Results are directly
|
||||||
|
/// written to \a engine.
|
||||||
|
/// \return Run OpenMW?
|
||||||
|
|
||||||
|
bool parseOptions (int argc, char**argv, OMW::Engine& engine)
|
||||||
{
|
{
|
||||||
assert (!dataDir.empty());
|
|
||||||
|
|
||||||
if (dataDir[dataDir.size()-1]!='/' && dataDir[dataDir.size()-1]!='\\')
|
|
||||||
dataDir += "/";
|
|
||||||
|
|
||||||
const char* esmFile = "Morrowind.esm";
|
|
||||||
const char* bsaFile = "Morrowind.bsa";
|
|
||||||
|
|
||||||
const char* plugCfg = "plugins.cfg";
|
|
||||||
|
|
||||||
cout << "Hello, fellow traveler!\n";
|
|
||||||
|
|
||||||
cout << "Your data directory for today is: " << dataDir << "\n";
|
|
||||||
|
|
||||||
cout << "Initializing OGRE\n";
|
|
||||||
Render::OgreRenderer ogre;
|
|
||||||
ogre.configure(!isFile("ogre.cfg"), plugCfg, false);
|
|
||||||
|
|
||||||
cout << "Adding " << bsaFile << endl;
|
|
||||||
addBSA(dataDir + bsaFile);
|
|
||||||
|
|
||||||
cout << "Loading ESM " << esmFile << "\n";
|
|
||||||
ESM::ESMReader esm;
|
|
||||||
ESMS::ESMStore store;
|
|
||||||
ESMS::CellStore cell;
|
|
||||||
|
|
||||||
// This parses the ESM file and loads a sample cell
|
|
||||||
esm.open(dataDir + esmFile);
|
|
||||||
store.load(esm);
|
|
||||||
|
|
||||||
cell.loadInt(cellName, store, esm);
|
|
||||||
|
|
||||||
// Create the window
|
|
||||||
ogre.createWindow("OpenMW");
|
|
||||||
|
|
||||||
cout << "\nSetting up cell rendering\n";
|
|
||||||
|
|
||||||
// Sets up camera, scene manager etc
|
|
||||||
MWRender::MWScene scene(ogre);
|
|
||||||
|
|
||||||
// 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();
|
|
||||||
|
|
||||||
cout << "Setting up input system\n";
|
|
||||||
|
|
||||||
// Sets up the input system
|
|
||||||
MWInput::MWInputManager input(ogre);
|
|
||||||
|
|
||||||
cout << "\nStart! Press Q/ESC or close window to exit.\n";
|
|
||||||
|
|
||||||
// Start the main rendering loop
|
|
||||||
ogre.start();
|
|
||||||
|
|
||||||
cout << "\nThat's all for now!\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char**argv)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
boost::program_options::options_description desc (
|
boost::program_options::options_description desc (
|
||||||
"Syntax: openmw <options>\nAllowed options");
|
"Syntax: openmw <options>\nAllowed options");
|
||||||
|
|
||||||
|
@ -90,6 +24,8 @@ int main(int argc, char**argv)
|
||||||
"set data directory")
|
"set data directory")
|
||||||
("start", boost::program_options::value<std::string>()->default_value ("Beshara"),
|
("start", boost::program_options::value<std::string>()->default_value ("Beshara"),
|
||||||
"set initial cell (only interior cells supported at the moment")
|
"set initial cell (only interior cells supported at the moment")
|
||||||
|
("master", boost::program_options::value<std::string>()->default_value ("Morrowind"),
|
||||||
|
"master file")
|
||||||
;
|
;
|
||||||
|
|
||||||
boost::program_options::variables_map variables;
|
boost::program_options::variables_map variables;
|
||||||
|
@ -107,10 +43,23 @@ int main(int argc, char**argv)
|
||||||
if (variables.count ("help"))
|
if (variables.count ("help"))
|
||||||
{
|
{
|
||||||
std::cout << desc << std::endl;
|
std::cout << desc << std::endl;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
engine.setDataDir (variables["data"].as<std::string>());
|
||||||
|
engine.setCell (variables["start"].as<std::string>());
|
||||||
|
engine.addMaster (variables["master"].as<std::string>());
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char**argv)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
maintest (variables["data"].as<std::string>(), variables["start"].as<std::string>());
|
OMW::Engine engine;
|
||||||
|
|
||||||
|
if (parseOptions (argc, argv, engine))
|
||||||
|
{
|
||||||
|
engine.go();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(exception &e)
|
catch(exception &e)
|
||||||
|
@ -118,5 +67,6 @@ int main(int argc, char**argv)
|
||||||
cout << "\nERROR: " << e.what() << endl;
|
cout << "\nERROR: " << e.what() << endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -604,7 +604,7 @@ void NIFLoader::loadResource(Resource *resource)
|
||||||
Record *r = nif.getRecord(0);
|
Record *r = nif.getRecord(0);
|
||||||
assert(r != NULL);
|
assert(r != NULL);
|
||||||
|
|
||||||
if(r->recType != RC_NiNode)
|
if(r->recType != RC_NiNode && r->recType != RC_NiTriShape)
|
||||||
{
|
{
|
||||||
warn("First record in file was not a NiNode, but a " +
|
warn("First record in file was not a NiNode, but a " +
|
||||||
r->recName.toString() + ". Skipping file.");
|
r->recName.toString() + ". Skipping file.");
|
||||||
|
|
Loading…
Reference in a new issue