Integrated OpenEngine, replaces entire components/engine/ directory.

pull/7/head
Nicolay Korslund 15 years ago
parent 186bf8c1a1
commit 13d3f9c87e

@ -50,36 +50,11 @@ source_group(components\\esm_store FILES ${ESM_STORE} ${ESM_STORE_HEADER})
file(GLOB ESM_HEADER ${COMP_DIR}/esm/*.hpp)
source_group(components\\esm FILES ${ESM_HEADER})
set(OGRE
${COMP_DIR}/engine/ogre/renderer.cpp)
set(OGRE_HEADER
${COMP_DIR}/engine/ogre/renderer.hpp)
source_group(components\\engine\\ogre FILES ${OGRE} ${OGRE_HEADER})
# components/mw_gui
set(MWGUI_HEADER
${COMP_DIR}/mw_gui/mw_layouts.hpp)
source_group(components\\mw_gui FILES ${MWGUI_HEADER})
# components/engine/gui
set(EGUI
${COMP_DIR}/engine/gui/manager.cpp)
set(EGUI_HEADER
${COMP_DIR}/engine/gui/manager.hpp
${COMP_DIR}/engine/gui/layout.hpp)
source_group(components\\engine\\gui FILES ${EGUI} ${EGUI_HEADER})
set(INPUT
${COMP_DIR}/engine/input/oismanager.cpp)
set(INPUT_HEADER
${COMP_DIR}/engine/input/oismanager.hpp
${COMP_DIR}/engine/input/listener.hpp
${COMP_DIR}/engine/input/func_binder.hpp
${COMP_DIR}/engine/input/dispatch_map.hpp
${COMP_DIR}/engine/input/dispatcher.hpp
${COMP_DIR}/engine/input/poller.hpp)
source_group(components\\engine\\input FILES ${INPUT} ${INPUT_HEADER})
set(COMMANDSERVER
${COMP_DIR}/commandserver/command.hpp
${COMP_DIR}/commandserver/server.hpp
@ -104,22 +79,35 @@ file(GLOB INTERPRETER ${COMP_DIR}/interpreter/*.cpp)
file(GLOB INTERPRETER_HEADER ${COMP_DIR}/interpreter/*.hpp)
source_group(components\\interpreter FILES ${INTERPRETER} ${INTERPRETER_HEADER})
set(COMPONENTS ${BSA} ${NIF} ${NIFOGRE} ${ESM_STORE} ${OGRE} ${INPUT} ${MISC}
${EGUI}
set(COMPONENTS ${BSA} ${NIF} ${NIFOGRE} ${ESM_STORE} ${MISC}
${COMMANDSERVER}
${COMPILER}
${INTERPRETER})
set(COMPONENTS_HEADER ${BSA_HEADER} ${NIF_HEADER} ${NIFOGRE_HEADER} ${ESM_STORE_HEADER}
${ESM_HEADER} ${OGRE_HEADER} ${INPUT_HEADER} ${MISC_HEADER} ${COMPILER_HEADER}
${INTERPRETER_HEADER} ${EGUI_HEADER} ${MWGUI_HEADER})
${ESM_HEADER} ${MISC_HEADER} ${COMPILER_HEADER}
${INTERPRETER_HEADER} ${MWGUI_HEADER})
# source directory: libs
set(LIBDIR ${CMAKE_SOURCE_DIR}/libs)
set(MANGLE_VFS ${LIBDIR}/mangle/vfs/servers/ogre_vfs.cpp)
source_group(libs\\mangle_vfs FILES ${MANGLE_VFS})
set(MANGLE_INPUT ${LIBDIR}/mangle/input/servers/ois_driver.cpp)
set(MANGLE_ALL ${MANGLE_VFS} ${MANGLE_INPUT})
source_group(libs\\mangle FILES ${MANGLE_ALL})
set(OPENMW_LIBS ${MANGLE_VFS})
set(OENGINE_OGRE
${LIBDIR}/openengine/ogre/renderer.cpp
${LIBDIR}/openengine/ogre/mouselook.cpp
)
set(OENGINE_GUI
# ${LIBDIR}/openengine/gui/events.cpp
${LIBDIR}/openengine/gui/manager.cpp
) # Not yet included in main executable
set(OENGINE_ALL ${OENGINE_OGRE})
source_group(libs\\openengine FILES ${OENGINE_ALL})
set(OPENMW_LIBS ${MANGLE_ALL} ${OENGINE_ALL})
set(OPENMW_LIBS_HEADER)
# Platform specific
@ -142,6 +130,7 @@ include_directories("."
${CMAKE_HOME_DIRECTORY}/extern/caelum/include
${CMAKE_HOME_DIRECTORY}/extern/mygui_3.0.1/MyGUIEngine/include
${CMAKE_HOME_DIRECTORY}/extern/mygui_3.0.1/OgrePlatform/include
${LIBDIR}
)

@ -1,8 +1,8 @@
add_executable(mygui_test
main.cpp
${BSA} ${BSA_HEADER}
${OGRE} ${OGRE_HEADER}
${EGUI} ${EGUI_HEADER}
${OENGINE_OGRE}
${OENGINE_GUI}
)
target_link_libraries(mygui_test
${OGRE_LIBRARIES}

@ -1,14 +1,16 @@
#include <iostream>
using namespace std;
#include <components/engine/gui/manager.hpp>
#include <openengine/gui/manager.hpp>
#include <openengine/ogre/renderer.hpp>
#include <components/mw_gui/mw_layouts.hpp>
#include <components/bsa/bsa_archive.hpp>
#include <components/engine/ogre/renderer.hpp>
#include <OgreResourceGroupManager.h>
#include <OgreRenderWindow.h>
#include <components/bsa/bsa_archive.hpp>
#include <OgreFrameListener.h>
#include <OgreRoot.h>
// Frame listener
struct Listener : public Ogre::FrameListener
@ -40,7 +42,7 @@ struct Listener : public Ogre::FrameListener
int main()
{
Render::OgreRenderer ogre;
OEngine::Render::OgreRenderer ogre;
ogre.configure(false, "plugins.cfg", false);
ogre.createWindow("MyGUI test");
ogre.createScene();
@ -60,7 +62,7 @@ int main()
// Make sure you load the data paths BEFORE you initialize the
// GUI. MyGUI depends on finding core.xml in resources/mygui/.
cout << "Setting up MyGUI\n";
GUI::MyGUIManager gui(ogre.getWindow(), ogre.getScene());
OEngine::GUI::MyGUIManager gui(ogre.getWindow(), ogre.getScene());
int w = ogre.getWindow()->getWidth();
int h = ogre.getWindow()->getHeight();

@ -7,7 +7,7 @@
#include <OgreFrameListener.h>
#include <components/engine/ogre/renderer.hpp>
#include <openengine/ogre/renderer.hpp>
#include <components/misc/tsdeque.hpp>
#include <components/commandserver/server.hpp>
#include <components/commandserver/command.hpp>
@ -44,7 +44,7 @@ namespace OMW
enum { kCommandServerPort = 27917 };
boost::filesystem::path mDataDir;
Render::OgreRenderer mOgre;
OEngine::Render::OgreRenderer mOgre;
std::string mCellName;
std::string mMaster;
bool mDebug;

@ -1,18 +1,24 @@
#ifndef _MWINPUT_MWINPUTMANAGER_H
#define _MWINPUT_MWINPUTMANAGER_H
#include <libs/openengine/input/dispatcher.hpp>
#include <libs/openengine/input/poller.hpp>
#include <openengine/input/dispatcher.hpp>
#include <openengine/input/poller.hpp>
#include <libs/openengine/ogre/exitlistener.hpp>
#include <libs/openengine/ogre/mouselook.hpp>
#include <openengine/ogre/exitlistener.hpp>
#include <openengine/ogre/mouselook.hpp>
#include <openengine/ogre/renderer.hpp>
#include <libs/mangle/input/drivers/ois_driver.hpp>
#include <mangle/input/servers/ois_driver.hpp>
#include <mangle/input/filters/eventlist.hpp>
#include <libs/platform/strings.h>
#include <boost/bind.hpp>
#include "../mwrender/playerpos.hpp"
#include <OgreRoot.h>
#include <OIS/OIS.h>
namespace MWInput
{
enum Actions
@ -34,10 +40,12 @@ namespace MWInput
// Class that handles all input and key bindings for OpenMW
class MWInputManager : public Ogre::FrameListener
{
Mangle::Input::EventPtr disp;
Render::OgreRenderer &ogre;
OEngine::Input::DispatcherPtr disp;
OEngine::Render::OgreRenderer &ogre;
OEngine::Render::ExitListener exit;
Mangle::Input::OISDriver input;
OEngine::Input::Poller poller;
OEngine::Render::MouseLookEventPtr mouse;
MWRender::PlayerPos &player;
// Count screenshots. TODO: We should move this functionality to
@ -59,35 +67,52 @@ namespace MWInput
}
public:
MWInputManager(Render::OgreRenderer &_ogre,
MWInputManager(OEngine::Render::OgreRenderer &_ogre,
MWRender::PlayerPos &_player, bool debug)
: ogre(_ogre),
exit(ogre.getWindow()),
input(ogre.getWindow(), !debug),
poller(input),
player(_player),
shotCount(0)
{
using namespace OEngine::Input;
using namespace OEngine::Render;
using namespace Mangle::Input;
using namespace OIS;
disp = EventPtr(new Dispatcher(A_LAST));
disp = DispatcherPtr(new Dispatcher(A_LAST));
// Bind MW-specific functions
disp->funcs.bind(A_Quit, boost::bind(&InputListener::exitNow, &listener),
disp->funcs.bind(A_Quit, boost::bind(&ExitListener::exitNow, &exit),
"Quit program");
disp->funcs.bind(A_Screenshot, boost::bind(&MWInputManager::screenshot, this),
"Screenshot");
// Add ourselves as a frame listener, to catch movement keys
// Add the exit listener
ogre.getRoot()->addFrameListener(&exit);
// Add ourselves as a frame listener to catch movement keys
ogre.getRoot()->addFrameListener(this);
// Tell the input listener about the camera
listener.setCamera(player.getCamera());
// Set up the mouse handler and tell it about the player camera
mouse = MouseLookEventPtr(new MouseLookEvent(player.getCamera()));
// Hook 'mouse' and 'disp' up as event handlers into 'input'
// (the OIS driver and event source.) We do this through an
// EventList which dispatches the event to multiple handlers for
// us.
{
EventList *lst = new EventList;
input.setEvent(EventPtr(lst));
lst->add(mouse,Event::EV_MouseMove);
lst->add(disp,Event::EV_KeyDown);
}
// Key bindings
disp->bind(KC_Q, A_Quit);
disp->bind(KC_ESCAPE, A_Quit);
disp->bind(KC_SYSRQ, A_Screenshot);
disp->bind(A_Quit, KC_Q);
disp->bind(A_Quit, KC_ESCAPE);
disp->bind(A_Screenshot, KC_SYSRQ);
// Key bindings for polled keys

@ -2,8 +2,11 @@
#include <OgreEntity.h>
#include <OgreLight.h>
#include <OgreSceneNode.h>
#include <OgreCamera.h>
#include <OgreSceneManager.h>
#include "components/nifogre/ogre_nif_loader.hpp"
#include <components/nifogre/ogre_nif_loader.hpp>
#include "mwscene.hpp"
using namespace MWRender;

@ -12,7 +12,7 @@
using namespace MWRender;
using namespace Ogre;
MWScene::MWScene(Render::OgreRenderer &_rend)
MWScene::MWScene(OEngine::Render::OgreRenderer &_rend)
: rend(_rend)
{
rend.createScene("PlayerCam", 55, 5);

@ -1,7 +1,7 @@
#ifndef _GAME_RENDER_MWSCENE_H
#define _GAME_RENDER_MWSCENE_H
#include "components/engine/ogre/renderer.hpp"
#include <openengine/ogre/renderer.hpp>
namespace Ogre
{
@ -20,7 +20,7 @@ namespace MWRender
*/
class MWScene
{
Render::OgreRenderer &rend;
OEngine::Render::OgreRenderer &rend;
// Root node for all objects added to the scene. This is rotated so
// that the OGRE coordinate system matches that used internally in
@ -28,7 +28,7 @@ namespace MWRender
Ogre::SceneNode *mwRoot;
public:
MWScene(Render::OgreRenderer &_rend);
MWScene(OEngine::Render::OgreRenderer &_rend);
Ogre::Camera *getCamera() { return rend.getCamera(); }
Ogre::SceneNode *getRoot() { return mwRoot; }

@ -4,7 +4,6 @@
#include <iostream>
#include "components/bsa/bsa_archive.hpp"
#include "components/engine/ogre/renderer.hpp"
#include "apps/openmw/mwrender/sky.hpp"
#include "apps/openmw/mwrender/interior.hpp"
@ -142,7 +141,7 @@ namespace MWWorld
return 0;
}
World::World (Render::OgreRenderer& renderer, const boost::filesystem::path& dataDir,
World::World (OEngine::Render::OgreRenderer& renderer, const boost::filesystem::path& dataDir,
const std::string& master, const std::string& startCell, bool newGame)
: mSkyManager (0), mScene (renderer), mPlayerPos (0), mCurrentCell (0)
{

@ -65,7 +65,7 @@ namespace MWWorld
public:
World (Render::OgreRenderer& renderer, const boost::filesystem::path& master,
World (OEngine::Render::OgreRenderer& renderer, const boost::filesystem::path& master,
const std::string& dataDir, const std::string& startCell, bool newGame);
~World();

@ -1,118 +0,0 @@
#ifndef ENGINE_MYGUI_LAYOUT_H
#define ENGINE_MYGUI_LAYOUT_H
#include <assert.h>
#include <MyGUI.h>
namespace GUI
{
/** The Layout class is an utility class used to load MyGUI layouts
from xml files, and to manipulate member widgets.
*/
class Layout
{
public:
Layout(const std::string & _layout, MyGUI::WidgetPtr _parent = nullptr)
: mMainWidget(nullptr)
{ initialise(_layout, _parent); }
virtual ~Layout() { shutdown(); }
template <typename T>
void getWidget(T * & _widget, const std::string & _name, bool _throw = true)
{
_widget = nullptr;
for (MyGUI::VectorWidgetPtr::iterator iter=mListWindowRoot.begin();
iter!=mListWindowRoot.end(); ++iter)
{
MyGUI::WidgetPtr find = (*iter)->findWidget(mPrefix + _name);
if (nullptr != find)
{
T * cast = find->castType<T>(false);
if (nullptr != cast)
_widget = cast;
else if (_throw)
{
MYGUI_EXCEPT("Error cast : dest type = '" << T::getClassTypeName()
<< "' source name = '" << find->getName()
<< "' source type = '" << find->getTypeName() << "' in layout '" << mLayoutName << "'");
}
return;
}
}
MYGUI_ASSERT( ! _throw, "widget name '" << _name << "' in layout '" << mLayoutName << "' not found.");
}
void initialise(const std::string & _layout,
MyGUI::WidgetPtr _parent = nullptr)
{
const std::string MAIN_WINDOW = "_Main";
mLayoutName = _layout;
if (mLayoutName.empty())
mMainWidget = _parent;
else
{
mPrefix = MyGUI::utility::toString(this, "_");
mListWindowRoot = MyGUI::LayoutManager::getInstance().loadLayout(mLayoutName, mPrefix, _parent);
const std::string main_name = mPrefix + MAIN_WINDOW;
for (MyGUI::VectorWidgetPtr::iterator iter=mListWindowRoot.begin(); iter!=mListWindowRoot.end(); ++iter)
{
if ((*iter)->getName() == main_name)
{
mMainWidget = (*iter);
break;
}
}
MYGUI_ASSERT(mMainWidget, "root widget name '" << MAIN_WINDOW << "' in layout '" << mLayoutName << "' not found.");
}
}
void shutdown()
{
MyGUI::LayoutManager::getInstance().unloadLayout(mListWindowRoot);
mListWindowRoot.clear();
}
void setCoord(int x, int y, int w, int h)
{
mMainWidget->setCoord(x,y,w,h);
}
void setVisible(bool b)
{
mMainWidget->setVisible(b);
}
void setText(const std::string& name, const std::string& caption)
{
MyGUI::WidgetPtr pt;
getWidget(pt, name);
pt->setCaption(caption);
}
void setTextColor(const std::string& name, float r, float g, float b)
{
MyGUI::WidgetPtr pt;
getWidget(pt, name);
MyGUI::StaticText *st = dynamic_cast<MyGUI::StaticText*>(pt);
if(st != NULL)
st->setTextColour(MyGUI::Colour(b,g,r));
}
void setImage(const std::string& name, const std::string& imgName)
{
MyGUI::StaticImagePtr pt;
getWidget(pt, name);
pt->setImageTexture(imgName);
}
protected:
MyGUI::WidgetPtr mMainWidget;
std::string mPrefix;
std::string mLayoutName;
MyGUI::VectorWidgetPtr mListWindowRoot;
};
}
#endif

@ -1,43 +0,0 @@
#include <MyGUI.h>
#include <MyGUI_OgrePlatform.h>
#include <assert.h>
#include "manager.hpp"
using namespace GUI;
void MyGUIManager::setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging)
{
assert(wnd);
assert(mgr);
using namespace MyGUI;
// Enable/disable MyGUI logging to stdout. (Logging to MyGUI.log is
// still enabled.) In order to do this we have to initialize the log
// manager before the main gui system itself, otherwise the main
// object will get the chance to spit out a few messages before we
// can able to disable it.
LogManager::initialise();
LogManager::setSTDOutputEnabled(logging);
// Set up OGRE platform. We might make this more generic later.
mPlatform = new OgrePlatform();
mPlatform->initialise(wnd, mgr);
// Create GUI
mGui = new Gui();
mGui->initialise();
}
void MyGUIManager::shutdown()
{
if(mGui) delete mGui;
if(mPlatform)
{
mPlatform->shutdown();
delete mPlatform;
}
mGui = NULL;
mPlatform = NULL;
}

@ -1,33 +0,0 @@
#ifndef ENGINE_MYGUI_MANAGER_H
#define ENGINE_MYGUI_MANAGER_H
namespace MyGUI
{
class OgrePlatform;
class Gui;
}
namespace Ogre
{
class RenderWindow;
class SceneManager;
}
namespace GUI
{
class MyGUIManager
{
MyGUI::OgrePlatform *mPlatform;
MyGUI::Gui *mGui;
public:
MyGUIManager() : mPlatform(NULL), mGui(NULL) {}
MyGUIManager(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging=false)
{ setup(wnd,mgr,logging); }
~MyGUIManager() { shutdown(); }
void setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging=false);
void shutdown();
};
}
#endif

@ -1,75 +0,0 @@
#ifndef _INPUT_DISPATCHMAP_H
#define _INPUT_DISPATCHMAP_H
#include <set>
#include <map>
#include <assert.h>
namespace Input {
/**
DispatchMap is a simple connection system that connects incomming
signals with outgoing signals.
The signals can be connected one-to-one, many-to-one, one-to-many
or many-to-many.
The dispatch map is completely system agnostic. It is a pure data
structure and all signals are just integer indices. It does not
delegate any actions, but used together with Dispatcher it can be
used to build an event system.
*/
struct DispatchMap
{
typedef std::set<int> OutList;
typedef std::map<int, OutList> InMap;
typedef OutList::iterator Oit;
typedef InMap::iterator Iit;
InMap map;
void bind(int in, int out)
{
map[in].insert(out);
}
void unbind(int in, int out)
{
Iit it = map.find(in);
if(it != map.end())
{
it->second.erase(out);
// If there are no more elements, then remove the entire list
if(it->second.empty())
map.erase(it);
}
}
/// Check if a given input is bound to anything
bool isBound(int in) const
{
return map.find(in) != map.end();
}
/**
Get the list of outputs bound to the given input. Only call this
on inputs that you know are bound to something.
The returned set is only intended for immediate iteration. Do not
store references to it.
*/
const OutList &getList(int in) const
{
assert(isBound(in));
InMap::const_iterator it = map.find(in);
assert(it != map.end());
const OutList &out = it->second;
assert(!out.empty());
return out;
}
};
}
#endif

@ -1,44 +0,0 @@
#ifndef _INPUT_DISPATCHER_H
#define _INPUT_DISPATCHER_H
#include "dispatch_map.hpp"
#include "func_binder.hpp"
namespace Input {
struct Dispatcher
{
DispatchMap map;
FuncBinder funcs;
/**
Constructor. Takes the number of actions and passes it to
FuncBinder.
*/
Dispatcher(int actions) : funcs(actions) {}
void bind(int in, int out) { map.bind(in, out); }
void unbind(int in, int out) { map.unbind(in, out); }
bool isBound(int in) const { return map.isBound(in); }
/**
Instigate an event. It is translated through the dispatch map and
sent to the function bindings.
*/
typedef DispatchMap::OutList _O;
void event(int index, const void* p=NULL) const
{
// No bindings, nothing happens
if(!isBound(index))
return;
// Get the mapped actions and execute them
const _O &list = map.getList(index);
_O::const_iterator it;
for(it = list.begin(); it != list.end(); it++)
funcs.call(*it, p);
}
};
}
#endif

@ -1,104 +0,0 @@
#ifndef _INPUT_FUNCBINDER_H
#define _INPUT_FUNCBINDER_H
#include <string>
#include <vector>
#include <boost/function.hpp>
#include <assert.h>
namespace Input {
/**
An Action defines the user defined action corresponding to a
binding.
The first parameter is the action index that invoked this call. You
can assign the same function to multiple actions, and this can help
you keep track of which action was invoked.
The second parameter is an optional user-defined parameter,
represented by a void pointer. In many cases it is practical to
point this to temporaries (stack values), so make sure not to store
permanent references to it unless you've planning for this on the
calling side as well.
*/
typedef boost::function<void(int,const void*)> Action;
/**
The FuncBinder is a simple struct that binds user-defined indices
to functions. It is useful for binding eg. keyboard events to
specific actions in your program, but can potentially have many
other uses as well.
*/
class FuncBinder
{
struct FuncBinding
{
std::string name;
Action action;
};
std::vector<FuncBinding> bindings;
public:
/**
Constructor. Initialize the struct by telling it how many action
indices you intend to bind.
The indices you use should be 0 <= i < number.
*/
FuncBinder(int number) : bindings(number) {}
/**
Bind an action to an index.
*/
void bind(int index, Action action, const std::string &name="")
{
assert(index >= 0 && index < (int)bindings.size());
FuncBinding &fb = bindings[index];
fb.action = action;
fb.name = name;
}
/**
Unbind an index, reverting a previous bind().
*/
void unbind(int index)
{
assert(index >= 0 && index < (int)bindings.size());
bindings[index] = FuncBinding();
}
/**
Call a specific action. Takes an optional parameter that is
passed to the action.
*/
void call(int index, const void *p=NULL) const
{
assert(index >= 0 && index < (int)bindings.size());
const FuncBinding &fb = bindings[index];
if(fb.action) fb.action(index, p);
}
/// Check if a given index is bound to anything
bool isBound(int index) const
{
assert(index >= 0 && index < (int)bindings.size());
return !bindings[index].action.empty();
}
/// Return the name associated with an action (empty if not bound)
const std::string &getName(int index) const
{
assert(index >= 0 && index < (int)bindings.size());
return bindings[index].name;
}
};
}
#endif

@ -1,113 +0,0 @@
#ifndef _INPUT_LISTENER_H
#define _INPUT_LISTENER_H
#include "oismanager.hpp"
#include "components/engine/ogre/renderer.hpp"
#include "dispatcher.hpp"
#include <OgreFrameListener.h>
#include <OgreRenderWindow.h>
namespace Input
{
struct InputListener : Ogre::FrameListener,
OIS::KeyListener,
OIS::MouseListener
{
InputListener(Render::OgreRenderer &rend,
Input::OISManager &input,
const Input::Dispatcher &_disp)
: disp(_disp), doExit(false)
{
// Set up component pointers
mWindow = rend.getWindow();
mMouse = input.mouse;
mKeyboard = input.keyboard;
assert(mKeyboard);
assert(mWindow);
// Add ourself to the managers
rend.getRoot() -> addFrameListener(this);
mKeyboard -> setEventCallback(this);
mMouse -> setEventCallback(this);
}
void setCamera(Ogre::Camera *cam) { camera = cam; }
// Call this to exit the main loop
void exitNow() { doExit = true; }
bool frameStarted(const Ogre::FrameEvent &evt)
{
if(mWindow->isClosed() || doExit)
return false;
// Capture keyboard and mouse events
mKeyboard->capture();
mMouse->capture();
return Ogre::FrameListener::frameStarted(evt);
}
bool keyPressed( const OIS::KeyEvent &arg )
{
// Pass the event to the dispatcher
disp.event(arg.key, &arg);
return true;
}
bool keyReleased( const OIS::KeyEvent &arg )
{
return true;
}
bool mouseMoved( const OIS::MouseEvent &arg )
{
using namespace Ogre;
assert(camera);
// Mouse sensitivity. Should be a config option later.
const float MS = 0.2f;
float x = arg.state.X.rel * MS;
float y = arg.state.Y.rel * MS;
camera->yaw(Degree(-x));
// The camera before pitching
Quaternion nopitch = camera->getOrientation();
camera->pitch(Degree(-y));
// Apply some failsafe measures against the camera flipping
// upside down. Is the camera close to pointing straight up or
// down?
if(camera->getUp()[1] <= 0.1)
// If so, undo the last pitch
camera->setOrientation(nopitch);
return true;
}
bool mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id )
{
return true;
}
bool mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id )
{
return true;
}
private:
const Dispatcher &disp;
Ogre::RenderWindow *mWindow;
Ogre::Camera *camera;
OIS::Mouse *mMouse;
OIS::Keyboard *mKeyboard;
bool doExit;
};
}
#endif

