Lysa Nodes  0.0
Lysa Nodes — Scene Graph for the Lysa Engine
RigidBody Class Reference

Detailed Description

A 3D physics body that is moved by a physics simulation, responds to forces.

+ Inheritance diagram for RigidBody:

Public Member Functions

 RigidBody (const std::shared_ptr< CollisionShape > &shape, collision_layer layer=0, const std::string &name=TypeNames[RIGID_BODY])
 
 RigidBody (const std::string &name=TypeNames[RIGID_BODY])
 
void setDensity (float density)
 
auto getDensity () const
 
virtual void setVelocity (const float3 &velocity, const quaternion &direction)
 
virtual void setGravityFactor (float factor)
 
void setMass (float value)
 
float getMass () const
 
virtual float3 getVelocity () const
 
void addForce (const float3 &force)
 
void addForce (const float3 &force, const float3 &position)
 
void addImpulse (const float3 &force)
 
void addImpulse (const float3 &force, const float3 &position)
 
void setProperty (const std::string &property, const std::string &value) override
 
 ~RigidBody () override = default
 
- Public Member Functions inherited from PhysicsBody
void recreateBody ()
 
 ~PhysicsBody () override = default
 
void setProperty (const std::string &property, const std::string &value) override
 
void activate (const float3 &position, const quaternion &rotation, const float3 &scale) override
 
- Public Member Functions inherited from CollisionObject
 CollisionObject (const CollisionObject &)
 
 ~CollisionObject () override
 
void setProperty (const std::string &property, const std::string &value) override
 
void setVisible (bool visible=true) override
 
void scale (float scale) override
 
void updateGlobalTransform () override
 
bool isVisible () const override
 
bool isProcessed () const override
 
- Public Member Functions inherited from Node
 Node (const Node &node)
 
 Node (const std::string &name=TypeNames[NODE], Type type=NODE)
 
virtual ~Node () = default
 
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 (const InputEvent &inputEvent)
 
const float4x4 & getTransform () const
 
void setTransform (const float4x4 &transform)
 
const float4x4 & getTransformGlobal () 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 (const float x, const float y, const float z)
 
virtual void setPositionGlobal (const float3 &position)
 
virtual void setPositionGlobal (const float x, const float y, const float z)
 
float3 getPositionGlobal () const
 
void rotate (const quaternion &quaternion)
 
void rotateX (float angle)
 
void rotateY (float angle)
 
void rotateZ (float angle)
 
void rotateGlobalX (float angle)
 
void rotateGlobalY (float angle)
 
void rotateGlobalZ (float angle)
 
quaternion getRotation () const
 
quaternion getRotationGlobal () const
 
float3 getRotationEulerAngles () const
 
float3 getRotationEulerAnglesGlobal () const
 
virtual void scale (float scale)
 
void setScale (const float3 &scale)
 
void setRotation (const quaternion &quat)
 
void setRotationGlobal (const quaternion &quat)
 
void setRotation (const float3 &rot)
 
void setRotationX (float angle)
 
void setRotationY (float angle)
 
void setRotationZ (float angle)
 
float getRotationX () const
 
float getRotationY () const
 
float getRotationZ () const
 
float getRotationGlobalX () const
 
float getRotationGlobalY () const
 
float getRotationGlobalZ () const
 
void setRotationGlobalX (float angle)
 
void setRotationGlobalY (float angle)
 
void setRotationGlobalZ (float angle)
 
float3 getScale () const
 
float3 getScaleGlobal () const
 
template<typename T = Node>
const std::shared_ptr< T > & addChild (const std::shared_ptr< T > &child, bool async=false)
 
template<typename T = Node>
bool removeChild (const std::shared_ptr< T > &child)
 
void removeAllChildren (bool async=false)
 
void lookAt (const float3 &target)
 
template<typename T = Node>
std::list< std::shared_ptr< T > > findAllChildrenByGroup (const std::string &groupName, const bool recursive=true) const
 
const std::list< std::string > & getGroups () const
 
void addToGroup (const std::string &group)
 
