Body Class Reference

#include <Body.h>

Inheritance diagram for Body:
Component

# Public Types

typedef const BodySpec BodyROMSpec

# Public Member Functions

void constructor (Entity owner, const BodySpec *bodySpec)
override void handleCommand (int32 command, va_list args)
void reset ()
 Clear the body's state.
void clearNormal (ListenerObject referent)
void update (uint16 cycle, fix7_9_ext elapsedTime)
uint8 applyForce (const Vector3D *force)
void bounce (ListenerObject bounceReferent, Vector3D bouncingPlaneNormal, fixed_t frictionCoefficient, fixed_t bounciness)
uint16 stopMovement (uint16 axis)
void setVelocity (const Vector3D *velocity)
const Vector3DgetVelocity ()
void setDirection (const Vector3D *direction)
const Vector3DgetDirection ()
 Retrieve the direction towards which the body is moving.
void setAxisSubjectToGravity (uint16 axisSubjectToGravity)
uint16 getAxisSubjectToGravity ()
void setAxisForSynchronizationWithBody (uint16 axisForSynchronizationWithBody)
uint16 getAxisForSynchronizationWithBody ()
void setBounciness (fixed_t bounciness)
fixed_t getBounciness ()
void setFrictionCoefficient (fixed_t frictionCoefficient)
fixed_t getFrictionCoefficient ()
void setMass (fixed_t mass)
fixed_t getMass ()
void setPosition (const Vector3D *position, Entity caller)
const Vector3DgetPosition ()
void setMaximumVelocity (Vector3D maximumVelocity)
Vector3D getMaximumVelocity ()
void setMaximumSpeed (fixed_t maximumSpeed)
fixed_t getMaximumSpeed ()
void sendMessages (bool value)
void setSkipCycles (int8 skipCycles)
void setSurroundingFrictionCoefficient (fixed_t surroundingFrictionCoefficient)
fixed_t getSpeed ()
uint16 getMovementOnAllAxis ()
void print (int32 x, int32 y)

# Static Public Member Functions

static void setGlobalGravity (Vector3D gravity)
static void setGlobalFrictionCoefficient (fixed_t frictionCoefficient)
static fixed_t getElapsedTimeStep ()
static fixed_t computeInstantaneousSpeed (fixed_t forceMagnitude, fixed_t gravity, fixed_t mass, fixed_t friction, fixed_t maximumSpeed)

# Protected Attributes

Vector3D position
 Spatial position.
Vector3DPlus internalPosition
 Spatial position at higher decimal precision.
Vector3D velocity
 Velocity vector.
Vector3DPlus internalVelocity
 Velocity vector at higher decimal precision.
Vector3D direction
Vector3D maximumVelocity
 Maximum velocity.
fixed_t speed
 Speed magnitude.
fixed_t maximumSpeed
 Maximum speed.
Vector3D gravity
 Gravity affecting the body.
Vector3D externalForce
 External applied force.
Vector3D friction
 Friction surrounding object.
Vector3D totalNormal
 Total normal forces applied to the body.
VirtualList normals
 List of normal for the forces affecting the body.
Vector3DFlag accelerating
 Flags for the acceleration state of the body on each axis.
fixed_t bounciness
 Body's bounciness factor.
fixed_t frictionCoefficient
 Friction coefficient of the body.
fixed_t surroundingFrictionCoefficient
 Friction coefficient of the body's surroundings.
fixed_t totalFrictionCoefficient
 Friction force's magnitude.
fixed_t frictionForceMagnitude
 Total friction force magnitude affecting the body.
fixed_t mass
 Body's mass.
MovementType movementType
 Body's movement type on each axis.
uint16 axisSubjectToGravity
 Axises on which the body is subject to gravity.
uint16 axisForSynchronizationWithBody
 Axises around which to rotate the owner when syncronizing with body.
int8 skipCycles
 Number of cycles to skip physical simulations to slow down physics.
int8 skipedCycles
 Number of skiped cycles.
bool awake
 If not true, the body skips physical simulations.
bool sendMessages
 If true, the body informs its owner of its change in movement state.
bool movesIndependentlyOnEachAxis
 If true, the movement of the body is independent on each axis.

# Additional Inherited Members

- Private Types inherited from Component
enum  ComponentCommands
enum  ComponentTypes
- Private Member Functions inherited from Component
void constructor (Entity owner, const ComponentSpec *componentSpec)
void destructor ()
 Class' destructor.
ComponentSpecgetSpec ()
Entity getOwner ()
 Retrieve the collider's owner.
uint32 getType ()
virtual void releaseResources ()
 Called to release the component.
virtual RightBox getRightBox ()
- Private Attributes inherited from Component
Entity owner
 Object to which this component attaches to.