@ -1,89 +0,0 @@
#include "oismanager.hpp"
#include <assert.h>
#include <string>
#include <sstream>
#include <iostream>
#include "OgreRenderWindow.h"
#ifdef __APPLE_CC__
#include <Carbon/Carbon.h>
#endif
using namespace Input;
using namespace Ogre;
using namespace OIS;
using namespace std;
OISManager::OISManager(Render::OgreRenderer &rend, bool debug)
{
RenderWindow *window = rend.getWindow();
assert(window);
size_t windowHnd;
window->getCustomAttribute("WINDOW", &windowHnd);
std::ostringstream windowHndStr;
ParamList pl;
windowHndStr << windowHnd;
pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
// Non-exclusive mouse and keyboard input in debug mode. Debug mode
// isn't implemented yet though.
if(debug)
{
#if defined OIS_WIN32_PLATFORM
pl.insert(std::make_pair(std::string("w32_mouse"),
std::string("DISCL_FOREGROUND" )));
pl.insert(std::make_pair(std::string("w32_mouse"),
std::string("DISCL_NONEXCLUSIVE")));
pl.insert(std::make_pair(std::string("w32_keyboard"),
std::string("DISCL_FOREGROUND")));
pl.insert(std::make_pair(std::string("w32_keyboard"),
std::string("DISCL_NONEXCLUSIVE")));
#elif defined OIS_LINUX_PLATFORM
pl.insert(std::make_pair(std::string("x11_mouse_grab"),
std::string("false")));
pl.insert(std::make_pair(std::string("x11_mouse_hide"),
std::string("false")));
pl.insert(std::make_pair(std::string("x11_keyboard_grab"),
std::string("false")));
pl.insert(std::make_pair(std::string("XAutoRepeatOn"),
std::string("true")));
#endif
}
#ifdef __APPLE_CC__
// Give the application window focus to receive input events
ProcessSerialNumber psn = { 0, kCurrentProcess };
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
SetFrontProcess(&psn);
#endif
inputMgr = InputManager::createInputSystem( pl );
// Create all devices
keyboard = static_cast<Keyboard*>(inputMgr->createInputObject
( OISKeyboard, true ));
mouse = static_cast<Mouse*>(inputMgr->createInputObject
( OISMouse, true ));
// Set mouse region
const MouseState &ms = mouse->getMouseState();
ms.width = window->getWidth();
ms.height = window->getHeight();
}
OISManager::~OISManager()
{
if(inputMgr == NULL) return;
// Kill the input systems. This will reset input options such as key
// repetition.
inputMgr->destroyInputObject(keyboard);
inputMgr->destroyInputObject(mouse);
InputManager::destroyInputSystem(inputMgr);
inputMgr = NULL;
}

