Files
Bret Curtis 188174e1da Hand mwgui GUI textures and character previews from the renderer
The inventory, race and map windows fetched osg::Texture2D objects from MWRender only to wrap them in MyGUIPlatform::OSGTexture, and WindowManager threaded the viewer's root osg::Group and the ResourceSystem through CharacterCreation, RaceDialog and InventoryWindow purely so they could construct MWRender previews. CharacterPreview, LocalMap and GlobalMap now return MyGUI::ITexture directly, RenderingManager creates the inventory and race selection previews, and GlobalMap::exploreCell reads the local map texture itself, so those mwgui files no longer name an osg scene type or include myguitexture.hpp; map segments keep their "tried, nothing there" state as an optional holding nullptr instead of an empty OSGTexture sentinel.
2026-10-20 16:08:46 +02:00

128 lines
3.0 KiB
C++

#ifndef MWRENDER_CHARACTERPREVIEW_H
#define MWRENDER_CHARACTERPREVIEW_H
#include <memory>
#include <osg/ref_ptr>
#include <osg/PositionAttitudeTransform>
#include <components/esm3/loadnpc.hpp>
#include <components/resource/resourcesystem.hpp>
#include "../mwworld/ptr.hpp"
namespace osg
{
class Texture2D;
class Camera;
class Group;
class Viewport;
class StateSet;
}
namespace MyGUI
{
class ITexture;
}
namespace MWRender
{
class NpcAnimation;
class DrawOnceCallback;
class CharacterPreviewRTTNode;
class CharacterPreview
{
public:
CharacterPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, const MWWorld::Ptr& character,
int sizeX, int sizeY, const osg::Vec3f& position, const osg::Vec3f& lookAt);
virtual ~CharacterPreview();
int getTextureWidth() const;
int getTextureHeight() const;
void redraw();
void rebuild();
std::unique_ptr<MyGUI::ITexture> makeGuiTexture();
private:
CharacterPreview(const CharacterPreview&);
CharacterPreview& operator=(const CharacterPreview&);
protected:
virtual bool renderHeadOnly() { return false; }
void setBlendMode();
virtual void onSetup();
osg::ref_ptr<osg::Group> mParent;
Resource::ResourceSystem* mResourceSystem;
osg::ref_ptr<osg::StateSet> mTextureStateSet;
osg::ref_ptr<DrawOnceCallback> mDrawOnceCallback;
osg::ref_ptr<CharacterPreviewRTTNode> mRTTNode;
osg::Vec3f mPosition;
osg::Vec3f mLookAt;
MWWorld::Ptr mCharacter;
std::unique_ptr<MWRender::NpcAnimation> mAnimation;
osg::ref_ptr<osg::PositionAttitudeTransform> mNode;
std::string mCurrentAnimGroup;
int mSizeX;
int mSizeY;
};
class InventoryPreview : public CharacterPreview
{
public:
InventoryPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, const MWWorld::Ptr& character);
void updatePtr(const MWWorld::Ptr& ptr);
void update(); // Render preview again, e.g. after changed equipment
void setViewport(int sizeX, int sizeY);
int getSlotSelected(int posX, int posY);
protected:
osg::ref_ptr<osg::Viewport> mViewport;
void onSetup() override;
};
class UpdateCameraCallback;
class RaceSelectionPreview : public CharacterPreview
{
ESM::NPC mBase;
MWWorld::LiveCellRef<ESM::NPC> mRef;
protected:
bool renderHeadOnly() override { return true; }
void onSetup() override;
public:
RaceSelectionPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem);
virtual ~RaceSelectionPreview();
void setAngle(float angleRadians);
const ESM::NPC& getPrototype() const { return mBase; }
void setPrototype(const ESM::NPC& proto);
private:
osg::ref_ptr<UpdateCameraCallback> mUpdateCameraCallback;
float mPitchRadians;
};
}
#endif