Lingo Examples
This is a link to a Director (MX 2004) example file I've put together.
You can use the file with or without the xtra. If you use the xtra and visor, make sure to setup everything as listed in Requirements. You can see how a 3D scene could be setup to use the xtra and visor.
The main scripts are NavCam and Visor Manager. NavCam shows how cameras and navigation can be setup to use stereo 3D. While playing, you can switch between camera views (C key) and adjust stereo settings with other keys. When using the visor with stereo cam view, you may need to toggle eye swap occasionally. Close one eye and look at the L and R in the corner of the visor screen to see if you need to toggle.
The basic idea is this:
-- Setup a camera system consisting of one central, one left, and one right camera. I use dummies to parent all cameras. The central camera is used for regular viewing, and the left and right cams (LR) are used for stereoscopic viewing. This illustration shows the setup, along with the way that the visor returns its rotation values:

-- The main camera dummy is rotated to match the canonical position of the visor, and then the flanking dummies/cameras are attached, positioned, and rotated accordingly. This is so that the visor’s Pitch, Yaw and Roll values can be directly applied to the main camera dummy at every frame/timeout interval (remember stepframe interval should be 60 fps, which is faster than the visor hardware polling limit). One code example showing applying rotation directly to the dummy:
on timeoutInterval me
vData = z800GetData()
if (vData[5] = 1) then
rot = vData[1] -- a vector
rot = rot * (180 / pi) -- convert returned radians to degrees
pSceneCameraDummy.transform.rotation = rot
else
-- visor data is invalid
end if
end timeoutInterval
-- Usually, you would want to attach this camera rig to some other navigational rig, being careful about relative rotations, etc.
For 3D stereo vision:
-- The LR cameras should be an equal distance from their center; think of them as acting like left and right eyes on a person.
-- All cameras look “forward”, but the LR cameras are “toed-in” a little. That is, instead of looking straight forward like the central camera, they look at a common convergence point some distance in front. I make this convergence point a box model that can appear and disappear as needed when adjusting, and parent it to the camera dummy.
-- LR camera separation and convergence point should be easily adjustable – each 3D scene will have different requirements for stereo viewing.
-- LR cameras can have an overlay (L and R) on them to show which camera they are. This makes debugging easy, so when you close one eye, you know which camera you’re looking through.
-- See the example file for a complete demonstration.
|