@ -1,19 +0,0 @@
#ifndef _INPUT_OISMANAGER_H
#define _INPUT_OISMANAGER_H
#include "components/engine/ogre/renderer.hpp"
#include <OIS/OIS.h>
namespace Input
{
struct OISManager
{
OIS::InputManager *inputMgr;
OIS::Mouse *mouse;
OIS::Keyboard *keyboard;
OISManager(Render::OgreRenderer &rend, bool debug);
~OISManager();
};
}
#endif

@ -1,51 +0,0 @@
#ifndef _INPUT_POLLER_H
#define _INPUT_POLLER_H
#include "dispatch_map.hpp"
#include "oismanager.hpp"
namespace Input {
/** The poller is used to check (poll) for keys rather than waiting
for events. TODO: Might make this OIS-independent later. */
struct Poller
{
DispatchMap map;
OIS::Keyboard *keyboard;
Poller(Input::OISManager &ois)
{
keyboard = ois.keyboard;
assert(keyboard);
}
/** Bind or unbind a given action with a key. The action is the first
parameter, the key is the second.
*/
void bind(int in, int out) { map.bind(in, out); }
void unbind(int in, int out) { map.unbind(in, out); }
bool isBound(int in) const { return map.isBound(in); }
/// Check whether a given action button is currently pressed.
typedef DispatchMap::OutList _O;
bool isDown(int index) const
{
assert(keyboard);
// No bindings, no action
if(!isBound(index))
return false;
// Get all the keys bound to this action, and check them.
const _O &list = map.getList(index);
_O::const_iterator it;
for(it = list.begin(); it != list.end(); it++)
// If there's any match, we're good to go.
if(keyboard->isKeyDown((OIS::KeyCode)*it)) return true;
return false;
}
};
}
#endif

