ZeroZero Game Engine  v0.0
A 3D game engine using Vulkan & Jolt
Public Member Functions | Static Public Attributes | List of all members
Character Class Reference

Detailed Description

A 3D physics body specialized for characters moved by code

Inheritance diagram for Character:
CollisionObject Node Object

Public Member Functions

 Character (float height, float radius, uint32_t layer, const string &name=TypeNames[CHARACTER])
 
void setShape (float height, float radius)
 
auto isOnGround () const
 
auto isGround (const CollisionObject &object) const
 
vec3 getGroundVelocity () const
 
NodegetGround () const
 
const auto & getUpVector () const
 
void setUpVector (const vec3 &vector)
 
list< Collision > getCollisions () const
 
void setVelocity (const vec3 &velocity)
 
void setMaxSlopeAngle (float angle) const
 
float getHeight () const
 
float getRadius () const
 
void setVisible (bool visible=true) override
 
void setCollisionLayer (uint32_t layer) override
 
vec3 getVelocity () const
 
- Public Member Functions inherited from CollisionObject
auto getCollisionLayer () const
 
virtual void setCollisionLayer (uint32_t layer)
 
auto sharedPtr ()
 
bool wereInContact (const CollisionObject *obj) const
 
- Public Member Functions inherited from Node
 Node (const Node &orig)
 
 Node (const string &nodeName="Node", Type type=NODE)
 
virtual void onReady ()
 
virtual void onEnterScene ()
 
virtual void onExitScene ()
 
virtual void onProcess (const float alpha)
 
virtual void onPhysicsProcess (const float delta)
 
virtual bool onInput (InputEvent &inputEvent)
 
const mat4 & getTransformLocal () const
 
const mat4 & getTransformGlobal () const
 
vec3 toGlobal (vec3 local) const
 
vec3 toLocal (vec3 global) const
 
virtual void setPosition (vec3 position)
 
vec3 getPosition () const
 
void translate (const vec3 &localOffset)
 
virtual void setPositionGlobal (const vec3 &position)
 
vec3 getPositionGlobal () const
 
void rotate (quat quaternion)
 
void rotateTowards (const quat &targetRotation, float maxAngle)
 
void rotateX (float angle)
 
void rotateY (float angle)
 
void rotateZ (float angle)
 
void setRotation (const quat &quater)
 
void setRotationGlobal (const quat &quater)
 
void setRotation (const vec3 &rot)
 
void setRotationX (float angle)
 
void setRotationY (float angle)
 
void setRotationZ (float angle)
 
vec3 getRotation () const
 
vec3 getRotationGlobal () const
 
quat getRotationQuaternion () const
 
quat getRotationQuaternionGlobal () const
 
float getRotationX () const
 
float getRotationY () const
 
float getRotationZ () const
 
virtual void setScale (const vec3 &scale)
 
void setScale (float scale)
 
vec3 getScale () const
 
vec3 getScaleGlobal () const
 
ProcessMode getProcessMode () const
 
void setProcessMode (const ProcessMode mode)
 
bool isProcessed () const
 
Node * getParent () const
 
bool addChild (shared_ptr< Node > child, bool async=false)
 
bool removeChild (const shared_ptr< Node > &child, bool async=false)
 
void removeAllChildren (bool async=false)
 
bool haveChild (const shared_ptr< Node > &child, bool recursive) const
 
template<typename T = Node>
shared_ptr< T > getChild (const string &name) const
 
template<typename T = Node>
shared_ptr< T > getChildByPath (const string &path) const
 
template<typename T = Node>
shared_ptr< T > findFirstChild (const string &name) const
 
void printTree (int tab=0) const
 
string toString () const override
 
id_t getId () const
 
shared_ptr< Node > duplicate (bool recursiveFilter=false) const
 
template<typename T = Node>
shared_ptr< T > makeFrom ()
 
template<typename T >
shared_ptr< T > findFirstChild (const bool recursive=true) const
 
