Drag[en]gine Game Engine  1.0
deForceField Class Reference

Force Field. More...

#include <deForceField.h>

Inheritance diagram for deForceField:
deResource deObject

Public Types

enum  eApplicationTypes { eatDirect, eatSurface, eatMass, eatSpeed }
 Force application types. More...
enum  eFieldTypes { eftRadial, eftLinear, eftVortex }
 Field types. More...

Public Member Functions

const decDVectorGetPosition () const
 Position. More...
void SetPosition (const decDVector &position)
 Set position. More...
const decQuaternionGetOrientation () const
 Orientation. More...
void SetOrientation (const decQuaternion &orientation)
 Set orientation. More...
const decShapeListGetInfluenceArea () const
 Influence area. More...
void SetInfluenceArea (const decShapeList &area)
 Set influence area. More...
float GetRadius () const
 Falloff radius. More...
void SetRadius (float radius)
 Set falloff radius. More...
float GetExponent () const
 Falloff exponent. More...
void SetExponent (float exponent)
 Set falloff exponent. More...
eFieldTypes GetFieldType () const
 Field type. More...
void SetFieldType (eFieldTypes type)
 Set field type. More...
eApplicationTypes GetApplicationType () const
 Force application type. More...
void SetApplicationType (eApplicationTypes type)
 Set application type. More...
const decVectorGetDirection () const
 Force direction. More...
void SetDirection (const decVector &direction)
 Set force direction. More...
float GetForce () const
 Force in newton. More...
void SetForce (float force)
 Set force in newton. More...
float GetFluctuationDirection () const
 Fluctuation of direction in radians. More...
void SetFluctuationDirection (float fluctuation)
 Set fluctuation of direction in radians. More...
float GetFluctuationForce () const
 Fluctuation of force in newton. More...
void SetFluctuationForce (float fluctuation)
 Set fluctuation of force in newton. More...
const decCollisionFilterGetCollisionFilter () const
 Collision filter. More...
void SetCollisionFilter (const decCollisionFilter &filter)
 Set collision filter. More...
bool GetEnabled () const
 Force field is enabled. More...
void SetEnabled (bool enabled)
 Set if force field is enabled. More...
System Peers
deBasePhysicsForceFieldGetPeerPhysics () const
 Physics system peer object. More...
void SetPeerPhysics (deBasePhysicsForceField *peer)
 Set physics system peer object. More...
Linked List
deWorldGetParentWorld () const
 Parent world or NULL. More...
void SetParentWorld (deWorld *world)
 Set parent world or NULL. More...
deForceFieldGetLLWorldPrev () const
 Previous force field in the parent world linked list. More...
void SetLLWorldPrev (deForceField *forceField)
 Set next force field in the parent world linked list. More...
deForceFieldGetLLWorldNext () const
 Next force field in the parent world linked list. More...
void SetLLWorldNext (deForceField *forceField)
 Set next force field in the parent world linked list. More...
- Public Member Functions inherited from deResource
deResourceManagerGetResourceManager () const
 Resource manager or NULL if resource is leaking. More...
deEngineGetEngine () const
 Game engine object from resource manager. More...
deResourceGetLLManagerPrev () const
 Previous resource in the resource manager linked list. More...
void SetLLManagerPrev (deResource *resource)
 Set next resource in the resource manager linked list. More...
deResourceGetLLManagerNext () const
 Next resource in the resource manager linked list. More...
void SetLLManagerNext (deResource *resource)
 Set next resource in the resource manager linked list. More...
void MarkLeaking ()
 Marks the resource leaking. More...
 deResource (deResourceManager *resourceManager)
 Create resource. More...
- Public Member Functions inherited from deObject
int GetRefCount () const
 Reference count. More...
void AddReference ()
 Add reference increasing reference count by 1. More...
void FreeReference ()
 Decrease reference count by one and delete object if count reaches 0. More...
 deObject ()
 Create object with reference count of 1. More...

Constructors and Destructors

 deForceField (deForceFieldManager *manager)
 Create force field. More...