@ -1,12 +0,0 @@
GCC=g++
all: funcbind_test dispatch_map_test
funcbind_test: funcbind_test.cpp ../func_binder.hpp
$(GCC) $< -o $@
dispatch_map_test: dispatch_map_test.cpp ../dispatch_map.hpp
$(GCC) $< -o $@
clean:
rm *_test

@ -1,54 +0,0 @@
#include <iostream>
using namespace std;
#include "../dispatch_map.hpp"
using namespace Input;
typedef DispatchMap::OutList OutList;
typedef OutList::const_iterator Cit;
void showList(const DispatchMap::OutList &out)
{
for(Cit it = out.begin();
it != out.end(); it++)
{
cout << " " << *it << endl;
}
}
void showAll(DispatchMap &map)
{
cout << "\nPrinting everything:\n";
for(DispatchMap::Iit it = map.map.begin();
it != map.map.end(); it++)
{
cout << it->first << ":\n";
showList(map.getList(it->first));
}
}
int main()
{
cout << "Testing the dispatch map\n";
DispatchMap dsp;
dsp.bind(1,9);
dsp.bind(2,-5);
dsp.bind(2,9);
dsp.bind(3,10);
dsp.bind(3,12);
dsp.bind(3,10);
showAll(dsp);
dsp.unbind(1,9);
dsp.unbind(5,8);
dsp.unbind(3,11);
dsp.unbind(3,12);
dsp.unbind(3,12);
showAll(dsp);
return 0;
}

