home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Best of Blender
/
bestofblender.iso
/
pc
/
blender
/
files
/
beastvr
/
beastvrm.dir
/
00068_Script_68
< prev
next >
Wrap
Text File
|
1996-04-25
|
29KB
|
738 lines
-- ⌐ 1992-1995 Apple Computer, Inc. All rights reserved.
--=============================================================================
-- Routines for initializing and cleaning up the Director movie.
-------------------------------------------------------------------------------
--=============================================================================
-- StartMovie
--
-- Runs at movie start time. Initializes key globals, opens the external code
-- library, registers the QuickTime VR components, and sets up the XCMD Callback
-- Factory.
-------------------------------------------------------------------------------
on StartMovie
global gPanoMovieID, gNavMovieID, gPathName, gLastTimeRollover, gPanoFrame, DEST
put empty into gPanoMovieID
put empty into gNavMovieID
put empty into gPathName
put false into gLastTimeRollover
put empty into gPanoFrame
-- Need to open up the external xlib so that we don't have the
-- XCMD floating-point bug problem when we save.
-- This would be commented out just before we turn this into a projector.
openxlib "BLENDER1:FILES:QuickTime VR XCMDs"
openxlib "BLENDER1:FILES:QuickTime VR Components"
-- Register the QuickTime VR component
-- This would turn into RegisterComponent (":", empty) when the components are
-- embedded in the projector.
RegisterComponent ("BLENDER1:FILES:QuickTime VR Components", empty)
-- Need to set up the XCMD Callback Factory so that we can execute callbacks
-- to Lingo handlers from PanoMovie
global gQTVRCallBackFactory
put CallBackTracer(mNew) into gQTVRCallBackFactory
SetCallBack PanoMovie,gQTVRCallBackFactory
end StartMovie
--=============================================================================
-- StopMovie
--
-- Runs at movie stop time. Closes any open pano or nav movies. Disposes
-- of the XCMD Callback Factory and closes the external code library.
-------------------------------------------------------------------------------
on StopMovie
-- Close any open panoramic or object movies
ClosePanoMovie
CloseNavMovie
-- Close the external XCMD library
-- This would be commented out just before we turn this into a projector.
closexlib "BLENDER1:FILES:QuickTime VR XCMDs"
closexlib "BLENDER1:FILES:QuickTime VR Components"
-- Dispose of the XCMD Callback Factory
global gQTVRCallBackFactory
if objectP(gQTVRCallBackFactory) then gQTVRCallBackFactory (mDispose)
end
--=============================================================================
-- Routines for managing navigable movies
-------------------------------------------------------------------------------
--=============================================================================
-- OpenNavMovie:
-- pFilename is the full file path of the file
-- pSpriteNum is the sprite associated with the direct Nav Movie
-- pShowOnOpen is a boolean for showing the movie on screen immediately
--
-- Opens the file pFileName as a nav movie at the top left corner of sprite
-- pSpriteNum. Shows it on the screen as dictated by pShowOnOpen.
-------------------------------------------------------------------------------
on OpenNavMovie pFilename, pSpriteNum, pShowOnOpen
global gNavMovieID
-- The use of a single global gNavMovieID constrains these routines
-- to only allow one pano movie to be open at a time.
-- Close any other open nav movie.
CloseNavMovie
-- Load in the movie. Assume the underlying sprite is the correct size.
put NavMovie ("openMovie", "Direct", pFilename ,¼
the left of sprite pSpriteNum & "," & the top of sprite pSpriteNum, ¼
"ShowPoster", "Invisible") into gNavMovieID
if gNavMovieID contains "error" then
put gNavMovieID
put empty into gNavMovieID
beep
exit
end if
if pShowOnOpen then
-- Show the poster frame of the nav movie on screen
NavMovie "Direct", gNavMovieID, "update"
end if
end OpenNavMovie
--=============================================================================
-- ShowNavMovie
--
-- Updates the nav movie display on screen.
-------------------------------------------------------------------------------
on ShowNavMovie
global gNavMovieID
if gNavMovieID <> empty then
NavMovie "Direct", gNavMovieID, "update"
end if
end ShowNavMovie
--=============================================================================
-- ZoomNavMovie:
-- pStartZoomRect specifies the start rect as a string rect
-- [pSkipFirstFrame] is "true" if the first zoom frame should not be shown
-- [pClipRect] is the screen string rect to which the zoom should be clipped
--
-- Zooms the nav movie out from the start rect specified, possibly skipping
-- the first frame and clipping to a given rect.
-------------------------------------------------------------------------------
on ZoomNavMovie pStartZoomRect, pSkipFirstFrame, pClipRect
global gNavMovieID
if gNavMovieID <> empty then
put "ZoomOutMovie" && quote & pStartZoomRect & quote into tCommand
if not voidP(pSkipFirstFrame) then
put tCommand & "," & pSkipFirstFrame into tCommand
end if
if not voidP(pClipRect) then
put tCommand & "," & quote & pClipRect & quote into tCommand
end if
NavMovie "Direct", gNavMovieID, tCommand
-- Send an idle so that if MoviesTask() is called, we don't get a
-- spurious update
NavMovie "Direct", gNavMovieID, "idle"
end if
end ZoomNavMovie
--=============================================================================
-- SetNavMovieView:
-- pHPan is the horizontal pan angle
-- pVPan is the vertical pan angle
--
-- Sets the nav movie view to the specified pan angles.
-------------------------------------------------------------------------------
on SetNavMovieView pHPan, pVPan
global gNavMovieID
if gNavMovieID <> empty then
NavMovie "Direct", gNavMovieID, "set", "hPanAngle", pHPan
NavMovie "Direct", gNavMovieID, "set", "vPanAngle", pVPan
end if
end SetNavMovieView
--=============================================================================
-- CloseNavMovie
--
-- Disposes an open nav movie. This does not remove the image from
-- the screen.
-------------------------------------------------------------------------------
on CloseNavMovie
global gNavMovieID
if gNavMovieID <> empty then
NavMovie "Direct", gNavMovieID, "dispose"
put empty into gNavMovieID
end if
end CloseNavMovie
--=============================================================================
-- NavFrameScript
-- pSpriteNum is the sprite which lies under the nav movie
--
-- When run frequently, provides cursor feedback over the nav movie
-- and handles mouse down and keyboard actions.
-------------------------------------------------------------------------------
on NavFrameScript pSpriteNum
global gNavMovieID
if gNavMovieID <> empty and RunningInForeground() = "true" then
if rollover (pSpriteNum) then
NavMovie "Direct", gNavMovieID, "mouseOver"
-- Set the cursor twice because Director tries to be smart and
-- doesn't change the cursor if your current cursor command
-- is the same as the last one. It doesn't realize of course,
-- that QTVR has changed the cursor in between.
-- KNOWN BUG: It appears that the cursor command is ignored if the mouse
-- is not over the stage, so if you move out of the movie window
-- fast enough and off the stage, the cursor will remain unchanged.
cursor 200
cursor -1
else
NavMovie "Direct", gNavMovieID, "idle"
end if
end if
end NavFrameScript
--=============================================================================
-- Routines for managing panoramic movies
-------------------------------------------------------------------------------
--=============================================================================
-- OpenPanoMovie
-- pFilename is the full file path of the file
-- pSpriteNum is the sprite associated with the direct Pano Movie
-- pShowOnOpen is a boolean for showing the movie on screen immediately
--
-- Opens the file pFileName as a panoramic movie, and sets up callback
-- handlers as specified. Updates the screen with the movie's default
-- view if requested by pShowOnOpen
-------------------------------------------------------------------------------
on OpenPanoMovie pFileName, pSpriteNum, pShowOnOpen
global gPanoMovieID, gPathName
-- The use of a single global gPanoMovieID constrains these routines
-- to only allow one pano movie to be open at a time.
-- Close any other open pano movie.
ClosePanoMovie
-- Make the pano movie display in the rect covered by sprite pSpriteNum
put the left of sprite pSpriteNum & "," & the top of sprite pSpriteNum & "," &¼
the right of sprite pSpriteNum & "," & the bottom of sprite pSpriteNum into tPanoRect
put PanoMovie("openMovie", "Direct", pFileName, tPanoRect) into gPanoMovieID
if gPanoMovieID contains "error" then
-- Display the error in the message window
put gPanoMovieID
put empty into gPanoMovieID
beep
exit
end if
put ExtractPathName(pFileName) into gPathName
InitPanoCallbacks
if pShowOnOpen then
PanoMovie "Direct", gPanoMovieID, "update"
end if
end OpenPanoMovie
--=============================================================================
-- InitPanoCallbacks
--
-- Initializes the callbacks used for panoramic movies.
-------------------------------------------------------------------------------
on InitPanoCallbacks
global gPanoMovieID
if gPanoMovieID <> empty then
-- Set up callback handlers for panoramic movies.
-- We reset each callback to empty if we're not setting it to a handler name;
-- this resets callbacks which may have been set in the Pano Callbacks frames.
-- The default value for each callback property is empty.
PanoMovie "Direct", gPanoMovieID, "set", "mouseOverHandler", empty
-- PanoMovie "Direct", gPanoMovieID, "set", "mouseOverHandler", "sampleMouseOverHandler"
-- PanoMovie "Direct", gPanoMovieID, "set", "rolloverHotSpotHandler", empty
PanoMovie "Direct", gPanoMovieID, "set", "rolloverHotSpotHandler", "sampleRolloverHandler"
PanoMovie "Direct", gPanoMovieID, "set", "mouseDownHandler", empty
-- PanoMovie "Direct", gPanoMovieID, "set", "mouseDownHandler", "sampleMouseDownHandler"
PanoMovie "Direct", gPanoMovieID, "set", "panZoomStartHandler", empty
-- PanoMovie "Direct", gPanoMovieID, "set", "panZoomStartHandler", "samplePanZoomStartHandler"
PanoMovie "Direct", gPanoMovieID, "set", "mouseStillDownHandler", empty
-- PanoMovie "Direct", gPanoMovieID, "set", "mouseStillDownHandler", "sampleMouseStillDownHandler"
PanoMovie "Direct", gPanoMovieID, "set", "nodeLeaveHandler", empty
-- PanoMovie "Direct", gPanoMovieID, "set", "nodeLeaveHandler", "sampleNodeLeaveHandler"
end if
end InitPanoCallbacks
--=============================================================================
-- ShowPanoMovie
-- [pQuality] is the quality level at which to display the update
--
-- Updates the pano movie display. Has the side effect of changing
-- the current quality level to pQuality, if specified.
-------------------------------------------------------------------------------
on ShowPanoMovie pQuality
global gPanoMovieID
if gPanoMovieID <> empty then
if not voidP(pQuality) then PanoMovie "Direct", gPanoMovieID, "set", "quality", pQuality
PanoMovie "Direct", gPanoMovieID, "update"
end if
end ShowPanoMovie
--=============================================================================
-- SetPanoNode
-- pNodeID is the number of the node to go to
-- pUpdate is true if a screen update is to be performed
-- [pQuality] is the quality level at which to display the update
--
-- Changes the current node as specified. If pUpdate is true, updates the
-- screen to reflect that node's default view. Has the side effect of changing
-- the current quality level to pQuality, if specified.
-------------------------------------------------------------------------------
on SetPanoNode pNodeID, pUpdate, pQuality
global gPanoMovieID
if gPanoMovieID <> empty then
PanoMovie "Direct", gPanoMovieID, "set", "nodeID", pNodeID
if not voidP(pQuality) then PanoMovie "Direct", gPanoMovieID, "set", "quality", pQuality
if pUpdate then PanoMovie "Direct", gPanoMovieID, "Update"
end if
end SetPanoNode
--=============================================================================
-- SwingPanoMovie
-- pHPan is the destination horizontal pan angle
-- pVPan is the destination vertical pan angle
-- pZoom is the destination zoom angle
-- pSwingSpeed is the speed at which to swing
-- pSwingQuality is the quality at which to swing
-- pFinalQuality is the quality at which to re-update the destination view
--
-- Swings the view around to a specified direction. Has the side effect of
-- changing the current quality level to pFinalQuality
-------------------------------------------------------------------------------
on SwingPanoMovie pHPan, pVPan, pZoom, pSwingSpeed, pSwingQuality, pFinalQuality
global gPanoMovieID
if gPanoMovieID <> empty then
-- Set up the destination pan and zoom angles
PanoMovie "Direct", gPanoMovieID, "set", "zoomAngle", pZoom
PanoMovie "Direct", gPanoMovieID, "set", "vPanAngle", pVPan
PanoMovie "Direct", gPanoMovieID, "set", "hPanAngle", pHPan
-- For performance, you can use lower quality during the swing
PanoMovie "Direct", gPanoMovieID, "set", "quality", pSwingQuality
PanoMovie "Direct", gPanoMovieID, "set", "transitionMode", "swing"
PanoMovie "Direct", gPanoMovieID, "set", "transitionSpeed", pSwingSpeed
PanoMovie "Direct", gPanoMovieID, "update"
-- Set transition mode to normal
PanoMovie "Direct", gPanoMovieID, "set", "transitionMode", "normal"
-- Only do a reupdate if the quality values are different
if pFinalQuality <> pSwingQuality then
PanoMovie "Direct", gPanoMovieID, "set", "quality", pFinalQuality
PanoMovie "Direct", gPanoMovieID, "update"
end if
end if
end SwingPanoMovie
--=============================================================================
-- CollapsePanoMovie
--
-- Collapses to the currently selected hot spot.
-------------------------------------------------------------------------------
on CollapsePanoMovie
global gPanoMovieID
if gPanoMovieID <> empty then
PanoMovie "Direct", gPanoMovieID, "CollapseToHotSpotRgn"
end if
end CollapsePanoMovie
--=============================================================================
-- SetPanoMovieView
-- pHPan is the destination horizontal pan angle
-- pVPan is the destination vertical pan angle
-- pZoom is the destination zoom angle
-- [pQuality] is the quality at which to display the view
--
-- Displays a new view in the current node. Has the side effect of changing
-- the current quality level to pQuality, if specified.
-------------------------------------------------------------------------------
on SetPanoMovieView pHPan, pVPan, pZoom, pQuality
global gPanoMovieID
if gPanoMovieID <> empty then
PanoMovie "Direct", gPanoMovieID, "set", "zoomAngle", pZoom
PanoMovie "Direct", gPanoMovieID, "set", "vPanAngle", pVPan
PanoMovie "Direct", gPanoMovieID, "set", "hPanAngle", pHPan
if not voidP(pQuality) then PanoMovie "Direct", gPanoMovieID, "set", "quality", pQuality
PanoMovie "Direct", gPanoMovieID, "update"
end if
end SetPanoMovieView
--=============================================================================
-- ClosePanoMovie
--
-- Disposes an open pano movie. This does not remove the image from
-- the screen.
-------------------------------------------------------------------------------
on ClosePanoMovie
global gPanoMovieID
if gPanoMovieID <> empty then
PanoMovie "Direct", gPanoMovieID, "dispose"
put empty into gPanoMovieID
end if
end ClosePanoMovie
--=============================================================================
-- PanoFrameScript
--
-- When run frequently, provides cursor feedback over the pano movie
-- and handles mouse down and keyboard actions.
-------------------------------------------------------------------------------
on PanoFrameScript pSpriteNum
global gLastTimeRollover
if rollover(pSpriteNum) then
global gPanoMovieID
-- Only run mouseOver if there's a movie AND Director is in the foreground
if gPanoMovieID <> empty and RunningInForeground() = "true" then
PanoMovie "Direct", gPanoMovieID, "mouseOver"
-- Result is 0 if you just wandered over the window
-- without mousing down, if you zoomed in or out without
-- mousing down, if you used the arrow keys, or if there
-- was an unhandled event
put the result into tMouseOverResult
if tMouseOverResult <> 0 then
put item 1 of tMouseOverResult into tAction
if tAction = "jump" then
put item 2 of tMouseOverResult into cast "Current Node ID"
else if tAction = "stil" then
put item 2 of tMouseOverResult into cast "Current Hot Spot ID"
else if tAction = "navg" then
global gLastPanoMovieData, gPathName
put item 2 of tMouseOverResult into tHotSpotID
put tHotSpotID into cast "Current Hot Spot ID"
-- We rely on all navigable objects having their all their properties
-- correctly authored. It is unclear what will happen if the properties
-- aren't set up correctly.
put PanoMovie ("Direct", gPanoMovieID, "get", "navgZoomRect") into tStartZoom
put PanoMovie ("Direct", gPanoMovieID, "get", "navgViewAngles") into tViewAngles
put PanoMovie ("Direct", gPanoMovieID, "get", "hotSpotName") into tFileName
CollapsePanoMovie
OpenNavMovie gPathName & ":" & tFileName, 2, false
global gNavMovieID
if gNavMovieID <> empty then
-- Remember the last marked frame so we can come back to where we
-- are now (including proper initialization)
global gPanoFrame
put marker(0) into gPanoFrame
-- Show the object controls and take us to the right view of the object
go to frame "Object From Pano"
SetNavMovieView item 1 of tViewAngles, item 2 of tViewAngles
-- Clip the zoom out effect to the movie rect
put the left of sprite 2 & "," & the top of sprite 2 & "," & ¼
the right of sprite 2 & "," & the bottom of sprite 2 into tClipRect
ZoomNavMovie tStartZoom, "true", tClipRect
else
-- Well, we couldn't open the object, so reupdate the panorama
PanoMovie ("Direct", gPanoMovieID, "update")
end if
else if tAction = "misc" then
put item 2 of tMouseOverResult into cast "Current Hot Spot ID"
else if tAction = "undf" then
put item 2 of tMouseOverResult into cast "Current Hot Spot ID"
else if tAction = "pan " then -- Watch out for that space!
end if
put true into gLastTimeRollover
else if rollover(pSpriteNum) then
-- There was an arrow key event or some unhandlable event,
-- but cursor is still over panoramic window
put true into gLastTimeRollover
else
-- The cursor is no longer over the panoramic window
-- Set the cursor twice because Director tries to be smart and
-- doesn't change the cursor if your current cursor command
-- is the same as the last one. It doesn't realize of course,
-- that QTVR has changed the cursor in between.
-- KNOWN BUG: It appears that the cursor command is ignored if the mouse
-- is not over the stage, so if you move out of the movie window
-- fast enough and off the stage, the cursor will remain unchanged.
cursor 200
cursor -1
put false into gLastTimeRollover
end if
end if
else if gLastTimeRollover then
-- See comment(s) above
cursor 200
cursor -1
put false into gLastTimeRollover
-- Allow a high quality update in pano window if needed
if gPanoMovieID <> empty then PanoMovie "Direct", gPanoMovieID, "idle"
end if
put PanoMovie("Direct", gPanoMovieID, "Get", "hPanAngle") into cast "HPanAngle"
end PanoFrameScript
--=============================================================================
-- Sample PanoMovie callback handler routines
-------------------------------------------------------------------------------
--=============================================================================
-- SampleMouseOverHandler
--
-- Called by PanoMovie periodically during mouseOver.
-------------------------------------------------------------------------------
on SampleMouseOverHandler
put "Mouse over panoramic movie"
-- If you want to exit from mouseOver, use this line
global gPanoMovieID
if gPanoMovieID <> empty then
--PanoMovie "Direct", gPanoMovieID, "ExitMouseOver"
end if
end SampleMouseOverHandler
--=============================================================================
-- SampleRolloverHandler
-- pHotSpotID is the id of the hot spot the user is over
--
-- Called by PanoMovie whenever the hot spot the cursor is over changes.
-------------------------------------------------------------------------------
on SampleRolloverHandler pHotSpotID
put pHotSpotID into cast "Current Hot Spot ID"
end SampleRolloverHandler
--=============================================================================
-- SampleMouseDownHandler
--
-- Called by PanoMovie when a mouseDown event occurs during a mouseOver call
-------------------------------------------------------------------------------
on SampleMouseDownHandler
put "Mouse down during mouseOver call"
global gPanoMovieID
if gPanoMovieID <> empty then
PanoMovie "Direct", gPanoMovieID, "PassMouseDown"
end if
end SampleMouseDownHandler
--=============================================================================
-- SamplePanZoomStartHandler
--
-- Called once by PanoMovie when the user starts to pan or zoom.
-------------------------------------------------------------------------------
on SamplePanZoomStartHandler
put "About to pan or zoom in panoramic movie"
end SamplePanZoomStartHandler
--=============================================================================
-- SampleMouseStillDownHandler
--
-- Called by PanoMovie periodically during while the mouse is down within
-- mouseOver or mouseDown.
-------------------------------------------------------------------------------
on SampleMouseStillDownHandler
put "Enter mouse still down from panoramic movie"
global gPanoMovieID
if gPanoMovieID <> empty then
--put PanoMovie("Direct", gPanoMovieID, "Get", "HPanAngle") into tHPanAngle
--put "HPanAngle is currently: " & tHPanAngle
end if
put "Leave mouse still down from panoramic movie"
end SampleMouseStillDownHandler
--=============================================================================
-- SampleNodeLeaveHandler
-- pToNodeID is the id of the node the user is leaving
--
-- Called by PanoMovie when the user moves between nodes by clicking on link
-- hot spots.
-------------------------------------------------------------------------------
on SampleNodeLeaveHandler pToNode
put "Jumping to node " & pToNode & " in panoramic movie"
end SampleNodeLeaveHandler
--=============================================================================
-- Utility routines
-------------------------------------------------------------------------------
--=============================================================================
-- ExtractPathName
-- pFileName is the full file path of the file
-- Returns the path component of pFileName
--
-- Extracts and returns the path component of a file specifier.
-------------------------------------------------------------------------------
on ExtractPathName pPathName
put ":" into tDelimiter
if pPathName contains tDelimiter then
put length(pPathName) into tCharPos
repeat while tCharPos >= 1
if char tCharPos of pPathName = tDelimiter then return char 1 to tCharPos - 1 of pPathName
put tCharPos - 1 into tCharPos
end repeat
return empty
else
return empty
end if
end ExtractPathName
--=============================================================================
-- XCMD Callback Factory
-------------------------------------------------------------------------------
--=============================================================================
-- CallBackTracer
--
-- As described in "Using Lingo", Appendix A. Pass any mSendCardMessage
-- commands on to Lingo so that callbacks can be handled.
-------------------------------------------------------------------------------
factory CallBackTracer
method mNew
method mEvalExpr pExpr
method mSendHCMessage pMessage
method mSendCardMessage pMessage
do pMessage
method mGetFieldByName pCard, pName
method mGetFieldByNum pCard, pNum
method mGetFieldByID pCard, pID
method mSetFieldByName pCard, pName, pValue
method mSetFieldByNum pCard, pNum, pValue
method mSetFieldByID pCard, pID, pValue
end
--=============================================================================
-- Routines used by Pano Callbacks pages
-------------------------------------------------------------------------------
--=============================================================================
-- SetupHandler
-- pHandlerName is the identifying name of the callback to be set up
--
-- Used to install and de-install callbacks on the Pano Callbacks pages
-------------------------------------------------------------------------------
on SetupHandler pHandlerName
global gPanoMovieID
if the hilite of cast (pHandlerName && "Check") then
PanoMovie "Direct", gPanoMovieID, "set", pHandlerName, "test" & pHandlerName
else
PanoMovie "Direct", gPanoMovieID, "set", pHandlerName, empty
end if
end SetupHandler
on TestMouseOverHandler
global gPanoMovieID
if gPanoMovieID <> empty then
put "In mouse over at: " & the ticks into cast "MouseOverHandler Message"
end if
end TestMouseOverHandler
on TestRolloverHotSpotHandler pHotSpotID
global gPanoMovieID
if gPanoMovieID <> empty then
put "Rolling over hot spot: " & pHotSpotID into cast "RolloverHotSpotHandler Message"
end if
end TestRolloverHotSpotHandler
on TestMouseDownHandler
global gPanoMovieID
if gPanoMovieID <> empty then
put "In mouse down at: " & the ticks into cast "MouseDownHandler Message"
PanoMovie "Direct", gPanoMovieID, "PassMouseDown"
end if
end TestMouseDownHandler
on TestPanZoomStartHandler
global gPanoMovieID
if gPanoMovieID <> empty then
put "In pan zoom start at: " & the ticks into cast "PanZoomStartHandler Message"
end if
end TestPanZoomStartHandler
on TestMouseStillDownHandler
global gPanoMovieID
if gPanoMovieID <> empty then
put "In mouse still down at: " & the ticks into cast "MouseStillDownHandler Message"
put PanoMovie("Direct", gPanoMovieID, "get", "hpanangle") into cast "MouseStillDownHandler Message"
end if
end TestMouseStillDownHandler
on TestNodeLeaveHandler pToNode
global gPanoMovieID
if gPanoMovieID <> empty then
put "Leaving node ID: " & pToNode into cast "NodeLeaveHandler Message"
end if
end TestNodeLeaveHandler