R3d.BoxShape.new: Difference between revisions

From GiderosMobile
Created page with "'''Available since:''' Gideros 2019.10<br/> '''Class:''' R3d.BoxShape<br/> === Description === Creates a new collision box shape (fixture). <source lang="lua"> r3d.BoxSha..."
 
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 4: Line 4:
=== Description ===
=== Description ===
Creates a new collision box shape (fixture).
Creates a new collision box shape (fixture).
<source lang="lua">
<syntaxhighlight lang="lua">
r3d.BoxShape.new(hX,hY,hZ)
r3d.BoxShape.new(hX,hY,hZ)
</source>
</syntaxhighlight>


=== Parameters ===
=== Parameters ===
'''hX''': (number) the height of the box on the X axis<br/>
'''hX''': (number) the half height of the box on the X axis<br/>
'''hY''': (number) the height of the box on the Y axis<br/>
'''hY''': (number) the half height of the box on the Y axis<br/>
'''hZ''': (number) the height of the box on the Z axis<br/>
'''hZ''': (number) the half height of the box on the Z axis<br/>


=== Example ===
=== Example ===
<source lang="lua">
<syntaxhighlight lang="lua">
-- a ship
-- a ship
local shipobj = loadObj("3d/ship", "ship.obj")
local shipobj = loadObj("3d/ship", "ship.obj")
shipobj.shape1 = r3d.BoxShape.new(4, 2, 6)
shipobj.mass = 128
local shipvp = Viewport.new()
local shipvp = Viewport.new()
shipvp:setContent(shipobj)
shipvp:setContent(shipobj)
shipvp.body = world:createBody(shipvp:getMatrix())
shipvp.body = world:createBody(shipvp:getMatrix())
shipobj.shape1 = r3d.BoxShape.new(4, 2, 6)
shipobj.mass = 128
shipvp.body:createFixture(shipobj.shape1, nil, shipobj.mass)
shipvp.body:createFixture(shipobj.shape1, nil, shipobj.mass)
</source>
</syntaxhighlight>


{{R3d.BoxShape}}
{{R3d.BoxShape}}

Latest revision as of 01:26, 19 December 2025

Available since: Gideros 2019.10
Class: R3d.BoxShape

Description

Creates a new collision box shape (fixture).

r3d.BoxShape.new(hX,hY,hZ)

Parameters

hX: (number) the half height of the box on the X axis
hY: (number) the half height of the box on the Y axis
hZ: (number) the half height of the box on the Z axis

Example

-- a ship
local shipobj = loadObj("3d/ship", "ship.obj")
local shipvp = Viewport.new()
shipvp:setContent(shipobj)
shipvp.body = world:createBody(shipvp:getMatrix())
shipobj.shape1 = r3d.BoxShape.new(4, 2, 6)
shipobj.mass = 128
shipvp.body:createFixture(shipobj.shape1, nil, shipobj.mass)