forked from teamnwah/openmw-tes3coop
Merge commit 'ape/master'
Conflicts: apps/openmw/mwworld/world.hpp
This commit is contained in:
commit
5827591d05
6 changed files with 87 additions and 0 deletions
|
@ -3,6 +3,7 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include <components/misc/fileops.hpp>
|
#include <components/misc/fileops.hpp>
|
||||||
#include <components/bsa/bsa_archive.hpp>
|
#include <components/bsa/bsa_archive.hpp>
|
||||||
|
@ -70,6 +71,15 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
|
||||||
// update actors
|
// update actors
|
||||||
mEnvironment.mMechanicsManager->update();
|
mEnvironment.mMechanicsManager->update();
|
||||||
|
|
||||||
|
if (focusFrameCounter++ == focusUpdateFrame)
|
||||||
|
{
|
||||||
|
std::pair<std::string, float> handle = mEnvironment.mWorld->getMWScene()->getFacedHandle();
|
||||||
|
|
||||||
|
std::cout << "Object: " << handle.first << ", distance: " << handle.second << std::endl;
|
||||||
|
|
||||||
|
focusFrameCounter = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,6 +243,8 @@ void OMW::Engine::go()
|
||||||
MWInput::MWInputManager input(mOgre, mEnvironment.mWorld->getPlayerPos(),
|
MWInput::MWInputManager input(mOgre, mEnvironment.mWorld->getPlayerPos(),
|
||||||
*mEnvironment.mWindowManager, mDebug);
|
*mEnvironment.mWindowManager, mDebug);
|
||||||
|
|
||||||
|
focusFrameCounter = 0;
|
||||||
|
|
||||||
std::cout << "\nPress Q/ESC or close window to exit.\n";
|
std::cout << "\nPress Q/ESC or close window to exit.\n";
|
||||||
|
|
||||||
mOgre.getRoot()->addFrameListener (this);
|
mOgre.getRoot()->addFrameListener (this);
|
||||||
|
|
|
@ -65,6 +65,9 @@ namespace OMW
|
||||||
Compiler::Context *mScriptContext;
|
Compiler::Context *mScriptContext;
|
||||||
OEngine::GUI::MyGUIManager *mGuiManager;
|
OEngine::GUI::MyGUIManager *mGuiManager;
|
||||||
|
|
||||||
|
int focusFrameCounter;
|
||||||
|
static const int focusUpdateFrame = 10;
|
||||||
|
|
||||||
// not implemented
|
// not implemented
|
||||||
Engine (const Engine&);
|
Engine (const Engine&);
|
||||||
Engine& operator= (const Engine&);
|
Engine& operator= (const Engine&);
|
||||||
|
|
|
@ -41,6 +41,8 @@ namespace MWInput
|
||||||
A_MoveForward, // Forward / Backward
|
A_MoveForward, // Forward / Backward
|
||||||
A_MoveBackward,
|
A_MoveBackward,
|
||||||
|
|
||||||
|
A_Activate,
|
||||||
|
|
||||||
A_LAST // Marker for the last item
|
A_LAST // Marker for the last item
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -133,6 +135,11 @@ namespace MWInput
|
||||||
else setGuiMode(GM_Console);
|
else setGuiMode(GM_Console);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void activate()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Exit program now button (which is disabled in GUI mode)
|
// Exit program now button (which is disabled in GUI mode)
|
||||||
void exitNow()
|
void exitNow()
|
||||||
{
|
{
|
||||||
|
@ -170,6 +177,8 @@ namespace MWInput
|
||||||
"Toggle inventory screen");
|
"Toggle inventory screen");
|
||||||
disp->funcs.bind(A_Console, boost::bind(&InputImpl::toggleConsole, this),
|
disp->funcs.bind(A_Console, boost::bind(&InputImpl::toggleConsole, this),
|
||||||
"Toggle console");
|
"Toggle console");
|
||||||
|
disp->funcs.bind(A_Activate, boost::bind(&InputImpl::activate, this),
|
||||||
|
"Activate");
|
||||||
|
|
||||||
|
|
||||||
// Add the exit listener
|
// Add the exit listener
|
||||||
|
@ -212,6 +221,7 @@ namespace MWInput
|
||||||
disp->bind(A_Screenshot, KC_SYSRQ);
|
disp->bind(A_Screenshot, KC_SYSRQ);
|
||||||
disp->bind(A_Inventory, KC_I);
|
disp->bind(A_Inventory, KC_I);
|
||||||
disp->bind(A_Console, KC_F1);
|
disp->bind(A_Console, KC_F1);
|
||||||
|
disp->bind(A_Activate, KC_SPACE);
|
||||||
|
|
||||||
// Key bindings for polled keys
|
// Key bindings for polled keys
|
||||||
|
|
||||||
|
@ -257,6 +267,7 @@ namespace MWInput
|
||||||
if(moveX != 0 || moveY != 0 || moveZ != 0)
|
if(moveX != 0 || moveY != 0 || moveZ != 0)
|
||||||
player.moveRel(moveX, moveY, moveZ);
|
player.moveRel(moveX, moveY, moveZ);
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -31,4 +31,53 @@ MWScene::MWScene(OEngine::Render::OgreRenderer &_rend)
|
||||||
SceneNode *rt = rend.getScene()->getRootSceneNode();
|
SceneNode *rt = rend.getScene()->getRootSceneNode();
|
||||||
mwRoot = rt->createChildSceneNode();
|
mwRoot = rt->createChildSceneNode();
|
||||||
mwRoot->pitch(Degree(-90));
|
mwRoot->pitch(Degree(-90));
|
||||||
|
|
||||||
|
//used to obtain ingame information of ogre objects (which are faced or selected)
|
||||||
|
mRaySceneQuery = rend.getScene()->createRayQuery(Ray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::pair<std::string, float> MWScene::getFacedHandle()
|
||||||
|
{
|
||||||
|
std::string handle = "";
|
||||||
|
float distance = -1;
|
||||||
|
|
||||||
|
//get a ray pointing to the center of the viewport
|
||||||
|
Ray centerRay = getCamera()->getCameraToViewportRay(
|
||||||
|
getViewport()->getWidth()/2,
|
||||||
|
getViewport()->getHeight()/2);
|
||||||
|
|
||||||
|
// get all objects touched by the ray
|
||||||
|
getRaySceneQuery()->setRay (centerRay );
|
||||||
|
RaySceneQueryResult &result = getRaySceneQuery()->execute();
|
||||||
|
|
||||||
|
RaySceneQueryResult::iterator nearest = result.end();
|
||||||
|
|
||||||
|
for (RaySceneQueryResult::iterator itr = result.begin();
|
||||||
|
itr != result.end(); itr++ )
|
||||||
|
{
|
||||||
|
// there seem to be omnipresent objects like the caelum sky dom,
|
||||||
|
// the distance of these objects is always 0 so this if excludes these
|
||||||
|
// TODO: Check if the object can be focused (ignore walls etc..
|
||||||
|
// in this state of openmw not possible)
|
||||||
|
if ( itr->movable && itr->distance >= 0.1)
|
||||||
|
{
|
||||||
|
if ( nearest == result.end() ) //if no object is set
|
||||||
|
{
|
||||||
|
nearest = itr;
|
||||||
|
}
|
||||||
|
else if ( itr->distance < nearest->distance )
|
||||||
|
{
|
||||||
|
nearest = itr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( nearest != result.end() )
|
||||||
|
{
|
||||||
|
handle = nearest->movable->getParentSceneNode()->getName();
|
||||||
|
distance = nearest->distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::pair<std::string, float>(handle, distance);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef _GAME_RENDER_MWSCENE_H
|
#ifndef _GAME_RENDER_MWSCENE_H
|
||||||
#define _GAME_RENDER_MWSCENE_H
|
#define _GAME_RENDER_MWSCENE_H
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
#include <openengine/ogre/renderer.hpp>
|
#include <openengine/ogre/renderer.hpp>
|
||||||
|
|
||||||
namespace Ogre
|
namespace Ogre
|
||||||
|
@ -9,6 +10,7 @@ namespace Ogre
|
||||||
class Viewport;
|
class Viewport;
|
||||||
class SceneManager;
|
class SceneManager;
|
||||||
class SceneNode;
|
class SceneNode;
|
||||||
|
class RaySceneQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
|
@ -26,6 +28,7 @@ namespace MWRender
|
||||||
// that the OGRE coordinate system matches that used internally in
|
// that the OGRE coordinate system matches that used internally in
|
||||||
// Morrowind.
|
// Morrowind.
|
||||||
Ogre::SceneNode *mwRoot;
|
Ogre::SceneNode *mwRoot;
|
||||||
|
Ogre::RaySceneQuery *mRaySceneQuery;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MWScene(OEngine::Render::OgreRenderer &_rend);
|
MWScene(OEngine::Render::OgreRenderer &_rend);
|
||||||
|
@ -34,6 +37,13 @@ namespace MWRender
|
||||||
Ogre::SceneNode *getRoot() { return mwRoot; }
|
Ogre::SceneNode *getRoot() { return mwRoot; }
|
||||||
Ogre::SceneManager *getMgr() { return rend.getScene(); }
|
Ogre::SceneManager *getMgr() { return rend.getScene(); }
|
||||||
Ogre::Viewport *getViewport() { return rend.getViewport(); }
|
Ogre::Viewport *getViewport() { return rend.getViewport(); }
|
||||||
|
Ogre::RaySceneQuery *getRaySceneQuery() { return mRaySceneQuery; }
|
||||||
|
|
||||||
|
//gets the handle of the object the player is looking at
|
||||||
|
//pair<name, distance>
|
||||||
|
//name is empty and distance = -1 if there is no object which
|
||||||
|
//can be faced
|
||||||
|
std::pair<std::string, float> getFacedHandle();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,8 @@ namespace MWWorld
|
||||||
|
|
||||||
~World();
|
~World();
|
||||||
|
|
||||||
|
MWRender::MWScene* getMWScene() { return &mScene; }
|
||||||
|
|
||||||
MWRender::PlayerPos& getPlayerPos();
|
MWRender::PlayerPos& getPlayerPos();
|
||||||
|
|
||||||
ESMS::ESMStore& getStore();
|
ESMS::ESMStore& getStore();
|
||||||
|
|
Loading…
Reference in a new issue