home *** CD-ROM | disk | FTP | other *** search
/ A Virtual Reality Guide to Texas / CD.iso / texdata / vrxtra.cst / 00005_movieFrameScript.ls < prev    next >
Encoding:
Text File  |  1998-06-17  |  5.2 KB  |  139 lines

  1. -- MovieFrameScript
  2. --
  3. -- MovieFrameScript
  4. -- When run frequently, provides cursor feedback over the pano movie
  5. -- and handles mouse down and keyboard actions.
  6. -- Call from a looping frame script
  7. -------------------------------------------------------------------------------
  8. on MovieFrameScriptXtra pSpriteNum
  9.   global gQTVRInstanceXtra, gLastTimeRollover, gOnPC, gHotSpot
  10.   if rollover(pSpriteNum) then
  11.     
  12.     -- running this script will set an invisible movie back to visible,
  13.     -- so test for visibility first
  14.     -- note that you can remove this test if you're not doing anything with the "visible" property
  15.     if QTVRGetVisible(gQTVRInstanceXtra) then 
  16.       
  17.       -- mac xtra uses "RunningInForeground()" XFCN, but there's nothing on
  18.       -- the win side for that, so we'll just gloss over it on the PC
  19.       if gOnPC then set foregroundFlag = "true"
  20.       else set foregroundFlag = RunningInForeground()
  21.       
  22.       -- Only run mouseOver if there's a movie AND Director is in the foreground
  23.       if IsQTVRMovie(gQTVRInstanceXtra) and foregroundFlag = "true" then
  24.         
  25.         -- Result is 0 if you just wandered over the window
  26.         -- without mousing down, if you zoomed in or out without
  27.         -- mousing down, if you used the arrow keys, or if there
  28.         -- was an unhandled event
  29.         put QTVRMouseOver(gQTVRInstanceXtra) into tMouseOverResult
  30.         
  31.         if tMouseOverResult <> 0 then
  32.           put item 1 of tMouseOverResult into tAction
  33.           case tAction of
  34.             "jump":
  35.               --put item 2 of tMouseOverResult into member "Current Node ID"
  36.               --put item 2 of tMouseOverResult
  37.             "stil":
  38.               --put item 2 of tMouseOverResult into member "Current Hot Spot ID"
  39.               --put item 2 of tMouseOverResult
  40.             "navg":
  41.               --processNavgResult tMouseOverResult
  42.             "misc":
  43.               --put item 2 of tMouseOverResult into member "Current Hot Spot ID"
  44.               --put item 2 of tMouseOverResult
  45.             "undf":
  46.               --put item 2 of tMouseOverResult into member "Current Hot Spot ID"
  47.               
  48.               --refresh hotspot ID
  49.               -- JHB
  50.               put item 2 of tMouseOverResult into gHotSpot
  51.               checkVRHotSpotClick
  52.               put item 2 of tMouseOverResult
  53.             "pan ":  -- Watch out for that space!
  54.               nothing
  55.           end case
  56.           
  57.           
  58.           put true into gLastTimeRollover
  59.           
  60.         else if rollover(pSpriteNum) then
  61.           -- There was an arrow key event or some unhandlable event,
  62.           -- but cursor is still over panoramic window
  63.           put true into gLastTimeRollover
  64.           
  65.         else
  66.           -- The cursor is no longer over the panoramic window
  67.           
  68.           -- Set the cursor twice because Director 
  69.           -- doesn't change the cursor if your current cursor command
  70.           -- is the same as the last one.  It doesn't realize of course,
  71.           -- that QTVR has changed the cursor in between.
  72.           
  73.           -- It appears that the cursor command is ignored if the mouse
  74.           -- is not over the stage, so if you move out of the movie window
  75.           -- fast enough and off the stage, the cursor will remain unchanged.
  76.           
  77.           cursor 200
  78.           cursor -1
  79.           put false into gLastTimeRollover
  80.         end if
  81.       end if
  82.     else if gLastTimeRollover then
  83.       -- See comment(s) above
  84.       cursor 200
  85.       cursor -1
  86.       put false into gLastTimeRollover
  87.     end if
  88.   else if gLastTimeRollover then
  89.     -- See comment(s) above
  90.     cursor 200
  91.     cursor -1
  92.     put false into gLastTimeRollover
  93.   end if
  94.   
  95.   if IsQTVRMovie(gQTVRInstanceXtra)  then
  96.     QTVRIdle(gQTVRInstanceXtra)
  97.   end if
  98.   
  99. end
  100.  
  101.  
  102. -------------------------------------------------------------------------------
  103. -- processNavgResult
  104. --
  105. -- Called from above handler when the result of "QTVRMouseOver" is "navg"
  106. -- Collapses pano to object. Attempts to open object movie in same directory as
  107. -- pano. Zooms object movie. If object can't be opened goes back to pano
  108. -------------------------------------------------------------------------------
  109. on processNavgResult pMouseOverResult
  110.   global gQTVRInstanceXtra, gLastPanoMovieData, gPathName, gOldFile, gFileName, gOldNode
  111.   
  112.   put item 2 of pMouseOverResult into tHotSpotID
  113.   put tHotSpotID into member "Current Hot Spot ID"
  114.   
  115.   -- We rely on all navigable objects having their all their properties
  116.   -- correctly authored.  It is unclear what will happen if the properties
  117.   -- aren't set up correctly.
  118.   
  119.   put QTVRGetObjectViewAngles(gQTVRInstanceXtra) into tViewAngles
  120.   put QTVRGetHotSpotName(gQTVRInstanceXtra) into tFileName
  121.   
  122.   -- stash pano filename & node so we can go back to it
  123.   set gOldFile = gFileName
  124.   set gOldNode = QTVRGetNodeID(gQTVRInstanceXtra)
  125.   
  126.   OpenMovie gPathName & ":" & tFileName, 1, "invisible"
  127.   
  128.   if IsQTVRMovie(gQTVRInstanceXtra) then
  129.     -- Show the object controls and take us to the right view of the object
  130.     go to frame "Object From Pano"
  131.     SetMovieView item 1 of tViewAngles, item 2 of tViewAngles, 0
  132.   else
  133.     -- Well, we couldn't open the object, so reupdate the panorama
  134.     OpenMovie gOldFile, 1, "visible"
  135.     QTVRUpdate(gQTVRInstanceXtra)
  136.   end if
  137. end
  138.  
  139.