Added camera and scene, started adding input. MISSING FindOIS.cmake!
parent
4d8040f96c
commit
855ca8ee74
@ -0,0 +1,50 @@
|
||||
#include "mwscene.hpp"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
using namespace Render;
|
||||
using namespace Ogre;
|
||||
|
||||
void MWScene::setup(OgreRenderer *_rend)
|
||||
{
|
||||
rend = _rend;
|
||||
assert(rend);
|
||||
|
||||
Root *root = rend->getRoot();
|
||||
RenderWindow *window = rend->getWindow();
|
||||
|
||||
// Get the SceneManager, in this case a generic one
|
||||
sceneMgr = root->createSceneManager(ST_GENERIC);
|
||||
|
||||
// Create the camera
|
||||
camera = sceneMgr->createCamera("PlayerCam");
|
||||
|
||||
camera->setNearClipDistance(5);
|
||||
|
||||
// Create one viewport, entire window
|
||||
vp = window->addViewport(camera);
|
||||
// Give the backround a healthy shade of green
|
||||
vp->setBackgroundColour(ColourValue(0,0.1,0));
|
||||
|
||||
// Alter the camera aspect ratio to match the viewport
|
||||
camera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
|
||||
camera->setFOVy(Degree(55));
|
||||
|
||||
// Set default mipmap level (NB some APIs ignore this)
|
||||
TextureManager::getSingleton().setDefaultNumMipmaps(5);
|
||||
|
||||
// Load resources
|
||||
ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
|
||||
|
||||
// Turn the entire scene (represented by the 'root' node) -90
|
||||
// degrees around the x axis. This makes Z go upwards, and Y go into
|
||||
// the screen (when x is to the right.) This is the orientation that
|
||||
// Morrowind uses, and it automagically makes everything work as it
|
||||
// should.
|
||||
SceneNode *rt = sceneMgr->getRootSceneNode();
|
||||
mwRoot = rt->createChildSceneNode();
|
||||
mwRoot->pitch(Degree(-90));
|
||||
|
||||
// For testing
|
||||
sceneMgr->setAmbientLight(ColourValue(1,1,1));
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
#ifndef _GAME_RENDER_MWSCENE_H
|
||||
#define _GAME_RENDER_MWSCENE_H
|
||||
|
||||
#include "ogre/renderer.hpp"
|
||||
|
||||
namespace Render
|
||||
{
|
||||
/** Class responsible for Morrowind-specific interfaces to OGRE.
|
||||
*/
|
||||
class MWScene
|
||||
{
|
||||
OgreRenderer *rend;
|
||||
Ogre::SceneManager *sceneMgr;
|
||||
Ogre::Camera *camera;
|
||||
Ogre::Viewport *vp;
|
||||
|
||||
// Root node for all objects added to the scene. This is rotated so
|
||||
// that the OGRE coordinate system matches that used internally in
|
||||
// Morrowind.
|
||||
Ogre::SceneNode *mwRoot;
|
||||
|
||||
public:
|
||||
void setup(OgreRenderer *_rend);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,83 @@
|
||||
#include "oismanager.hpp"
|
||||
#include <assert.h>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
using namespace Input;
|
||||
using namespace Ogre;
|
||||
using namespace OIS;
|
||||
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
void OISManager::setup(Render::OgreRenderer *rend)
|
||||
{
|
||||
assert(rend);
|
||||
|
||||
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
|
||||
if(true)
|
||||
{
|
||||
#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
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
/*
|
||||
// Register the input listener
|
||||
keyboard -> setEventCallback( &mInput );
|
||||
mouse -> setEventCallback( &mInput );
|
||||
*/
|
||||
}
|
||||
|
||||
void OISManager::cleanup()
|
||||
{
|
||||
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;
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#ifndef _INPUT_OISMANAGER_H
|
||||
#define _INPUT_OISMANAGER_H
|
||||
|
||||
#include "ogre/renderer.hpp"
|
||||
#include <OIS/OIS.h>
|
||||
|
||||
namespace Input
|
||||
{
|
||||
class OISManager
|
||||
{
|
||||
OIS::InputManager *inputMgr;
|
||||
OIS::Mouse *mouse;
|
||||
OIS::Keyboard *keyboard;
|
||||
|
||||
public:
|
||||
void setup(Render::OgreRenderer *rend);
|
||||
void cleanup();
|
||||
};
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue