GetTriangleNormal

This function calculates a normal based on the positions of a triangle's vertices. This value will not necessarily be the same as the vertex normals, though the values are likely to be similar.

Syntax

Parameters

Returns

Returns a normal describing the direction in which a triangle's face points.

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

local model = Model:Box()
model:SetColor(0.0,0.0,1.0)
local surface = model:GetSurface(0)

--Print out the triangle normals
for t=0, surface:CountTriangles()-1 do

System:Print(surface:GetTriangleNormal(t))
end

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

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

end