@ -1,47 +0,0 @@
#include <iostream>
using namespace std;
#include "../func_binder.hpp"
void f1(int i, const void *p)
{
cout << " F1 i=" << i << endl;
if(p)
cout << " Got a nice gift: "
<< *((const float*)p) << endl;
}
void f2(int i, const void *p)
{
cout << " F2 i=" << i << endl;
}
using namespace Input;
int main()
{
cout << "This will test the function binding system\n";
FuncBinder bnd(5);
bnd.bind(0, &f1, "This is action 1");
bnd.bind(1, &f2);
bnd.bind(2, &f1, "This is action 3");
bnd.bind(3, &f2, "This is action 4");
bnd.unbind(2);
for(int i=0; i<5; i++)
{
cout << "Calling " << i << ": '" << bnd.getName(i) << "'\n";
bnd.call(i);
if(!bnd.isBound(i)) cout << " (not bound)\n";
}
cout << "\nCalling with parameter:\n";
float f = 3.1415;
bnd.call(0, &f);
return 0;
}

@ -1,18 +0,0 @@
Testing the dispatch map
Printing everything:
1:
9
2:
-5
9
3:
10
12
Printing everything:
2:
-5
9
3:
10

@ -1,15 +0,0 @@
This will test the function binding system
Calling 0: 'This is action 1'
F1 i=0
Calling 1: ''
F2 i=1
Calling 2: ''
(not bound)
Calling 3: 'This is action 4'
F2 i=3
Calling 4: ''
(not bound)
Calling with parameter:
F1 i=0
Got a nice gift: 3.1415