const ComponentSpeccomponentSpec
 Pointer to the spec that defines how to initialize the component.
const Transformationtransformation
bool deleteMe
 Flag to mark the component as pending deletion.

# Detailed Description

Class Body

Inherits from Component

Implements newtonian physics.

Definition at line 99 of file Body.h.

# Member Typedef Documentation

# BodyROMSpec

typedef const BodySpec BodyROMSpec

A Body spec that is stored in ROM

Definition at line 78 of file Body.h.

# Member Function Documentation

# applyForce()

uint8 Body::applyForce ( const Vector3D * force)

Apply a force to the body.

Parameters
forceForce to be applied

Definition at line 345 of file Body.c.

# bounce()

void Body::bounce ( ListenerObject bounceReferent,
Vector3D bouncingPlaneNormal,
fixed_t frictionCoefficient,
fixed_t bounciness )

Make the body to bounce on the profixed plane according to the provided friction and bounciness.

Parameters
bounceReferentReferent of the normal to the plane on which the body has to bounce
bouncingPlaneNormalNormal of the plane on which the body has to bounce
frictionCoefficientFriction coefficient of the bounce referent
bouncinessBounciness coefficient of the bounce referent

Definition at line 385 of file Body.c.

# clearNormal()

void Body::clearNormal ( ListenerObject referent)

Remove any normal vector affecting the body belonging to the provided referent.

Parameters
referentNormal vector affecting the body's owner

Definition at line 253 of file Body.c.

# computeInstantaneousSpeed()

static fixed_t Body::computeInstantaneousSpeed ( fixed_t forceMagnitude,
fixed_t gravity,
fixed_t mass,
fixed_t friction,
fixed_t maximumSpeed )
inlinestatic

Compute the instantaneous speed caused by the provided physical properties.

Parameters
forceMagnitudeMagnitude of the applied force
gravityGravity acceleration vector that affects the resulting speed
massThe mass that will aquire the computed speed
frictionFriction affecting the mass that will aquire the computed speed
maximumSpeedMaximum value that the computated speed can reach
Returns
The instantaneous speed caused by the provided physical properties

Definition at line 106 of file Body.c.

# constructor()

void Body::constructor ( Entity owner,
const BodySpec * bodySpec )

Class' constructor

Parameters
ownerEntity to which the body attaches to
bodySpecStruct that specifies the physical properties of bodies

Definition at line 147 of file Body.c.

# getAxisForSynchronizationWithBody()

uint16 Body::getAxisForSynchronizationWithBody ( )

Retrieve the axises around which the owner's rotation must be synchronized.

Returns
Flag containing the axises around which the owner is subject to rotation synchronization

Definition at line 645 of file Body.c.

# getAxisSubjectToGravity()

uint16 Body::getAxisSubjectToGravity ( )

Retrieve the axises on which the body is subject to gravity.

Returns
Flag containing the axises on which the body is subject to gravity

Definition at line 631 of file Body.c.

# getBounciness()

fixed_t Body::getBounciness ( )

Retrieve the body's bounciness factor.

Returns
Body's bounciness factor

Definition at line 668 of file Body.c.

# getDirection()

const Vector3D * Body::getDirection ( )

Retrieve the direction towards which the body is moving.

Definition at line 614 of file Body.c.

# getElapsedTimeStep()

static fixed_t Body::getElapsedTimeStep ( )
static

Retrieve the time that passes between each physical simulation step.

Returns
The time that passes between each physical simulation step

Definition at line 99 of file Body.c.

# getFrictionCoefficient()

fixed_t Body::getFrictionCoefficient ( )

Retrieve the body's friction coefficient.

Returns
Body's friction coefficient

Definition at line 692 of file Body.c.

# getMass()

fixed_t Body::getMass ( )

Retrieve the body's mass.

Returns
Body's mass

Definition at line 706 of file Body.c.

# getMaximumSpeed()

fixed_t Body::getMaximumSpeed ( )

Retrieve the body's maximum speed.

Returns
Maximum magnitude of the body's velocity

Definition at line 755 of file Body.c.

# getMaximumVelocity()

Vector3D Body::getMaximumVelocity ( )

Retrieve the body's maximum velocity.

Returns
3D vector defining the body's maximum speed on each axis (only applicable when the body's movement is independent on each axis)

Definition at line 741 of file Body.c.

# getMovementOnAllAxis()

uint16 Body::getMovementOnAllAxis ( )

Retrieve the body's current movement state

Returns
Flag containing the body's current movement state on each axis

Definition at line 801 of file Body.c.

# getPosition()

const Vector3D * Body::getPosition ( )

Retrieve the body's position.

Returns
Pointer to the body's 3D vector defining its position

Definition at line 727 of file Body.c.

# getSpeed()

