UpdateNormals

This function calculates normals for a surface.

Syntax

Parameters

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,-4)
local light = DirectionalLight:Create()
light:SetRotation(35,35,0)

--Average normal
local model = Model:Cylinder()
model:SetColor(1.0,0.0,0.0)
model:SetPosition(-2.0,0.0,0.0)
local surface = model:GetSurface(0)
surface:UpdateNormals(false)

--Angular threshold at 180 degrees
model = Model:Cylinder()
model:SetColor(0.0,1.0,0.0)
model:SetPosition(0.0,0.0,0.0)
surface = model:GetSurface(0)
surface:UpdateNormals(true,0.01,180)

--Angular threshold at 25 degrees
model = Model:Cylinder()
model:SetColor(0.0,0.0,1.0)
model:SetPosition(2.0,0.0,0.0)
surface = model:GetSurface(0)
surface:UpdateNormals(true,0.01,25)

while true do

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

Time:Update()
world:Update()
world:Render()
context:Sync()

end