singe/testScripts/scene6.singe
2026-09-05 19:52:04 -05:00

75 lines
2.1 KiB
Text

-- Stage 6 test: the disc as a material on a tilted screen, a loaded video on a sphere, a small
-- marker placed with sceneUnproject at the overlay's centre, and antialiasing.
local font = fontLoad("Singe/FreeSansBold.ttf", 28)
local clip = videoLoad("Singe/menuBackground.mkv")
local frames = 0
fontSelect(font)
discPlay()
videoPlay(clip)
sceneEnable(true)
sceneSetBackground(20, 20, 40, 255)
sceneSetAmbient(80, 80, 90)
local screen = materialNew()
materialSetVideo(screen)
materialSetUnlit(screen, true)
local ballSkin = materialNew()
materialSetVideo(ballSkin, clip)
local cabinet = materialNew()
materialSetColor(cabinet, 60, 60, 70)
materialSetRoughness(cabinet, 0.6)
local marker = materialNew()
materialSetColor(marker, 255, 60, 60)
materialSetEmissive(marker, 120, 0, 0)
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.2), screen)
nodeSetPosition(tv, 0, 0, 0.21)
nodeSetRotation(tv, 90, 0, 0)
local ball = nodeNew()
nodeSetMesh(ball, meshSphere(0.7, 48), ballSkin)
nodeSetPosition(ball, 2.0, -0.2, 0.8)
local width, height = sceneGetSize()
local cx, cy, cz = sceneUnproject(width / 2, height / 2, 4.0)
local dot = nodeNew()
nodeSetMesh(dot, meshSphere(0.08, 16), marker)
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)
if frames == 2 then
-- After the first render the camera matrices exist; place the marker 4 units in at the centre.
cx, cy, cz = sceneUnproject(width / 2, height / 2, 4.0)
nodeSetPosition(dot, cx, cy, cz)
debugPrint(string.format("unproject centre -> %.2f %.2f %.2f", cx, cy, cz))
end
overlayClear()
fontPrint(20, 20, "Stage 6, frame " .. frames)
if frames == 80 then
singeScreenshot()
end
if frames == 100 then
singeQuit()
end
end