Difference between revisions of "R3d.Body"

From GiderosMobile
(Created page with "__NOTOC__ <languages /> <!-- GIDEROSOBJ:r3d.World --> '''<translate>Supported platforms</translate>:''' File:Platform android.pngFile:Platform ios.pngFile:Platform m...")
 
(update to r3d v0.8)
 
(13 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
<languages />
+
<!-- GIDEROSOBJ:r3d.Body -->
<!-- GIDEROSOBJ:r3d.World -->
+
'''Supported platforms:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/>
'''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/>
+
'''Available since:''' Gideros 2019.10<br/>
'''<translate>Available since</translate>:''' Gideros 2019.10<br/>
+
 
=== <translate>Description</translate> ===
+
=== Description ===
 +
Once the dynamics world has been created, you can create rigid bodies into the world.
 +
 
 +
A rigid body represents an object that you want to simulate in the world. It has a mass, a position, an orientation, a type, and one or several collision shapes. You can also create joints between the bodies in the world.
 +
 
 +
The dynamics world will compute collisions between the bodies and will update the bodies position
 +
and orientation accordingly every time step.
 +
 
 +
In ReactPhysics3D, the RigidBody class (which inherits from the CollisionBody class) is used to describe a rigid body.
 +
 
 
{|-
 
{|-
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== <translate>Methods</translate> ===
+
=== Methods ===
[[Special:MyLanguage/r3d.World.createBody|r3d.World.createBody]] ''<translate>create a new body</translate>''<br/><!-- GIDEROSMTD:r3d.World.createBody(transform) create a new body -->
+
[[r3d.Body:applyForce]] ''applies a force to this body''<br/><!--GIDEROSMTD:r3d.Body:applyForce(forceX,forceY,forceZ[,pointX,pointY,pointZ]) applies a force to this body-->
[[Special:MyLanguage/r3d.World.destroyBody|r3d.World.destroyBody]] ''<translate>destroy a body</translate>''<br/><!-- GIDEROSMTD:r3d.World.destroyBody(body) destroy a body -->
+
[[r3d.Body:applyTorque]] ''applies a torque to this body''<br/><!--GIDEROSMTD:r3d.Body:applyTorque(torqueX,torqueY,torqueZ) applies a torque to this body-->
[[Special:MyLanguage/r3d.World.step|r3d.World.step]] ''<translate>Step the world</translate>''<br/><!-- GIDEROSMTD:r3d.World.step(time) step the world -->
+
[[r3d.Body:createFixture]] ''creates a new fixture''<br/><!--GIDEROSMTD:r3d.Body:createFixture(shape,transform,mass) creates a new fixture-->
[[Special:MyLanguage/r3d.World.raycast|r3d.World.raycast]] ''<translate>perform a ray cast on the world</translate>''<br/><!-- GIDEROSMTD:r3d.World.raycast(sx,sy,sz,ex,ey,ez,callback,category) perform a ray cast on the world -->
+
[[r3d.Body:destroyFixture]] ''destroys a fixture''<br/><!--GIDEROSMTD:r3d.Body:destroyFixture(fixture) destroys a fixture-->
[[Special:MyLanguage/r3d.World.testOverlap|r3d.World.testOverlap]] ''<translate>check if two bodies overlap</translate>''<br/><!-- GIDEROSMTD:r3d.World.testOverlap(bodyA,bodyB) check if two bodies overlap -->
+
[[r3d.Body:enableGravity]] ''enables or disables gravity force on the body''<br/><!--GIDEROSMTD:r3d.Body:enableGravity(enable) enables or disables gravity force on the body-->
[[Special:MyLanguage/r3d.World.testAABBOverlap|r3d.World.testAABBOverlap]] ''<translate>check if two bodies AABB overlap</translate>''<br/><!-- GIDEROSMTD:r3d.World.testAABBOverlap(bodyA,bodyB) check if two bodies AABB overlap -->
+
[[r3d.Body:getAngularDamping]] ''gets the body angular damping''<br/><!--GIDEROSMTD:r3d.Body:getAngularDamping() gets the body angular damping-->
[[Special:MyLanguage/r3d.World.testCollision|r3d.World.testCollision]] ''<translate>check collisions</translate>''<br/><!-- GIDEROSMTD:r3d.World.testCollision([bodyA,[bodyB,]]callback[,category]) check collisions -->
+
[[r3d.Body:getAngularVelocity]] ''gets the body angular velocity''<br/><!--GIDEROSMTD:r3d.Body:getAngularVelocity() gets the body angular velocity-->
[[Special:MyLanguage/r3d.World.setEventListener|r3d.World.setEventListener]] ''<translate>set the event listener for collisions in the world</translate>''<br/><!-- GIDEROSMTD:r3d.World.setEventListener(listener) set the event listener for collisions in the world -->
+
[[r3d.Body:getLinearDamping]] ''gets the body linear damping''<br/><!--GIDEROSMTD:r3d.Body:getLinearDamping() gets the body linear damping-->
[[Special:MyLanguage/r3d.World.createBallAndSocketJoint|r3d.World.createBallAndSocketJoint]] <br/><!-- GIDEROSMTD:r3d.World.createBallAndSocketJoint(bodyA,bodyB,anchorX,anchorY,anchorZ,params) -->
+
[[r3d.Body:getLinearVelocity]] ''gets the body linear velocity''<br/><!--GIDEROSMTD:r3d.Body:getLinearVelocity() gets the body linear velocity-->
[[Special:MyLanguage/r3d.World.createHingeJoint|r3d.World.createHingeJoint]] <br/><!-- GIDEROSMTD:r3d.World.createHingeJoint(bodyA,bodyB,anchorX,anchorY,anchorZ,params) -->
+
[[r3d.Body:getMass]] ''gets the body mass''<br/><!--GIDEROSMTD:r3d.Body:getMass() gets the body mass-->
[[Special:MyLanguage/r3d.World.createSliderJoint|r3d.World.createSliderJoint]] <br/><!-- GIDEROSMTD:r3d.World.createSliderJoint(bodyA,bodyB,anchorX,anchorY,anchorZ,params) -->
+
[[r3d.Body:getTransform]] ''gets the body transform (position and rotation) matrix''<br/><!--GIDEROSMTD:r3d.Body:getTransform() gets the body transform (position and rotation) matrix-->
[[Special:MyLanguage/r3d.World.createFixedJoint|r3d.World.createFixedJoint]] <br/><!-- GIDEROSMTD:r3d.World.createFixedJoint(bodyA,bodyB,anchorX,anchorY,anchorZ,params) -->
+
[[r3d.Body:raycast]] ''performs a ray cast on the body''<br/><!--GIDEROSMTD:r3d.Body:raycast(sx,sy,sz,ex,ey,ez) performs a ray cast on the body-->
[[Special:MyLanguage/r3d.World.destroyJoint|r3d.World.destroyJoint]] ''<translate>destroy a joint</translate>''<br/><!-- GIDEROSMTD:r3d.World.destroyBody(joint) destroy a joint -->
+
[[r3d.Body:setAngularDamping]] ''sets the body angular damping''<br/><!--GIDEROSMTD:r3d.Body:setAngularDamping(number) sets the body angular damping-->
 +
[[r3d.Body:setAngularVelocity]] ''sets the body angular velocity''<br/><!--GIDEROSMTD:r3d.Body:setAngularVelocity(number) sets the body angular velocity-->
 +
[[r3d.Body:setIsAllowedToSleep]] ''allows or disallows a body to sleep''<br/><!--GIDEROSMTD:r3d.Body:setIsAllowedToSleep(allowed) allows or disallows a body to sleep-->
 +
[[r3d.Body:setLinearDamping]] ''sets the body linear damping''<br/><!--GIDEROSMTD:r3d.Body:setLinearDamping(number) sets the body linear damping-->
 +
[[r3d.Body:setLinearVelocity]] ''sets the body linear velocity''<br/><!--GIDEROSMTD:r3d.Body:setLinearVelocity(number) sets the body linear velocity-->
 +
[[r3d.Body:setMass]] ''sets the mass of the body''<br/><!--GIDEROSMTD:r3d.Body:setMass(number) sets the mass of the body-->
 +
[[r3d.Body:setTransform]] ''sets the body transform matrix''<br/><!--GIDEROSMTD:r3d.Body:setTransform(transform) sets the body transform matrix-->
 +
[[r3d.Body:setType]] ''sets the body type''<br/><!--GIDEROSMTD:r3d.Body:setType(type) sets the body type-->
 +
[[r3d.Body:testPointInside]] ''checks if a point is inside the body''<br/><!--GIDEROSMTD:r3d.Body:testPointInside(x,y,z) checks if a point is inside the body-->
 +
 
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== <translate>Constants</translate> ===
+
=== Constants ===
[[Special:MyLanguage/r3d.World.DYNAMIC_BODY|r3d.World.DYNAMIC_BODY]]<br/><!-- GIDEROSCST:r3d.World.DYNAMIC_BODY 2-->
+
[[r3d.Body.STATIC_BODY]]<br/><!--GIDEROSCST:r3d.Body.STATIC_BODY 0-->
[[Special:MyLanguage/r3d.World.KINEMATIC_BODY|r3d.World.KINEMATIC_BODY]]<br/><!-- GIDEROSCST:r3d.World.KINEMATIC_BODY 1-->
+
[[r3d.Body.KINEMATIC_BODY]]<br/><!--GIDEROSCST:r3d.Body.KINEMATIC_BODY 1-->
[[Special:MyLanguage/r3d.World.STATIC_BODY|r3d.World.STATIC_BODY]]<br/><!-- GIDEROSCST:r3d.World.STATIC_BODY 0-->
+
[[r3d.Body.DYNAMIC_BODY]]<br/><!--GIDEROSCST:r3d.Body.DYNAMIC_BODY 2-->
 
|}
 
|}
 +
 +
----
 +
'''[[ReactPhysics3D]]'''

Latest revision as of 23:05, 17 December 2020

Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.pngPlatform html5.pngPlatform winrt.pngPlatform win32.png
Available since: Gideros 2019.10

Description

Once the dynamics world has been created, you can create rigid bodies into the world.

A rigid body represents an object that you want to simulate in the world. It has a mass, a position, an orientation, a type, and one or several collision shapes. You can also create joints between the bodies in the world.

The dynamics world will compute collisions between the bodies and will update the bodies position and orientation accordingly every time step.

In ReactPhysics3D, the RigidBody class (which inherits from the CollisionBody class) is used to describe a rigid body.

Methods

r3d.Body:applyForce applies a force to this body
r3d.Body:applyTorque applies a torque to this body
r3d.Body:createFixture creates a new fixture
r3d.Body:destroyFixture destroys a fixture
r3d.Body:enableGravity enables or disables gravity force on the body
r3d.Body:getAngularDamping gets the body angular damping
r3d.Body:getAngularVelocity gets the body angular velocity
r3d.Body:getLinearDamping gets the body linear damping
r3d.Body:getLinearVelocity gets the body linear velocity
r3d.Body:getMass gets the body mass
r3d.Body:getTransform gets the body transform (position and rotation) matrix
r3d.Body:raycast performs a ray cast on the body
r3d.Body:setAngularDamping sets the body angular damping
r3d.Body:setAngularVelocity sets the body angular velocity
r3d.Body:setIsAllowedToSleep allows or disallows a body to sleep
r3d.Body:setLinearDamping sets the body linear damping
r3d.Body:setLinearVelocity sets the body linear velocity
r3d.Body:setMass sets the mass of the body
r3d.Body:setTransform sets the body transform matrix
r3d.Body:setType sets the body type
r3d.Body:testPointInside checks if a point is inside the body

Constants

r3d.Body.STATIC_BODY
r3d.Body.KINEMATIC_BODY
r3d.Body.DYNAMIC_BODY


ReactPhysics3D