Lysa  0.0
Lysa 3D Engine
Character Class Reference

Detailed Description

A 3D physics body specialized for characters moved by code

+ Inheritance diagram for Character:

Public Member Functions

 Character (float height, float radius, collision_layer layer, const std::string &name=TypeNames[CHARACTER])
 
void setShape (float height, float radius)
 
bool isOnGround () const
 
bool isGround (const CollisionObject &object) const
 
float3 getGroundVelocity () const
 
NodegetGround () const
 
const auto & getUp () const
 
void setUp (const float3 &vector)
 
std::list< Collision > getCollisions () const
 
void setVelocity (const float3 &velocity)
 
void setMaxSlopeAngle (float angle)
 
float getHeight () const
 
float getRadius () const
 
void setVisible (bool visible=true) override
 
void setCollisionLayer (collision_layer layer) override
 
float3 getVelocity () const
 
 ~Character () override = default
 
- Public Member Functions inherited from CollisionObject
auto getCollisionLayer () const
 
bool wereInContact (const CollisionObject *obj) const
 
void setProperty (const std::string &property, const std::string &value) override
 
void setVisible (bool visible=true) override
 
void scale (float scale) override
 
 CollisionObject (const CollisionObject &)
 
 ~CollisionObject () override
 
- Public Member Functions inherited from Node
 Node (const Node &node)
 
 Node (const std::string &name=TypeNames[NODE], Type type=NODE)
 
auto getId () const
 
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)
 
void setTransformLocal (const float4x4 &transform)
 
const float4x4 & getTransformGlobal () const
 
const float4x4 & getTransform () const
 
virtual void setPosition (const float3 &position)
 
virtual void setPosition (const float x, const float y, const float z)
 
float3 getPosition () const
 
void translate (const float3 &localOffset)
 
void translate (float x, float y, float z)
 
virtual void setPositionGlobal (const float3 &position)
 
virtual void setPositionGlobal (const float x, const float y, const float z)
 
float3 getPositionGlobal () const
 
void rotateX (float angle)
 
void rotateY (float angle)
 
void rotateZ (float angle)
 
quaternion getRotation () const
 
quaternion getRotationGlobal () const
 
float3 getRotationEulerAngles () const
 
float3 getRotationEulerAnglesGlobal () const
 
void setRotation (const quaternion &quat)
 
void setRotationGlobal (const quaternion &quat)
 
void setRotationX (float angle)
 
void setRotationY (float angle)
 
void setRotationZ (float angle)
 
float getRotationX () const
 
float getRotationY () const
 
float getRotationZ () const
 
float3 getScale () const
 
float3 getScaleGlobal () const
 
auto * getParent () const
 
bool addChild (std::shared_ptr< Node > child, bool async=false)
 
bool removeChild (const std::shared_ptr< Node > &child, bool async=false)
 
void removeAllChildren (bool async=false)
 
bool haveChild (const std::shared_ptr< Node > &child, bool recursive) const
 
void lookAt (const float3 &target)
 
template<typename T = Node>
std::shared_ptr< T > getChild (const std::string &name) const
 
template<typename T = Node>
std::shared_ptr< T > getChildByPath (const std::string &path) const
 
template<typename T = Node>
std::shared_ptr< T > findFirstChild (const std::string &name) const
 
template<typename T >
std::shared_ptr< T > findFirstChild (const bool recursive=true) const
 
template<typename T >
std::list< std::shared_ptr< T > > findAllChildren (const bool recursive=true) const
 
template<typename T = Node>
std::list< std::shared_ptr< T > > findAllChildren (const std::string &name, const bool recursive=true) const
 
template<typename T = Node>
std::list< std::shared_ptr< T > > findAllChildrenByGroup (const std::string &groupName, const bool recursive=true) const
 
const std::list< std::shared_ptr< Node > > & getChildren () const
 
const std::list< std::string > & getGroups () const
 
void addToGroup (const std::string &group)
 
void removeFromGroup (const std::string &group)
 
bool isVisible () const
 
auto isInGroup (const std::string &group) const
 
void setProcessMode (const ProcessMode mode)
 
bool isProcessed () const
 
auto getType () const
 
auto getViewport () const
 
const std::string & getName () const
 
std::string getPath () const
 
void printTree (int tab=0) const
 
std::shared_ptr< Node > duplicate (bool recursiveFilter=false) const
 
float3 toGlobal (const float3 &local) const
 
float3 toLocal (const float3 &global) const
 
float3 getRightVector () const
 
float3 getLeftVector () const
 
float3 getFrontVector () const
 
float3 getBackVector () const
 
float3 getUpVector () const
 
float3 getDownVector () const
 
void setName (const std::string &nodeName)
 
template<typename T >
std::shared_ptr< TweencreatePropertyTween (typename PropertyTween< T >::Setter set, const T initial, const T final, float duration, const TransitionType ttype=TransitionType::LINEAR, const Tween::Callback &callback=nullptr)
 
