singe/testScripts/scene37.singe
2026-09-07 23:44:37 -05:00

71 lines
2.1 KiB
Text

-- GUI on a material: the scene36 document rendered into a GUI and shown on the arcade monitor
-- from scene6 through materialSetGui (unlit, so the picture is not shaded), with the same GUI
-- composited over the overlay in the corner through guiDraw. A rotating glass ball in front
-- shows the material is an ordinary texture: lit, blended and reflected like any other.
local font = fontLoad("Singe/FreeSansBold.ttf", 24)
local frames = 0
fontSelect(font)
discPlay()
sceneEnable(true)
sceneSetBackground(20, 20, 40, 255)
sceneSetAmbient(80, 80, 90)
local gui = guiNew(720, 480)
local doc = guiLoad(gui, "testScripts/scene36.rml")
local screen = materialNew()
materialSetGui(screen, gui)
materialSetUnlit(screen, true)
local cabinet = materialNew()
materialSetColor(cabinet, 60, 60, 70)
materialSetRoughness(cabinet, 0.6)
local glass = materialNew()
materialSetColor(glass, 200, 220, 255, 90)
materialSetBlend(glass, true)
materialSetRoughness(glass, 0.1)
materialSetMetallic(glass, 0.5)
local body = nodeNew()
nodeSetMesh(body, meshBox(3.2, 2.4, 0.4), cabinet)
nodeSetPosition(body, -0.6, 0.2, -0.3)
nodeSetRotation(body, 0, 25, 0)
local tv = nodeNew(body)
nodeSetMesh(tv, meshPlane(3.0, 2.0), screen)
nodeSetPosition(tv, 0, 0, 0.21)
nodeSetRotation(tv, 90, 0, 0)
local ball = nodeNew()
nodeSetMesh(ball, meshSphere(0.6, 48), glass)
nodeSetPosition(ball, 1.6, -0.3, 1.2)
local sun = lightNew(LIGHT_DIRECTIONAL)
nodeSetPosition(sun, 2, 4, 3)
nodeLookAt(sun, 0, 0, 0)
lightSetIntensity(sun, 1.3)
local camera = nodeNew()
nodeSetPosition(camera, 0, 0.8, 5.5)
nodeLookAt(camera, 0, 0, 0)
cameraSet(camera)
function onOverlayUpdate()
frames = frames + 1
nodeRotate(ball, 0, 1.2, 0)
nodeSetRotation(body, 0, 25 + 10 * math.sin(frames / 30), 0)
overlayClear()
colorForeground(255, 255, 255, 255)
fontPrint(10, 10, "scene37 frame " .. frames)
guiSetValue(gui, doc, "frame", "frame " .. frames)
guiDraw(gui, overlayGetWidth() * 0.66, overlayGetHeight() * 0.68, overlayGetWidth() * 0.32, overlayGetHeight() * 0.3)
if frames == 60 or frames == 120 then
singeScreenshot()
end
if frames == 140 then
singeQuit()
end
return OVERLAY_UPDATED
end