The Nebula Device 3: PhysicsFeature::ActorPhysicsProperty Class Reference

The Nebula Device 3

PhysicsFeature::ActorPhysicsProperty Class Reference

#include <actorphysicsproperty.h>

Inheritance diagram for PhysicsFeature::ActorPhysicsProperty:

PhysicsFeature::PhysicsProperty BaseGameFeature::TransformableProperty Game::Property Messaging::Port Core::RefCounted

Detailed Description

ActorPhysicsProperty adds "actor physics" to an entity. This is mainly a capsule which is always kept upright and responds "immediately" to move messages. Attach the ActorPhysicsProperty instead of a PhysicsProperty to an entity.

ActorPhysicsProperty implements the following messages:

MoveGoto MoveFollow MoveDirection MoveStop MoveTurn MoveRotate

(C) 2008 Radon Labs GmbH

Public Types

enum  CallbackType
 callback types

Public Member Functions

 ActorPhysicsProperty ()
 constructor
virtual ~ActorPhysicsProperty ()
 destructor
virtual void SetupCallbacks ()
 setup callbacks for this property, call by entity in OnActivate()
virtual void SetupDefaultAttributes ()
 setup default entity attributes
virtual void OnActivate ()
 called from Entity::ActivateProperties()
virtual void OnDeactivate ()
 called from Entity::DeactivateProperties()
virtual void OnMoveBefore ()
 called before movement has happened
virtual void OnMoveAfter ()
 called after movement has happened
virtual void OnRenderDebug ()
 called on debug visualization
virtual void OnLoseActivity ()
 called on losing activity (no longer triggered)
virtual Ptr< Physics::PhysicsEntity > GetPhysicsEntity () const
 get a pointer to the physics entity
virtual void SetupAcceptedMessages ()
 override to register accepted messages
virtual void HandleMessage (const Ptr< Messaging::Message > &msg)
 handle a single message
void SetEnabled (bool enabled)
 enable/disable physics
bool IsEnabled () const
 is physics enabled
const Ptr< Entity > & GetEntity () const
 get entity this property is attached to
bool HasEntity () const
 return true if entity pointer is valid
bool IsActive () const
 return true if property is currently active
virtual void OnLoad ()
 called from within Entity::Load() after attributes are loaded
virtual void OnStart ()
 called from within Entity::OnStart() after OnLoad when the complete world exist
virtual void OnSave ()
 called from within Entity::Save() before attributes are saved back to database
virtual void OnBeginFrame ()
 called on begin of frame
virtual void OnRender ()
 called before rendering happens
virtual void OnGainActivity ()
 called when game debug visualization is on
void AttachHandler (const Ptr< Handler > &h)
 attach a message handler to the port
void RemoveHandler (const Ptr< Handler > &h)
 remove a message handler from the port
void RemoveAllHandlers ()
 remove all message handler from the port
SizeT GetNumHandlers () const
 return number of handlers attached to the port
const Ptr< Handler > & GetHandlerAtIndex (IndexT i) const
 get a message handler by index
virtual void Send (const Ptr< Message > &msg)
 send a message to the port
const Util::Array< const Id * > & GetAcceptedMessages () const
 get the array of accepted messages (sorted)
bool AcceptsMessage (const Id &msgId) const
 return true if port accepts this msg
int GetRefCount () const
 get the current refcount
void AddRef ()
 increment refcount by one
void Release ()
 decrement refcount and destroy object if refcount is zero
bool IsInstanceOf (const Rtti &rtti) const
 return true if this object is instance of given class
bool IsInstanceOf (const Util::String &className) const
 return true if this object is instance of given class by string
bool IsInstanceOf (const Util::FourCC &classFourCC) const
 return true if this object is instance of given class by fourcc
bool IsA (const Rtti &rtti) const
 return true if this object is instance of given class, or a derived class
bool IsA (const Util::String &rttiName) const
 return true if this object is instance of given class, or a derived class, by string
bool IsA (const Util::FourCC &rttiFourCC) const
 return true if this object is instance of given class, or a derived class, by fourcc
const Util::StringGetClassName () const
 get the class name
Util::FourCC GetClassFourCC () const
 get the class FourCC code

Static Public Member Functions

static void DumpRefCountingLeaks ()
 dump refcounting leaks, call at end of application (NEBULA3_DEBUG builds only!)

Protected Member Functions

virtual void EnablePhysics ()
 enable and activate the physics
virtual void DisablePhysics ()
 disable and cleanup the physics
void Stop ()
 immediately stop the entity
