SetMass

Sets an entity's mass.

Syntax

Parameters

Remarks

Entities with zero mass will still collide with other objects, but will be unmovable and unresponsive to physical forces.

If the mass matrix is not specified then the center of mass and moment of inertia will be automatically calculated. The second function overload can be used to specify the mass matrix for fine control of the object's behavior.

Example

--Create a window
window = Window:Create()
context = Context:Create(window)
world = World:Create()

local camera = Camera:Create()
camera:SetRotation(35,0,0)
camera:Move(0,0,-5)

local light = DirectionalLight:Create()
light:SetRotation(35,35,0)

--Create the ground
local ground = Model:Box(10,1,10)
ground:SetPosition(0,0,-0.5)
ground:SetColor(0.0,1.0,0.0)

--Create a shape
local shape = Shape:Box(0,0,0, 0,0,0, 10,1,10)
ground:SetShape(shape)
shape:Release()

--Create a model
entity = Model:Box()
entity:SetColor(0.0,0.0,1.0)
entity:SetPosition(0,3,0)
entity:SetMass(1)

--Create a shape
shape = Shape:Box()
entity:SetShape(shape)
shape:Release()

while true do
if window:Closed() or window:KeyHit(Key.Escape) then return false end

Time:Update()
world:Update()
world:Render()

context:SetBlendMode(Blend.Alpha)
context:DrawText("Mass: "..entity:GetMass(),2,2)

context:Sync()
end
function App:Loop()

if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end

Time:Update()
self.world:Update()
self.world:Render()

self.context:SetBlendMode(Blend.Alpha)
self.context:DrawText("Mass: "..self.entity:GetMass(),2,2)

self.context:Sync()

return true
end