1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 13:49:55 +00:00
openmw-tes3mp/apps/openmw/mwrender/characterpreview.hpp

123 lines
2.8 KiB
C++
Raw Normal View History

2012-09-12 22:54:32 +00:00
#ifndef MWRENDER_CHARACTERPREVIEW_H
#define MWRENDER_CHARACTERPREVIEW_H
2015-05-20 00:18:20 +00:00
#include <osg/ref_ptr>
#include <components/esm/loadnpc.hpp>
2012-09-14 12:34:18 +00:00
2015-05-20 00:18:20 +00:00
#include <components/resource/resourcesystem.hpp>
#include "../mwworld/ptr.hpp"
2015-05-20 00:18:20 +00:00
namespace osg
2012-09-14 12:34:18 +00:00
{
2015-05-20 00:18:20 +00:00
class Texture2D;
class Camera;
2012-09-14 12:34:18 +00:00
}
2015-05-20 00:18:20 +00:00
namespace osgViewer
{
class Viewer;
2012-09-14 12:34:18 +00:00
}
2012-09-12 22:54:32 +00:00
namespace MWRender
{
2012-09-13 17:03:31 +00:00
class NpcAnimation;
2015-05-20 00:18:20 +00:00
class DrawOnceCallback;
2012-09-13 17:03:31 +00:00
2015-05-20 00:18:20 +00:00
class CharacterPreview
2012-09-12 22:54:32 +00:00
{
public:
2015-05-20 00:18:20 +00:00
CharacterPreview(osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem, MWWorld::Ptr character, int sizeX, int sizeY,
const osg::Vec3f& position, const osg::Vec3f& lookAt);
virtual ~CharacterPreview();
2015-05-20 00:18:20 +00:00
int getTextureWidth() const;
int getTextureHeight() const;
2012-09-12 22:54:32 +00:00
2015-05-20 00:18:20 +00:00
void redraw();
2015-05-20 00:18:20 +00:00
void rebuild();
2015-05-20 00:18:20 +00:00
osg::ref_ptr<osg::Texture2D> getTexture();
2014-04-30 19:15:14 +00:00
private:
CharacterPreview(const CharacterPreview&);
CharacterPreview& operator=(const CharacterPreview&);
2012-09-13 17:03:31 +00:00
protected:
virtual bool renderHeadOnly() { return false; }
2015-05-20 00:18:20 +00:00
virtual void onSetup();
2015-05-20 00:18:20 +00:00
osg::ref_ptr<osgViewer::Viewer> mViewer;
Resource::ResourceSystem* mResourceSystem;
osg::ref_ptr<osg::Texture2D> mTexture;
osg::ref_ptr<osg::Camera> mCamera;
osg::ref_ptr<DrawOnceCallback> mDrawOnceCallback;
2012-09-13 17:03:31 +00:00
2015-05-20 00:18:20 +00:00
osg::Vec3f mPosition;
osg::Vec3f mLookAt;
MWWorld::Ptr mCharacter;
MWRender::NpcAnimation* mAnimation;
2015-05-20 00:18:20 +00:00
osg::ref_ptr<osg::PositionAttitudeTransform> mNode;
std::string mCurrentAnimGroup;
2012-09-13 17:03:31 +00:00
int mSizeX;
int mSizeY;
};
class InventoryPreview : public CharacterPreview
{
public:
2015-05-20 00:18:20 +00:00
InventoryPreview(osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem, MWWorld::Ptr character);
void updatePtr(const MWWorld::Ptr& ptr);
2012-09-13 17:03:31 +00:00
void update(); // Render preview again, e.g. after changed equipment
2015-05-20 00:18:20 +00:00
void setViewport(int sizeX, int sizeY);
2012-09-13 17:03:31 +00:00
2012-09-14 12:34:18 +00:00
int getSlotSelected(int posX, int posY);
protected:
2015-05-20 00:18:20 +00:00
virtual void onSetup();
2012-09-13 17:03:31 +00:00
};
2015-05-20 00:18:20 +00:00
class UpdateCameraCallback;
2012-09-13 17:03:31 +00:00
class RaceSelectionPreview : public CharacterPreview
{
ESM::NPC mBase;
MWWorld::LiveCellRef<ESM::NPC> mRef;
protected:
virtual bool renderHeadOnly() { return true; }
2015-05-20 00:18:20 +00:00
virtual void onSetup();
2012-09-13 17:03:31 +00:00
public:
2015-05-20 00:18:20 +00:00
RaceSelectionPreview(osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem);
virtual ~RaceSelectionPreview();
2012-09-13 17:03:31 +00:00
2015-05-20 00:18:20 +00:00
void setAngle(float angleRadians);
const ESM::NPC &getPrototype() const {
return mBase;
}
void setPrototype(const ESM::NPC &proto);
private:
2015-05-20 00:18:20 +00:00
osg::ref_ptr<UpdateCameraCallback> mUpdateCameraCallback;
float mPitchRadians;
2012-09-12 22:54:32 +00:00
};
}
#endif