GetOcclusionCullingMode

This function gets an entity's occlusion testing mode.

Syntax

Returns

Returns true if per-entity occlusion testing is enabled, otherwise false is returned.

Example

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

local camera = Camera:Create()
camera:Move(0,0,-8)

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

--Create a model to act as an occluder
local model = Model:Box()
model:SetScale(2)
model:SetColor(0.0,0.0,1.0)

--Create a model to test the visibility of
model = Model:Box()
model:SetColor(0.0,1.0,0.0)
model:SetPosition(0,0,6)

--Enable individual entity occlusion culling. Normally we would not do this
--because the occlusion test is as expensive as just rendering the object.
--A courser occlusion culling system is always active in the world octree.
model:SetOcclusionCullingMode(true)

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

model:SetPosition(Math:Sin(Time:GetCurrent()/20.0)*4.0,0,4)

if (window:KeyHit(Key.Space)) then
model:SetOcclusionCullingMode(not self.model:GetOcclusionCullingMode())
end

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

context:SetBlendMode(Blend.Alpha)
context:DrawText("Culled: "..tostring(model:GetCulled(camera)),2,2)
context:DrawText("Occlusion culling mode: "..tostring(model:GetOcclusionCullingMode()),2,22)

context:Sync()
end