MPhysicsProperties

From MaratisWiki
Revision as of 10:14, 9 February 2014 by Dahnielson (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Contents

API

MPhysicsConstraint* MPhysicsProperties::m_constraintNone

unsigned int MPhysicsProperties::m_shapeIdNone

unsigned int MPhysicsProperties::m_collisionObjectIdNone

M_COLLISION_SHAPE_TYPE MPhysicsProperties::m_collisionShapeNone

bool MPhysicsProperties::m_ghostNone

float MPhysicsProperties::m_massNone

float MPhysicsProperties::m_frictionNone

float MPhysicsProperties::m_restitutionNone

float MPhysicsProperties::m_linearDampingNone

float MPhysicsProperties::m_angularDampingNone

float MPhysicsProperties::m_angularFactorNone

MVector3 MPhysicsProperties::m_linearFactorNone

MPhysicsProperties::MPhysicsProperties(void)

MPhysicsProperties::MPhysicsProperties(const MPhysicsProperties &physicsProperties)

MPhysicsProperties::~MPhysicsProperties(void)

void MPhysicsProperties::deleteConstraint(void)

MPhysicsConstraint* MPhysicsProperties::createConstraint(void)

MPhysicsConstraint* MPhysicsProperties::getConstraint(void)

void MPhysicsProperties::setShapeId(unsigned int shapeId)

unsigned int MPhysicsProperties::getShapeId(void)

void MPhysicsProperties::setCollisionObjectId(unsigned int collisionObjectId)

unsigned int MPhysicsProperties::getCollisionObjectId(void)

void MPhysicsProperties::setCollisionShape(M_COLLISION_SHAPE_TYPE collisionShape)

M_COLLISION_SHAPE_TYPE MPhysicsProperties::getCollisionShape(void)

void MPhysicsProperties::setGhost(bool ghost)

bool MPhysicsProperties::isGhost(void)

void MPhysicsProperties::setMass(float mass)

float MPhysicsProperties::getMass(void)

void MPhysicsProperties::setFriction(float friction)

float MPhysicsProperties::getFriction(void)

void MPhysicsProperties::setRestitution(float restitution)

float MPhysicsProperties::getRestitution(void)

void MPhysicsProperties::setLinearDamping(float linearDamping)

float MPhysicsProperties::getLinearDamping(void)

void MPhysicsProperties::setAngularDamping(float angularDamping)

float MPhysicsProperties::getAngularDamping(void)

void MPhysicsProperties::setAngularFactor(float angularFactor)

float MPhysicsProperties::getAngularFactor(void)

void MPhysicsProperties::setLinearFactor(const MVector3 &linearFactor)

MVector3* MPhysicsProperties::getLinearFactor(void)


Example

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:

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

Shape ID

The ID of the shape used by MPhysicsContext. See Creating and updating physics objects.

Collision object ID

The ID of the very collision object used by MPhysicsContext. See the introduction of this page or Creating and updating physics objects.

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.

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

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

Check if the entity is a ghost.

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

Mass

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. Setting the mass to zero makes the entity a static mesh, which means that it will be still for the entire game and objects can collide with it. This is generally used for rooms, using the collision shape "Triangle mesh" so you can have precise collisions against walls and other elements of the room. If you want the entity to pass through other objects but still detect collisions you should use the MPhysicsProperties#Ghost property.

Set the Mass. Float type.

 phyProps->setMass(5.2f);

Retrieve the Mass. Float type.

 float mass = phyProp->getMass();

Friction

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

Restitution

Restitution is basically how much the object bounces against others. Notice that the property is not applied until you create/update the real physics object. See Creating and updating physics objects.

Linear damping

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

Angular damping

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

Angular factor

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

Linear factor

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

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox