Tramway SDK
Public Member Functions | List of all members
tram::PhysicsComponent Class Reference

#include <physics.h>

Inheritance diagram for tram::PhysicsComponent:
tram::EntityComponent

Public Member Functions

 PhysicsComponent ()
 
 ~PhysicsComponent ()
 
void EventHandler (Event &event)
 
void Start ()
 
name_t GetModel ()
 Returns the name of the collision model. More...
 
void SetModel (name_t model)
 Sets the collision model. More...
 
void SetMass (float mass)
 Sets the mass of the physics object. More...
 
void SetShape (Physics::CollisionShape shape)
 Sets the collision shape of the physics object. More...
 
void Push (vec3 direction)
 Pushes the physics object. More...
 
void Push (vec3 direction, vec3 local_position)
 
void Spin (vec3 direction)
 
void SetCollisionMask (uint32_t flags)
 Sets the collision mask of the physics object. More...
 
void SetCollisionGroup (uint32_t flags)
 Sets the collision group of the physics object. More...
 
uint32_t GetCollisionMask ()
 Returns the collision mask. More...
 
uint32_t GetCollisionGroup ()
 Returns the collision group. More...
 
void SetDebugDrawing (bool drawing)
 Sets the debug drawing of a physics object. More...
 
void SetKinematic (bool kinematic)
 Sets the physics object to kinematic. More...
 
void SetUpdateParentTransform (bool update)
 Sets whether the movement of the rigibody should update parent Entity's transform. More...
 
void SetRotation (quat rotation)
 Sets the rotation of the physics object. More...
 
void SetLocation (vec3 location)
 Sets the position of the physics object. More...
 
void DisableDeactivation ()
 Disables deactivation of the object. More...
 
void Awaken ()
 Awakens the object. More...
 
void Sleep ()
 Puts the object to sleep. More...
 
void SetAngularFactor (vec3 factor)
 Sets the angular factor of the physics object. More...
 
void SetLinearFactor (vec3 factor)
 Sets the angular factor of the physics object. More...
 
void SetVelocity (const vec3 &velocity)
 Sets the velocity of the physics object. More...
 
vec3 GetVelocity ()
 Returns the velocity of the physics object. More...
 
- Public Member Functions inherited from tram::EntityComponent
 EntityComponent ()
 
virtual ~EntityComponent ()
 
virtual void Init ()
 
bool IsReady ()
 
bool IsInit ()
 
EntityGetParent ()
 
void SetParent (Entity *parent)
 

Additional Inherited Members

- Protected Member Functions inherited from tram::EntityComponent
void ResourceReady ()
 
- Protected Attributes inherited from tram::EntityComponent
size_t resources_waiting = 0
 
bool is_ready = false
 
bool is_init = false
 
Entityparent = nullptr
 

Constructor & Destructor Documentation

◆ PhysicsComponent()

tram::PhysicsComponent::PhysicsComponent ( )
inline

◆ ~PhysicsComponent()

tram::PhysicsComponent::~PhysicsComponent ( )

Member Function Documentation

◆ Awaken()

void tram::PhysicsComponent::Awaken ( )

Awakens the object.

◆ DisableDeactivation()

void tram::PhysicsComponent::DisableDeactivation ( )

Disables deactivation of the object.

This makes the object to never fall asleep.

◆ EventHandler()

void tram::PhysicsComponent::EventHandler ( Event event)
inlinevirtual

Implements tram::EntityComponent.

◆ GetCollisionGroup()

uint32_t tram::PhysicsComponent::GetCollisionGroup ( )

Returns the collision group.

See SetCollisionGroup() for more information.

◆ GetCollisionMask()

uint32_t tram::PhysicsComponent::GetCollisionMask ( )

Returns the collision mask.

See SetCollisionMask() for more information.

◆ GetModel()

name_t tram::PhysicsComponent::GetModel ( )

Returns the name of the collision model.

