ConvexHull

This function creates s new shape using the convex hull algorithm.

Syntax

Parameters

Returns

Returns a new shape.

Remarks

The convex hull approximation algorithm calculates a convex shape that encompasses all the vertices in the original surface.

Example

window=Window:Create()
context=Context:Create(window)
world=World:Create()
camera = Camera:Create()
camera:SetRotation(35,0,0)
camera:Move(0,0,-10)
light = DirectionalLight:Create()
light:SetRotation(35,35,0)

--Create the ground
local ground = Model:Box(10,1,10)
ground:SetPosition(0,-.05,0)
ground:SetColor(0,1,0)

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

--Load a model
local model = Model:Load("Models/teapot.mdl")
model:SetCollisionType(1)
model:SetPosition(0,2,0)
model:SetColor(0,0,1)
model:SetMass(1)
model:SetRotation(0,0,45)

--Create a shape
model:SetScale(1,1,1)
shape = Shape:ConvexHull((model:GetSurface(0)))
model: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:Sync()

end