SetMaterial
This function sets an entity's material.
Syntax
- SetMaterial(Material material, bool recursive = false)
Parameters
- material: the new material to set. This value may be NULL if no material is to be used.
- recursive: if set to true, the function will be called recursively for all children.
Remarks
This function will increment the reference count of the new material and decrement the reference count of the old material (if they exist).
Example
--Create a window
window = Window:Create()
context = Context:Create(window)
world = World:Create()
local camera = Camera:Create()
local light = DirectionalLight:Create()
--Create a material
local material = Material:Create()
material:SetColor(1,0,0)
--Create a model and apply the material to it
local model = Model:Sphere()
model:SetPosition(0,0,2)
model:SetMaterial(material)
while true do
if window:Closed() or window:KeyHit(Key.Escape) then return false end
Time:Update()
world:Update()
world:Render()
context:Sync()
end