Blowbox 2017
A 3D Game Engine by Riko Ophorst using DirectX 12
Public Member Functions | Protected Member Functions | Private Attributes | Friends | List of all members
blowbox::Entity Class Reference

#include <entity.h>

Public Member Functions

 Entity (const String &name)
 
 ~Entity ()
 
void SetName (const String &name)
 
const StringGetName () const
 
void SetLocalPosition (const DirectX::XMFLOAT3 &position)
 
void SetLocalRotation (const DirectX::XMFLOAT3 &rotation)
 
void SetLocalScaling (const DirectX::XMFLOAT3 &scaling)
 
void SetMesh (SharedPtr< Mesh > mesh)
 
const DirectX::XMFLOAT3 & GetLocalPosition () const
 
const DirectX::XMFLOAT3 & GetLocalRotation () const
 
const DirectX::XMFLOAT3 & GetLocalScaling () const
 
SharedPtr< MeshGetMesh () const
 
const DirectX::XMMATRIX & GetWorldTransform ()
 
const Vector< SharedPtr< Entity > > & GetChildren () const
 
UploadBufferGetConstantBuffer ()
 

Protected Member Functions

void Init ()
 
void Update ()
 
void Shutdown ()
 
bool AddChild (SharedPtr< Entity > entity)
 
bool RemoveChild (SharedPtr< Entity > entity)
 
void SetInScene (bool in_scene)
 
bool GetInScene () const
 
bool IsTransformDirty ()
 
void UpdateWorldTransform ()
 

Private Attributes

String name_
 
WeakPtr< Entityparent_
 
Vector< SharedPtr< Entity > > children_
 
DirectX::XMFLOAT3 position_
 
DirectX::XMFLOAT3 rotation_
 
DirectX::XMFLOAT3 scaling_
 
DirectX::XMMATRIX world_transform_
 
bool transform_dirty_
 
bool in_scene_
 
SharedPtr< Meshmesh_
 
UploadBuffer constant_buffer_
 

Friends

class SceneManager
 
class EntityFactory
 

Detailed Description

The Blowbox equivalent of a game object.

An Entity is the Blowbox equivalent of a game object. It has everything in it that you need. There are no components. Every Entity has the same layout and same functionality: it allows you to render something into the scene. It contains a transform, and it is part of a scene graph. It is recommended that you construct an Entity through the EntityFactory instead of doing it through the Entity::Entity() constructor. However, it is very much possible to create an Entity through its constructor.

Constructor & Destructor Documentation

blowbox::Entity::Entity ( const String name)

Constructs an Entity.

Parameters
[in]nameThe name of this Entity.
blowbox::Entity::~Entity ( )

Destructs the Entity.

Member Function Documentation

bool blowbox::Entity::AddChild ( SharedPtr< Entity entity)
protected

Adds a child Entity to this Entity.

Parameters
[in]entityThe child Entity that should be added to this Entity
Returns
Whether the child Entity was successfully added
const Vector< SharedPtr< Entity > > & blowbox::Entity::GetChildren ( ) const
Returns
The children of this Entity.
UploadBuffer& blowbox::Entity::GetConstantBuffer ( )
inline
Returns
This Entity's constant buffer.
bool blowbox::Entity::GetInScene ( ) const
protected

Returns whether the Entity is present in the SceneManager.

Returns
Whether the Entity exists in the SceneManager.
const DirectX::XMFLOAT3 & blowbox::Entity::GetLocalPosition ( ) const
Returns
The local position of this Entity.
const DirectX::XMFLOAT3 & blowbox::Entity::GetLocalRotation ( ) const
Returns
The local rotation of this Entity.
const DirectX::XMFLOAT3 & blowbox::Entity::GetLocalScaling ( ) const
Returns
The local scaling of this Entity.
SharedPtr< Mesh > blowbox::Entity::GetMesh ( ) const
Returns
The mesh that is bound to this Entity.
const String & blowbox::Entity::GetName ( ) const

Returns the name of this Entity.

Returns
The name of this Entity.
const DirectX::XMMATRIX & blowbox::Entity::GetWorldTransform ( )

Returns the world transform of this Entity.

Returns
The world transform of this Entity.
Remarks
This function is not marked const because it might calculate the world transform upon call of this function, depending on whether the current transform is dirty.
void blowbox::Entity::Init ( )
protected

Initialises the Entity.

bool blowbox::Entity::IsTransformDirty ( )
protected

Returns whether the transform is dirty.

Returns
Whether the transform is dirty.
bool blowbox::Entity::RemoveChild ( SharedPtr< Entity entity)
protected

Removes a child Entity from this Entity.

Parameters
[in]entityThe child Entity that should be removed from this Entity
Returns
Whether the child Entity was successfully removed
void blowbox::Entity::SetInScene ( bool  in_scene)
protected

Sets whether the Entity is present in the SceneManager.

Parameters
[in]in_sceneWhether the Entity exists in the SceneManager.
void blowbox::Entity::SetLocalPosition ( const DirectX::XMFLOAT3 &  position)

Sets the local position of this Entity.

Parameters
[in]positionThe new local position for this Entity.
void blowbox::Entity::SetLocalRotation ( const DirectX::XMFLOAT3 &  rotation)

Sets the local rotation of this Entity.

Parameters
[in]rotationThe new local rotation for this Entity.
void blowbox::Entity::SetLocalScaling ( const DirectX::XMFLOAT3 &  scaling)

Sets the local scaling of this Entity.

Parameters
[in]scalingThe new local scaling for this Entity.
void blowbox::Entity::SetMesh ( SharedPtr< Mesh mesh)

Sets the Mesh of this Entity.

Parameters
[in]meshThe mesh that you want to bind to this Entity.
void blowbox::Entity::SetName ( const String name)

Sets the name of this Entity.

Parameters
[in]nameThe new name of this Entity.
void blowbox::Entity::Shutdown ( )
protected

Shuts down the Entity.

void blowbox::Entity::Update ( )
protected

Updates the Entity.

void blowbox::Entity::UpdateWorldTransform ( )
protected

Updates the world transform based on current position, rotation and scaling.

Member Data Documentation

Vector<SharedPtr<Entity> > blowbox::Entity::children_
private

All the children of this Entity.

UploadBuffer blowbox::Entity::constant_buffer_
private

This Entity's constant buffer.

bool blowbox::Entity::in_scene_
private

Flag that determines whether this Entity exists in the SceneManager.

SharedPtr<Mesh> blowbox::Entity::mesh_
private

The Mesh object that is attached to this Entity.

String blowbox::Entity::name_
private

The name of this Entity.

WeakPtr<Entity> blowbox::Entity::parent_
private

The parent of this Entity.

DirectX::XMFLOAT3 blowbox::Entity::position_
private

The local position of this Entity.

DirectX::XMFLOAT3 blowbox::Entity::rotation_
private

The local rotation of this Entity.

DirectX::XMFLOAT3 blowbox::Entity::scaling_
private

The local scaling of this Entity.

bool blowbox::Entity::transform_dirty_
private

Whether the current world_transform_ is dirty (i.e. position/rotation/scaling changed).

DirectX::XMMATRIX blowbox::Entity::world_transform_
private

The world transform of this Entity.


The documentation for this class was generated from the following files: