Merge branch 'externalrendering' of https://github.com/zinnschlag/openmw into characterpreview

Conflicts:
	apps/openmw/CMakeLists.txt
	apps/openmw/mwbase/world.hpp
	apps/openmw/mwrender/renderingmanager.cpp
	apps/openmw/mwrender/renderingmanager.hpp
	apps/openmw/mwworld/worldimp.cpp
	apps/openmw/mwworld/worldimp.hpp
actorid
scrawl 12 years ago
commit 2793096b50

@ -16,7 +16,7 @@ source_group(game FILES ${GAME} ${GAME_HEADER})
add_openmw_dir (mwrender add_openmw_dir (mwrender
renderingmanager debugging sky player animation npcanimation creatureanimation actors objects renderingmanager debugging sky player animation npcanimation creatureanimation actors objects
renderinginterface localmap occlusionquery terrain terrainmaterial water shadows renderinginterface localmap occlusionquery terrain terrainmaterial water shadows
compositors characterpreview compositors characterpreview externalrendering
) )
add_openmw_dir (mwinput add_openmw_dir (mwinput

@ -35,6 +35,11 @@ namespace ESMS
struct ESMStore; struct ESMStore;
} }
namespace MWRender
{
class ExternalRendering;
}
namespace MWWorld namespace MWWorld
{ {
class CellStore; class CellStore;
@ -271,10 +276,8 @@ namespace MWBase
virtual void togglePlayerLooking(bool enable) = 0; virtual void togglePlayerLooking(bool enable) = 0;
virtual void renderPlayer() = 0; virtual void renderPlayer() = 0;
virtual void updateCharacterPreview(int sizeX, int sizeY) = 0; virtual void setupExternalRendering (MWRender::ExternalRendering& rendering) = 0;
virtual void updateRaceSelectionPreview(float angle) = 0;
virtual MWWorld::Ptr getCharacterPreviewItemSelected(int posX, int posY) = 0;
}; };
} }

@ -46,6 +46,7 @@ namespace MWGui
, mTrading(false) , mTrading(false)
, mLastXSize(0) , mLastXSize(0)
, mLastYSize(0) , mLastYSize(0)
, mPreview(MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer ())
{ {
static_cast<MyGUI::Window*>(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &InventoryWindow::onWindowResize); static_cast<MyGUI::Window*>(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &InventoryWindow::onWindowResize);
@ -79,6 +80,8 @@ namespace MWGui
setCoord(0, 342, 498, 258); setCoord(0, 342, 498, 258);
MWBase::Environment::get().getWorld ()->setupExternalRendering (mPreview);
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
openContainer(player); openContainer(player);
} }
@ -189,11 +192,11 @@ namespace MWGui
MyGUI::IntPoint relPos = mousePos - mAvatar->getAbsolutePosition (); MyGUI::IntPoint relPos = mousePos - mAvatar->getAbsolutePosition ();
int realX = int(float(relPos.left) / float(mAvatar->getSize().width) * 512.f ); int realX = int(float(relPos.left) / float(mAvatar->getSize().width) * 512.f );
int realY = int(float(relPos.top) / float(mAvatar->getSize().height) * 1024.f ); int realY = int(float(relPos.top) / float(mAvatar->getSize().height) * 1024.f );
MWWorld::Ptr itemSelected = MWBase::Environment::get().getWorld ()->getCharacterPreviewItemSelected (realX, realY);
MWWorld::Ptr itemSelected = getAvatarSelectedItem (realX, realY);
if (itemSelected.isEmpty ()) if (itemSelected.isEmpty ())
return; return;
for (unsigned int i=0; i < mContainerWidget->getChildCount (); ++i) for (unsigned int i=0; i < mContainerWidget->getChildCount (); ++i)
{ {
MyGUI::Widget* w = mContainerWidget->getChildAt (i); MyGUI::Widget* w = mContainerWidget->getChildAt (i);
@ -207,6 +210,21 @@ namespace MWGui
} }
} }
MWWorld::Ptr InventoryWindow::getAvatarSelectedItem(int x, int y)
{
int slot = mPreview.getSlotSelected (x, y);
if (slot == -1)
return MWWorld::Ptr();
MWWorld::Ptr player = mPtr;
MWWorld::InventoryStore& invStore = MWWorld::Class::get(player).getInventoryStore(player);
if (invStore.getSlot(slot) != invStore.end())
return *invStore.getSlot (slot);
else
return MWWorld::Ptr();
}
std::vector<MWWorld::Ptr> InventoryWindow::getEquippedItems() std::vector<MWWorld::Ptr> InventoryWindow::getEquippedItems()
{ {
MWWorld::InventoryStore& invStore = MWWorld::Class::get(mPtr).getInventoryStore(mPtr); MWWorld::InventoryStore& invStore = MWWorld::Class::get(mPtr).getInventoryStore(mPtr);
@ -293,7 +311,7 @@ namespace MWGui
MyGUI::IntSize size = mAvatar->getSize(); MyGUI::IntSize size = mAvatar->getSize();
MWBase::Environment::get().getWorld()->updateCharacterPreview (size.width, size.height); mPreview.update (size.width, size.height);
mAvatarImage->setSize(MyGUI::IntSize(std::max(mAvatar->getSize().width, 512), std::max(mAvatar->getSize().height, 1024))); mAvatarImage->setSize(MyGUI::IntSize(std::max(mAvatar->getSize().width, 512), std::max(mAvatar->getSize().height, 1024)));
mAvatarImage->setImageTexture("CharacterPreview"); mAvatarImage->setImageTexture("CharacterPreview");
} }

