1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 22:19:54 +00:00
openmw-tes3mp/apps/openmw/mwrender/characterpreview.hpp

126 lines
2.9 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>
2015-11-10 23:50:57 +00:00
#include <memory>
2015-05-20 00:18:20 +00:00
#include <osg/PositionAttitudeTransform>
#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;
class Group;
2017-07-21 22:06:43 +00:00
class Viewport;
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:
2017-04-20 11:36:14 +00:00
CharacterPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, const MWWorld::Ptr& character, int sizeX, int sizeY,
2015-05-20 00:18:20 +00:00
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; }
void setBlendMode();
2015-05-20 00:18:20 +00:00
virtual void onSetup();
osg::ref_ptr<osg::Group> mParent;
2015-05-20 00:18:20 +00:00
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;
osg::ref_ptr<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:
2017-04-20 11:36:14 +00:00
InventoryPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, const MWWorld::Ptr& character);
2015-05-20 00:18:20 +00:00
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:
2017-07-21 22:06:43 +00:00
osg::ref_ptr<osg::Viewport> mViewport;
void onSetup() override;
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:
bool renderHeadOnly() override { return true; }
void onSetup() override;
2012-09-13 17:03:31 +00:00
public:
RaceSelectionPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem);
2015-05-20 00:18:20 +00:00
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