template<typename T >
list< shared_ptr< T > > findAllChildren (const bool recursive=true) const
 
template<typename T = Node>
list< shared_ptr< T > > findAllChildrenByGroup (const string &groupName, const bool recursive=true) const
 
vec3 getRightVector () const
 
vec3 getLeftVector () const
 
vec3 getFrontVector () const
 
vec3 getBackVector () const
 
vec3 getUpVector () const
 
vec3 getDownVector () const
 
template<typename T >
shared_ptr< TweencreatePropertyTween (PropertyTween< T >::Setter set, T initial, T final, float duration, const TransitionType ttype=TransitionType::LINEAR, const Tween::Callback &callback=nullptr)
 
void killTween (const shared_ptr< Tween > &tween)
 
virtual void setProperty (const string &property, const string &value)
 
void setName (const string &nodeName)
 
const list< shared_ptr< Node > > & getChildren () const
 
Type getType () const
 
const string & getName () const
 
string getPath () const
 
const list< string > & getGroups () const
 
void addToGroup (const string &group)
 
void removeFromGroup (const string &group)
 
bool isInGroup (const string &group) const
 
bool isVisible () const
 
virtual void setVisible (bool visible=true)
 
bool isInsideTree () const
 
void setCastShadows (bool castShadows)
 
- Public Member Functions inherited from Object
void connect (const Signal::signal &name, const Signal::Handler &handler)
 
void connect (const Signal::signal &name, const function< void ()> &handler)
 
void emit (const Signal::signal &name, void *params=nullptr)
 
virtual string toString () const
 

Static Public Attributes

static const Signal::signal on_collision = "on_character_collision"
 
- Static Public Attributes inherited from CollisionObject
static const Signal::signal on_collision_starts = "on_collision_starts"
 
static const Signal::signal on_collision_persists = "on_collision_persists"
 

Additional Inherited Members

- Public Types inherited from Node
enum  Type
 Node type.
 

Constructor & Destructor Documentation

Character ( float  height,
float  radius,
uint32_t  layer,
const string &  name = TypeNames[CHARACTER] 
)
explicit

Creates a Character with a given collision shape, belonging to the layer layers and detecting collisions with bodies having a layer in the mask value.

Parameters
heightHeight of the collision shape capsule shape
radiusRadius of the collision shape capsule
layerCollision layer
nameName of the node

Member Function Documentation

list<Collision> getCollisions ( ) const
nodiscard

Returns the list of the currently colliding bodies

Node* getGround ( ) const
nodiscard

Returns the ground node, if any

vec3 getGroundVelocity ( ) const
nodiscard

Returns the velocity in the world space of the ground.

float getHeight ( ) const
inline

Returns the height of the capsule collision shape

float getRadius ( ) const
inline

Returns the radius of the capsule collision shape

const auto& getUpVector ( ) const
nodiscardinline

Returns the UP axis for this Character

vec3 getVelocity ( ) const

Returns the linear velocity of the character

auto isGround ( const CollisionObject object) const
nodiscardinline

Returns true if object is the ground

auto isOnGround ( ) const
nodiscardinline

Returns true if the Character is on a ground

void setCollisionLayer ( uint32_t  layer)
override

Sets the current collision layer

void setMaxSlopeAngle ( float  angle) const

Set the maximum angle of slope that character can still walk on (degrres)

void setShape ( float  height,
float  radius 
)

Sets a new capsule shape, recreates the virtualCharacter in the physic system

void setUpVector ( const vec3 &  vector)

Sets the UP axis for this Character

void setVelocity ( const vec3 &  velocity)

Moves the virtualCharacter using this velocity

void setVisible ( bool  visible = true)
override

Sets the current visibility of the character.

Member Data Documentation

const Signal::signal on_collision = "on_character_collision"
inlinestatic

Signal called whenever the character collides with a body and reports the first contact point in a CollisionObject::Collision<br>