setObjectMaterial()
Purpose
Set the material of a 3D object
Description
Changes the way light behaves on the surface of the object.
Syntax
setObjectMaterial( handle, colour, metallic, roughness )
setObjectMaterial( handle, colour, metallic, roughness, emissiveStrength )
Arguments
handle The handle of the placed 3D object
colour colour name or RGB values { red, green, blue, opacity } between 0 and 1
metallic A flag to indictate whether the object is metallic(1) or non metallic(0)
roughness A value for the roughness of the objects between 0 and 1 (0 is completely smooth and 1 is very rough)
emissiveStrength Float strength of the object's light emission. Emitted light does not affect other objects and does not cast shadows
Example
obj = placeObject( sphere, { 0, 0, 0 }, { 2, 2, 2 } )
setObjectMaterial( obj, red, 1, 1 )
setCamera( { 5, 5, 10 }, { 0, 0, 0 } )
light = pointLight( { 0, 4, 2 }, white, 50 )
loop
clear()
c = controls( 0 )
if c.a then
setObjectMaterial( obj, red, 0, 1 )
endIf
if c.b then
setObjectMaterial( obj, red, 1, 0 )
endIf
if c.x then
setObjectMaterial( obj, red, 0, 0 )
endIf
if c.y then
setObjectMaterial( obj, red, 1, 1 )
endIf
drawObjects()
printAt( 0, 0, "Use A, B, X and Y buttons to change object material" )
update()
repeat
Associated Commands
drawObjects(), loadModel(), objectPointAt(), placeObject(), removeObject(), rotateObject(), setObjectPos(), setObjectScale()