GetMaterial

This function gets an entity's material.

Syntax

Remarks

This function does not increment the material's reference count. If you want to hold onto a handle to the material so that it won't be deleted if the entity is deleted, increment the reference count. When you are done with this handle, call Release() to decrement the reference count:
Material* material = entity->GetMaterial()
if (material) material->AddRef()

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,-5)

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

--Create a model
local entity = Model:Box()

--Load a material
local material = Material:Load("Materials/Grass/grass01.mat")

--Set the entity material
entity:SetMaterial(material)
material:Release()

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

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

--Get the entity material
local material = entity:GetMaterial()

context:SetBlendMode(Blend.Alpha)
context:DrawText("Material: "..material:GetPath(),2,2)

context:Sync()
end