fixed_t Body::getSpeed ( )

Retrieve the body's current speed (velocity vector's magnitude).

Returns
Body's current speed (velocity vector's magnitude)

Definition at line 794 of file Body.c.

# getVelocity()

const Vector3D * Body::getVelocity ( )

Retrieve the current velocity at which the body move.

Returns
Pointer to the body's velocity vector

Definition at line 590 of file Body.c.

# handleCommand()

void Body::handleCommand ( int32 command,
va_list args )
virtual

Handle a command.

Parameters
commandCommand to handle
argsVariable arguments list depending on the command to handle

Reimplemented from Component.

Definition at line 218 of file Body.c.

# print()

void Body::print ( int32 x,
int32 y )

Print the body's properties.

Parameters
xScreen x coordinate where to print
yScreen y coordinate where to print

Definition at line 830 of file Body.c.

# reset()

void Body::reset ( )

Clear the body's state.

Definition at line 231 of file Body.c.

# sendMessages()

void Body::sendMessages ( bool value)

Set the flag that enables or prevents the sending of messages to the body's owner about its state changes.

Parameters
valueIf true, the body sends messages to its owner when its movement state changes

# setAxisForSynchronizationWithBody()

void Body::setAxisForSynchronizationWithBody ( uint16 axisForSynchronizationWithBody)

Set the axises around which the owner's rotation must be synchronized.

Parameters
axisForSynchronizationWithBodyFlag containing the axises around which the owner must be subject to rotation synchronization

Definition at line 638 of file Body.c.

# setAxisSubjectToGravity()

void Body::setAxisSubjectToGravity ( uint16 axisSubjectToGravity)

Set the axises on which the body is subject to gravity.

Parameters
axisSubjectToGravityFlag containing the axises on which the body is subject to gravity

Definition at line 621 of file Body.c.

# setBounciness()

void Body::setBounciness ( fixed_t bounciness)

Set the body's bounciness factor.

Parameters
bouncinessValue to set as the body's bounciness factor (between 0 and 1)

Definition at line 652 of file Body.c.

# setDirection()

void Body::setDirection ( const Vector3D * direction)

Set the direction towards which the body must move.

Parameters
directionPointer to a direction vector

Definition at line 597 of file Body.c.

# setFrictionCoefficient()

void Body::setFrictionCoefficient ( fixed_t frictionCoefficient)

Set the body's friction coefficient.

Parameters
frictionCoefficientValue to set as the body's friction coefficient (between 0 and __MAXIMUM_FRICTION_COEFFICIENT)

Definition at line 675 of file Body.c.

# setGlobalFrictionCoefficient()

static void Body::setGlobalFrictionCoefficient ( fixed_t frictionCoefficient)
static

Set the current global gravity.

Parameters
frictionCoefficientValue to set as the body's friction coefficient (between 0 and __MAXIMUM_FRICTION_COEFFICIENT)

Definition at line 92 of file Body.c.

# setGlobalGravity()

static void Body::setGlobalGravity ( Vector3D gravity)
static

Set the current global gravity.

Parameters
gravityGravity to set in the current physical world

Definition at line 85 of file Body.c.

# setMass()

void Body::setMass ( fixed_t mass)

Set the body's mass.

Parameters
massValue to set as the body's mass (between 0.01f and 1)

Definition at line 699 of file Body.c.

# setMaximumSpeed()

void Body::setMaximumSpeed ( fixed_t maximumSpeed)

Set the body's maximum speed.

Parameters
maximumSpeedMaximum magnitude of the body's velocity

Definition at line 748 of file Body.c.

# setMaximumVelocity()

void Body::setMaximumVelocity ( Vector3D maximumVelocity)

Set the body's maximum velocity.

Parameters
maximumVelocity3D vector defining the body's maximum speed on each axis (only applicable when the body's movement is independent on each axis)

Definition at line 734 of file Body.c.

# setPosition()

void Body::setPosition ( const Vector3D * position,
Entity caller )

Set the body's position.

Parameters
position3D vector defining the body's new position
callerMust be the body's owner; otherwise the call to this method doesn't have any effect

Definition at line 713 of file Body.c.

# setSkipCycles()

void Body::setSkipCycles ( int8 skipCycles)

Set the number of cycles to wait before updating the physics simulations on the body.

Parameters
skipCyclesNumber of cycles to skip physical simulations to slow down physics

Definition at line 769 of file Body.c.

# setSurroundingFrictionCoefficient()

void Body::setSurroundingFrictionCoefficient ( fixed_t surroundingFrictionCoefficient)

Set the body's friction coefficient of the its surroundings.

Parameters
surroundingFrictionCoefficientBody's friction coefficient of the its surroundings

Definition at line 777 of file Body.c.

