Files
Seele/src/Engine/Scene/Actor/Actor.cpp
T

112 lines
2.2 KiB
C++
Raw Normal View History

2020-04-15 02:03:56 +02:00
#include "Actor.h"
2020-05-05 01:51:13 +02:00
#include "Scene/Components/Component.h"
#include "Scene/Scene.h"
2020-04-15 02:03:56 +02:00
using namespace Seele;
Actor::Actor()
{
}
Actor::~Actor()
{
}
2020-05-05 01:51:13 +02:00
void Actor::tick(float deltaTime)
{
}
void Actor::notifySceneAttach(PScene scene)
{
owningScene = scene;
rootComponent->notifySceneAttach(scene);
2021-05-06 17:02:10 +02:00
for(auto child : children)
{
child->notifySceneAttach(scene);
}
2020-05-05 01:51:13 +02:00
}
PScene Actor::getScene()
{
return owningScene;
}
2020-04-15 02:03:56 +02:00
void Actor::setParent(PActor newParent)
{
parent = newParent;
}
void Actor::addChild(PActor child)
{
children.add(child);
2020-05-05 01:51:13 +02:00
child->setParent(this);
child->notifySceneAttach(owningScene);
2020-04-15 02:03:56 +02:00
}
void Actor::detachChild(PActor child)
{
children.remove(children.find(child), false);
2020-05-05 01:51:13 +02:00
child->setParent(nullptr);
child->notifySceneAttach(nullptr);
2020-04-15 02:03:56 +02:00
}
void Actor::setWorldLocation(Vector location)
{
rootComponent->setWorldLocation(location);
}
2020-10-23 01:47:56 +02:00
void Actor::setWorldRotation(Quaternion rotation)
{
rootComponent->setWorldRotation(rotation);
}
void Actor::setWorldRotation(Vector rotation)
2020-04-15 02:03:56 +02:00
{
rootComponent->setWorldRotation(rotation);
}
void Actor::setWorldScale(Vector scale)
{
rootComponent->setWorldScale(scale);
}
void Actor::setRelativeLocation(Vector location)
{
rootComponent->setRelativeLocation(location);
}
2020-10-23 01:47:56 +02:00
void Actor::setRelativeRotation(Quaternion rotation)
{
rootComponent->setRelativeRotation(rotation);
}
void Actor::setRelativeRotation(Vector rotation)
2020-04-15 02:03:56 +02:00
{
rootComponent->setRelativeRotation(rotation);
}
void Actor::setRelativeScale(Vector scale)
{
rootComponent->setRelativeScale(scale);
}
void Actor::addWorldTranslation(Vector translation)
{
rootComponent->addWorldTranslation(translation);
}
2020-10-23 01:47:56 +02:00
void Actor::addWorldRotation(Quaternion rotation)
{
rootComponent->addWorldRotation(rotation);
}
void Actor::addWorldRotation(Vector rotation)
2020-04-15 02:03:56 +02:00
{
rootComponent->addWorldRotation(rotation);
}
PComponent Actor::getRootComponent()
{
return rootComponent;
}
void Actor::setRootComponent(PComponent newRoot)
{
2020-05-05 01:51:13 +02:00
if(rootComponent != nullptr)
{
rootComponent->owner = nullptr;
}
2020-04-15 02:03:56 +02:00
rootComponent = newRoot;
2020-05-05 01:51:13 +02:00
rootComponent->owner = this;
2020-04-15 02:03:56 +02:00
}
Transform Actor::getTransform() const
{
return rootComponent->getTransform();
}