@ -1,6 +1,8 @@
#ifndef MGUI_Inventory_H #ifndef MGUI_Inventory_H
#define MGUI_Inventory_H #define MGUI_Inventory_H
#include "../mwrender/characterpreview.hpp"
#include "container.hpp" #include "container.hpp"
#include "window_pinnable_base.hpp" #include "window_pinnable_base.hpp"
@ -24,6 +26,8 @@ namespace MWGui
MyGUI::IntCoord getAvatarScreenCoord(); MyGUI::IntCoord getAvatarScreenCoord();
MWWorld::Ptr getAvatarSelectedItem(int x, int y);
protected: protected:
MyGUI::Widget* mAvatar; MyGUI::Widget* mAvatar;
MyGUI::ImageBox* mAvatarImage; MyGUI::ImageBox* mAvatarImage;
@ -43,6 +47,7 @@ namespace MWGui
int mLastXSize; int mLastXSize;
int mLastYSize; int mLastYSize;
MWRender::InventoryPreview mPreview;
bool mTrading; bool mTrading;

@ -33,7 +33,8 @@ RaceDialog::RaceDialog(MWBase::WindowManager& parWindowManager)
setText("AppearanceT", mWindowManager.getGameSettingString("sRaceMenu1", "Appearance")); setText("AppearanceT", mWindowManager.getGameSettingString("sRaceMenu1", "Appearance"));
getWidget(mPreviewImage, "PreviewImage"); getWidget(mPreviewImage, "PreviewImage");
MWBase::Environment::get().getWorld ()->updateRaceSelectionPreview (0); MWBase::Environment::get().getWorld ()->setupExternalRendering (mPreview);
mPreview.update (0);
mPreviewImage->setImageTexture ("CharacterHeadPreview"); mPreviewImage->setImageTexture ("CharacterHeadPreview");
@ -153,7 +154,7 @@ void RaceDialog::onHeadRotate(MyGUI::ScrollBar*, size_t _position)
{ {
float angle = (float(_position) / 49.f - 0.5) * 3.14 * 2; float angle = (float(_position) / 49.f - 0.5) * 3.14 * 2;
float diff = angle - mCurrentAngle; float diff = angle - mCurrentAngle;
MWBase::Environment::get().getWorld ()->updateRaceSelectionPreview (diff); mPreview.update (diff);
mCurrentAngle += diff; mCurrentAngle += diff;
} }

