Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,84 @@
|
||||
#pragma once
|
||||
|
||||
#include <dtEntity/defaultentitysystem.h>
|
||||
#include <dtEntityOSG/cameracomponent.h>
|
||||
#include <dtEntity/inputinterface.h>
|
||||
|
||||
namespace VCtrl
|
||||
{
|
||||
|
||||
class MotionModelComponent final
|
||||
: public dtEntity::Component
|
||||
, public dtEntity::InputCallbackInterface
|
||||
{
|
||||
public:
|
||||
static const dtEntity::ComponentType TYPE;
|
||||
static const dtEntity::StringId ContextIdId;
|
||||
static const dtEntity::StringId MoveSpeedId;
|
||||
static const dtEntity::StringId RotateSpeedId;
|
||||
static const dtEntity::StringId RotateKeySpeedId;
|
||||
static const dtEntity::StringId EnabledId;
|
||||
|
||||
|
||||
MotionModelComponent();
|
||||
|
||||
dtEntity::ComponentType GetType() const override { return TYPE; }
|
||||
|
||||
virtual bool IsInstanceOf(dtEntity::ComponentType id) const
|
||||
{
|
||||
return (id == TYPE);
|
||||
}
|
||||
|
||||
void OnAddedToEntity(dtEntity::Entity &entity) override;
|
||||
void OnRemovedFromEntity(dtEntity::Entity &) override;
|
||||
|
||||
void Finished() override;
|
||||
void Tick(float dt);
|
||||
|
||||
unsigned int GetContextId() const { return mContextId.Get(); }
|
||||
void SetContextId(unsigned int i) { mContextId.Set(i); }
|
||||
|
||||
bool KeyUp(const std::string &key, bool handled, unsigned int contextid) override;
|
||||
bool KeyDown(const std::string &name, bool handled, unsigned int contextid) override;
|
||||
bool MouseButtonUp(int button, bool handled, unsigned int contextid) override;
|
||||
bool MouseButtonDown(int button, bool handled, unsigned int contextid) override;
|
||||
bool MouseWheel(int dir, bool handled, unsigned int contextid) override;
|
||||
bool MouseMove(float x, float y, bool handled, unsigned int contextid) override;
|
||||
void MouseEnterLeave(bool, unsigned int) override {}
|
||||
|
||||
dtEntityOSG::CameraComponent *GetCamera() const { return mCamera; }
|
||||
private:
|
||||
dtEntity::IntProperty mContextId;
|
||||
dtEntity::UIntProperty mMoveSpeed;
|
||||
dtEntity::FloatProperty mRotateSpeed;
|
||||
dtEntity::FloatProperty mRotateKeySpeed;
|
||||
dtEntity::BoolProperty mEnabled;
|
||||
dtEntityOSG::CameraComponent *mCamera = nullptr;
|
||||
dtEntity::Entity *mEntity = nullptr;
|
||||
osg::Vec3d mPivot;
|
||||
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
class MotionModelSystem final
|
||||
: public dtEntity::DefaultEntitySystem<MotionModelComponent>
|
||||
{
|
||||
using BaseClass = dtEntity::DefaultEntitySystem<MotionModelComponent>;
|
||||
|
||||
public:
|
||||
|
||||
static const dtEntity::ComponentType TYPE;
|
||||
|
||||
explicit MotionModelSystem(dtEntity::EntityManager &em);
|
||||
|
||||
private:
|
||||
|
||||
void Tick(const dtEntity::Message &m);
|
||||
void MoveToPos(const dtEntity::Message &m);
|
||||
void MoveToEntity(const dtEntity::Message &m);
|
||||
|
||||
dtEntity::MessageFunctor mTickFunctor;
|
||||
dtEntity::MessageFunctor mMoveToPosFunctor;
|
||||
dtEntity::MessageFunctor mMoveToEntityFunctor;
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user