virtual ~deForceField ()
 Clean up force field. More...

Additional Inherited Members

- Protected Member Functions inherited from deResource
virtual ~deResource ()
 Clean up resource. More...
- Protected Member Functions inherited from deObject
virtual ~deObject ()
 Clean up object. More...

Detailed Description

Force Field.

Applies a force to prop fields, particles cast by particle systems and dynamic colliders.

The field affects elements inside its area of effect defined by a shape list. The force is at the maximum inside the shape. Optionally it diminishes by distance from the border of the shape. An exponent can be defined to alter the falloff from the border. No area shape equals a point force field.

The force is applied either radially from the center, linearily along direction or vertex like swirrling around the direction. Negative force creates a force field attracting elements instead of repelling them. For vortrex type positive force swirls around counter-clock-wise while negative force swirls around clock-wise. The force direction is relative to the force field orientation allowing to alter the force direction without needing to adjust the area of influence shape which is oriented to the force field orientation itself. The force is measured in newton and can be applied directly, by surface or by volume.

Directly applied the force affects all elements exactly the same. This can be used for example for paranomal effects where the shape of elements is unimportant.

Applied by surface the set force is Newton per Meter-Squared. The area used to calculate the force is the surface area exposed to the force direction. This can be used for wind or water forces pushing against exposed surface area. Physics modules are free to approximate this surface area as they see fit.

Applied by volume the set force is Newton per Meter-Cubic. The volume used to calculate the force is the real or representative volume of elements. For elements having a shape the volume is the volume of all space occupied by all shapes combined. For particles the shape is usually a sphere roughly representing the particle. This can be used for field effects like magentism which do not care about exposed surface area only the volume they can affect. Physics modules are free to approximate this volume as they see fit.

The force direction and force can be subject to fluctuation to make the force field more life-like. Physics modules alter the applied force direction and force strength randomly over time.

Force fields can be disabled avoiding the need to remove and add them to the world.

Default settings are radial type, apply direct, no shape, 1N force, 1m radius, exponent 1, no fluctuations and enabled.

using a 3d image as custom force field? like red=x-axis, green=y-axis and blue=z-axis?
Force fields can be set to be blocked by non-dynamic colliders? Force fields have no effect on objects along the force direction if a non-dynamic colliders is crossed? (bool pBlocked?)

Member Enumeration Documentation

◆ eApplicationTypes

Force application types.


Apply force equally to all elements independend of shape.


Apply force on exposed surface area.


Apply force on mass.


Apply force relative to speed of element.

◆ eFieldTypes

Field types.


Force is applied radial from the center.


Force is applied along the force direction.


Force is applied vortex like swirling around.

Constructor & Destructor Documentation

◆ deForceField()

deForceField::deForceField ( deForceFieldManager manager)

Create force field.

◆ ~deForceField()

virtual deForceField::~deForceField ( )

Clean up force field.

Subclasses should set their destructor protected too to avoid users accidently deleting a reference counted object through the object pointer. Only FreeReference() is allowed to delete the object.

Member Function Documentation

◆ GetApplicationType()

eApplicationTypes deForceField::GetApplicationType ( ) const

Force application type.

References SetApplicationType().

◆ GetCollisionFilter()

const decCollisionFilter& deForceField::GetCollisionFilter ( ) const

Collision filter.

References SetCollisionFilter().

◆ GetDirection()

const decVector& deForceField::GetDirection ( ) const

Force direction.

References SetDirection().

◆ GetEnabled()

bool deForceField::GetEnabled ( ) const

Force field is enabled.

References SetEnabled().

◆ GetExponent()

float deForceField::GetExponent ( ) const

Falloff exponent.

References SetExponent().

◆ GetFieldType()

eFieldTypes deForceField::GetFieldType ( ) const

Field type.

References SetFieldType().

◆ GetFluctuationDirection()

float deForceField::GetFluctuationDirection ( ) const

Fluctuation of direction in radians.

References SetFluctuationDirection().

◆ GetFluctuationForce()

float deForceField::GetFluctuationForce ( ) const

Fluctuation of force in newton.

References SetFluctuationForce().

◆ GetForce()

float deForceField::GetForce ( ) const

Force in newton.

References SetForce().

◆ GetInfluenceArea()

const decShapeList& deForceField::GetInfluenceArea ( ) const

Influence area.

References SetInfluenceArea().

◆ GetLLWorldNext()

deForceField* deForceField::GetLLWorldNext ( ) const

Next force field in the parent world linked list.

References SetLLWorldNext().

◆ GetLLWorldPrev()

deForceField* deForceField::GetLLWorldPrev ( ) const

Previous force field in the parent world linked list.

References SetLLWorldPrev().

◆ GetOrientation()

const decQuaternion& deForceField::GetOrientation ( ) const


References SetOrientation().

◆ GetParentWorld()

deWorld* deForceField::GetParentWorld ( ) const

Parent world or NULL.

References SetParentWorld().

◆ GetPeerPhysics()

deBasePhysicsForceField* deForceField::GetPeerPhysics ( ) const

Physics system peer object.

References SetPeerPhysics().

◆ GetPosition()

const decDVector& deForceField::GetPosition ( ) const


References SetPosition().

◆ GetRadius()

float deForceField::GetRadius ( ) const

Falloff radius.

References SetRadius().

◆ SetApplicationType()

void deForceField::SetApplicationType ( eApplicationTypes  type)

Set application type.

Referenced by GetApplicationType().

◆ SetCollisionFilter()

void deForceField::SetCollisionFilter ( const decCollisionFilter filter)

Set collision filter.

Referenced by GetCollisionFilter().

◆ SetDirection()

void deForceField::SetDirection ( const decVector direction)

Set force direction.

Referenced by GetDirection().

◆ SetEnabled()

void deForceField::SetEnabled ( bool  enabled)

Set if force field is enabled.

Referenced by GetEnabled().

◆ SetExponent()

void deForceField::SetExponent ( float  exponent)

Set falloff exponent.

Referenced by GetExponent().

◆ SetFieldType()

void deForceField::SetFieldType ( eFieldTypes  type)

Set field type.

Referenced by GetFieldType().

◆ SetFluctuationDirection()

void deForceField::SetFluctuationDirection ( float  fluctuation)

Set fluctuation of direction in radians.

Referenced by GetFluctuationDirection().

◆ SetFluctuationForce()

void deForceField::SetFluctuationForce ( float  fluctuation)

Set fluctuation of force in newton.

Referenced by GetFluctuationForce().

◆ SetForce()

void deForceField::SetForce ( float  force)

Set force in newton.

Referenced by GetForce().

◆ SetInfluenceArea()

void deForceField::SetInfluenceArea ( const decShapeList area)

Set influence area.

Referenced by GetInfluenceArea().

◆ SetLLWorldNext()

void deForceField::SetLLWorldNext ( deForceField forceField)

Set next force field in the parent world linked list.

Referenced by GetLLWorldNext().

◆ SetLLWorldPrev()

void deForceField::SetLLWorldPrev ( deForceField forceField)

Set next force field in the parent world linked list.

Referenced by GetLLWorldPrev().

◆ SetOrientation()

void deForceField::SetOrientation ( const decQuaternion orientation)

Set orientation.

Referenced by GetOrientation().

◆ SetParentWorld()

void deForceField::SetParentWorld ( deWorld world)

Set parent world or NULL.

Referenced by GetParentWorld().

◆ SetPeerPhysics()

void deForceField::SetPeerPhysics ( deBasePhysicsForceField peer)

Set physics system peer object.

Referenced by GetPeerPhysics().

◆ SetPosition()

void deForceField::SetPosition ( const decDVector position)

Set position.

Referenced by GetPosition().

◆ SetRadius()

void deForceField::SetRadius ( float  radius)

Set falloff radius.

Referenced by GetRadius().

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