# setVelocity()

void Body::setVelocity ( const Vector3D * velocity)

Set a constant velocity at which the body must move.

Parameters
velocityPointer to a velocity vector

Definition at line 546 of file Body.c.

# stopMovement()

uint16 Body::stopMovement ( uint16 axis)

Stop the body's movement on the speficied axis.

Parameters
axisFlag indicating the axises on which the movement has to stop
Returns
Flag indicatiing the actual axises on which the body's movement stopped

Definition at line 499 of file Body.c.

# update()

void Body::update ( uint16 cycle,
fix7_9_ext elapsedTime )

Update the physics simulation on the body.

Parameters
cycleCycle number during the current second
elapsedTimeElapsed time since the last call to this method

Definition at line 285 of file Body.c.

# Member Data Documentation

# accelerating

Vector3DFlag Body::accelerating
protected

Flags for the acceleration state of the body on each axis.

Definition at line 143 of file Body.h.

# awake

void Body::awake
protected

If not true, the body skips physical simulations.

Definition at line 179 of file Body.h.

# axisForSynchronizationWithBody

uint16 Body::axisForSynchronizationWithBody
protected

Axises around which to rotate the owner when syncronizing with body.

Definition at line 170 of file Body.h.

# axisSubjectToGravity

uint16 Body::axisSubjectToGravity
protected

Axises on which the body is subject to gravity.

Definition at line 167 of file Body.h.

# bounciness

fixed_t Body::bounciness
protected

Body's bounciness factor.

Definition at line 146 of file Body.h.

# direction

Vector3D Body::direction
protected

Definition at line 116 of file Body.h.

# externalForce

Vector3D Body::externalForce
protected

External applied force.

Definition at line 131 of file Body.h.

# friction

Vector3D Body::friction
protected

Friction surrounding object.

Definition at line 134 of file Body.h.

# frictionCoefficient

fixed_t Body::frictionCoefficient
protected

Friction coefficient of the body.

Definition at line 149 of file Body.h.

# frictionForceMagnitude

fixed_t Body::frictionForceMagnitude
protected

Total friction force magnitude affecting the body.

Definition at line 158 of file Body.h.

# gravity

Vector3D Body::gravity
protected

Gravity affecting the body.

Definition at line 128 of file Body.h.

# internalPosition

Vector3DPlus Body::internalPosition
protected

Spatial position at higher decimal precision.

Definition at line 107 of file Body.h.

# internalVelocity

Vector3DPlus Body::internalVelocity
protected

Velocity vector at higher decimal precision.

Definition at line 113 of file Body.h.

# mass

fixed_t Body::mass
protected

Body's mass.

Definition at line 161 of file Body.h.

# maximumSpeed

fixed_t Body::maximumSpeed
protected

Maximum speed.

Definition at line 125 of file Body.h.

# maximumVelocity

Vector3D Body::maximumVelocity
protected

Maximum velocity.

Definition at line 119 of file Body.h.

# movementType

MovementType Body::movementType
protected

Body's movement type on each axis.

Definition at line 164 of file Body.h.

# movesIndependentlyOnEachAxis

bool Body::movesIndependentlyOnEachAxis
protected

If true, the movement of the body is independent on each axis.

Definition at line 185 of file Body.h.

# normals

VirtualList Body::normals
protected

List of normal for the forces affecting the body.

Definition at line 140 of file Body.h.

# position

Vector3D Body::position
protected

Spatial position.

Definition at line 104 of file Body.h.

# sendMessages

void Body::sendMessages
protected

If true, the body informs its owner of its change in movement state.

Definition at line 182 of file Body.h.

# skipCycles

int8 Body::skipCycles
protected

Number of cycles to skip physical simulations to slow down physics.

Definition at line 173 of file Body.h.

# skipedCycles

int8 Body::skipedCycles
protected

Number of skiped cycles.

Definition at line 176 of file Body.h.

# speed

fixed_t Body::speed
protected

Speed magnitude.

Definition at line 122 of file Body.h.

# surroundingFrictionCoefficient

fixed_t Body::surroundingFrictionCoefficient
protected

Friction coefficient of the body's surroundings.

Definition at line 152 of file Body.h.

# totalFrictionCoefficient

fixed_t Body::totalFrictionCoefficient
protected

Friction force's magnitude.

Definition at line 155 of file Body.h.

# totalNormal

Vector3D Body::totalNormal
protected

Total normal forces applied to the body.

Definition at line 137 of file Body.h.

# velocity

Vector3D Body::velocity
protected

Velocity vector.

Definition at line 110 of file Body.h.


The documentation for this class was generated from the following files:
  • VUEngine-Core/source/Component/Body/Body.h
  • VUEngine-Core/source/Component/Body/Body.c