2010-02-28 13:51:17 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
2010-06-11 17:53:00 +00:00
|
|
|
#include <string>
|
|
|
|
#include <fstream>
|
|
|
|
|
2010-06-15 17:04:52 +00:00
|
|
|
#include <boost/program_options.hpp>
|
|
|
|
#include <boost/filesystem.hpp>
|
2010-06-10 08:31:50 +00:00
|
|
|
|
2010-06-08 11:53:34 +00:00
|
|
|
#include "esm_store/cell_store.hpp"
|
2010-06-03 18:44:55 +00:00
|
|
|
#include "bsa/bsa_archive.hpp"
|
2010-06-03 19:51:59 +00:00
|
|
|
#include "ogre/renderer.hpp"
|
|
|
|
#include "tools/fileops.hpp"
|
2010-06-08 11:53:34 +00:00
|
|
|
|
2010-06-12 11:01:20 +00:00
|
|
|
#include "mwrender/interior.hpp"
|
2010-06-08 11:53:34 +00:00
|
|
|
#include "mwrender/mwscene.hpp"
|
|
|
|
#include "mwinput/inputmanager.hpp"
|
2010-02-28 13:51:17 +00:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2010-06-15 17:04:52 +00:00
|
|
|
void maintest (boost::filesystem::path dataDir, const std::string& cellName,
|
|
|
|
std::string master)
|
2010-06-03 18:44:55 +00:00
|
|
|
{
|
2010-06-15 17:04:52 +00:00
|
|
|
assert (!dataDir.empty());
|
2010-06-11 17:53:00 +00:00
|
|
|
|
2010-06-15 17:04:52 +00:00
|
|
|
dataDir = boost::filesystem::system_complete (dataDir);
|
2010-06-11 17:53:00 +00:00
|
|
|
|
2010-06-15 17:04:52 +00:00
|
|
|
std::string masterName; // name without extension
|
|
|
|
|
|
|
|
std::string::size_type sep = master.find_last_of (".");
|
|
|
|
|
|
|
|
if (sep==std::string::npos)
|
|
|
|
{
|
|
|
|
masterName = master;
|
|
|
|
master += ".esm";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
masterName = master.substr (0, sep);
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::filesystem::path masterPath (dataDir);
|
|
|
|
masterPath /= master;
|
|
|
|
|
|
|
|
boost::filesystem::path bsa (dataDir);
|
|
|
|
bsa /= masterName + ".bsa";
|
2010-06-03 18:44:55 +00:00
|
|
|
|
2010-06-15 17:04:52 +00:00
|
|
|
const char* plugCfg = "plugins.cfg";
|
2010-06-03 18:44:55 +00:00
|
|
|
|
2010-06-15 17:04:52 +00:00
|
|
|
cout << "Hello, fellow traveler!\n";
|
2010-06-11 17:53:00 +00:00
|
|
|
|
2010-06-15 17:04:52 +00:00
|
|
|
cout << "Your data directory for today is: " << dataDir << "\n";
|
2010-06-03 18:44:55 +00:00
|
|
|
|
2010-06-15 17:04:52 +00:00
|
|
|
cout << "Initializing OGRE\n";
|
|
|
|
Render::OgreRenderer ogre;
|
|
|
|
ogre.configure(!isFile("ogre.cfg"), plugCfg, false);
|
2010-06-03 18:44:55 +00:00
|
|
|
|
2010-06-15 17:04:52 +00:00
|
|
|
if (boost::filesystem::exists (bsa))
|
|
|
|
{
|
|
|
|
cout << "Adding " << bsa.string() << endl;
|
|
|
|
addBSA(bsa.file_string());
|
|
|
|
}
|
2010-02-28 13:51:17 +00:00
|
|
|
|
2010-06-15 17:04:52 +00:00
|
|
|
cout << "Loading ESM " << masterPath.string() << "\n";
|
|
|
|
ESM::ESMReader esm;
|
|
|
|
ESMS::ESMStore store;
|
|
|
|
ESMS::CellStore cell;
|
2010-05-20 16:59:36 +00:00
|
|
|
|
2010-06-15 17:04:52 +00:00
|
|
|
// This parses the ESM file and loads a sample cell
|
|
|
|
esm.open(masterPath.file_string());
|
|
|
|
store.load(esm);
|
2010-06-06 22:33:45 +00:00
|
|
|
|
2010-06-15 17:04:52 +00:00
|
|
|
cell.loadInt(cellName, store, esm);
|
2010-02-28 13:51:17 +00:00
|
|
|
|
2010-06-15 17:04:52 +00:00
|
|
|
// Create the window
|
|
|
|
ogre.createWindow("OpenMW");
|
2010-06-03 19:51:59 +00:00
|
|
|
|
2010-06-15 17:04:52 +00:00
|
|
|
cout << "\nSetting up cell rendering\n";
|
2010-06-06 11:48:20 +00:00
|
|
|
|
2010-06-15 17:04:52 +00:00
|
|
|
// Sets up camera, scene manager etc
|
|
|
|
MWRender::MWScene scene(ogre);
|
2010-06-05 18:37:01 +00:00
|
|
|
|
2010-06-15 17:04:52 +00:00
|
|
|
// This connects the cell data with the rendering scene.
|
|
|
|
MWRender::InteriorCellRender rend(cell, scene);
|
2010-06-06 22:33:45 +00:00
|
|
|
|
2010-06-15 17:04:52 +00:00
|
|
|
// Load the cell and insert it into the renderer
|
|
|
|
rend.show();
|
2010-06-06 10:52:21 +00:00
|
|
|
|
2010-06-15 17:04:52 +00:00
|
|
|
cout << "Setting up input system\n";
|
2010-06-06 11:48:20 +00:00
|
|
|
|
2010-06-15 17:04:52 +00:00
|
|
|
// Sets up the input system
|
|
|
|
MWInput::MWInputManager input(ogre);
|
2010-06-06 11:48:20 +00:00
|
|
|
|
2010-06-15 17:04:52 +00:00
|
|
|
cout << "\nStart! Press Q/ESC or close window to exit.\n";
|
2010-06-05 18:37:01 +00:00
|
|
|
|
2010-06-15 17:04:52 +00:00
|
|
|
// Start the main rendering loop
|
|
|
|
ogre.start();
|
2010-06-05 18:37:01 +00:00
|
|
|
|
2010-06-15 17:04:52 +00:00
|
|
|
cout << "\nThat's all for now!\n";
|
2010-02-28 13:51:17 +00:00
|
|
|
}
|
|
|
|
|
2010-06-10 08:31:50 +00:00
|
|
|
int main(int argc, char**argv)
|
2010-02-28 13:51:17 +00:00
|
|
|
{
|
2010-06-10 08:31:50 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
boost::program_options::options_description desc (
|
|
|
|
"Syntax: openmw <options>\nAllowed options");
|
|
|
|
|
|
|
|
desc.add_options()
|
2010-06-11 17:53:00 +00:00
|
|
|
("help", "print help message")
|
|
|
|
("data", boost::program_options::value<std::string>()->default_value ("data"),
|
2010-06-12 09:49:37 +00:00
|
|
|
"set data directory")
|
|
|
|
("start", boost::program_options::value<std::string>()->default_value ("Beshara"),
|
|
|
|
"set initial cell (only interior cells supported at the moment")
|
2010-06-15 17:04:52 +00:00
|
|
|
("master", boost::program_options::value<std::string>()->default_value ("Morrowind"),
|
|
|
|
"master file")
|
2010-06-12 09:49:37 +00:00
|
|
|
;
|
2010-06-10 08:31:50 +00:00
|
|
|
|
|
|
|
boost::program_options::variables_map variables;
|
2010-06-11 17:53:00 +00:00
|
|
|
|
|
|
|
std::ifstream configFile ("openmw.cfg");
|
|
|
|
|
2010-06-10 08:31:50 +00:00
|
|
|
boost::program_options::store (
|
|
|
|
boost::program_options::parse_command_line (argc, argv, desc), variables);
|
|
|
|
boost::program_options::notify (variables);
|
|
|
|
|
2010-06-11 17:53:00 +00:00
|
|
|
if (configFile.is_open())
|
|
|
|
boost::program_options::store (
|
|
|
|
boost::program_options::parse_config_file (configFile, desc), variables);
|
|
|
|
|
2010-06-10 08:31:50 +00:00
|
|
|
if (variables.count ("help"))
|
|
|
|
{
|
|
|
|
std::cout << desc << std::endl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-06-15 17:04:52 +00:00
|
|
|
maintest (variables["data"].as<std::string>(), variables["start"].as<std::string>(),
|
|
|
|
variables["master"].as<std::string>());
|
2010-06-10 08:31:50 +00:00
|
|
|
}
|
|
|
|
}
|
2010-02-28 13:51:17 +00:00
|
|
|
catch(exception &e)
|
|
|
|
{
|
|
|
|
cout << "\nERROR: " << e.what() << endl;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|