Bubba-3D  0.9.0
Awesome game engine!
Public Member Functions | List of all members
GameObject Class Reference

A class for containing all information about a object in the game world. More...

#include <GameObject.h>

Inheritance diagram for GameObject:
IDrawable

Public Member Functions

 GameObject (GameObject *parent)
 
 GameObject (Mesh *mesh)
 
 GameObject (Mesh *mesh, Mesh *colliderMesh)
 
 GameObject (Mesh *mesh, GameObject *parent)
 
 GameObject (Mesh *mesh, Mesh *colliderMesh, GameObject *parent)
 
virtual void render ()
 
virtual void renderShadow (ShaderProgram *shaderProgram)
 
void addRenderComponent (IRenderComponent *renderer)
 
void addComponent (IComponent *newComponent)
 
void update (float dt)
 
void callEvent (EventType type, GameObject *data)
 
chag::float4x4 getModelMatrix ()
 
void move (chag::float4x4 model_matrix)
 
void update (chag::float4x4 update_matrix)
 
chag::float3 getRelativeScale ()
 
chag::float3 getAbsoluteScale ()
 
void setScale (chag::float3 s)
 
chag::Quaternion getRelativeRotation ()
 
chag::Quaternion getAbsoluteRotation ()
 
void setRotation (chag::Quaternion r)
 
void updateRotation (chag::Quaternion r)
 
chag::float3 getRelativeLocation ()
 
chag::float3 getAbsoluteLocation ()
 
void setLocation (chag::float3 l)
 
void addChild (GameObject *child)
 
TypeIdentifier getIdentifier ()
 
void setIdentifier (TypeIdentifier identifier)
 
void addCollidesWith (TypeIdentifier colliderID)
 
void addCollidesWith (std::initializer_list< TypeIdentifier > colliderIDs)
 
void clearCollidesWithList ()
 
bool collidesWith (TypeIdentifier id)
 
OctreegetOctree ()
 
std::vector< Triangle * > getTriangles ()
 
AABB getTransformedAABB ()
 
Sphere getTransformedSphere ()
 
bool isDynamicObject ()
 
void setDynamic (bool isDynamic)
 
int getId ()
 
void makeDirty ()
 
bool isDirty ()
 

Additional Inherited Members

- Public Attributes inherited from IDrawable
float shininess
 

Detailed Description

A class for containing all information about a object in the game world.

Contains information about the mesh; how to render it, how to manipulate it and how to collide it.

Standard usage:

//Initiation
GameObject object(mesh);
object.addRenderComponent(renderComp); //If the mesh should be rendered
object.addComponent(comp); //All other components, such as MoveComponents
//Rendering
object.render();
//Update all its internal components
object.update(timeSinceLastUpdate);

If the object can move, call setDynamic(true) to indicate this. The objects dynamicity can be used by collision handlers to determine if two objects can possibly collide (eg, two static objects can never collide).

The dirty flag can be used to indicate that an objects should be removed when possible. This can be useful if calculations involving the object needs to be performed after it has been marked as dirty. Then you can at a later point, when calculations arent being done, safely remove the object.

Definition at line 67 of file GameObject.h.

Constructor & Destructor Documentation

GameObject::GameObject ( Mesh mesh)
explicit

Initiates the GameObject with the same mesh for rendering and collision

Parameters
meshThe mesh to render and perform collisions with

Definition at line 61 of file GameObject.cpp.

GameObject::GameObject ( Mesh mesh,
Mesh colliderMesh 
)

Initiates the GameObject with different meshes for rendering and collisions

Parameters
meshThe mesh to use for rendering
colliderMeshThe mesh to use for collision

Definition at line 66 of file GameObject.cpp.

Member Function Documentation

void GameObject::callEvent ( EventType  type,
GameObject data 
)

Calls a specific component event on all components in the GameObject

Parameters
typeThe event to call on the components
data// TODO(Bubbad) Do all events need to involve another gameobject?

Definition at line 207 of file GameObject.cpp.

Octree * GameObject::getOctree ( )

NOTE: The octree has not been transformed.

Returns
The octree containing the GameObject

Definition at line 274 of file GameObject.cpp.

std::vector< Triangle * > GameObject::getTriangles ( )

NOTE: The triangles have not been transformed.

Returns
A list of all the triangles in the GameObject

Definition at line 148 of file GameObject.cpp.

void GameObject::makeDirty ( )

Marks the GameObject as dirty, indicating that it should be removed at some point.

Definition at line 118 of file GameObject.cpp.

void GameObject::move ( chag::float4x4  model_matrix)

Replaces the old model matrix completely

Parameters
modelMatrixThe new model matrix

Definition at line 129 of file GameObject.cpp.

void GameObject::render ( )
virtual

Renders the GameObject using the GameObjects RenderComponent, if any.

Implements IDrawable.

Definition at line 137 of file GameObject.cpp.

void GameObject::renderShadow ( ShaderProgram shaderProgram)
virtual

Renders the GameObject shadows using the GameObjects RenderComponent, if any.

Implements IDrawable.

Definition at line 157 of file GameObject.cpp.

void GameObject::update ( float  dt)

Calls update for all components in the GameObject

Parameters
dtThe time since last called

Definition at line 192 of file GameObject.cpp.

void GameObject::update ( chag::float4x4  update_matrix)

Multiplies the old model matrix with the specified

Parameters
updateMatrixThe matrix to multiply with

Definition at line 133 of file GameObject.cpp.


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