MPhysicsProperties

From MaratisWiki
Revision as of 20:49, 20 October 2013 by 255 (Talk | contribs)
Jump to: navigation, search

For detailed explanations on how to manipulate physics via code see Creating and updating physics objects.


MPhysicsProperties is a class used by MOEntity.

The class is defined in the MOEntity source code itself.

This class has and can set the MPhysicsConstraint.

MPhysicsProperties contains all the properties that will be used by the physics engine.

These properties can also be edited in the Maratis Editor.

The properties are mere value holders for the physics engine. This means that editing them when the game is already started will have no effect at all. The properties take effect only when the scene prepares the physics (MScene::preparePhysics) creating the collision objects for every entity.

However you can apply the new values using these methods of MPhysicsContext:

setObjectMass

setObjectRestitution

setObjectFriction

setObjectLinearFactor

setObjectAngularFactor

setObjectDamping

Another option is to reload all the physics properties of the entity using MScene::prepareCollisionShape and MScene::PrepareCollisionObject.


Contents

Source code

MOEntity.h

MOEntity.cpp


API

constraint

deleteConstraint

[...]

createConstraint

[...]

getConstraint

[...]

Shape ID

setShapeId

[...]

getShapeId

[...]

Collision object ID

The ID of the very collision object used by MPhysicsContext. See the introduction of this page.

setCollisionObjectId

[...]

getCollisionObjectId

[...]

Collision shape

setCollisionShape

[...]

getCollisionShape

[...]

Ghost

Setting the entity as a ghost disables all the physics properties (e.g. mass, friction) but the collision shape (which you can set, e.g. Box, Sphere). Constraints are also disabled.

The entity will allow you to detect collisions with other objects (because it has a physics shape) but it will not interact with them (it will just pass through, hence the name ghost).

This is generally used as a child object of another entity which is moving, so you can check if there is a collision at specific areas (e.g. feet).

If what you want is to have a static entity, you should set the mass to zero instead. See MPhysicsProperties#Mass.


setGhost

Set the entity as a ghost.

phyProps->setGhost(true); //set entity as ghost
phyProps->setGhost(false); //entity is no more a ghost

isGhost

Check if the entity is a ghost.

if(phyProps->isGhost())
  printf("Entity is a ghost");

Mass

Set the mass of the entity.

Notice that the property is not applied until you create/update the real physics object. See Creating and updating physics objects

setMass

Set the Mass. Float type.

phyProps->setMass(5.2f);

getMass

Retrieve the Mass. Float type.

float mass = phyProp->getMass();

Friction

setFriction

[...]

getFriction

[...]

Restitution

setRestitution

[...]

getRestitution

[...]

Linear damping

setLinearDamping

[...]

getLinearDamping

[...]

Angular damping

setAngularDamping

[...]

getAngularDamping

[...]

Angular factor

setAngularFactor

[...]

getAngularFactor

[...]

Linear factor

setLinearFactor

[...]

getLinearFactor

[...]

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox