![]() |
Jopnal Engine
alpha 0.4
Simple Component Based 2D/3D Game Engine
|
#include <Object.hpp>
Public Types | |
enum | TransformRestriction : uint32 { TranslationX = 1 << 10, TranslationY = 1 << 11, TranslationZ = 1 << 12, Translation = TranslationX | TranslationY | TranslationZ, ScaleX = 1 << 13, ScaleY = 1 << 14, ScaleZ = 1 << 15, Scale = ScaleX | ScaleY | ScaleZ, Rotation = 1 << 16, IgnoreParent = Translation | Scale | Rotation } |
Public Member Functions | |
Object (const std::string &ID) | |
Constructor. More... | |
Object (const Object &other, const std::string &newID, const Transform::Variables &newTransform) | |
Copy constructor. More... | |
Object (Object &&other) | |
Move constructor. More... | |
Object & | operator= (Object &&other) |
Move assignment operator. More... | |
~Object () | |
Destructor. More... | |
std::vector< std::unique_ptr< Component > > & | getComponents () |
Get all components. More... | |
const std::vector< std::unique_ptr< Component > > & | getComponents () const |
Get all components. More... | |
template<typename T > | |
T * | getComponent () |
Get a component using type info. More... | |
template<typename T > | |
const T * | getComponent () const |
Get a component using type info. More... | |
template<typename T > | |
T * | getComponent (const uint32 ID) |
Get a component using component ID and type info. More... | |
template<typename T > | |
const T * | getComponent (const uint32 ID) const |
Get a component using component ID and type info. More... | |
template<typename T , typename... Args> | |
T & | createComponent (Args &&...args) |
Create a component. More... | |
template<typename T > | |
T * | cloneComponent (Object &object, const uint32 ID=0) const |
Clone a component. More... | |
Object & | removeComponents (const uint32 ID) |
Remove components. More... | |
template<typename T > | |
Object & | removeComponent (const uint32 ID=0) |
Remove a component. More... | |
Object & | clearComponents () |
Remove all components. More... | |
unsigned int | componentCount () const |
Get amount of components. More... | |
WeakReference< Object > | createChild (const std::string &ID) |
Create a new child. More... | |
WeakReference< Object > | adoptChild (Object &child) |
Adopt a child. More... | |
std::vector< Object > & | getChildren () |
Get all children. More... | |
const std::vector< Object > & | getChildren () const |
Get all children. More... | |
WeakReference< Object > | cloneChild (const std::string &ID, const std::string &clonedID) |
Clone a child with the given id. More... | |
WeakReference< Object > | cloneChild (const std::string &ID, const std::string &clonedID, const Transform::Variables &newTransform) |
Clone a child with the given id. More... | |
Object & | removeChildren (const std::string &ID) |
Remove children with the given identifier. More... | |
Object & | removeChildrenWithTag (const std::string &tag, const bool recursive) |
Remove all children with the given tag. More... | |
Object & | reserveChildren (const uint32 size) |
Reserve memory for children. More... | |
Object & | clearChildren () |
Remove all children. More... | |
void | removeSelf () |
Mark this to be removed. More... | |
WeakReference< Object > | cloneSelf () |
Clone/instantiate this object. More... | |
WeakReference< Object > | cloneSelf (const std::string &newID) |
Clone/instantiate this object. More... | |
WeakReference< Object > | cloneSelf (const std::string &newID, const Transform::Variables &newTransform) |
Clone/instantiate this object. More... | |
bool | isRemoved () const |
Check if this object has been marked to be removed. More... | |
unsigned int | childCount () const |
Get amount of children. More... | |
unsigned int | childCountRecursive () const |
Get amount of children recursively. More... | |
WeakReference< Object > | getParent () const |
Get this object's parent. More... | |
WeakReference< Object > | setParent (Object &newParent) |
Set a new parent. More... | |
Scene & | getScene () |
Get the scene this objects is bound to. More... | |
const Scene & | getScene () const |
Get the scene this objects is bound to. More... | |
Message::Result | sendMessage (const Message &message) |
Send a message. More... | |
WeakReference< Object > | findChild (const std::string &ID, const bool recursive=false, const bool strict=true) const |
Find a child. More... | |
std::vector< WeakReference< Object > > | findChildren (const std::string &ID, const bool recursive, const bool strict) const |
Find all children matching the criteria. More... | |
std::vector< WeakReference< Object > > | findChildrenWithTag (const std::string &tag, const bool recursive) const |
Find children with a tag. More... | |
WeakReference< Object > | findChildWithPath (const std::string &path) const |
Find child with a search path. More... | |
std::string | makeSearchPath () const |
Make a string path through this object's parents. More... | |
Object & | setActive (const bool active) |
Set this object active/inactive. More... | |
bool | isActive () const |
Check if this object is active. More... | |
const std::string & | getID () const |
Get this object's identifier. More... | |
Object & | setID (const std::string &ID) |
Set the identifier. More... | |
Object & | addTag (const std::string &tag) |
Add a tag. More... | |
Object & | removeTag (const std::string &tag) |
Remove a tag. More... | |
Object & | clearTags () |
Clear tags. More... | |
bool | hasTag (const std::string &tag) const |
Check if this object has a tag. More... | |
void | update (const float deltaTime) |
Update. More... | |
void | printDebugTree () const |
Print the tree of objects into the console, this object as root. More... | |
const Transform & | getTransform () const |
Get the transform. More... | |
const Transform & | getInverseTransform () const |
Get the inverse transform. More... | |
const Transform::Variables & | getLocalTransformVars () const |
Get the local transformation variables. More... | |
const Transform::Variables & | getGlobalTransformVars () const |
Get the global transformation variables. More... | |
Object & | setRotation (const float x, const float y, const float z) |
Set the rotation. More... | |
Object & | setRotation (const glm::vec3 &rotation) |
Set the rotation. More... | |
Object & | setRotation (const float angle, const glm::vec3 &axis) |
Set the rotation using angle-axis. More... | |
Object & | setRotation (const glm::quat &rotation) |
Set the rotation. More... | |
const glm::quat & | getLocalRotation () const |
Get the local rotation. More... | |
const glm::quat & | getGlobalRotation () const |
Get the global rotation. More... | |
glm::vec3 | getGlobalFront () const |
Get the global front vector. More... | |
glm::vec3 | getGlobalRight () const |
Get the global right vector. More... | |
glm::vec3 | getGlobalUp () const |
Get the global up vector. More... | |
glm::vec3 | getLocalFront () const |
Get the local front vector. More... | |
glm::vec3 | getLocalRight () const |
Get the local right vector. More... | |
glm::vec3 | getLocalUp () const |
Get the local up vector. More... | |
Object & | setScale (const float x, const float y, const float z) |
Set the scale. More... | |
Object & | setScale (const glm::vec3 &scale) |
Set the scale. More... | |
Object & | setScale (const float delta) |
Set the scale. More... | |
const glm::vec3 & | getLocalScale () const |
Get the local scale. More... | |
const glm::vec3 & | getGlobalScale () const |
Get the global scale. More... | |
Object & | setPosition (const float x, const float y, const float z) |
Set the position. More... | |
Object & | setPosition (const glm::vec3 &position) |
Set the position. More... | |
const glm::vec3 & | getLocalPosition () const |
Get the local position. More... | |
const glm::vec3 & | getGlobalPosition () const |
Get the global position. More... | |
Object & | lookAt (const glm::vec3 &point) |
Set this transform to look at a certain point. More... | |
Object & | lookAt (const glm::vec3 &point, const glm::vec3 &up) |
Set this transform to look at a certain point. More... | |
Object & | lookAt (const float x, const float y, const float z) |
Set this transform to look at a certain point. More... | |
Object & | move (const float x, const float y, const float z) |
Move this object. More... | |
Object & | move (const glm::vec3 &offset) |
Move this object. More... | |
Object & | rotate (const float x, const float y, const float z) |
Rotate this object. More... | |
Object & | rotate (const glm::quat &rotation) |
Rotate this object. More... | |
Object & | rotate (const glm::vec3 &rotation) |
Rotate this object. More... | |
Object & | rotate (const float angle, const glm::vec3 &axis) |
Rotate this object using an axis-angle. More... | |
Object & | scale (const float x, const float y, const float z) |
Scale this object. More... | |
Object & | scale (const glm::vec3 &scale) |
Scale this object. More... | |
Object & | scale (const float delta) |
Scale this object. More... | |
Object & | setIgnoreParent (const bool ignore) |
Set this node to ignore its parent. More... | |
bool | ignoresParent () const |
Check if this node ignores its parent. More... | |
Object & | setIgnoreTransform (const uint32 flags) |
Set transform restriction flags. More... | |
bool | ignoresTransform (const uint32 flag) const |
Check if a transform restriction has been set. More... | |
![]() | |
WeakReference< Object > | getReference () const |
Get a weak reference to the bound object. More... | |
![]() | |
SerializeInfo () | |
void | setSerializePackage (const uint16 package) |
uint16 | getSerializePackage () const |
void | setShouldSerialize (const bool set) |
bool | shouldSerialize () const |
void | setLightSerializeable (const bool set) |
bool | isLightSerializeable () const |
Friends | |
class | SceneLoader |
class | Component |
Additional Inherited Members | |
![]() | |
SafeReferenceable (Object *ref) | |
Constructor. More... | |
SafeReferenceable (SafeReferenceable< Object > &&other) | |
Move constructor. More... | |
SafeReferenceable & | operator= (SafeReferenceable< Object > &&other) |
Move assignment operator. More... | |
~SafeReferenceable () | |
Protected destructor. More... | |
Definition at line 43 of file Object.hpp.
Transformation restrictions
Definition at line 73 of file Object.hpp.
jop::Object::Object | ( | const std::string & | ID | ) |
Constructor.
ID | Object identifier |
jop::Object::Object | ( | const Object & | other, |
const std::string & | newID, | ||
const Transform::Variables & | newTransform | ||
) |
Copy constructor.
other | The other object to copy |
newID | The ID of the new object |
newTransform | The transform values of the new object |
jop::Object::Object | ( | Object && | other | ) |
Move constructor.
jop::Object::~Object | ( | ) |
Destructor.
Object& jop::Object::addTag | ( | const std::string & | tag | ) |
Add a tag.
tag | The tag to add |
WeakReference<Object> jop::Object::adoptChild | ( | Object & | child | ) |
Adopt a child.
This will move the child onto this object and remove it from its old parent. If the child's parent is equal to this, this function does nothing.
child | The child to adopt |
unsigned int jop::Object::childCount | ( | ) | const |
Get amount of children.
unsigned int jop::Object::childCountRecursive | ( | ) | const |
Get amount of children recursively.
Object& jop::Object::clearChildren | ( | ) |
Remove all children.
The children will be removed immediately.
Object& jop::Object::clearComponents | ( | ) |
Remove all components.
Object& jop::Object::clearTags | ( | ) |
Clear tags.
WeakReference<Object> jop::Object::cloneChild | ( | const std::string & | ID, |
const std::string & | clonedID | ||
) |
Clone a child with the given id.
The child object, if successfully cloned, will be added to the internal array and then returned.
ID | The ID to search with |
clonedID | The ID of the cloned object |
WeakReference<Object> jop::Object::cloneChild | ( | const std::string & | ID, |
const std::string & | clonedID, | ||
const Transform::Variables & | newTransform | ||
) |
Clone a child with the given id.
The child object, if successfully cloned, will be added to the internal array and then returned.
ID | The ID to search with |
clonedID | The ID of the cloned object |
newTransform | New transform for the cloned child |
Clone a component.
object | New object for the cloned component |
ID | Identifier of the component to clone |
WeakReference<Object> jop::Object::cloneSelf | ( | ) |
Clone/instantiate this object.
The same ID and transform will be used.
WeakReference<Object> jop::Object::cloneSelf | ( | const std::string & | newID | ) |
Clone/instantiate this object.
The same transform will be used.
newID | The ID of the cloned object |
WeakReference<Object> jop::Object::cloneSelf | ( | const std::string & | newID, |
const Transform::Variables & | newTransform | ||
) |
Clone/instantiate this object.
newID | The ID of the cloned object |
newTransform | The transform of the cloned object |
unsigned int jop::Object::componentCount | ( | ) | const |
Get amount of components.
WeakReference<Object> jop::Object::createChild | ( | const std::string & | ID | ) |
Create a new child.
ID | Id for the new child object |
T& jop::Object::createComponent | ( | Args &&... | args | ) |
Create a component.
args | Arguments to use with construction |
WeakReference<Object> jop::Object::findChild | ( | const std::string & | ID, |
const bool | recursive = false , |
||
const bool | strict = true |
||
) | const |
Find a child.
ID | Object identifier |
recursive | Search recursively? |
strict | Does the ID have to match exactly? |
std::vector<WeakReference<Object> > jop::Object::findChildren | ( | const std::string & | ID, |
const bool | recursive, | ||
const bool | strict | ||
) | const |
Find all children matching the criteria.
When ID is empty and strict is false, all children will be returned.
ID | Object identifier |
recursive | Search recursively? |
strict | Does the ID have to match exactly? |
std::vector<WeakReference<Object> > jop::Object::findChildrenWithTag | ( | const std::string & | tag, |
const bool | recursive | ||
) | const |
Find children with a tag.
tag | Object identifier |
recursive | Search recursively? |
WeakReference<Object> jop::Object::findChildWithPath | ( | const std::string & | path | ) | const |
Find child with a search path.
path | Search path |
std::vector<Object>& jop::Object::getChildren | ( | ) |
Get all children.
const std::vector<Object>& jop::Object::getChildren | ( | ) | const |
Get all children.
T* jop::Object::getComponent | ( | ) |
Get a component using type info.
const T* jop::Object::getComponent | ( | ) | const |
Get a component using type info.
T* jop::Object::getComponent | ( | const uint32 | ID | ) |
Get a component using component ID and type info.
ID | The identifier to search with |
const T* jop::Object::getComponent | ( | const uint32 | ID | ) | const |
Get a component using component ID and type info.
ID | The identifier to search with |
std::vector<std::unique_ptr<Component> >& jop::Object::getComponents | ( | ) |
Get all components.
const std::vector<std::unique_ptr<Component> >& jop::Object::getComponents | ( | ) | const |
Get all components.
glm::vec3 jop::Object::getGlobalFront | ( | ) | const |
Get the global front vector.
const glm::vec3& jop::Object::getGlobalPosition | ( | ) | const |
Get the global position.
glm::vec3 jop::Object::getGlobalRight | ( | ) | const |
Get the global right vector.
const glm::quat& jop::Object::getGlobalRotation | ( | ) | const |
Get the global rotation.
const glm::vec3& jop::Object::getGlobalScale | ( | ) | const |
Get the global scale.
const Transform::Variables& jop::Object::getGlobalTransformVars | ( | ) | const |
Get the global transformation variables.
glm::vec3 jop::Object::getGlobalUp | ( | ) | const |
Get the global up vector.
const std::string& jop::Object::getID | ( | ) | const |
const Transform& jop::Object::getInverseTransform | ( | ) | const |
Get the inverse transform.
glm::vec3 jop::Object::getLocalFront | ( | ) | const |
Get the local front vector.
const glm::vec3& jop::Object::getLocalPosition | ( | ) | const |
Get the local position.
glm::vec3 jop::Object::getLocalRight | ( | ) | const |
Get the local right vector.
const glm::quat& jop::Object::getLocalRotation | ( | ) | const |
Get the local rotation.
const glm::vec3& jop::Object::getLocalScale | ( | ) | const |
Get the local scale.
const Transform::Variables& jop::Object::getLocalTransformVars | ( | ) | const |
Get the local transformation variables.
glm::vec3 jop::Object::getLocalUp | ( | ) | const |
Get the local up vector.
WeakReference<Object> jop::Object::getParent | ( | ) | const |
Get this object's parent.
If the result is empty, it means that this object is a scene.
Scene& jop::Object::getScene | ( | ) |
Get the scene this objects is bound to.
You should avoid calling this when you can use Engine::getCurrentScene() or Engine::getSharedScene().
const Scene& jop::Object::getScene | ( | ) | const |
Get the scene this objects is bound to.
You should avoid calling this when you can use Engine::getCurrentScene() or Engine::getSharedScene().
const Transform& jop::Object::getTransform | ( | ) | const |
Get the transform.
bool jop::Object::hasTag | ( | const std::string & | tag | ) | const |
Check if this object has a tag.
tag | The tag to check |
bool jop::Object::ignoresParent | ( | ) | const |
Check if this node ignores its parent.
bool jop::Object::ignoresTransform | ( | const uint32 | flag | ) | const |
Check if a transform restriction has been set.
You should only check a single flag at a time.
flag | The flag to check |
bool jop::Object::isActive | ( | ) | const |
Check if this object is active.
bool jop::Object::isRemoved | ( | ) | const |
Check if this object has been marked to be removed.
Object& jop::Object::lookAt | ( | const glm::vec3 & | point | ) |
Set this transform to look at a certain point.
The rotation is applied locally. If you want to set the rotation to point at an absolute world position, use setIgnoreTransform() to restrict the rotation.
This overload will use Transform::Up as the up vector.
point | The point to look at |
Object& jop::Object::lookAt | ( | const glm::vec3 & | point, |
const glm::vec3 & | up | ||
) |
Set this transform to look at a certain point.
The rotation is applied locally. If you want to set the rotation to point at an absolute world position, use setIgnoreTransform() to restrict the rotation.
This overload will use Transform::Up as the up vector.
point | The point to look at |
up | Custom up vector |
Object& jop::Object::lookAt | ( | const float | x, |
const float | y, | ||
const float | z | ||
) |
Set this transform to look at a certain point.
x | The X point |
y | The Y point |
z | The Z point |
std::string jop::Object::makeSearchPath | ( | ) | const |
Make a string path through this object's parents.
The path will be in the following format: GrandParent>Parent>ThisObject
. Due to how the format works, the character '>' in an object ID is forbidden.
Object& jop::Object::move | ( | const float | x, |
const float | y, | ||
const float | z | ||
) |
Move this object.
x | The X offset |
y | The Y offset |
z | The Z offset |
Object& jop::Object::move | ( | const glm::vec3 & | offset | ) |
Move this object.
offset | The movement offset |
Move assignment operator.
void jop::Object::printDebugTree | ( | ) | const |
Print the tree of objects into the console, this object as root.
Object& jop::Object::removeChildren | ( | const std::string & | ID | ) |
Remove children with the given identifier.
The children will actually be removed only at the beginning of the next update call.
ID | The id to search with |
Object& jop::Object::removeChildrenWithTag | ( | const std::string & | tag, |
const bool | recursive | ||
) |
Remove all children with the given tag.
The children will actually be removed only at the beginning of the next update call.
tag | The tag to search with |
recursive | Search recursively? |
Remove a component.
ID | The ID to search with |
Remove components.
All components matching the identifier will be removed
ID | The ID to search with |
void jop::Object::removeSelf | ( | ) |
Mark this to be removed.
The object will be actually removed at the beginning of the next update call.
Object& jop::Object::removeTag | ( | const std::string & | tag | ) |
Remove a tag.
tag | The tag to be removed |
Reserve memory for children.
Reallocates children if param size is greater than currently reserved size. It's recommended to call tis before adding a large amount of children.
size | Size to reserve |
Object& jop::Object::rotate | ( | const float | x, |
const float | y, | ||
const float | z | ||
) |
Rotate this object.
x | The X offset |
y | The Y offset |
z | The Z offset |
Object& jop::Object::rotate | ( | const glm::quat & | rotation | ) |
Rotate this object.
rotation | The rotation offset |
Object& jop::Object::rotate | ( | const glm::vec3 & | rotation | ) |
Rotate this object.
rotation | The rotation offset |
Object& jop::Object::rotate | ( | const float | angle, |
const glm::vec3 & | axis | ||
) |
Rotate this object using an axis-angle.
angle | The angle |
axis | The axis |
Object& jop::Object::scale | ( | const float | x, |
const float | y, | ||
const float | z | ||
) |
Scale this object.
x | The X multiplier |
y | The Y multiplier |
z | The Z multiplier |
Object& jop::Object::scale | ( | const glm::vec3 & | scale | ) |
Scale this object.
scale | The scale multiplier |
Object& jop::Object::scale | ( | const float | delta | ) |
Scale this object.
This call is equal to scale(delta, delta, delta).
delta | The scale multiplier |
Message::Result jop::Object::sendMessage | ( | const Message & | message | ) |
Send a message.
The message will be forwarded to children and components.
message | The message |
Object& jop::Object::setActive | ( | const bool | active | ) |
Set this object active/inactive.
active | True to set active |
Object& jop::Object::setID | ( | const std::string & | ID | ) |
Set the identifier.
The character '>' in an object identifier is forbidden.
ID | Object identifier |
Object& jop::Object::setIgnoreParent | ( | const bool | ignore | ) |
Set this node to ignore its parent.
Objects that ignore their parent will not take into account the parent's transformation.
ignore | The flag to set |
Set transform restriction flags.
Use this function to ignore certain global transformations. The local transformation values remain unaffected.
flags | The flags to set |
WeakReference<Object> jop::Object::setParent | ( | Object & | newParent | ) |
Set a new parent.
This is equivalent to calling newParent.adoptChild(this)
newParent | The new parent |
Object& jop::Object::setPosition | ( | const float | x, |
const float | y, | ||
const float | z | ||
) |
Set the position.
x | The X component |
y | The Y component |
z | The Z component |
Object& jop::Object::setPosition | ( | const glm::vec3 & | position | ) |
Set the position.
position | Vector with the position to set |
Object& jop::Object::setRotation | ( | const float | x, |
const float | y, | ||
const float | z | ||
) |
Set the rotation.
x | The X angle |
y | The Y angle |
z | The Z angle |
Object& jop::Object::setRotation | ( | const glm::vec3 & | rotation | ) |
Set the rotation.
rotation | Rotation vector in euler angles |
Object& jop::Object::setRotation | ( | const float | angle, |
const glm::vec3 & | axis | ||
) |
Set the rotation using angle-axis.
angle | The angle |
axis | The axis |
Object& jop::Object::setRotation | ( | const glm::quat & | rotation | ) |
Set the rotation.
rotation | Quaternion with the rotation to set |
Object& jop::Object::setScale | ( | const float | x, |
const float | y, | ||
const float | z | ||
) |
Set the scale.
1.f means the original scale.
x | The X component |
y | The Y component |
z | The Z component |
Object& jop::Object::setScale | ( | const glm::vec3 & | scale | ) |
Set the scale.
scale | Vector with the scale to set |
Object& jop::Object::setScale | ( | const float | delta | ) |
Set the scale.
This call is equal to setScale(delta, delta, delta)
delta | The new scale |
void jop::Object::update | ( | const float | deltaTime | ) |
Update.
This is for internal use.
deltaTime | The delta time |
|
friend |
Definition at line 50 of file Object.hpp.
|
friend |
Definition at line 49 of file Object.hpp.