|
|
|
@ -7,32 +7,54 @@
|
|
|
|
|
#include <libs/openengine/ogre/selectionbuffer.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
|
#include "../mwworld/player.hpp"
|
|
|
|
|
|
|
|
|
|
#include "renderconst.hpp"
|
|
|
|
|
#include "npcanimation.hpp"
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
: mSceneMgr(sceneMgr)
|
|
|
|
|
, mSizeX(sizeX)
|
|
|
|
|
: mSizeX(sizeX)
|
|
|
|
|
, 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);
|
|
|
|
|
|
|
|
|
|
mCamera->setPosition(position);
|
|
|
|
|
mCamera->lookAt(lookAt);
|
|
|
|
|
mCamera->setPosition(mPosition);
|
|
|
|
|
mCamera->lookAt(mLookAt);
|
|
|
|
|
|
|
|
|
|
mCamera->setNearClipDistance (0.01);
|
|
|
|
|
mCamera->setFarClipDistance (1000);
|
|
|
|
|
|
|
|
|
|
mTexture = Ogre::TextureManager::getSingleton().createManual(name,
|
|
|
|
|
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, sizeX, sizeY, 0, Ogre::PF_A8R8G8B8, Ogre::TU_RENDERTARGET);
|
|
|
|
|
mTexture = Ogre::TextureManager::getSingleton().createManual(mName,
|
|
|
|
|
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, mSizeX, mSizeY, 0, Ogre::PF_A8R8G8B8, Ogre::TU_RENDERTARGET);
|
|
|
|
|
|
|
|
|
|
mRenderTarget = mTexture->getBuffer()->getRenderTarget();
|
|
|
|
|
mViewport = mRenderTarget->addViewport(mCamera);
|
|
|
|
@ -43,16 +65,22 @@ namespace MWRender
|
|
|
|
|
mViewport->setVisibilityMask (RV_PlayerPreview);
|
|
|
|
|
mRenderTarget->setActive(true);
|
|
|
|
|
mRenderTarget->setAutoUpdated (false);
|
|
|
|
|
|
|
|
|
|
onSetup ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CharacterPreview::~CharacterPreview ()
|
|
|
|
|
{
|
|
|
|
|
Ogre::TextureManager::getSingleton().remove(mName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InventoryPreview::InventoryPreview(Ogre::SceneManager *sceneMgr, Ogre::SceneNode *node)
|
|
|
|
|
: CharacterPreview(sceneMgr, node, 512, 1024, "CharacterPreview", Ogre::Vector3(0, 65, -180), Ogre::Vector3(0,65,0))
|
|
|
|
|
, mAnimation(NULL)
|
|
|
|
|
InventoryPreview::InventoryPreview(MWWorld::Ptr character)
|
|
|
|
|
: CharacterPreview(character, 512, 1024, "CharacterPreview", Ogre::Vector3(0, 65, -180), Ogre::Vector3(0,65,0))
|
|
|
|
|
{
|
|
|
|
|
mSelectionBuffer = new OEngine::Render::SelectionBuffer(mCamera, 512, 1024, RV_PlayerPreview);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
InventoryPreview::~InventoryPreview()
|
|
|
|
@ -62,8 +90,7 @@ namespace MWRender
|
|
|
|
|
|
|
|
|
|
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)));
|
|
|
|
|
|
|
|
|
@ -77,20 +104,21 @@ namespace MWRender
|
|
|
|
|
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)
|
|
|
|
|
: CharacterPreview(sceneMgr, node, 512, 512, "CharacterHeadPreview", Ogre::Vector3(0, 120, -35), Ogre::Vector3(0,125,0))
|
|
|
|
|
RaceSelectionPreview::RaceSelectionPreview()
|
|
|
|
|
: CharacterPreview(MWBase::Environment::get().getWorld()->getPlayer().getPlayer(),
|
|
|
|
|
512, 512, "CharacterHeadPreview", Ogre::Vector3(0, 120, -35), Ogre::Vector3(0,125,0))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|