101 lines
2.3 KiB
C++
Executable File
101 lines
2.3 KiB
C++
Executable File
#pragma once
|
|
|
|
#include <dtEntity/component.h>
|
|
#include <dtEntity/entity.h>
|
|
#include <dtEntity/defaultentitysystem.h>
|
|
#include <dtEntityOSG/nodecomponent.h>
|
|
#include <osg/AutoTransform>
|
|
#include <dtEntity/dynamicproperty.h>
|
|
#include <dtEntityOSG/transformcomponent.h>
|
|
|
|
namespace VCtrl
|
|
{
|
|
|
|
class IconComponent : public dtEntityOSG::TransformComponent
|
|
{
|
|
|
|
public:
|
|
static const dtEntity::StringId TYPE;
|
|
|
|
static const dtEntity::StringId PathId;
|
|
static const dtEntity::StringId VOffsetId;
|
|
|
|
|
|
IconComponent();
|
|
|
|
dtEntity::ComponentType GetType() const override { return TYPE; }
|
|
|
|
bool IsInstanceOf(dtEntity::ComponentType id) const
|
|
{
|
|
return ((id == TYPE));
|
|
}
|
|
|
|
std::string GetPath() const;
|
|
void SetPath(const std::string &path);
|
|
void Reload();
|
|
|
|
float GetVOffset() const;
|
|
void SetVOffset(float v);
|
|
|
|
osg::Vec4 GetColor() const { return mColor; }
|
|
void SetColor(const osg::Vec4 &);
|
|
|
|
bool GetShowDot() const { return mShowDot; }
|
|
void SetShowDot(bool);
|
|
|
|
bool GetOriginAtBottom() const { return mOriginAtBottom; }
|
|
void SetOriginAtBottom(bool);
|
|
|
|
dtEntity::Vec3d GetTranslation() const override;
|
|
void SetTranslation(const dtEntity::Vec3d &) override;
|
|
|
|
dtEntity::Vec3d GetScale() const override;
|
|
void SetScale(const dtEntity::Vec3d &) override;
|
|
|
|
dtEntity::Quat GetRotation() const override;
|
|
void SetRotation(const dtEntity::Quat &) override;
|
|
|
|
bool GetShowSelection() const;
|
|
void SetShowSelection(bool v);
|
|
|
|
void SetVisible(bool v);
|
|
bool GetVisible() const { return mVisible; }
|
|
|
|
void SetRoomNumber(int roomNumber);
|
|
int GetRoomNumber() const { return mRoomNumber; }
|
|
|
|
private:
|
|
|
|
void Rebuild();
|
|
|
|
dtEntity::DynamicStringProperty mPath;
|
|
dtEntity::DynamicFloatProperty mVOffset;
|
|
|
|
std::string mPathVal;
|
|
osg::Vec4 mColor;
|
|
float mVOffsetVal = 0;
|
|
bool mShowDot = false;
|
|
bool mOriginAtBottom = false;
|
|
bool mSelected = false;
|
|
bool mVisible = false;
|
|
|
|
int mRoomNumber{-1};
|
|
};
|
|
|
|
|
|
///////////////////////////////////////////////
|
|
|
|
|
|
// iterates over MovementComponents and updates the translation of the entity
|
|
// after applying forces
|
|
class IconSystem final : public dtEntity::DefaultEntitySystem<IconComponent>
|
|
{
|
|
|
|
public:
|
|
explicit IconSystem(dtEntity::EntityManager &em);
|
|
|
|
static osg::Drawable *CreateSquare(float width, float height, float voffset, bool originAtBottom, osg::Image *image = nullptr);
|
|
};
|
|
|
|
}
|