Scripting QuickTime VR Panoramas with Lingo

QTVR panoramas provide users with an observer's perspective of a space in 360 degrees. Numerous QTVR scenes can be linked together with embedded hotspots that the user can click on; for example, to go from room to room. These are called nodes. The direction the camera is facing is called its pan. While QTVR's provide valuable information, a bird's eye perspective provides context and orientation; for example, where the observer is in the building or which way they are facing.

In the example above the room that the observer is in the church is highlighted in the floorplan. The orientation of the observer is indicated by the direction of the arrowhead. As the user interacts with the QTVR panorama the floorplan display is dynamically updated.

To achieve this Lingo has to constantly poll the state of the QTVR. This is done on a looping frame to determine the node of the QTVR, and in a mouseDown loop to determine the camera pan.


In the frame script, the global variable gRoom is updated with the node of the QTVR sprite every time the playback head exits the frame (15 times per second). A set of conditional statements then determine which of the room highlights should be turned on or off, and where the arrowhead should be placed.

on exitFrame me

global gRoom

put the node of sprite 1 into gRoom

global gAngle

if gRoom = 128 then
put the pan of sprite 1 into gAngle
set the visible of sprite 6 to TRUE
set the visible of sprite 7 to FALSE
set the visible of sprite 8 to FALSE
set the loc of sprite 10 to point(384, 422)
set the rotation of sprite 10 = -gAngle
else
if gRoom = 129 then
put the pan of sprite 1 into gAngle
set the visible of sprite 7 to TRUE
set the visible of sprite 6 to FALSE
set the visible of sprite 8 to FALSE
set the loc of sprite 10 to point(384, 362)
set the rotation of sprite 10 = -gAngle
else
if gRoom = 130 then
put the pan of sprite 1 into gAngle
set the visible of sprite 8 to TRUE
set the visible of sprite 6 to FALSE
set the visible of sprite 7 to FALSE
set the loc of sprite 10 to point(296, 302)
set the rotation of sprite 10 = -(gAngle + 90) + 180
end if
end if
end if

go the frame

end


In the mouseDown loop the rotation of the observer sprite is set to the pan of the QTVR sprite. This polling is repeated while the mouse is down. The updateStage command is used because in Director the display is refreshed by the playback head exiting a frame. The mouseDown loop precludes this so the refresh has to be "forced".

on mouseDown

global gRoom
global gAngle

repeat while the mouseDown

put the pan of sprite 1 into gAngle

if gRoom = 130 then

set the rotation of sprite 10 = -(gAngle + 90) + 180

else

set the rotation of sprite 10 to -gAngle

end if

updateStage

end repeat

end