Difference between revisions of "R3d.World:createBody"
From GiderosMobile
(Created page with "'''Available since:''' Gideros 2019.10<br/> '''Class:''' R3d.World<br/> === Description === A rigid body represents an object that you want to simulate in the world. It h...") |
m (Text replacement - "</source>" to "</syntaxhighlight>") |
||
(One intermediate revision by the same user not shown) | |||
Line 7: | Line 7: | ||
In order to create a rigid body, you need to specify its transform. | In order to create a rigid body, you need to specify its transform. | ||
− | < | + | <syntaxhighlight lang="lua"> |
body = r3d.World:createBody(matrix) | body = r3d.World:createBody(matrix) | ||
− | </ | + | </syntaxhighlight> |
=== Parameters === | === Parameters === | ||
Line 15: | Line 15: | ||
=== Example === | === Example === | ||
− | < | + | <syntaxhighlight lang="lua"> |
-- mesh | -- mesh | ||
local mesh = D3.Mesh.new() | local mesh = D3.Mesh.new() | ||
Line 29: | Line 29: | ||
-- body | -- body | ||
meshview.body = world:createBody(meshview:getMatrix()) | meshview.body = world:createBody(meshview:getMatrix()) | ||
− | </ | + | </syntaxhighlight> |
{{R3d.World}} | {{R3d.World}} |
Latest revision as of 14:32, 13 July 2023
Available since: Gideros 2019.10
Class: R3d.World
Description
A rigid body represents an object that you want to simulate in the world. It has a mass, a position, an orientation and one or several collision shapes. The dynamics world will compute collisions between the bodies and will update its position and orientation accordingly at each time step. You can also create joints between the bodies in the world.
In order to create a rigid body, you need to specify its transform.
body = r3d.World:createBody(matrix)
Parameters
matrix: (matrix) the initial position and orientation of the body in the world
Example
-- mesh
local mesh = D3.Mesh.new()
local meshview = Viewport.new()
meshview:setContent(mesh)
-- transform
matrix = meshview:getMatrix()
matrix:setPosition(posx, posy, posz)
matrix:setRotationX(rotx)
matrix:setRotationY(roty)
matrix:setRotationZ(rotz)
meshview:setMatrix(matrix)
-- body
meshview.body = world:createBody(meshview:getMatrix())
- R3d.World
- R3d.World.new
- R3d.World:createBallAndSocketJoint
- R3d.World:createBody
- R3d.World:createFixedJoint
- R3d.World:createHingeJoint
- R3d.World:createSliderJoint
- R3d.World:destroyBody
- R3d.World:destroyJoint
- R3d.World:raycast
- R3d.World:setEventListener
- R3d.World:step
- R3d.World:testAABBOverlap
- R3d.World:testCollision
- R3d.World:testOverlap