VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
Signals | Public Member Functions | Properties | List of all members
RollingMovementLogic Class Reference

Logic which exerts force in a specified direction, causing the actor to roll in that direction. More...

Inheritance diagram for RollingMovementLogic:
Logic QObject

Signals

void directionChanged ()
 Emitted when direction changes. More...
 
void magnetismInfluenceChanged ()
 Emitted when magnetismInfluence changes. More...
 
void speedChanged ()
 Emitted when speed changes. More...
 
void proximityRadiusChanged ()
 Emitted when proximityRadius changes. More...
 
void antiGravityAmountChanged ()
 Emitted when antiGravityAmount changes. More...
 
void turnBoostChanged ()
 Emitted when turnBoost changes. More...
 
void torqueForceRatioChanged ()
 Emitted when torqueForceRatio changes. More...
 
void speedFalloffRatioChanged ()
 Emitted when speedFalloffRatio changes. More...
 
- Signals inherited from Logic
void activeChanged ()
 Emitted when active changes. More...
 

Public Member Functions

QPointF getDirection () const
 Returns direction. More...
 
void setDirection (const QPointF &value)
 Sets direction. More...
 
QPointF getMagnetismInfluence () const
 Returns magnetismInfluence. More...
 
void setMagnetismInfluence (const QPointF &value)
 Sets magnetismInfluence. More...
 
float getSpeed () const
 Returns speed. More...
 
void setSpeed (float value)
 Sets speed. More...
 
float getProximityRadius () const
 Returns proximityRadius. More...
 
void setProximityRadius (float value)
 Sets proximityRadius. More...
 
float getAntiGravityAmount () const
 Returns antiGravityAmount. More...
 
void setAntiGravityAmount (float value)
 Sets antiGravityAmount. More...
 
float getTurnBoost () const
 Returns turnBoost. More...
 
void setTurnBoost (float value)
 Sets turnBoost. More...
 
float getTorqueForceRatio () const
 Returns torqueForceRatio. More...
 
void setTorqueForceRatio (float value)
 Sets torqueForceRatio. More...
 
float getSpeedFalloffRatio () const
 Returns speedFalloffRatio. More...
 
void setSpeedFalloffRatio (float value)
 Sets speedFalloffRatio. More...
 
Q_INVOKABLE QPointF getGroundNormal () const
 Returns the current "up" direction used to orient movement. More...
 
virtual void update () override
 Computes and applys torque and linear forces on this actor's Body. More...
 
- Public Member Functions inherited from Logic
 Logic (QObject *parent=nullptr)
 Constructs a Logic. More...
 
ActorgetActor () const
 Returns actor. More...
 
bool isActive () const
 Returns active. More...
 
void setActive (bool value)
 Sets active. More...
 
virtual void init ()
 Performs initialization of this Logic. More...
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
virtual const QMetaObjectmetaObject () const
 
QString objectName () const
 
void setObjectName (const QString &name)
 
bool isWidgetType () const
 
bool isWindowType () const
 
bool signalsBlocked () const
 
bool blockSignals (bool block)
 
QThreadthread () const
 
void moveToThread (QThread *targetThread)
 
int startTimer (int interval, Qt::TimerType timerType)
 
void killTimer (int id)
 
findChild (const QString &name, QFlags< Qt::FindChildOption > options) const
 
QList< T > findChildren (const QString &name, QFlags< Qt::FindChildOption > options) const
 
QList< T > findChildren (const QRegExp &regExp, QFlags< Qt::FindChildOption > options) const
 
QList< T > findChildren (const QRegularExpression &re, QFlags< Qt::FindChildOption > options) const
 
const QObjectList & children () const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const
 
bool disconnect (const QObject *receiver, const char *method) const
 
void dumpObjectTree ()
 
void dumpObjectInfo ()
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const
 
QList< QByteArraydynamicPropertyNames () const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const
 
bool inherits (const char *className) const
 
void deleteLater ()
 

Properties

QPointF direction
 Direction the actor should move in. More...
 
QPointF magnetismInfluence
 Direction to the magnetic object this actor is magnetizing to, or a zero vector if there is currently no such object. More...
 
float speed
 Speed the actor accelerates at. More...
 
float proximityRadius
 Distance that the actor will sense other bodies to use as orientation references. More...
 
float antiGravityAmount
 Amount of force the actor can exert against gravity, as a percentage from 0.0f to 1.0f. More...
 
float turnBoost
 Extra force multiplier applied when turning. More...
 
float torqueForceRatio
 Balance of torque to linear force. More...
 
float speedFalloffRatio
 Amount of falloff at higher speeds. More...
 
- Properties inherited from Logic
Actor actor
 Parent actor that is affected by this Logic's behavior. More...
 
bool active
 Whether or not Engine calls update() on this Logic during the Engine::LOGICS_PHASE. More...
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 

Detailed Description

Logic which exerts force in a specified direction, causing the actor to roll in that direction.

The movement direction is specified using the direction property. X represents forwards and backwards movement, while Y represents upwards and downwards movement. This "direction" is not always aligned to world space, or even gravity. When the actor is considered "in the air", the reference direction for "up" is gravity. When the actor is close to a surface (i.e. the ground), that surface's normal will be used as "up". Forward and backwards movement will be oriented to this direction.