void killTween (const std::shared_ptr< Tween > &tween)
 
auto getSharedPtr ()
 
 ~Node () override = default
 
- Public Member Functions inherited from Object
void connect (const Signal::signal &name, const Signal::Handler &handler)
 
void connect (const Signal::signal &name, const std::function< void ()> &handler)
 
void emit (const Signal::signal &name, void *params=nullptr)
 
virtual std::string toString () const
 
 Object () = default
 
virtual ~Object () = default
 
- Public Member Functions inherited from Updatable
auto isUpdated () const
 
void decrementUpdates ()
 
void setUpdated ()
 
void setMaxUpdates (const uint32 maxUpdates)
 

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"
 
- Static Public Attributes inherited from Node
static constexpr auto TypeNames
 

Protected Member Functions

void setPositionAndRotation () override
 
void physicsProcess (float delta) override
 
void process (float alpha) override
 
void attachToViewport (Viewport *viewport) override
 
void enterScene () override
 
void resume () override
 
- Protected Member Functions inherited from CollisionObject
 CollisionObject (const std::shared_ptr< Shape > &shape, collision_layer layer, const std::string &name=TypeNames[COLLISION_OBJECT], Type type=COLLISION_OBJECT)
 
 CollisionObject (collision_layer layer, const std::string &name=TypeNames[COLLISION_OBJECT], Type type=COLLISION_OBJECT)
 
void updateGlobalTransform () override
 
void releaseResources ()
 
void process (float alpha) override
 
void attachToViewport (Viewport *viewport) override
 
void enterScene () override
 
void exitScene () override
 
void pause () override
 
void resume () override
 
- Protected Member Functions inherited from Node
virtual std::shared_ptr< Node > duplicateInstance () const
 
virtual void ready ()
 
virtual void detachFromViewport ()
 

Protected Attributes

float height
 
float radius
 
float3 upVector {AXIS_UP}
 
float yDelta {0}
 
- Protected Attributes inherited from CollisionObject
bool updating {false}
 
collision_layer collisionLayer
 
std::shared_ptr< Shapeshape {nullptr}
 
- Protected Attributes inherited from Node
float4x4 localTransform {}
 
float4x4 globalTransform {}
 

Additional Inherited Members

- Public Types inherited from Node
enum  Type {
  ANIMATION_PLAYER, CAMERA, CHARACTER, COLLISION_AREA,
  COLLISION_OBJECT, DIRECTIONAL_LIGHT, ENVIRONMENT, KINEMATIC_BODY,
  LIGHT, MESH_INSTANCE, NODE, OMNI_LIGHT,
  PHYSICS_BODY, RAYCAST, RIGID_BODY, SKYBOX,
  SPOT_LIGHT, STATIC_BODY, VIEWPORT
}
 Node type. More...
 
- Public Attributes inherited from Updatable
uint32 pendingUpdates {0}
 
uint32 maxUpdates {0}
 

Constructor & Destructor Documentation

Character ( float  height,
float  radius,
collision_layer  layer,
const std::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
~Character ( )
overridedefault

Member Function Documentation

void attachToViewport ( Viewport viewport)
overrideprotectedvirtual

Reimplemented from lysa::Node::attachToViewport()

void enterScene ( )
overrideprotectedvirtual

Reimplemented from lysa::Node::enterScene()

std::list<Collision> getCollisions ( ) const

Returns the list of the currently colliding bodies

Node* getGround ( ) const

Returns the ground node, if any

float3 getGroundVelocity ( ) const

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& getUp ( ) const
inline

Returns the UP axis for this Character

float3 getVelocity ( ) const

Returns the linear velocity of the character

bool isGround ( const CollisionObject object) const

Returns true if object is the ground

bool isOnGround ( ) const

Returns true if the Character is on a ground

void physicsProcess ( float  delta)
overrideprotectedvirtual

Reimplemented from lysa::Node::physicsProcess()

void process ( float  alpha)
overrideprotectedvirtual

Reimplemented from lysa::Node::process()

void resume ( )
overrideprotectedvirtual

Reimplemented from lysa::Node::resume()

void setCollisionLayer ( collision_layer  layer)
overridevirtual

Sets the current collision layer

Reimplemented from lysa::CollisionObject::setCollisionLayer()

void setMaxSlopeAngle ( float  angle)

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

void setPositionAndRotation ( )
overrideprotectedvirtual
void setShape ( float  height,
float  radius 
)

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

void setUp ( const float3 &  vector)

Sets the UP axis for this Character

void setVelocity ( const float3 &  velocity)

Moves the virtualCharacter using this velocity

void setVisible ( bool  visible = true)
overridevirtual

Sets the current visibility of the character.

Reimplemented from lysa::Node::setVisible()

Member Data Documentation

float height
protected
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>

float radius
protected
float3 upVector {AXIS_UP}
protected
float yDelta {0}
protected