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
|
|
|
|
2015-11-20 20:57:04 +00:00
|
|
|
#include <osg/PositionAttitudeTransform>
|
|
|
|
|
2012-11-10 07:41:12 +00:00
|
|
|
#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>
|
|
|
|
|
2012-09-14 22:57:29 +00:00
|
|
|
#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;
|
2016-08-16 20:47:45 +00:00
|
|
|
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);
|
2012-09-14 22:57:29 +00:00
|
|
|
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();
|
2014-08-08 13:44:22 +00:00
|
|
|
|
2015-05-20 00:18:20 +00:00
|
|
|
void rebuild();
|
2014-08-04 14:32:53 +00:00
|
|
|
|
2015-05-20 00:18:20 +00:00
|
|
|
osg::ref_ptr<osg::Texture2D> getTexture();
|
2014-08-08 13:44:22 +00:00
|
|
|
|
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:
|
2013-03-06 17:03:47 +00:00
|
|
|
virtual bool renderHeadOnly() { return false; }
|
2017-02-21 17:29:18 +00:00
|
|
|
void setBlendMode();
|
2015-05-20 00:18:20 +00:00
|
|
|
virtual void onSetup();
|
2013-03-06 17:03:47 +00:00
|
|
|
|
2016-08-16 20:47:45 +00:00
|
|
|
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;
|
2012-09-14 22:57:29 +00:00
|
|
|
|
|
|
|
MWWorld::Ptr mCharacter;
|
|
|
|
|
2017-02-22 14:22:40 +00:00
|
|
|
osg::ref_ptr<MWRender::NpcAnimation> mAnimation;
|
2015-05-20 00:18:20 +00:00
|
|
|
osg::ref_ptr<osg::PositionAttitudeTransform> mNode;
|
2013-04-29 19:08:43 +00:00
|
|
|
std::string mCurrentAnimGroup;
|
2012-09-14 22:57:29 +00:00
|
|
|
|
2012-09-13 17:03:31 +00:00
|
|
|
int mSizeX;
|
|
|
|
int mSizeY;
|
|
|
|
};
|
|
|
|
|
|
|
|
class InventoryPreview : public CharacterPreview
|
|
|
|
{
|
|
|
|
public:
|
2012-09-14 22:57:29 +00:00
|
|
|
|
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
|
|
|
|
2014-08-12 14:36:13 +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);
|
|
|
|
|
2014-08-04 14:32:53 +00:00
|
|
|
protected:
|
2017-07-21 22:06:43 +00:00
|
|
|
osg::ref_ptr<osg::Viewport> mViewport;
|
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
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
|
|
|
|
{
|
2012-11-10 07:41:12 +00:00
|
|
|
ESM::NPC mBase;
|
|
|
|
MWWorld::LiveCellRef<ESM::NPC> mRef;
|
|
|
|
|
2013-03-06 17:03:47 +00:00
|
|
|
protected:
|
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
bool renderHeadOnly() override { return true; }
|
|
|
|
void onSetup() override;
|
2013-03-06 17:03:47 +00:00
|
|
|
|
2012-09-13 17:03:31 +00:00
|
|
|
public:
|
2016-08-16 20:47:45 +00:00
|
|
|
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);
|
2012-11-10 07:41:12 +00:00
|
|
|
|
|
|
|
const ESM::NPC &getPrototype() const {
|
|
|
|
return mBase;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setPrototype(const ESM::NPC &proto);
|
2014-12-23 18:51:17 +00:00
|
|
|
|
|
|
|
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
|