@ -1,11 +1,15 @@
#ifndef MWGUI_RACE_H #ifndef MWGUI_RACE_H
#define MWGUI_RACE_H #define MWGUI_RACE_H
#include <boost/array.hpp>
#include <components/esm_store/store.hpp> #include <components/esm_store/store.hpp>
#include "../mwrender/characterpreview.hpp"
#include "window_base.hpp" #include "window_base.hpp"
#include <boost/array.hpp>
namespace MWGui namespace MWGui
{ {
@ -89,6 +93,8 @@ namespace MWGui
std::string mCurrentRaceId; std::string mCurrentRaceId;
float mCurrentAngle; float mCurrentAngle;
MWRender::RaceSelectionPreview mPreview;
}; };
} }
#endif #endif

@ -174,7 +174,7 @@ void ToolTips::onFrame(float frameDuration)
MyGUI::IntPoint relMousePos = MyGUI::InputManager::getInstance ().getMousePosition () - MyGUI::IntPoint(avatarPos.left, avatarPos.top); MyGUI::IntPoint relMousePos = MyGUI::InputManager::getInstance ().getMousePosition () - MyGUI::IntPoint(avatarPos.left, avatarPos.top);
int realX = int(float(relMousePos.left) / float(avatarPos.width) * 512.f ); int realX = int(float(relMousePos.left) / float(avatarPos.width) * 512.f );
int realY = int(float(relMousePos.top) / float(avatarPos.height) * 1024.f ); int realY = int(float(relMousePos.top) / float(avatarPos.height) * 1024.f );
MWWorld::Ptr item = MWBase::Environment::get().getWorld ()->getCharacterPreviewItemSelected (realX, realY); MWWorld::Ptr item = mWindowManager->getInventoryWindow ()->getAvatarSelectedItem (realX, realY);
mFocusObject = item; mFocusObject = item;
if (!mFocusObject.isEmpty ()) if (!mFocusObject.isEmpty ())

