3 Replies Latest reply on May 25, 2006 9:15 AM by TLScan

    Error in a script and i can´t find it

    TLScan
      Hi,
      I found a very interesting Tutorial about an Archtitcural Fly-Trough at the Adobe Sites.
      As I tried make the same i got an Error in the Lingo Script that was providet with the Tutorial. I have no experience with Lingo so I can´t find the Error. Could sombody find the Error?
      I marked the Line with <<<<<<<<
      Here is the Script (just a little bit long)
      You can see the whole Tutorial here: http://www.adobe.com/devnet/director/articles/shockwave_3d/shockwave3d_ch3.pdf

      on beginSprite (me)

      -- initialize properties

      pMember = sprite(me.spriteNum).member
      pSprite = sprite(me.spriteNum)
      pMouseDown = FALSE
      pRightMouseDown = FALSE
      pCamera = sprite(me.spriteNum).camera
      pCamAnimFlag = TRUE
      pCamAnimInfo = [#initT: pCamera.transform.duplicate(), \
      #finalT: pMember.camera ("first_person").transform.duplicate(), \
      #count: 0]

      -- create the camera’s bounding sphere

      mr = pMember.newModelResource("camera_sphere",#sphere)
      mr.radius = 7.5
      pCameraSphere = pMember.newModel("camera_sphere",mr)

      -- create a light to carry with the camera

      camLight = pMember.newLight("camera_light",#point)
      camLight.color = rgb(170,170,170)

      -- make the sphere and light children of the camera

      pCamera.addChild(pCameraSphere,#preserveParent)
      pCamera.addChild(camLight,#preserveParent)

      -- register the camera for the timeMS event in order to perform the intro animation if any

      pCamera.registerScript(#timeMS,#animateCamera,me,0,50,51)

      -- register the member for regular timeMS events in order to respond to user input and resolve camera “collisions”

      pMember.registerForEvent(#timeMS,#controlCamera,me,2500,50,0)
      end beginSprite

      on mouseDown (me)

      -- update the mouse down property

      pMouseDown = TRUE
      end mouseDown
      on mouseUp (me)

      -- update the mouse down property

      pMouseDown = FALSE
      end mouseUp
      on rightMouseDown (me)

      -- update the right mouse down property

      pRightMouseDown = TRUE
      end rightMouseDown
      on rightMouseUp (me)

      -- update the right mouse down property

      pRightMouseDown = FALSE
      end rightMouseUp
      -- The animateCamera handler is used to animate the camera automatically over time:
      on animateCamera (me)

      -- increment the internal counter for the animation

      pCamAnimInfo.count = pCamAnimInfo.count + 1 <<<<<<I get an Errormessage in this Line!!!!!

      -- determine the interpolation percentage

      pctg = 100.0 × (pCamAnimInfo.count / 50.0)

      -- if pctg is greater than 100 end animation sequence

      if (pctg > 100) then
      pctg = 100
      pCamAnimFlag = FALSE
      end if

      -- determine the new interpolated camera transform

      t = pCamAnimInfo.initT.interpolate (pCamAnimInfo.finalT,pctg)

      -- apply that transform to the camera

      pCamera.transform = t
      end animateCamera

      on controlCamera (me)

      -- respond only if the intro camera animation is completed

      if not(pCamAnimFlag) then

      -- CONTROL THE LEFT/RIGHT ROTATION OF THE CAMERA
      -- if the shift key is *not* down then follow the mouse
      -- to adjust left right looking

      if not(the shiftDown) then

      -- check for the mouse locH wrt the sprite loc

      deltaH = the mouseH - pSprite.locH

      -- calculate rotation value to apply

      rotn = -(deltaH/165.0) * 4.0

      -- apply that rotation

      pCamera.rotate(pCamera.worldPosition, vector(0,0,1),rotn,#world)
      end if

      -- CONTROL THE FORWARD/BACKWARD MOVEMENT OF THE CAMERA
      -- if the left mouse is down then move the character forward

      if pMouseDown then
      pCamera.translate(0,0,-2.5)
      end if

      -- if the right mouse is down then move the character backward

      if pRightMouseDown then
      pCamera.translate(0,0,2.5)
      end if

      -- cast one ray fwd/bckwrd depending upon which mouse button is down

      case (TRUE) of

      -- left mouse down, cast ray forward

      (pMouseDown):

      -- cast ray

      tList = pMember.modelsUnderRay (pCamera.worldPosition,-pCamera.transform. zAxis,#detailed)

      -- if there are models in front of the camera, check for collisions

      if (tList.count) then
      me.checkForCollision(tList[1])
      end if

      -- right (control+) mouse down, cast ray backward

      (pRightMouseDown):

      -- cast ray

      tList = pMember.modelsUnderRay (pCamera.worldPosition,pCamera.transform. zAxis,#detailed)

      -- if there are models in front of the camera, check for collisions

      if (tList.count) then
      me.checkForCollision(tList[1])
      end if
      end case

      -- cast a ray to the left

      tList = pMember.modelsUnderRay (pCamera.worldPosition,-pCamera.transform. xAxis,#detailed)

      -- if there are models in front of the camera, check for collisions

      if (tList.count) then
      me.checkForCollision(tList[1])
      end if

      -- cast a ray to the right

      tList = pMember.modelsUnderRay(pCamera.worldPosition,pCamera.transform.xAxis, #detailed)

      -- if there are models in front of the camera, check for collisions

      if (tList.count) then
      me.checkForCollision(tList[1])
      end if
      end if
      end controlCamera
      on checkForCollision (me, thisData)

      -- grab the distance value

      dist = thisData.distance

      -- if distance is smaller than bounding radius, resolve collision

      if (dist < pCameraSphere.resource.radius) then

      -- get distance of penetration

      diff = pCameraSphere.resource.radius - dist

      -- calculate vector perpendicular to the wall’s surface to move the camera

      tVector = thisData.isectNormal * diff

      -- move the camera in order to resolve the collision

      pCamera.translate(tVector,#world)
      end if
      end checkForCollision