@ -1,18 +0,0 @@
#!/bin/bash
make || exit
mkdir -p output
PROGS=*_test
for a in $PROGS; do
if [ -f "output/$a.out" ]; then
echo "Running $a:"
./$a | diff output/$a.out -
else
echo "Creating $a.out"
./$a > "output/$a.out"
git add "output/$a.out"
fi
done

@ -1,80 +0,0 @@
#include "renderer.hpp"
#include "OgreRoot.h"
#include "OgreRenderWindow.h"
#include "OgreLogManager.h"
#include "OgreLog.h"
#include <assert.h>
using namespace Ogre;
using namespace Render;
void OgreRenderer::cleanup()
{
if(mRoot)
delete mRoot;
mRoot = NULL;
}
void OgreRenderer::screenshot(const std::string &file)
{
mWindow->writeContentsToFile(file);
}
bool OgreRenderer::configure(bool showConfig,
const std::string &pluginCfg,
bool _logging)
{
// Set up logging first
new LogManager;
Log *log = LogManager::getSingleton().createLog("Ogre.log");
logging = _logging;
if(logging)
// Full log detail
log->setLogDetail(LL_BOREME);
else
// Disable logging
log->setDebugOutputEnabled(false);
mRoot = new Root(pluginCfg, "ogre.cfg", "");
// Show the configuration dialog and initialise the system, if the
// showConfig parameter is specified. The settings are stored in
// ogre.cfg. If showConfig is false, the settings are assumed to
// already exist in ogre.cfg.
int result;
if(showConfig)
result = mRoot->showConfigDialog();
else
result = mRoot->restoreConfig();
return !result;
}
void OgreRenderer::createWindow(const std::string &title)
{
assert(mRoot);
// Initialize OGRE window
mWindow = mRoot->initialise(true, title, "");
}
void OgreRenderer::createScene(const std::string camName, float fov, float nearClip)
{
assert(mRoot);
assert(mWindow);
// Get the SceneManager, in this case a generic one
mScene = mRoot->createSceneManager(ST_GENERIC);
// Create the camera
mCamera = mScene->createCamera(camName);
mCamera->setNearClipDistance(nearClip);
mCamera->setFOVy(Degree(fov));
// Create one viewport, entire window
mView = mWindow->addViewport(mCamera);
// Alter the camera aspect ratio to match the viewport
mCamera->setAspectRatio(Real(mView->getActualWidth()) / Real(mView->getActualHeight()));
}