◆ GetVelocity()

vec3 tram::PhysicsComponent::GetVelocity ( )

Returns the velocity of the physics object.

Always returns zero velocity if component is not loaded.

◆ Push() [1/2]

void tram::PhysicsComponent::Push ( vec3  direction)

Pushes the physics object.

I have no idea what the units are. Direction of direction is the direction into which the object will be pushed and the length of the vector is the force of the push.

◆ Push() [2/2]

void tram::PhysicsComponent::Push ( vec3  direction,
vec3  local_position 
)

◆ SetAngularFactor()

void tram::PhysicsComponent::SetAngularFactor ( vec3  factor)

Sets the angular factor of the physics object.

Changes how much the object will rotate around the x, y, z axes. Can be used to restrict rotation around certain axes.

◆ SetCollisionGroup()

void tram::PhysicsComponent::SetCollisionGroup ( uint32_t  flags)

Sets the collision group of the physics object.

Collision group is a bitmask. A physics object will only collide with an another object if their collision group and collision mask bitmasks have at least one bit in common, i.e. they will be bitwise and'ed together.

◆ SetCollisionMask()

void tram::PhysicsComponent::SetCollisionMask ( uint32_t  flags)

Sets the collision mask of the physics object.

Collision mask is a bitmask. A physics object will only collide with an another object if their collision group and collision mask bitmasks have at least one bit in common, i.e. they will be bitwise and'ed together.

◆ SetDebugDrawing()

void tram::PhysicsComponent::SetDebugDrawing ( bool  drawing)

Sets the debug drawing of a physics object.

Set to false, if you don't want the physics object to show up when drawing physics debug.

◆ SetKinematic()

void tram::PhysicsComponent::SetKinematic ( bool  kinematic)

Sets the physics object to kinematic.

If set to kinematic, then the physics object will poll its parent entity for its position, instead of simulated and pushing its position into its parent entity.

Note
Use DisableDeactivation() if you don't want to constantly wake the object up.

◆ SetLinearFactor()

void tram::PhysicsComponent::SetLinearFactor ( vec3  factor)

Sets the angular factor of the physics object.

Changes how much the object will move along the x, y, z axes. Can be used to restrict movement along certain axes.

◆ SetLocation()

void tram::PhysicsComponent::SetLocation ( vec3  location)

Sets the position of the physics object.

◆ SetMass()

void tram::PhysicsComponent::SetMass ( float  mass)

Sets the mass of the physics object.

Mass specified in kilograms. If the mass is set to 0, then it's assumed to be infinite, and the object will become static and immovable.

Note
Has no effect after the PhysicsComponent is loaded.

◆ SetModel()

void tram::PhysicsComponent::SetModel ( name_t  model)

Sets the collision model.

◆ SetRotation()

void tram::PhysicsComponent::SetRotation ( quat  rotation)

Sets the rotation of the physics object.

◆ SetShape()

void tram::PhysicsComponent::SetShape ( Physics::CollisionShape  shape)

Sets the collision shape of the physics object.

◆ SetUpdateParentTransform()

void tram::PhysicsComponent::SetUpdateParentTransform ( bool  update)

Sets whether the movement of the rigibody should update parent Entity's transform.

If set to true, then whenever the rigidbody moves, the transform of the parent will be set to the transform of the rigidbody. Otherwise, the parent's transform will remain unaffected.

Note
This only works if set before the component is initialized.

◆ SetVelocity()

void tram::PhysicsComponent::SetVelocity ( const vec3 velocity)

Sets the velocity of the physics object.

Only works if is component is loaded.

◆ Sleep()

void tram::PhysicsComponent::Sleep ( )

Puts the object to sleep.

◆ Spin()

void tram::PhysicsComponent::Spin ( vec3  direction)

◆ Start()

void tram::PhysicsComponent::Start ( )
virtual

Implements tram::EntityComponent.


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