Carpenter Engine
A C++ game engine with a build once run anywhere solution
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
Engine::GameObject Class Reference

A Game Object loaded in the scene. More...

#include <GameObject.hpp>

Inheritance diagram for Engine::GameObject:
Engine::Node Engine::Camera

Public Member Functions

 GameObject (std::string name)
 Default constructor.
 
Vec3f GetGlobalPosition ()
 Returns the position of the game object relative to the global 0,0.
 
Vec3f GetGlobalRotation ()
 Returns the overall rotation in respect to any parent game objects.
 
- Public Member Functions inherited from Engine::Node
 Node (std::string name)
 Default constructor.
 
virtual ~Node ()
 Default destructor.
 
size_t AddChild (Node *child)
 Adds a child to the node and assigns itself as the parent of the new node.
 
NodeGetChild (size_t index)
 Returns a reference to the child at the specified index.
 
Success RemoveChild (size_t index)
 Removes the child at the specified index.
 
Success SetEnabled (bool enabled=true)
 Toggles the state of the node.
 
virtual void OnEnable ()
 Overridable enable method for the node.
 
virtual void OnDisable ()
 Overridable disable method for the node.
 
virtual void Init ()
 
virtual void Draw ()
 Overridable draw method for the node.
 
virtual void Update (float dt)
 Overridable update method for the node.
 

Public Attributes

Vec3f Position {0.0f, 0.0f, 0.0f}
 
Vec3f Scale {1.0f, 1.0f, 1.0f}
 
Vec3f Rotation {0.0f, 0.0f, 0.0f}
 
- Public Attributes inherited from Engine::Node
const char * m_nodeType
 
std::string m_name
 

Additional Inherited Members

- Protected Attributes inherited from Engine::Node
Nodem_parent
 

Detailed Description

A Game Object loaded in the scene.

Each game object is a node. However it also has its own position, rotation, and scale allowing it to be moved around in space.

Example

// Object of Focus
class CubeObject : public GameObject {
public:
Cube mesh;
CubeObject() : GameObject("Cube") {
Position = {0, 3, 4};
}
void Draw() override {
Engine::Game::getInstance().GetRenderer().DrawMesh(&mesh, Position, Scale, Rotation);
}
};
// Implementation
class CubeScene : public Scene {
public:
CubeObject cube;
CubeScene() : Scene("CubeScene") {
AddChild(&cube);
}
};
A Game Object loaded in the scene.
Definition GameObject.hpp:50
Graphics::Renderer & GetRenderer()
Definition Game.cpp:65
void DrawMesh(Mesh *mesh, Vec3f position={0, 0, 0}, Vec3f scale={1, 1, 1}, Vec3f rotation={0, 0, 0})
Draws a mesh to the canvas.
Definition Renderer.cpp:69
See also
Node
Author
Roberto Selles

Constructor & Destructor Documentation

◆ GameObject()

Engine::GameObject::GameObject ( std::string  name)

Default constructor.

takes in an object name to make searching easier

Member Function Documentation

◆ GetGlobalPosition()

Engine::Vec3f Engine::GameObject::GetGlobalPosition ( )

Returns the position of the game object relative to the global 0,0.

Returns
The global position of the game object

◆ GetGlobalRotation()

Engine::Vec3f Engine::GameObject::GetGlobalRotation ( )

Returns the overall rotation in respect to any parent game objects.

Returns
The global rotation

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