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
|
|
|
|
2015-11-20 21:57:04 +01:00
|
|
|
#include <osg/PositionAttitudeTransform>
|
|
|
|
|
2022-01-22 15:58:41 +01:00
|
|
|
#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>
|
|
|
|
|
2012-09-15 00:57:29 +02:00
|
|
|
#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;
|
2016-08-16 22:47:45 +02:00
|
|
|
class Group;
|
2017-07-22 00:06:43 +02:00
|
|
|
class Viewport;
|
2021-10-25 07:28:32 +00:00
|
|
|
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;
|
2022-04-04 22:51:23 +02:00
|
|
|
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);
|
2012-09-15 00:57:29 +02:00
|
|
|
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();
|
2014-08-08 15:44:22 +02:00
|
|
|
|
2015-05-20 02:18:20 +02:00
|
|
|
void rebuild();
|
2014-08-04 16:32:53 +02:00
|
|
|
|
2015-05-20 02:18:20 +02:00
|
|
|
osg::ref_ptr<osg::Texture2D> getTexture();
|
2021-10-25 07:28:32 +00:00
|
|
|
/// Get the osg::StateSet required to render the texture correctly, if any.
|
|
|
|
osg::StateSet* getTextureStateSet() { return mTextureStateSet; }
|
2014-08-08 15:44:22 +02:00
|
|
|
|
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:
|
2013-03-06 18:03:47 +01:00
|
|
|
virtual bool renderHeadOnly() { return false; }
|
2017-02-21 18:29:18 +01:00
|
|
|
void setBlendMode();
|
2015-05-20 02:18:20 +02:00
|
|
|
virtual void onSetup();
|
2013-03-06 18:03:47 +01:00
|
|
|
|
2016-08-16 22:47:45 +02:00
|
|
|
osg::ref_ptr<osg::Group> mParent;
|
2015-05-20 02:18:20 +02:00
|
|
|
Resource::ResourceSystem* mResourceSystem;
|
2021-10-25 07:28:32 +00:00
|
|
|
osg::ref_ptr<osg::StateSet> mTextureStateSet;
|
2015-05-20 02:18:20 +02:00
|
|
|
osg::ref_ptr<DrawOnceCallback> mDrawOnceCallback;
|
2022-04-04 22:51:23 +02:00
|
|
|
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;
|
2012-09-15 00:57:29 +02:00
|
|
|
|
|
|
|
MWWorld::Ptr mCharacter;
|
|
|
|
|
2017-02-22 15:22:40 +01:00
|
|
|
osg::ref_ptr<MWRender::NpcAnimation> mAnimation;
|
2015-05-20 02:18:20 +02:00
|
|
|
osg::ref_ptr<osg::PositionAttitudeTransform> mNode;
|
2013-04-29 12:08:43 -07:00
|
|
|
std::string mCurrentAnimGroup;
|
2012-09-15 00:57:29 +02:00
|
|
|
|
2012-09-13 19:03:31 +02:00
|
|
|
int mSizeX;
|
|
|
|
int mSizeY;
|
|
|
|
};
|
|
|
|
|
|
|
|
class InventoryPreview : public CharacterPreview
|
|
|
|
{
|
|
|
|
public:
|
2012-09-15 00:57:29 +02:00
|
|
|
|
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
|
|
|
|
2014-08-12 16:36:13 +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);
|
|
|
|
|
2014-08-04 16:32:53 +02:00
|
|
|
protected:
|
2017-07-22 00:06:43 +02:00
|
|
|
osg::ref_ptr<osg::Viewport> mViewport;
|
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
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
|
|
|
|
{
|
2012-11-10 11:41:12 +04:00
|
|
|
ESM::NPC mBase;
|
|
|
|
MWWorld::LiveCellRef<ESM::NPC> mRef;
|
|
|
|
|
2013-03-06 18:03:47 +01:00
|
|
|
protected:
|
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
bool renderHeadOnly() override { return true; }
|
|
|
|
void onSetup() override;
|
2013-03-06 18:03:47 +01:00
|
|
|
|
2012-09-13 19:03:31 +02:00
|
|
|
public:
|
2016-08-16 22:47:45 +02:00
|
|
|
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);
|
2012-11-10 11:41:12 +04:00
|
|
|
|
|
|
|
const ESM::NPC &getPrototype() const {
|
|
|
|
return mBase;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setPrototype(const ESM::NPC &proto);
|
2014-12-23 19:51:17 +01:00
|
|
|
|
|
|
|
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
|