@ -25,7 +25,7 @@ void Actors::setMwRoot(Ogre::SceneNode* root){
void Actors::insertNPC(const MWWorld::Ptr& ptr, MWWorld::InventoryStore& inv){ void Actors::insertNPC(const MWWorld::Ptr& ptr, MWWorld::InventoryStore& inv){
insertBegin(ptr, true, true); insertBegin(ptr, true, true);
NpcAnimation* anim = new MWRender::NpcAnimation(ptr, ptr.getRefData ().getBaseNode (), mRend, inv, RV_Actors); NpcAnimation* anim = new MWRender::NpcAnimation(ptr, ptr.getRefData ().getBaseNode (), inv, RV_Actors);
mAllActors[ptr] = anim; mAllActors[ptr] = anim;
} }
@ -70,7 +70,7 @@ void Actors::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){
void Actors::insertCreature (const MWWorld::Ptr& ptr){ void Actors::insertCreature (const MWWorld::Ptr& ptr){
insertBegin(ptr, true, true); insertBegin(ptr, true, true);
CreatureAnimation* anim = new MWRender::CreatureAnimation(ptr, mRend); CreatureAnimation* anim = new MWRender::CreatureAnimation(ptr);
//mAllActors.insert(std::pair<MWWorld::Ptr, Animation*>(ptr,anim)); //mAllActors.insert(std::pair<MWWorld::Ptr, Animation*>(ptr,anim));
delete mAllActors[ptr]; delete mAllActors[ptr];
mAllActors[ptr] = anim; mAllActors[ptr] = anim;

@ -11,9 +11,8 @@
namespace MWRender namespace MWRender
{ {
Animation::Animation(OEngine::Render::OgreRenderer& _rend) Animation::Animation()
: mInsert(NULL) : mInsert(NULL)
, mRend(_rend)
, mTime(0.0f) , mTime(0.0f)
, mSkipFrame(false) , mSkipFrame(false)
{ {

@ -31,7 +31,6 @@ class Animation {
protected: protected:
Ogre::SceneNode* mInsert; Ogre::SceneNode* mInsert;
OEngine::Render::OgreRenderer &mRend;
float mTime; float mTime;
GroupTimes mCurGroup; GroupTimes mCurGroup;
@ -45,7 +44,7 @@ protected:
bool findGroupTimes(const std::string &groupname, GroupTimes *times); bool findGroupTimes(const std::string &groupname, GroupTimes *times);
public: public:
Animation(OEngine::Render::OgreRenderer& _rend); Animation();
virtual ~Animation(); virtual ~Animation();
void playGroup(std::string groupname, int mode, int loops); void playGroup(std::string groupname, int mode, int loops);

@ -7,32 +7,54 @@
#include <libs/openengine/ogre/selectionbuffer.hpp> #include <libs/openengine/ogre/selectionbuffer.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/player.hpp"
#include "renderconst.hpp" #include "renderconst.hpp"
#include "npcanimation.hpp" #include "npcanimation.hpp"
namespace MWRender namespace MWRender
{ {
CharacterPreview::CharacterPreview(Ogre::SceneManager *sceneMgr, Ogre::SceneNode *node, int sizeX, int sizeY, const std::string& name, CharacterPreview::CharacterPreview(MWWorld::Ptr character, int sizeX, int sizeY, const std::string& name,
Ogre::Vector3 position, Ogre::Vector3 lookAt) Ogre::Vector3 position, Ogre::Vector3 lookAt)
: mSceneMgr(sceneMgr) : mSizeX(sizeX)
, mSizeX(sizeX)
, mSizeY(sizeY) , mSizeY(sizeY)
, mName(name)
, mPosition(position)
, mLookAt(lookAt)
, mCharacter(character)
{
}
void CharacterPreview::onSetup()
{ {
mCamera = mSceneMgr->createCamera (name);
mCamera->setAspectRatio (float(sizeX) / float(sizeY));
mNode = node; }
void CharacterPreview::setup (Ogre::SceneManager *sceneManager)
{
mSceneMgr = sceneManager;
mCamera = mSceneMgr->createCamera (mName);
mCamera->setAspectRatio (float(mSizeX) / float(mSizeY));
mNode = static_cast<Ogre::SceneNode*>(mSceneMgr->getRootSceneNode()->getChild("mwRoot"))->createChildSceneNode ();
mAnimation = new NpcAnimation(mCharacter, mNode,
MWWorld::Class::get(mCharacter).getInventoryStore (mCharacter), RV_PlayerPreview);
mNode->setVisible (false); mNode->setVisible (false);
mCamera->setPosition(position); mCamera->setPosition(mPosition);
mCamera->lookAt(lookAt); mCamera->lookAt(mLookAt);
mCamera->setNearClipDistance (0.01); mCamera->setNearClipDistance (0.01);
mCamera->setFarClipDistance (1000); mCamera->setFarClipDistance (1000);
mTexture = Ogre::TextureManager::getSingleton().createManual(name, mTexture = Ogre::TextureManager::getSingleton().createManual(mName,
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, sizeX, sizeY, 0, Ogre::PF_A8R8G8B8, Ogre::TU_RENDERTARGET); Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, mSizeX, mSizeY, 0, Ogre::PF_A8R8G8B8, Ogre::TU_RENDERTARGET);
mRenderTarget = mTexture->getBuffer()->getRenderTarget(); mRenderTarget = mTexture->getBuffer()->getRenderTarget();
mViewport = mRenderTarget->addViewport(mCamera); mViewport = mRenderTarget->addViewport(mCamera);
@ -43,16 +65,22 @@ namespace MWRender
mViewport->setVisibilityMask (RV_PlayerPreview); mViewport->setVisibilityMask (RV_PlayerPreview);
mRenderTarget->setActive(true); mRenderTarget->setActive(true);
mRenderTarget->setAutoUpdated (false); mRenderTarget->setAutoUpdated (false);
onSetup ();
}
CharacterPreview::~CharacterPreview ()
{
Ogre::TextureManager::getSingleton().remove(mName);
} }
// -------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------
InventoryPreview::InventoryPreview(Ogre::SceneManager *sceneMgr, Ogre::SceneNode *node) InventoryPreview::InventoryPreview(MWWorld::Ptr character)
: CharacterPreview(sceneMgr, node, 512, 1024, "CharacterPreview", Ogre::Vector3(0, 65, -180), Ogre::Vector3(0,65,0)) : CharacterPreview(character, 512, 1024, "CharacterPreview", Ogre::Vector3(0, 65, -180), Ogre::Vector3(0,65,0))
, mAnimation(NULL)
{ {
mSelectionBuffer = new OEngine::Render::SelectionBuffer(mCamera, 512, 1024, RV_PlayerPreview);
} }
InventoryPreview::~InventoryPreview() InventoryPreview::~InventoryPreview()
@ -62,8 +90,7 @@ namespace MWRender
void InventoryPreview::update(int sizeX, int sizeY) void InventoryPreview::update(int sizeX, int sizeY)
{ {
if (mAnimation) mAnimation->forceUpdate ();
mAnimation->forceUpdate ();
mViewport->setDimensions (0, 0, std::min(1.f, float(sizeX) / float(512)), std::min(1.f, float(sizeY) / float(1024))); mViewport->setDimensions (0, 0, std::min(1.f, float(sizeX) / float(512)), std::min(1.f, float(sizeY) / float(1024)));
@ -77,20 +104,21 @@ namespace MWRender
mNode->setVisible (false); mNode->setVisible (false);
} }
void InventoryPreview::setNpcAnimation (NpcAnimation *anim) int InventoryPreview::getSlotSelected (int posX, int posY)
{ {
mAnimation = anim; return mSelectionBuffer->getSelected (posX, posY);
} }
int InventoryPreview::getSlotSelected (int posX, int posY) void InventoryPreview::onSetup ()
{ {
return mSelectionBuffer->getSelected (posX, posY); mSelectionBuffer = new OEngine::Render::SelectionBuffer(mCamera, 512, 1024, RV_PlayerPreview);
} }
// -------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------
RaceSelectionPreview::RaceSelectionPreview(Ogre::SceneManager *sceneMgr, Ogre::SceneNode *node) RaceSelectionPreview::RaceSelectionPreview()
: CharacterPreview(sceneMgr, node, 512, 512, "CharacterHeadPreview", Ogre::Vector3(0, 120, -35), Ogre::Vector3(0,125,0)) : CharacterPreview(MWBase::Environment::get().getWorld()->getPlayer().getPlayer(),
512, 512, "CharacterHeadPreview", Ogre::Vector3(0, 120, -35), Ogre::Vector3(0,125,0))
{ {
} }

@ -5,6 +5,10 @@
#include <OgreMaterialManager.h> #include <OgreMaterialManager.h>
#include "externalrendering.hpp"
#include "../mwworld/ptr.hpp"
namespace OEngine namespace OEngine
{ {
namespace Render namespace Render
@ -18,11 +22,16 @@ namespace MWRender
class NpcAnimation; class NpcAnimation;
class CharacterPreview class CharacterPreview : public ExternalRendering
{ {
public: public:
CharacterPreview(Ogre::SceneManager* sceneMgr, Ogre::SceneNode* node, int sizeX, int sizeY, const std::string& name, CharacterPreview(MWWorld::Ptr character, int sizeX, int sizeY, const std::string& name,
Ogre::Vector3 position, Ogre::Vector3 lookAt); Ogre::Vector3 position, Ogre::Vector3 lookAt);
virtual ~CharacterPreview();
virtual void setup (Ogre::SceneManager *sceneManager);
virtual void onSetup();
protected: protected:
Ogre::TexturePtr mTexture; Ogre::TexturePtr mTexture;
@ -34,6 +43,15 @@ namespace MWRender
Ogre::SceneManager* mSceneMgr; Ogre::SceneManager* mSceneMgr;
Ogre::SceneNode* mNode; Ogre::SceneNode* mNode;
Ogre::Vector3 mPosition;
Ogre::Vector3 mLookAt;
MWWorld::Ptr mCharacter;
MWRender::NpcAnimation* mAnimation;
std::string mName;
int mSizeX; int mSizeX;
int mSizeY; int mSizeY;
}; };
@ -41,8 +59,10 @@ namespace MWRender
class InventoryPreview : public CharacterPreview class InventoryPreview : public CharacterPreview
{ {
public: public:
InventoryPreview(Ogre::SceneManager* sceneMgr, Ogre::SceneNode* node);
InventoryPreview(MWWorld::Ptr character);
virtual ~InventoryPreview(); virtual ~InventoryPreview();
virtual void onSetup();
void update(int sizeX, int sizeY); void update(int sizeX, int sizeY);
@ -51,7 +71,6 @@ namespace MWRender
void setNpcAnimation (NpcAnimation* anim); void setNpcAnimation (NpcAnimation* anim);
private: private:
NpcAnimation* mAnimation;
OEngine::Render::SelectionBuffer* mSelectionBuffer; OEngine::Render::SelectionBuffer* mSelectionBuffer;
}; };
@ -59,7 +78,7 @@ namespace MWRender
class RaceSelectionPreview : public CharacterPreview class RaceSelectionPreview : public CharacterPreview
{ {
public: public:
RaceSelectionPreview(Ogre::SceneManager* sceneMgr, Ogre::SceneNode* node); RaceSelectionPreview();
void update(float angle); void update(float angle);
}; };

@ -16,7 +16,7 @@ CreatureAnimation::~CreatureAnimation()
{ {
} }
CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend): Animation(_rend) CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr): Animation()
{ {
mInsert = ptr.getRefData().getBaseNode(); mInsert = ptr.getRefData().getBaseNode();
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>(); MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();

@ -8,13 +8,13 @@
namespace MWRender{ namespace MWRender{
class CreatureAnimation: public Animation{ class CreatureAnimation: public Animation
{
public: public:
virtual ~CreatureAnimation(); virtual ~CreatureAnimation();
CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend); CreatureAnimation(const MWWorld::Ptr& ptr);
virtual void runAnimation(float timepassed); virtual void runAnimation(float timepassed);
}; };
} }
#endif #endif

@ -0,0 +1,23 @@
#ifndef GAME_RENDERING_EXTERNALRENDERING_H
#define GAME_RENDERING_EXTERNALRENDERING_H
namespace Ogre
{
class SceneManager;
}
namespace MWRender
{
/// \brief Base class for out of world rendering
class ExternalRendering
{
public:
virtual void setup (Ogre::SceneManager *sceneManager) = 0;
virtual ~ExternalRendering() {}
};
}
#endif

@ -45,8 +45,8 @@ NpcAnimation::~NpcAnimation()
} }
NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv, int visibilityFlags) NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWorld::InventoryStore& _inv, int visibilityFlags)
: Animation(_rend), mStateID(-1), mInv(_inv), timeToChange(0), mVisibilityFlags(visibilityFlags), : Animation(), mStateID(-1), mInv(_inv), timeToChange(0), mVisibilityFlags(visibilityFlags),
robe(mInv.end()), helmet(mInv.end()), shirt(mInv.end()), robe(mInv.end()), helmet(mInv.end()), shirt(mInv.end()),
cuirass(mInv.end()), greaves(mInv.end()), cuirass(mInv.end()), greaves(mInv.end()),
leftpauldron(mInv.end()), rightpauldron(mInv.end()), leftpauldron(mInv.end()), rightpauldron(mInv.end()),

@ -68,7 +68,7 @@ private:
int mVisibilityFlags; int mVisibilityFlags;
public: public:
NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, OEngine::Render::OgreRenderer& _rend, NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node,
MWWorld::InventoryStore& _inv, int visibilityFlags); MWWorld::InventoryStore& _inv, int visibilityFlags);
virtual ~NpcAnimation(); virtual ~NpcAnimation();
NifOgre::EntityList insertBoundedPart(const std::string &mesh, int group, const std::string &bonename); NifOgre::EntityList insertBoundedPart(const std::string &mesh, int group, const std::string &bonename);

@ -34,7 +34,7 @@
#include "water.hpp" #include "water.hpp"
#include "compositors.hpp" #include "compositors.hpp"
#include "npcanimation.hpp" #include "npcanimation.hpp"
#include "characterpreview.hpp" #include "externalrendering.hpp"
using namespace MWRender; using namespace MWRender;
using namespace Ogre; using namespace Ogre;
@ -138,7 +138,7 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
// Morrowind uses, and it automagically makes everything work as it // Morrowind uses, and it automagically makes everything work as it
// should. // should.
SceneNode *rt = mRendering.getScene()->getRootSceneNode(); SceneNode *rt = mRendering.getScene()->getRootSceneNode();
mMwRoot = rt->createChildSceneNode(); mMwRoot = rt->createChildSceneNode("mwRoot");
mMwRoot->pitch(Degree(-90)); mMwRoot->pitch(Degree(-90));
mObjects.setMwRoot(mMwRoot); mObjects.setMwRoot(mMwRoot);
@ -176,8 +176,6 @@ RenderingManager::~RenderingManager ()
delete mOcclusionQuery; delete mOcclusionQuery;
delete mCompositors; delete mCompositors;
delete mWater; delete mWater;
delete mInventoryPreview;
delete mRaceSelectionPreview;
delete mPreviewAnimation; delete mPreviewAnimation;
} }
@ -863,19 +861,9 @@ void RenderingManager::renderPlayer(const MWWorld::Ptr &ptr)
MWRender::NpcAnimation *anim = MWRender::NpcAnimation *anim =
new MWRender::NpcAnimation( new MWRender::NpcAnimation(
ptr, ptr.getRefData ().getBaseNode (), ptr, ptr.getRefData ().getBaseNode (),
mRendering,
MWWorld::Class::get(ptr).getInventoryStore(ptr), RV_Actors MWWorld::Class::get(ptr).getInventoryStore(ptr), RV_Actors
); );
mPlayer->setAnimation(anim); mPlayer->setAnimation(anim);
MWWorld::InventoryStore& invStore = MWWorld::Class::get(ptr).getInventoryStore (ptr);
Ogre::SceneNode* previewNode = mMwRoot->createChildSceneNode ();
mPreviewAnimation = new NpcAnimation(ptr, previewNode, mRendering, invStore, RV_PlayerPreview);
mInventoryPreview = new InventoryPreview(mRendering.getScene (), previewNode);
mInventoryPreview->setNpcAnimation (mPreviewAnimation);
mRaceSelectionPreview = new RaceSelectionPreview(mRendering.getScene (), previewNode);
} }
void RenderingManager::getPlayerData(Ogre::Vector3 &eyepos, float &pitch, float &yaw) void RenderingManager::getPlayerData(Ogre::Vector3 &eyepos, float &pitch, float &yaw)
@ -895,19 +883,9 @@ bool RenderingManager::isPositionExplored (float nX, float nY, int x, int y, boo
return mLocalMap->isPositionExplored(nX, nY, x, y, interior); return mLocalMap->isPositionExplored(nX, nY, x, y, interior);
} }
void RenderingManager::updateCharacterPreview (int sizeX, int sizeY) void RenderingManager::setupExternalRendering (MWRender::ExternalRendering& rendering)
{
mInventoryPreview->update(sizeX, sizeY);
}
void RenderingManager::updateRaceSelectionPreview (float angle)
{
mRaceSelectionPreview->update(angle);
}
int RenderingManager::getCharacterPreviewSlotSelected(int posX, int posY)
{ {
return mInventoryPreview->getSlotSelected(posX, posY); rendering.setup (mRendering.getScene());
} }
} // namespace } // namespace