@ -1,77 +0,0 @@
#ifndef _OGRE_RENDERER_H
#define _OGRE_RENDERER_H
/*
Ogre renderer class
*/
#include <OgreRoot.h>
#include <string>
namespace Ogre
{
class Root;
class RenderWindow;
class SceneManager;
class Camera;
class Viewport;
}
namespace Render
{
class OgreRenderer
{
Ogre::Root *mRoot;
Ogre::RenderWindow *mWindow;
Ogre::SceneManager *mScene;
Ogre::Camera *mCamera;
Ogre::Viewport *mView;
bool logging;
public:
OgreRenderer()
: mRoot(NULL), mWindow(NULL), mScene(NULL) {}
~OgreRenderer() { cleanup(); }
/** Configure the renderer. This will load configuration files and
set up the Root and logging classes. */
bool configure(bool showConfig, // Show config dialog box?
const std::string &pluginCfg, // plugin.cfg file
bool _logging); // Enable or disable logging
/// Create a window with the given title
void createWindow(const std::string &title);
/// Set up the scene manager, camera and viewport
void createScene(const std::string camName="Camera",// Camera name
float fov=55, // Field of view angle
float nearClip=5 // Near clip distance
);
/// Kill the renderer.
void cleanup();
/// Start the main rendering loop
void start() { mRoot->startRendering(); }
/// Write a screenshot to file
void screenshot(const std::string &file);
/// Get the Root
Ogre::Root *getRoot() { return mRoot; }
/// Get the rendering window
Ogre::RenderWindow *getWindow() { return mWindow; }
/// Get the scene manager
Ogre::SceneManager *getScene() { return mScene; }
/// Camera
Ogre::Camera *getCamera() { return mCamera; }
/// Viewport
Ogre::Viewport *getViewport() { return mView; }
};
}
#endif

@ -1,7 +1,7 @@
#ifndef MWGUI_LAYOUTS_H
#define MWGUI_LAYOUTS_H
#include <components/engine/gui/layout.hpp>
#include <openengine/gui/layout.hpp>
/*
This file contains classes corresponding to all the window layouts
@ -18,7 +18,7 @@
namespace MWGUI
{
class HUD : public GUI::Layout
class HUD : public OEngine::GUI::Layout
{
public:
HUD(int width, int height)
@ -103,7 +103,7 @@ namespace MWGUI
MyGUI::StaticImagePtr crosshair;
};
class MapWindow : public GUI::Layout
class MapWindow : public OEngine::GUI::Layout
{
public:
MapWindow()
@ -123,7 +123,7 @@ namespace MWGUI
}
};
class MainMenu : public GUI::Layout
class MainMenu : public OEngine::GUI::Layout
{
public:
MainMenu(int w, int h)
@ -133,7 +133,7 @@ namespace MWGUI
}
};
class StatsWindow : public GUI::Layout
class StatsWindow : public OEngine::GUI::Layout
{
public:
void setBar(const char* name, const char* tname, int val, int max)

@ -1 +1 @@
Subproject commit 5333b8e230e285e9183b0639188283bdbc15af6c
Subproject commit 69a56e867749944dc0e86b9ef5c54bac4339b454
Loading…
Cancel
Save