The closest surface is found approximately by casting several rays. If no surface is found, the actor is considered "in the air" (and orients to gravity). The distance that rays will be cast is controlled by the proximityRadius property. Alternatively, when magnetism is in effect and the actor is near a magnetic object, the direction to that object's center will be used as "up".

The force that is exerted is a combination of torque (angular acceleration) and linear acceleration (i.e. jetpack-like). Because the actor can exert a jetpack-like force, to prevent the actor from "climbing" unnaturally against gravity, damping is applied in the direction of gravity. For example, if the actor's current reference surface is a vertical wall, when the actor moves forwards, it will attempt to climb up (or down) the wall. Since this is against gravity, the amount of force that is effectively exerted is reduced (compared to the force that is exerted when on the ground). The amount of reduction is controlled through the antiGravityAmount property.

Member Function Documentation

void RollingMovementLogic::antiGravityAmountChanged ( )
signal

Emitted when antiGravityAmount changes.

void RollingMovementLogic::directionChanged ( )
signal

Emitted when direction changes.

float RollingMovementLogic::getAntiGravityAmount ( ) const
inline
QPointF RollingMovementLogic::getDirection ( ) const
inline

Returns direction.

Q_INVOKABLE QPointF RollingMovementLogic::getGroundNormal ( ) const

Returns the current "up" direction used to orient movement.

This is computed internally using one of the following: Gravity, the closest surface, or the magnetic object being attracted.

QPointF RollingMovementLogic::getMagnetismInfluence ( ) const
float RollingMovementLogic::getProximityRadius ( ) const
inline

Returns proximityRadius.

float RollingMovementLogic::getSpeed ( ) const
inline

Returns speed.

float RollingMovementLogic::getSpeedFalloffRatio ( ) const
inline
float RollingMovementLogic::getTorqueForceRatio ( ) const
inline

Returns torqueForceRatio.

float RollingMovementLogic::getTurnBoost ( ) const
inline

Returns turnBoost.

void RollingMovementLogic::magnetismInfluenceChanged ( )
signal

Emitted when magnetismInfluence changes.

void RollingMovementLogic::proximityRadiusChanged ( )
signal

Emitted when proximityRadius changes.

void RollingMovementLogic::setAntiGravityAmount ( float  value)

Sets antiGravityAmount.

Parameters
valueFloat to set antiGravityAmount to
void RollingMovementLogic::setDirection ( const QPointF value)

Sets direction.

Parameters
valueQPointF to set direction to
void RollingMovementLogic::setMagnetismInfluence ( const QPointF value)

Sets magnetismInfluence.

Parameters
valueQPointF to set magnetismInfluence to
void RollingMovementLogic::setProximityRadius ( float  value)

Sets proximityRadius.

Parameters
valueFloat to set proximityRadius to
void RollingMovementLogic::setSpeed ( float  value)

Sets speed.

Parameters
valueFloat to set speed to
void RollingMovementLogic::setSpeedFalloffRatio ( float  value)

Sets speedFalloffRatio.

Parameters
valueFloat to set speedFalloffRatio to
void RollingMovementLogic::setTorqueForceRatio ( float  value)

Sets torqueForceRatio.

Parameters
valueFloat to set torqueForceRatio to
void RollingMovementLogic::setTurnBoost ( float  value)

Sets turnBoost.

Parameters
valueFloat to set turnBoost to
void RollingMovementLogic::speedChanged ( )
signal

Emitted when speed changes.

void RollingMovementLogic::speedFalloffRatioChanged ( )
signal

Emitted when speedFalloffRatio changes.

void RollingMovementLogic::torqueForceRatioChanged ( )
signal

Emitted when torqueForceRatio changes.

void RollingMovementLogic::turnBoostChanged ( )
signal

Emitted when turnBoost changes.

virtual void RollingMovementLogic::update ( )
overridevirtual

Computes and applys torque and linear forces on this actor's Body.

Reimplemented from Logic.

Property Documentation

float RollingMovementLogic::antiGravityAmount
readwrite

Amount of force the actor can exert against gravity, as a percentage from 0.0f to 1.0f.

Setting this value high allows the actor to climb steep hills, but also act physically unrealistically.

QPointF RollingMovementLogic::direction
readwrite

Direction the actor should move in.

This should be set by other Logics in response to player input.

QPointF RollingMovementLogic::magnetismInfluence
readwrite

Direction to the magnetic object this actor is magnetizing to, or a zero vector if there is currently no such object.

This property is used to determine whether the normal "up" reference direction should be overridden, and the direction to the magnetic object used instead.

float RollingMovementLogic::proximityRadius
readwrite

Distance that the actor will sense other bodies to use as orientation references.

float RollingMovementLogic::speed
readwrite

Speed the actor accelerates at.

Acceleration and top speed are also affected by Body density, and linear and angular damping.

float RollingMovementLogic::speedFalloffRatio
readwrite

Amount of falloff at higher speeds.

A higher falloff causes the actor to reach top speed more quickly, but reduces top speed.

float RollingMovementLogic::torqueForceRatio
readwrite

Balance of torque to linear force.

float RollingMovementLogic::turnBoost
readwrite

Extra force multiplier applied when turning.