VoltAir
|
A QObject container for a Box2D b2Body
.
More...
Public Types | |
enum | BodyType { StaticBody = 0, KinematicBody, DynamicBody } |
Overarching category of how this Body interacts with the world. More... | |
Signals | |
void | bodyTypeChanged () |
Emitted when bodyType changes. More... | |
void | activeChanged () |
Emitted when active changes. More... | |
void | linearDampingChanged () |
Emitted when linearDamping changes. More... | |
void | angularDampingChanged () |
Emitted when angularDamping changes. More... | |
void | gravityScaleChanged () |
Emitted when gravityScale changes. More... | |
void | magneticChanged () |
Emitted when magnetic changes. More... | |
void | magneticStrengthChanged () |
Emitted when magneticStrength changes. More... | |
void | positionSet () |
Emitted when position is set. More... | |
void | angleInRadiansSet () |
Emitted when angleInRadians is set. More... | |
void | linearVelocitySet () |
Emitted when linearVelocity is set. More... | |
void | angularVelocitySet () |
Emitted when angularVelocity is set. More... | |
void | sensorChanged () |
Emitted when sensor changes. More... | |
void | densityChanged () |
Emitted when density changes. More... | |
void | frictionChanged () |
Emitted when friction changes. More... | |
void | restitutionChanged () |
Emitted when restitution changes. More... | |
void | jointsChanged () |
Emitted when joints changes. More... | |
void | contactBegun (Body *otherBody, QPointF normal) |
Emitted when a contact begins. More... | |
void | contactEnded (Body *otherBody, QPointF normal) |
Emitted when a contact ends. More... | |
void | queuedContactBegun (Body *otherBody, QPointF normal) |
Queued version of contactBegun(). More... | |
void | queuedContactEnded (Body *otherBody, QPointF normal) |
Queued version of contactEnded(). More... | |
Public Member Functions | |
Body (QObject *parent=0) | |
Constructs a Body. More... | |
virtual | ~Body () |
Destroys a Body. More... | |
Actor * | getActor () const |
Returns actor. More... | |
BodyType | getBodyType () const |
Returns bodyType. More... | |
void | setBodyType (BodyType value) |
Sets bodyType. More... | |
bool | isActive () const |
Returns active. More... | |
void | setActive (bool value) |
Sets active. More... | |
float | getLinearDamping () const |
Returns linearDamping. More... | |
void | setLinearDamping (float value) |
Sets linearDamping. More... | |
float | getAngularDamping () const |
Returns angularDamping. More... | |
void | setAngularDamping (float value) |
Sets angularDamping. More... | |
float | getGravityScale () const |
Returns gravityScale. More... | |
void | setGravityScale (float value) |
Sets gravityScale. More... | |
bool | isMagnetic () const |
Returns magnetic. More... | |
void | setMagnetic (bool value) |
Sets magnetic. More... | |
float | getMagneticStrength () const |
Returns magneticStrength. More... | |
void | setMagneticStrength (float value) |
Sets magneticStrength. More... | |
QPointF | getPosition () const |
Returns position. More... | |
bool | isSensor () const |
Returns sensor. More... | |
void | setSensor (bool value) |
Sets sensor. More... | |
float | getDensity () const |
Returns density. More... | |
void | setDensity (float value) |
Sets density. More... | |
float | getFriction () const |
Returns friction. More... | |
void | setFriction (float value) |
Sets friction. More... | |
float | getRestitution () const |
Returns restitution. More... | |
void | setRestitution (float value) |
Sets restitution. More... | |
const QList< Joint * > & | getJoints () const |
Returns joints as a const QList<Joint*>&. More... | |
QQmlListProperty< Joint > | getJointListProperty () |
Returns joints as a QQmlListProperty<Joint>. More... | |
void | setJoints (const QList< Joint * > &value) |
Sets joints. More... | |
Q_INVOKABLE Joint * | getJoint (int index) |
Returns a Joint at a given index . More... | |
Q_INVOKABLE int | getJointCount () const |
Returns the number of Joints associated with this Body. More... | |
Q_INVOKABLE void | addJoint (Joint *joint) |
Add a Joint to the Body. More... | |
Q_INVOKABLE void | removeJoint (Joint *joint) |
Remove a Joint from the Body. More... | |
Q_INVOKABLE void | clearJoints () |
Clear all the Joints owned by this Body. More... | |
Q_INVOKABLE void | clearAllAttachedJoints () |
Destroys all Joints associated with this Body, whether or not this Body is the Joint's parent. More... | |
b2Body * | getBody () |
Returns the b2Body associated with this Body. More... | |
Q_INVOKABLE void | applyTorque (float torque) |
Apply torque to the associated b2Body . More... | |
Q_INVOKABLE void | applyForceToCenter (const QPointF &force) |
Apply force to the associated b2Body . More... | |
void | invalidateTransform () |
Marks the transform for this Body as dirty. More... | |
virtual void | updateBeforePhysics () |
Called immediately preceding the physics step. More... | |
virtual void | updateAfterPhysics () |
Called immediately following the physics step. More... | |
QList< Body * > | getContactedBodies () const |
Returns a QList containing the list of Bodys in contact with this Body. More... | |
void | beginContact (Body *otherBody, const QPointF &normal) |
Called when this Body has made contact with another. More... | |
void | endContact (Body *otherBody, const QPointF &normal) |
Called when this Body loses contact with another. More... | |
virtual void | forEachShape (const std::function< void(b2Shape *)> &func) |
Calls func on the complete set of b2Shapes that represent this Body. More... | |
Setters and Getters for Properties Affected by Physics | |
Please see Properties Affected by Physics. | |
void | setPosition (const QPointF &value) |
Sets position. More... | |
float | getAngleInRadians () const |
Returns angleInRadians. More... | |
void | setAngleInRadians (float value) |
Sets angleInRadians. More... | |
QPointF | getLinearVelocity () const |
Returns linearVelocity. More... | |
void | setLinearVelocity (const QPointF &value) |
Sets linearVelocity. More... | |
float | getAngularVelocity () const |
Returns angularVelocity. More... | |
void | setAngularVelocity (float value) |
Sets angularVelocity. More... | |
Public Member Functions inherited from QObject | |
QObject (QObject *parent) | |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
virtual const QMetaObject * | metaObject () const |
QString | objectName () const |
void | setObjectName (const QString &name) |
bool | isWidgetType () const |
bool | isWindowType () const |
bool | signalsBlocked () const |
bool | blockSignals (bool block) |
QThread * | thread () const |
void | moveToThread (QThread *targetThread) |
int | startTimer (int interval, Qt::TimerType timerType) |
void | killTimer (int id) |
T | 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 ®Exp, 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< QByteArray > | dynamicPropertyNames () const |
void | destroyed (QObject *obj) |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const |
bool | inherits (const char *className) const |
void | deleteLater () |
Protected Member Functions | |
void | invalidateFixtures () |
Marks the Body's fixtures as dirty and that they need to be recreated. More... | |
void | forEachFixture (const std::function< void(b2Fixture *)> &func) |
Applies func to each of the Body's fixtures. More... | |
Protected Member Functions inherited from QObject | |
QObject * | sender () 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) |
Properties | |
Actor | actor |
Actor object associated with this Body. Always the parent in the item hierarchy. More... | |
BodyType | bodyType |
BodyType of this Body. More... | |
bool | active |
Whether or not the Body takes part in the physics simulation. More... | |
float | linearDamping |
Dampens the linearVelocity of the Body. More... | |
float | angularDamping |
Dampens the angularVelocity of the Body. More... | |
float | gravityScale |
Coefficient on the continuous force of gravity. More... | |
bool | magnetic |
Whether or not magnetism is set on for this Body. More... | |
float | magneticStrength |
Intensity of the magnetic forces involving this Body. More... | |
bool | sensor |
The sensor value for all of this Body's b2Fixtures . More... | |
float | density |
The density value for all of this Body's b2Fixtures . More... | |
float | friction |
The friction value for all of this Body's b2Fixtures . More... | |
float | restitution |
The restitution value for all of this Body's b2Fixtures . More... | |
QQmlListProperty< Joint > | joints |
List of Joint objects associated with this Body. More... | |
Properties Affected by Physics | |
The following group of properties are special in that their values can potentially be modified by the physics simulation. Implicit in this is that the property a user writes to them may not be the same one that is read back at a later time. Furthermore, each of their respective "property changed" signals are only emitted when the property is explicitly set (i.e. not when they are changed by the physics simulation). | |
QPointF | position |
Positional component of the b2Body's transform. More... | |
float | angleInRadians |
Rotational component of the b2Body's transform, in radians. More... | |
QPointF | linearVelocity |
The rate which the Bodys position changes. More... | |
float | angularVelocity |
The rate which the Bodys angle changes. More... | |
Properties inherited from QObject | |
objectName | |
Friends | |
class | Joint |
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) |
A QObject container for a Box2D b2Body
.
Along with representing the Box2D object, this class maintains several additional properties including magnetic strength and the concept of uniform fixture properties (e.g. density, restitution, friction, sensor, etc.).
Body objects expect to be a direct child (in the QQuickItem hierarchy) of an Actor. When one places a Body as a child of an Actor, that actor's position and rotation can potentially be modified by this Body as a result of the physics simulation.
Body is a base class. Its subclasses are required to define the b2Fixture objects to be associated with this Body's b2Body.
enum Body::BodyType |
Overarching category of how this Body interacts with the world.
Equivalent to the b2BodyType
of this object.
Enumerator | |
---|---|
StaticBody |
A non-movable Body. Equivalent to |
KinematicBody |
A movable Body that is not affected by forces or collisions. Equivalent to |
DynamicBody |
A movable Body that is affected by forces or collisions. Equivalent to |
|
virtual |
Destroys a Body.
|
signal |
Emitted when active changes.
Q_INVOKABLE void Body::addJoint | ( | Joint * | joint | ) |
|
signal |
Emitted when angleInRadians is set.
|
signal |
Emitted when angularDamping changes.
|
signal |
Emitted when angularVelocity is set.
Q_INVOKABLE void Body::applyForceToCenter | ( | const QPointF & | force | ) |
Apply force
to the associated b2Body
.
force | Amount of force to apply |
Q_INVOKABLE void Body::applyTorque | ( | float | torque | ) |
Apply torque
to the associated b2Body
.
torque | Amount of torque to apply |
|
signal |
Emitted when bodyType changes.
Q_INVOKABLE void Body::clearAllAttachedJoints | ( | ) |
Emitted when a contact begins.
otherBody | The other Body with which this one made contact |
normal | The normal on otherBody at point of contact |
Emitted when a contact ends.
otherBody | The other Body with which this one lost contact |
normal | The normal on otherBody at point of contact |
|
signal |
Emitted when density changes.
|
protected |
Applies func
to each of the Body's fixtures.
func | Function to apply |
|
inlinevirtual |
Calls func
on the complete set of b2Shapes
that represent this Body.
func | Function to call, which receives the b2Shape as an argument |
Reimplemented in PolygonBody, and CircleBody.
|
signal |
Emitted when friction changes.
float Body::getAngleInRadians | ( | ) | const |
Returns angleInRadians.
float Body::getAngularDamping | ( | ) | const |
Returns angularDamping.
float Body::getAngularVelocity | ( | ) | const |
Returns angularVelocity.
|
inline |
Returns the b2Body
associated with this Body.
|
inline |
Returns density.
|
inline |
Returns friction.
float Body::getGravityScale | ( | ) | const |
Returns gravityScale.
|
inline |
|
inline |
QQmlListProperty<Joint> Body::getJointListProperty | ( | ) |
Returns joints as a QQmlListProperty<Joint>.
Returns joints as a const QList<Joint*>&.
float Body::getLinearDamping | ( | ) | const |
Returns linearDamping.
QPointF Body::getLinearVelocity | ( | ) | const |
Returns linearVelocity.
|
inline |
Returns magneticStrength.
|
inline |
Returns restitution.
|
signal |
Emitted when gravityScale changes.
|
inlineprotected |
Marks the Body's fixtures as dirty and that they need to be recreated.
|
inline |
Marks the transform for this Body as dirty.
This informs updateBeforePhysics() whether it's necessary to set this b2Body's transform.
bool Body::isActive | ( | ) | const |
Returns active.
|
inline |
Returns magnetic.
|
inline |
Returns sensor.
|
signal |
Emitted when joints changes.
|
signal |
Emitted when linearDamping changes.
|
signal |
Emitted when linearVelocity is set.
|
signal |
Emitted when magnetic changes.
|
signal |
Emitted when magneticStrength changes.
|
signal |
Emitted when position is set.
Queued version of contactBegun().
Rather than triggering immediately, the connected slot will be called in a queued fashion, using Qt::QueuedConnection.
otherBody | The other Body with which this one made contact |
normal | The normal on otherBody at point of contact |
Queued version of contactEnded().
Rather than triggering immediately, the connected slot will be called in a queued fashion, using Qt::QueuedConnection.
otherBody | The other Body with which this one lost contact |
normal | The normal on otherBody at point of contact |
Q_INVOKABLE void Body::removeJoint | ( | Joint * | joint | ) |
|
signal |
Emitted when restitution changes.
|
signal |
Emitted when sensor changes.
void Body::setAngleInRadians | ( | float | value | ) |
Sets angleInRadians.
value | Float to set angleInRadians to |
void Body::setAngularDamping | ( | float | value | ) |
Sets angularDamping.
value | Float to set angularDamping to |
void Body::setAngularVelocity | ( | float | value | ) |
Sets angularVelocity.
value | Float to set angularVelocity to |
void Body::setGravityScale | ( | float | value | ) |
Sets gravityScale.
value | Float to set gravityScale to |
Sets joints.
value | QList<Joint*> to set joints to |
void Body::setLinearDamping | ( | float | value | ) |
Sets linearDamping.
value | Float to set linearDamping to |
void Body::setLinearVelocity | ( | const QPointF & | value | ) |
Sets linearVelocity.
value | QPointF to set linearVelocity to |
void Body::setMagneticStrength | ( | float | value | ) |
Sets magneticStrength.
value | Float to set magneticStrength to |
void Body::setPosition | ( | const QPointF & | value | ) |
void Body::setRestitution | ( | float | value | ) |
Sets restitution.
value | Float to set restitution to |
|
virtual |
Called immediately following the physics step.
Pushes the pertinent Box2D data to this object's data.
|
virtual |
Called immediately preceding the physics step.
Pushes this object's data to the Box2D data.
|
readwrite |
Whether or not the Body takes part in the physics simulation.
Equivalent to the b2Body's
active property.
|
read |
|
readwrite |
Rotational component of the b2Body's
transform, in radians.
|
readwrite |
Dampens the angularVelocity of the Body.
Equivalent to the b2Body's
angular damping property.
|
readwrite |
The rate which the Bodys angle changes.
Equivalent to the b2Body's
angular velocity.
|
readwrite |
The density value for all of this Body's b2Fixtures
.
|
readwrite |
The friction value for all of this Body's b2Fixtures
.
|
readwrite |
Coefficient on the continuous force of gravity.
Equivalent to the b2Body's
gravity scale property.
|
read |
|
readwrite |
Dampens the linearVelocity of the Body.
Equivalent to the b2Body's
linear damping property.
|
readwrite |
The rate which the Bodys position changes.
Equivalent to the b2Body's
linear velocity.
|
readwrite |
Whether or not magnetism is set on for this Body.
Magnetism is a pseudo-physical effect in the system that causes forces to be applied between all nearby Bodys that have this value set to true
. The actual behavior for it defined elsewhere in MagneticAttractorLogic.
|
readwrite |
Intensity of the magnetic forces involving this Body.
|
readwrite |
Positional component of the b2Body's
transform.
|
readwrite |
The restitution value for all of this Body's b2Fixtures
.