Files
Seele/src/Engine/Scene/Components/Component.h
T

55 lines
1.6 KiB
C++
Raw Normal View History

2020-04-15 02:03:56 +02:00
#pragma once
#include "MinimalEngine.h"
2020-05-05 01:51:13 +02:00
#include "Math/Transform.h"
2020-04-15 02:03:56 +02:00
namespace Seele
{
DECLARE_REF(Actor);
2020-05-05 01:51:13 +02:00
DECLARE_REF(Scene);
DECLARE_REF(Component);
2020-04-15 02:03:56 +02:00
class Component
{
public:
Component();
virtual ~Component();
2020-05-05 01:51:13 +02:00
void tick(float deltaTime);
2020-04-15 02:03:56 +02:00
PComponent getParent();
PActor getOwner();
2020-05-05 01:51:13 +02:00
virtual void notifySceneAttach(PScene scene);
2020-04-15 02:03:56 +02:00
void setWorldLocation(Vector location);
void setWorldRotation(Vector rotation);
void setWorldRotation(Quaternion rotation);
void setWorldScale(Vector scale);
void setRelativeLocation(Vector location);
void setRelativeRotation(Vector rotation);
void setRelativeRotation(Quaternion rotation);
void setRelativeScale(Vector scale);
2020-05-05 01:51:13 +02:00
2020-04-15 02:03:56 +02:00
void addWorldTranslation(Vector translation);
void addWorldRotation(Vector rotation);
void addWorldRotation(Quaternion rotation);
Transform getTransform() const;
2020-05-05 01:51:13 +02:00
2020-04-15 02:03:56 +02:00
private:
2020-05-05 01:51:13 +02:00
void setParent(PComponent parent);
2020-04-15 02:03:56 +02:00
void internalSetTransform(Vector newLocation, Quaternion newRotation);
void propagateTransformUpdate();
void updateComponentTransform(Quaternion relativeRotationQuat);
2020-05-05 01:51:13 +02:00
Quaternion getRelativeWorldRotation(Quaternion worldRotation);
void setRelativeLocationAndRotation(Vector newLocation, Quaternion newRotation);
uint8 bComponentTransformClean : 1;
2020-04-15 02:03:56 +02:00
Vector relativeLocation;
Vector relativeRotation;
Vector relativeScale;
Transform transform;
2020-05-05 01:51:13 +02:00
PScene owningScene;
2020-04-15 02:03:56 +02:00
PActor owner;
PComponent parent;
Array<PComponent> children;
2020-05-05 01:51:13 +02:00
friend class Actor;
2020-04-15 02:03:56 +02:00
};
DEFINE_REF(Component)
2020-05-05 01:51:13 +02:00
} // namespace Seele