void removeFromGroup (const std::string &group)
 
virtual bool isVisible () const
 
virtual void setVisible (bool visible=true)
 
bool isInGroup (const std::string &group) const
 
void setProcessMode (const ProcessMode mode)
 
bool isProcessed () const
 
auto getType () const
 
std::string getPath () const
 
virtual void setProperty (const std::string &property, const std::string &value)
 
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
 
template<typename T >
bool haveChild (const std::shared_ptr< T > &child, const bool recursive=true) const
 
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::string getRelativePath (const std::shared_ptr< T > &root) 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
 
const std::list< std::shared_ptr< Node > > & getChildren ()
 
const std::list< std::shared_ptr< Node > > & getChildren () const
 
void setName (const std::string &nodeName)
 
template<typename T = Node>
std::shared_ptr< T > getSharedPtr ()
 
const std::string & getName () const
 
template<typename T = Scene>
T * getScene () const
 
const auto & getParent () const
 
bool haveParent () const
 
virtual std::shared_ptr< Node > copy () const
 
void setLuaThis () override
 

Protected Member Functions

void createBody (const float3 &position, const quaternion &rotation, const float3 &scale) override
 
void activate (const float3 &position, const quaternion &rotation, const float3 &scale) override
 
std::shared_ptr< Nodecopy () const override
 
- Protected Member Functions inherited from PhysicsBody
void setShape (const std::shared_ptr< CollisionShape > &shape)
 
- Protected Member Functions inherited from CollisionObject
 CollisionObject (const std::shared_ptr< CollisionShape > &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)
 
- Protected Member Functions inherited from Node
virtual void updateGlobalTransform ()
 

Protected Attributes

float gravityFactor {1.0f}
 
float density {100.0f}
 
float mass {-1.0f}
 
- Protected Attributes inherited from Node
float4x4 localTransform {}
 
float4x4 globalTransform {}
 
Scene * scene {nullptr}
 

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...
 
- Static Public Member Functions inherited from Node
static std::string sanitizeName (const std::string &name)
 
- Static Public Attributes inherited from Node
static constexpr auto TypeNames
 Display names for each node Type value, indexed by the Type enum. More...
 

Constructor & Destructor Documentation

RigidBody ( const std::shared_ptr< CollisionShape > &  shape,
collision_layer  layer = 0,
const std::string &  name = TypeNames[RIGID_BODY] 
)

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

RigidBody ( const std::string &  name = TypeNames[RIGID_BODY])

Creates a RigidBody without a collision shape,

~RigidBody ( )
overridedefault

Member Function Documentation

void activate ( const float3 &  position,
const quaternion &  rotation,
const float3 &  scale 
)
overrideprotected
void addForce ( const float3 &  force)

Adds force at the center of mass for the next time step, will be reset after the next physics update

void addForce ( const float3 &  force,
const float3 &  position 
)

Adds force at position for the next time step, will be reset after the next physics update

void addImpulse ( const float3 &  force)

Adds an impulse at the center of mass

void addImpulse ( const float3 &  force,
const float3 &  position 
)

Adds an impulse at position

std::shared_ptr<Node> copy ( ) const
overrideprotected
void createBody ( const float3 &  position,
const quaternion &  rotation,
const float3 &  scale 
)
overrideprotectedvirtual
auto getDensity ( ) const
inline

Returns the density of the body

float getMass ( ) const

Returns the body's mass.

virtual float3 getVelocity ( ) const
virtual

Returns the linear velocity

void setDensity ( float  density)

Sets the density of the body

virtual void setGravityFactor ( float  factor)
virtual

Sets the gravity multiplier (set to 0.0f to disable gravity).

void setMass ( float  value)

Sets the body's mass.

void setProperty ( const std::string &  property,
const std::string &  value 
)
override
virtual void setVelocity ( const float3 &  velocity,
const quaternion &  direction 
)
virtual

Sets the linear velocity

Member Data Documentation

float density {100.0f}
protected
float gravityFactor {1.0f}
protected
float mass {-1.0f}
protected