Class Body
Definition
- Namespace:
- Tizen.NUI.Physics2D.Chipmunk
- Assembly:
- Tizen.NUI.Physics2D.dll
Mass and moment are ignored when BodyType is Kinematic
or Static. Guessing the mass for a body is usually fine, but guessing
a moment of inertia can lead to a very poor simulation. It’s recommended to use Chipmunk’s
moment-calculating functions to estimate the moment for you.
public class Body : IDisposable
- Inheritance
-
Constructors
View Source
Body()
Create a Dynamic Body with no mass and no moment.
Declaration
View Source
Body(double, double, BodyType)
Creates a body with the given mass and moment, of the give BodyType.
Declaration
public Body(double mass, double moment, BodyType type)
Parameters
Type |
Name |
Description |
double |
mass |
|
double |
moment |
|
BodyType |
type |
|
View Source
Body(double, double)
Creates a body with the given mass and moment.
Declaration
public Body(double mass, double moment)
Parameters
Type |
Name |
Description |
double |
mass |
|
double |
moment |
|
View Source
Body(BodyType)
Declaration
public Body(BodyType type)
Parameters
Properties
View Source
AllContactedBodies
Get the list of all bodies in contact with this one
Declaration
public IReadOnlyList<Body> AllContactedBodies { get; }
Property Value
Type |
Description |
IReadOnlyList<><Body> |
|
View Source
Angle
Rotation of the body in radians. When changing the rotation, you may also want to call
ReindexShapesForBody(Body) to update the collision detection information
for the attached shapes if you plan to make any queries against the space. A body
rotates around its center of gravity, not its position.
Declaration
public double Angle { get; set; }
Property Value
View Source
AngularVelocity
The angular velocity of the body in radians per second.
Declaration
public double AngularVelocity { get; set; }
Property Value
View Source
Arbiters
Get the list of body Arbiters
Declaration
public IReadOnlyList<Arbiter> Arbiters { get; }
Property Value
Type |
Description |
IReadOnlyList<><Arbiter> |
|
View Source
CenterOfGravity
Location of the center of gravity in body-local coordinates. The default value is
(0, 0), meaning the center of gravity is the same as the position of the body.
Declaration
public Vect CenterOfGravity { get; set; }
Property Value
View Source
Constraints
All constraints attached to the body
Declaration
public IReadOnlyList<Constraint> Constraints { get; }
Property Value
View Source
Data
Declaration
public object Data { get; set; }
Property Value
View Source
Force
Force applied to the center of gravity of the body. This value is reset for every time
step.
Declaration
public Vect Force { get; set; }
Property Value
View Source
Handle
Declaration
public System.IntPtr Handle { get; }
Property Value
Type |
Description |
System.IntPtr |
|
View Source
IsSleeping
Returns true if body is sleeping.
Declaration
public bool IsSleeping { get; }
Property Value
View Source
KineticEnergy
Get the kinetic energy of a body.
Declaration
public double KineticEnergy { get; }
Property Value
View Source
Mass
Mass of the rigid body. Mass does not have to be expressed in any particular units, but
relative masses should be consistent.
Declaration
public double Mass { get; set; }
Property Value
View Source
Moment
Moment of inertia of the body. The mass tells you how hard it is to push an object,
the MoI tells you how hard it is to spin the object. Don't try to guess the MoI, use the
MomentFor*() functions to estimate it, or the physics may behave strangely.
Declaration
public double Moment { get; set; }
Property Value
View Source
Position
Position of the body. When changing the position, you may also want to call
ReindexShapesForBody(Body) to update the collision detection information
for the attached shapes if you plan to make any queries against the space.
Declaration
public Vect Position { get; set; }
Property Value
View Source
PositionUpdateFunction
Set the callback used to update a body's position.
Parameters: body, deltaTime
Declaration
public Action<Body, double> PositionUpdateFunction { get; set; }
Property Value
Type |
Description |
Action<, ><Body, double> |
|
View Source
Rotation
The rotation vector for the body. Can be used with cpvrotate() or cpvunrotate() to perform fast rotations.
Declaration
public Vect Rotation { get; }
Property Value
View Source
Shapes
All shapes attached to the body
Declaration
public IReadOnlyList<Shape> Shapes { get; }
Property Value
Type |
Description |
IReadOnlyList<><Shape> |
|
View Source
Space
Get the space this body is associated with, or null if it is not currently associated.
Declaration
public Space Space { get; }
Property Value
View Source
Torque
The torque applied to the body. This value is reset for every time step.
Declaration
public double Torque { get; set; }
Property Value
View Source
Type
The way the body behaves in physics simulations.
Declaration
public BodyType Type { get; set; }
Property Value
View Source
Velocity
Linear velocity of the center of gravity of the body.
Declaration
public Vect Velocity { get; set; }
Property Value
View Source
VelocityUpdateFunction
Set the callback used to update a body's velocity.
Parameters: body, gravity, damping and deltaTime
Declaration
public Action<Body, Vect, double, double> VelocityUpdateFunction { get; set; }
Property Value
Type |
Description |
Action<, , , ><Body, Vect, double, double> |
|
Methods
View Source
Activate()
Reset the idle timer on a body.
If it was sleeping, wake it and any other bodies it was touching.
Declaration
View Source
ActivateStatic(Shape)
Similar in function to Activate(). Activates all bodies touching body. If filter is not NULL, then only bodies touching through filter will be awoken.
Declaration
public void ActivateStatic(Shape filter)
Parameters
Type |
Name |
Description |
Shape |
filter |
|
View Source
ApplyAngularImpulse(double)
Declaration
public void ApplyAngularImpulse(double impulse)
Parameters
Type |
Name |
Description |
double |
impulse |
|
View Source
ApplyForceAtLocalPoint(Vect, Vect)
Add the local force force to body as if applied from the body local point.
Declaration
public void ApplyForceAtLocalPoint(Vect force, Vect point)
Parameters
Type |
Name |
Description |
Vect |
force |
|
Vect |
point |
|
View Source
ApplyForceAtWorldPoint(Vect, Vect)
Add the force force to body as if applied from the world point.
People are sometimes confused by the difference between a force and an impulse.
An impulse is a very large force applied over a very short period of time.
Some examples are a ball hitting a wall or cannon firing.
Chipmunk treats impulses as if they occur instantaneously by adding directly to the velocity of an object.
Both impulses and forces are affected the mass of an object.
Doubling the mass of the object will halve the effect.
Declaration
public void ApplyForceAtWorldPoint(Vect force, Vect point)
Parameters
Type |
Name |
Description |
Vect |
force |
|
Vect |
point |
|
View Source
ApplyImpulseAtLocalPoint(Vect, Vect)
Apply an impulse to a body. Both the impulse and point are expressed in body local coordinates.
Declaration
public void ApplyImpulseAtLocalPoint(Vect impulse, Vect point)
Parameters
Type |
Name |
Description |
Vect |
impulse |
|
Vect |
point |
|
View Source
ApplyImpulseAtWorldPoint(Vect, Vect)
Apply an impulse to a body. Both the impulse and point are expressed in world coordinates.
Declaration
public void ApplyImpulseAtWorldPoint(Vect impulse, Vect point)
Parameters
Type |
Name |
Description |
Vect |
impulse |
|
Vect |
point |
|
View Source
ApplyTorque(double)
Declaration
public void ApplyTorque(double torque)
Parameters
Type |
Name |
Description |
double |
torque |
|
View Source
ContactWith(Body)
Check if a Body is in contact with another
Declaration
public bool ContactWith(Body other)
Parameters
Type |
Name |
Description |
Body |
other |
|
Returns
View Source
Dispose()
Declaration
View Source
Dispose(bool)
Declaration
protected virtual void Dispose(bool dispose)
Parameters
Type |
Name |
Description |
bool |
dispose |
|
View Source
Free()
Destroy and free the body.
Declaration
View Source
FromHandle(IntPtr)
Get a Body object from a native cpBody handle.
Declaration
public static Body FromHandle(System.IntPtr body)
Parameters
Type |
Name |
Description |
System.IntPtr |
body |
|
Returns
View Source
FromHandleSafe(IntPtr)
Get the managed Body object from the native handle.
Declaration
public static Body FromHandleSafe(System.IntPtr nativeBodyHandle)
Parameters
Type |
Name |
Description |
System.IntPtr |
nativeBodyHandle |
|
Returns
View Source
GetTransform(out Vect, out double)
Get body position and rotation angle (in radians)
Declaration
public void GetTransform(out Vect position, out double angle)
Parameters
Type |
Name |
Description |
Vect |
position |
|
double |
angle |
|
View Source
GetVelocityAtLocalPoint(Vect)
Get the velocity on a body (in world units) at a point on the body in local coordinates.
Declaration
public Vect GetVelocityAtLocalPoint(Vect point)
Parameters
Type |
Name |
Description |
Vect |
point |
|
Returns
View Source
GetVelocityAtWorldPoint(Vect)
Get the velocity on a body (in world units) at a point on the body in world coordinates.
Declaration
public Vect GetVelocityAtWorldPoint(Vect point)
Parameters
Type |
Name |
Description |
Vect |
point |
|
Returns
View Source
LocalToWorld(Vect)
Convert body relative/local coordinates to absolute/world coordinates.
Declaration
public Vect LocalToWorld(Vect point)
Parameters
Type |
Name |
Description |
Vect |
point |
|
Returns
View Source
MomentForBox(double, double, double)
Calculate the moment of inertia for a solid box centered on the body.
Declaration
public static double MomentForBox(double mass, double width, double height)
Parameters
Type |
Name |
Description |
double |
mass |
|
double |
width |
|
double |
height |
|
Returns
View Source
SetTransform(Vect, double)
Set body position and rotation angle (in radians)
Declaration
public void SetTransform(Vect position, double angle)
Parameters
Type |
Name |
Description |
Vect |
position |
|
double |
angle |
|
View Source
Sleep()
Forces a body to fall asleep immediately even if it’s in midair. Cannot be called from a callback.
Declaration
View Source
SleepWithGroup(Body)
When objects in Chipmunk sleep, they sleep as a group of all objects that are touching or jointed together.
When an object is woken up, all of the objects in its group are woken up.
SleepWithGroup() allows you group sleeping objects together. It acts identically to Sleep() if you pass null as
group by starting a new group.
If you pass a sleeping body for group, body will be awoken when group is awoken.
You can use this to initialize levels and start stacks of objects in a pre-sleeping state.
Declaration
public void SleepWithGroup(Body group)
Parameters
Type |
Name |
Description |
Body |
group |
|
View Source
UpdatePosition(double)
Default position integration function.
Declaration
public void UpdatePosition(double dt)
Parameters
Type |
Name |
Description |
double |
dt |
|
View Source
UpdateVelocity(Vect, double, double)
Default velocity integration function..
Declaration
public void UpdateVelocity(Vect gravity, double damping, double dt)
Parameters
Type |
Name |
Description |
Vect |
gravity |
|
double |
damping |
|
double |
dt |
|
View Source
WorldToLocal(Vect)
Convert body absolute/world coordinates to relative/local coordinates.
Declaration
public Vect WorldToLocal(Vect point)
Parameters
Type |
Name |
Description |
Vect |
point |
|
Returns
Extension Methods