void SendStop ()
 send a synchronous MoveStop message to self
void HandleMoveDirection (BaseGameFeature::MoveDirection *msg)
 handle a MoveDirection message
void HandleMoveGoto (BaseGameFeature::MoveGoto *msg)
 handle a MoveGoto message
void HandleSetTransform (BaseGameFeature::SetTransform *msg)
 handle a SetTransform message
void HandleMoveTurn (BaseGameFeature::MoveTurn *msg)
 handle a MoveTurn message
void HandleMoveRotate (BaseGameFeature::MoveRotate *msg)
 handle a MoveRotate message
void HandleMoveFollow (BaseGameFeature::MoveFollow *msg)
 handle a MoveFollow message
bool IsGotoActive () const
 return true if Goto is currently active
void ContinueGoto ()
 continue a Goto
void ContinueFollow ()
 continue a Follow
void SkipSegments ()
 skip segments
void AutoEvade (Math::vector &targetVec)
 perform auto evade
virtual Ptr< Physics::PhysicsEntity > CreatePhysicsEntity () const
 create physics entity
void ApplyImpulseAtPos (const Math::vector &impulse, const Math::vector &pos, bool multByMass=false)
 apply a global impulse vector at the next time step at a global position
void SetEntity (const Ptr< Entity > &v)
 Set entity, this is attached to, to `v'.
void ClearEntity ()
 Remove entity.
void RegisterMessage (const Id &msgId)
 register a single accepted message

Static Protected Attributes

static const float AutoEvadeProbeAboveGround
 dist of auto evade probe to entity's pos
static const float AutoEvadeProbeRadius
 radius of auto evade probe

Member Function Documentation

void PhysicsFeature::ActorPhysicsProperty::OnMoveBefore (  )  [virtual]

called before movement has happened

The OnMoveBefore() method handles all pending messages, and other per-frame-stuff that must happen before the physics subsystem is triggered.

Reimplemented from Game::Property.

void PhysicsFeature::ActorPhysicsProperty::OnMoveAfter (  )  [virtual]

called after movement has happened

The OnMoveAfter() method transfers the current physics entity transform to the game entity.

Reimplemented from PhysicsFeature::PhysicsProperty.

void PhysicsFeature::ActorPhysicsProperty::OnRenderDebug (  )  [virtual]

called on debug visualization

Render a debug visualization of the current 3d navigation path.

Reimplemented from Game::Property.

void PhysicsFeature::ActorPhysicsProperty::EnablePhysics (  )  [protected, virtual]

enable and activate the physics

Creates a Physics::CharEntity instead of a normal Physics::PhysicsEntity.

Reimplemented from PhysicsFeature::PhysicsProperty.

void PhysicsFeature::ActorPhysicsProperty::Stop (  )  [protected]

immediately stop the entity

Immediately stop the entity.

26-Jan-06 floh bugfix: also cancelled MoveFollow 14-Feb-06 nico bugfix: now really cancelled MoveFollow ;)

void PhysicsFeature::ActorPhysicsProperty::SendStop (  )  [protected]

send a synchronous MoveStop message to self

This simply sends a synchronous stop message to myself. This uses a message so that everybody else who might be interested in the information that I have stopped can listen to the message.

void PhysicsFeature::ActorPhysicsProperty::HandleMoveDirection ( BaseGameFeature::MoveDirection *  msg  )  [protected]

handle a MoveDirection message

Handle a MoveDirection message.

void PhysicsFeature::ActorPhysicsProperty::HandleMoveGoto ( BaseGameFeature::MoveGoto *  msg  )  [protected]

handle a MoveGoto message

Handle a MoveGoto message.

void PhysicsFeature::ActorPhysicsProperty::HandleSetTransform ( BaseGameFeature::SetTransform *  msg  )  [protected]

handle a SetTransform message

Handle a SetTransform message.

void PhysicsFeature::ActorPhysicsProperty::HandleMoveTurn ( BaseGameFeature::MoveTurn *  msg  )  [protected]

handle a MoveTurn message

Handle a MoveTurn message.

void PhysicsFeature::ActorPhysicsProperty::HandleMoveRotate ( BaseGameFeature::MoveRotate *  msg  )  [protected]

handle a MoveRotate message

Handle a MoveTurn message.

void PhysicsFeature::ActorPhysicsProperty::HandleMoveFollow ( BaseGameFeature::MoveFollow *  msg  )  [protected]

handle a MoveFollow message

Handle a MoveFollow message.

void PhysicsFeature::ActorPhysicsProperty::ContinueGoto (  )  [protected]

continue a Goto

Continue the current Goto action.

void PhysicsFeature::ActorPhysicsProperty::ContinueFollow (  )  [protected]

continue a Follow

Continue the current Follow action.

void PhysicsFeature::ActorPhysicsProperty::AutoEvade ( Math::vector targetVec  )  [protected]

perform auto evade

Function was changed(11.07.07). Now AutoEvade()will be called by HandleMoveDirection() to avoid replacement of non-static physic objekts.

void PhysicsFeature::PhysicsProperty::ApplyImpulseAtPos ( const Math::vector impulse,
const Math::vector pos,
bool  multByMass = false 
) [protected, inherited]

apply a global impulse vector at the next time step at a global position

Apply an impulse vector at a position in the global coordinate frame.

void Game::Property::OnLoad (  )  [virtual, inherited]

called from within Entity::Load() after attributes are loaded

This method is called from within Game::Entity::Load() after the entity attributes have been loaded from the database. You can override this method in a subclass if further initialization is needed for the property after attributes have been loaded from the database, but please be aware that this method may not be called if the entity is created directly.

Reimplemented in PhysicsFeature::TriggerProperty, and StateObjectFeature::StateProperty.

void Game::Property::OnStart (  )  [virtual, inherited]

called from within Entity::OnStart() after OnLoad when the complete world exist

This method is called from within Game::Entity::OnStart(). This is the moment when the world is complete and the entity can establish connections to other entitys.

Reimplemented in GraphicsFeature::CameraProperty.

void Game::Property::OnSave (  )  [virtual, inherited]

called from within Entity::Save() before attributes are saved back to database

This method is called from within Game::Entity::Save() before the entity attributes will be saved to the database. You can override this method in a subclass if actions are needed before a save happens (this is usually the case if entity attributes need to be updated by the property before saving).

Reimplemented in PhysicsFeature::TriggerProperty, and StateObjectFeature::StateProperty.

void Game::Property::OnBeginFrame (  )  [virtual, inherited]

called on begin of frame

This method is called from Game::Entity::OnBeginFrame() on all properties attached to an entity in the order of attachment. Override this method if your property has to do any work at the beginning of the frame.

Reimplemented in PhysicsFeature::TriggerProperty, and StateObjectFeature::StateProperty.

void Game::Property::OnRender (  )  [virtual, inherited]

called before rendering happens

This method is called from Game::Entity::OnRender() on all properties attached to an entity in the order of attachment. Override this method if your property has any work to do before rendering happens.

Reimplemented in GraphicsFeature::CameraProperty, GraphicsFeature::ChaseCameraProperty, and GraphicsFeature::MayaCameraProperty.

void Game::Property::OnGainActivity (  )  [virtual, inherited]

called when game debug visualization is on

This method is called from Game::Entity::OnRenderDebug() on all properties attached to an entity in the order of attachment. It indicates that the entity will be trigger from now on, due to entering the "Activity Bubble", i.e. the area of interest (most probably around the active camera).

void Messaging::Port::AttachHandler ( const Ptr< Handler > &  h  )  [inherited]

attach a message handler to the port

Attach a message handler to the port.

void Messaging::Port::RemoveHandler ( const Ptr< Handler > &  h  )  [inherited]

remove a message handler from the port

Remove a message handler from the port.

void Messaging::Port::Send ( const Ptr< Message > &  msg  )  [virtual, inherited]

send a message to the port

Send a message to the port. This will immediately call the HandleMessage() method of all attached handlers. If the message has been handled by at least one of the handlers, the Handled() flag of the message will be set to true.

int Core::RefCounted::GetRefCount (  )  const [inline, inherited]

get the current refcount

Return the current refcount of the object.

void Core::RefCounted::AddRef (  )  [inline, inherited]

increment refcount by one

Increment the refcount of the object.

void Core::RefCounted::Release (  )  [inline, inherited]

decrement refcount and destroy object if refcount is zero

Decrement the refcount and destroy object if refcount is zero.

const Util::String & Core::RefCounted::GetClassName (  )  const [inline, inherited]

get the class name

Get the class name of the object.

Util::FourCC Core::RefCounted::GetClassFourCC (  )  const [inline, inherited]

get the class FourCC code

Get the class FourCC of the object.

void Core::RefCounted::DumpRefCountingLeaks (  )  [static, inherited]

dump refcounting leaks, call at end of application (NEBULA3_DEBUG builds only!)

This method should be called as the very last before an application exits.