1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 18:35:20 +00:00
OpenMW/apps/openmw/mwrender/characterpreview.hpp

130 lines
3.2 KiB
C++
Raw Normal View History

2012-09-13 00:54:32 +02:00
#ifndef MWRENDER_CHARACTERPREVIEW_H
#define MWRENDER_CHARACTERPREVIEW_H
2015-05-20 02:18:20 +02:00
#include <osg/ref_ptr>
2015-11-11 00:50:57 +01:00
#include <memory>
2015-05-20 02:18:20 +02:00
#include <osg/PositionAttitudeTransform>
#include <components/esm3/loadnpc.hpp>
2012-09-14 14:34:18 +02:00
2015-05-20 02:18:20 +02:00
#include <components/resource/resourcesystem.hpp>
#include "../mwworld/ptr.hpp"
2015-05-20 02:18:20 +02:00
namespace osg
2012-09-14 14:34:18 +02:00
{
2015-05-20 02:18:20 +02:00
class Texture2D;
class Camera;
class Group;
2017-07-22 00:06:43 +02:00
class Viewport;
class StateSet;
2012-09-14 14:34:18 +02:00
}
2012-09-13 00:54:32 +02:00
namespace MWRender
{
2012-09-13 19:03:31 +02:00
class NpcAnimation;
2015-05-20 02:18:20 +02:00
class DrawOnceCallback;
class CharacterPreviewRTTNode;
2012-09-13 19:03:31 +02:00
2015-05-20 02:18:20 +02:00
class CharacterPreview
2012-09-13 00:54:32 +02:00
{
public:
2017-04-20 20:36:14 +09:00
CharacterPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, const MWWorld::Ptr& character, int sizeX, int sizeY,
2015-05-20 02:18:20 +02:00
const osg::Vec3f& position, const osg::Vec3f& lookAt);
virtual ~CharacterPreview();
2015-05-20 02:18:20 +02:00
int getTextureWidth() const;
int getTextureHeight() const;
2012-09-13 00:54:32 +02:00
2015-05-20 02:18:20 +02:00
void redraw();
2015-05-20 02:18:20 +02:00
void rebuild();
2015-05-20 02:18:20 +02:00
osg::ref_ptr<osg::Texture2D> getTexture();
/// Get the osg::StateSet required to render the texture correctly, if any.
osg::StateSet* getTextureStateSet() { return mTextureStateSet; }
2014-04-30 21:15:14 +02:00
private:
CharacterPreview(const CharacterPreview&);
CharacterPreview& operator=(const CharacterPreview&);
2012-09-13 19:03:31 +02:00
protected:
virtual bool renderHeadOnly() { return false; }
void setBlendMode();
2015-05-20 02:18:20 +02:00
virtual void onSetup();
osg::ref_ptr<osg::Group> mParent;
2015-05-20 02:18:20 +02:00
Resource::ResourceSystem* mResourceSystem;
osg::ref_ptr<osg::StateSet> mTextureStateSet;
2015-05-20 02:18:20 +02:00
osg::ref_ptr<DrawOnceCallback> mDrawOnceCallback;
osg::ref_ptr<CharacterPreviewRTTNode> mRTTNode;
2012-09-13 19:03:31 +02:00
2015-05-20 02:18:20 +02:00
osg::Vec3f mPosition;
osg::Vec3f mLookAt;
MWWorld::Ptr mCharacter;
osg::ref_ptr<MWRender::NpcAnimation> mAnimation;
2015-05-20 02:18:20 +02:00
osg::ref_ptr<osg::PositionAttitudeTransform> mNode;
std::string mCurrentAnimGroup;
2012-09-13 19:03:31 +02:00
int mSizeX;
int mSizeY;
};
class InventoryPreview : public CharacterPreview
{
public:
2017-04-20 20:36:14 +09:00
InventoryPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, const MWWorld::Ptr& character);
2015-05-20 02:18:20 +02:00
void updatePtr(const MWWorld::Ptr& ptr);
2012-09-13 19:03:31 +02:00
void update(); // Render preview again, e.g. after changed equipment
2015-05-20 02:18:20 +02:00
void setViewport(int sizeX, int sizeY);
2012-09-13 19:03:31 +02:00
2012-09-14 14:34:18 +02:00
int getSlotSelected(int posX, int posY);
protected:
2017-07-22 00:06:43 +02:00
osg::ref_ptr<osg::Viewport> mViewport;
void onSetup() override;
2012-09-13 19:03:31 +02:00
};
2015-05-20 02:18:20 +02:00
class UpdateCameraCallback;
2012-09-13 19:03:31 +02:00
class RaceSelectionPreview : public CharacterPreview
{
ESM::NPC mBase;
MWWorld::LiveCellRef<ESM::NPC> mRef;
protected:
bool renderHeadOnly() override { return true; }
void onSetup() override;
2012-09-13 19:03:31 +02:00
public:
RaceSelectionPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem);
2015-05-20 02:18:20 +02:00
virtual ~RaceSelectionPreview();
2012-09-13 19:03:31 +02:00
2015-05-20 02:18:20 +02:00
void setAngle(float angleRadians);
const ESM::NPC &getPrototype() const {
return mBase;
}
void setPrototype(const ESM::NPC &proto);
private:
2015-05-20 02:18:20 +02:00
osg::ref_ptr<UpdateCameraCallback> mUpdateCameraCallback;
float mPitchRadians;
2012-09-13 00:54:32 +02:00
};
}
#endif