@ -43,8 +43,7 @@ namespace MWRender
class LocalMap; class LocalMap;
class Water; class Water;
class Compositors; class Compositors;
class InventoryPreview; class ExternalRendering;
class RaceSelectionPreview;
class RenderingManager: private RenderingInterface, public Ogre::WindowEventListener { class RenderingManager: private RenderingInterface, public Ogre::WindowEventListener {
@ -187,15 +186,13 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList
static bool waterShaderSupported(); static bool waterShaderSupported();
virtual void getInteriorMapPosition (Ogre::Vector2 position, float& nX, float& nY, int &x, int& y); void getInteriorMapPosition (Ogre::Vector2 position, float& nX, float& nY, int &x, int& y);
///< see MWRender::LocalMap::getInteriorMapPosition ///< see MWRender::LocalMap::getInteriorMapPosition
virtual bool isPositionExplored (float nX, float nY, int x, int y, bool interior); bool isPositionExplored (float nX, float nY, int x, int y, bool interior);
///< see MWRender::LocalMap::isPositionExplored ///< see MWRender::LocalMap::isPositionExplored
void updateCharacterPreview(int sizeX, int sizeY); void setupExternalRendering (MWRender::ExternalRendering& rendering);
void updateRaceSelectionPreview(float angle);
int getCharacterPreviewSlotSelected(int posX, int posY);
protected: protected:
virtual void windowResized(Ogre::RenderWindow* rw); virtual void windowResized(Ogre::RenderWindow* rw);
@ -219,9 +216,6 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList
TerrainManager* mTerrainManager; TerrainManager* mTerrainManager;
InventoryPreview* mInventoryPreview;
RaceSelectionPreview* mRaceSelectionPreview;
MWRender::Water *mWater; MWRender::Water *mWater;
OEngine::Render::OgreRenderer &mRendering; OEngine::Render::OgreRenderer &mRendering;

@ -1223,28 +1223,8 @@ namespace MWWorld
mRendering->renderPlayer(mPlayer->getPlayer()); mRendering->renderPlayer(mPlayer->getPlayer());
} }
void World::updateCharacterPreview (int sizeX, int sizeY) void World::setupExternalRendering (MWRender::ExternalRendering& rendering)
{ {
mRendering->updateCharacterPreview(sizeX, sizeY); mRendering->setupExternalRendering (rendering);
}
void World::updateRaceSelectionPreview (float angle)
{
mRendering->updateRaceSelectionPreview(angle);
}
MWWorld::Ptr World::getCharacterPreviewItemSelected(int posX, int posY)
{
int slot = mRendering->getCharacterPreviewSlotSelected(posX, posY);
if (slot == -1)
return MWWorld::Ptr();
MWWorld::Ptr player = getPlayer().getPlayer ();
MWWorld::InventoryStore& invStore = MWWorld::Class::get(player).getInventoryStore(player);
if (invStore.getSlot(slot) != invStore.end())
return *invStore.getSlot (slot);
else
return MWWorld::Ptr();
} }
} }

@ -307,10 +307,8 @@ namespace MWWorld
} }
virtual void renderPlayer(); virtual void renderPlayer();
virtual void updateCharacterPreview(int sizeX, int sizeY); virtual void setupExternalRendering (MWRender::ExternalRendering& rendering);
virtual void updateRaceSelectionPreview(float angle);
virtual MWWorld::Ptr getCharacterPreviewItemSelected(int posX, int posY);
}; };
} }

@ -78,7 +78,7 @@ void OgreRenderer::start()
#endif #endif
} }
bool OgreRenderer::loadPlugins() const bool OgreRenderer::loadPlugins()
{ {
#ifdef ENABLE_PLUGIN_GL #ifdef ENABLE_PLUGIN_GL
mGLPlugin = new Ogre::GLPlugin(); mGLPlugin = new Ogre::GLPlugin();

@ -151,7 +151,7 @@ namespace OEngine
/// Start the main rendering loop /// Start the main rendering loop
void start(); void start();
bool loadPlugins() const; bool loadPlugins() ;
void update(float dt); void update(float dt);

Loading…
Cancel
Save