  | | | Lightwave and Shockwave 3D | Lightwave and Shockwave 3D 2004-02-26 - By Thomas Williams
Back Lightwave and Shockwave 3Doops... I left someting out in that script I just sent. (adding it to the actor list) this line should be inserted into the constructor on new me .... just before return (the actorList).append(me) return me end
for your conveniece I put the entire corrected script below
=======================================================================
-- CameraRotateZoom -- OOP Camera Controller.
-- Input: the camera to be controlled
-- Usage: -- this scsript rotates the camera around the center of the world. -- Also features ease in motion. This will be implemented by using a buffer variable that will -- store incremented mouse change. This in turn will be used to rotate a controller dummy model. -- The camera is parented to a dummy group. -- Rotation will be triggered by the user holding down the <control> key. -- Zoom will be triggered by the user holding down the <shift> key. -- Elevation mode is triggered by holding down both the <control> and the <shift> key
-- Implementation: -- In the init script, add these lines. -- Name this script "CameraControl" -- Make sure it is a Parent script. -- -- Create a camera control object. -- gCameraControl = script("CameraControl").new(scene.camera[1]) -- (the actorList).append(gCameraControl)
global scene global gCameraControl -- reference the instance of this class. -- Use this as a global variable in the initialize movie script to reference an instance of this class.. global gNavMode -- string: indicates the current navigation mode. Options are Rotate,Zoom,Elevate.
property pRotateBufferX -- the amount of rotation that remains to be done. Mouse action adds to this, rotation subtracts. property pRotateBufferY -- the amount of rotation that remains to be done. Mouse action adds to this property pZoomBuffer -- the amount of zooming that remains to be done. property pElevBuffer -- the amount of elevating that remains to be done. property pCamera property pMouseOld -- a reference to the last mouse loc property pMouseIsDown -- boolean used to determine if this is the mouse has just benn clicked. property pInterpPercent -- a factor that determines how much of the pRotateBuffer the camera will rotate. property pCameraMagnitude -- the distance from the camera to the dummy. property pZoomLimit -- the range in vector magniture the the camera may zoom in and out. property pFriction -- a list of min and max values that limit the amount of spin after user lets go. 0 means spin forever. 1 is normal property pZoomLag -- the interpolation factor for zooming. 0 is infinite lag, 1 is no lag. property pDummyCamInitialTransform -- the transform of the camera controller dummy at world start. property pCamInitialTransform -- the transform of the camera controller dummy at world start. property pDummy_cam_Rot_old -- float: the recorded trandoform.rotation.x of model("dummy_camera_Plane") property pWM -- the model that will be the world Master. All models will be parented to it. property pInitialWMTransform -- the initial transform of the world master, after it is adjusted to face camera.
on new me,mCamera pCamera = mCamera -- the camera -- Dummy_camera: Interpolates to Dummy_mouse. the camera is parented to this. if voidP(scene.group("Cam_Master")) then pWM = scene.newGroup("Cam_Master") else pWM = scene.Group("Cam_Master") end if
-- Set initial rotation of the Dummy camera to be the same as the camera, then reset the position to the origin.. pWM.transform = pCamera.transform pWM.transform.position = vector(0,0,0) pWM.translate(0,30,0) pInitialWMTransform = pWM.transform.duplicate()
-- Parent the camera to the "Dummy_camera" pWM.addChild(pCamera,#preserveWorld) pRotateBufferX = 0 pRotateBufferY = 0 pZoomBuffer = 0 pMouseIsDown = 0 pCameraMagnitude = (pCamera.worldPosition- pWM.worldPosition).magnitude pZoomLimit = [pCameraMagnitude*.3,pCameraMagnitude*2] pInterpPercent = .2 pFriction = .5 -- point the camera at the dummy pCamera.pointat( pWM.worldposition) -- Record the initial transforms of the camera and its dummys to be used later in camera reset. pCamInitialTransform = pCamera.transform.duplicate() pDummyCamInitialTransform = pWM.transform.duplicate() pZoomLag = .2 pDummy_cam_Rot_old = pDummyCamInitialTransform.rotation.x pInit = 1 (the actorList).append(me)
-- This line makes the mouse rotate the world. This shows off the reflection maps as the glide over the models. -- create a World Master model that will be the parent of all the objects in the scene. --pWM = createPlane("World Master".100,100,rgb(150,255,0))
-- parent all the models you want to spin to the world master -- repeat with m = 1 to scene.model.count -- if scene.model[m].name contains "Dummy" then -- nothing -- else -- pWM.addchild(scene.model(m),#preserveWorld) -- end if -- end repeat
return me
end
---************************************************************************* *****
on stepFrame me
mouseDif = the mouseloc - me.pMouseOld
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----- -- Set the Navigation mode by trapping key Press events. -- <Shift> induces rotate mode, -- <control> induces zoom mode, -- <Shift> and <Zoom> induce elevate mode. if the shiftDown = true then gNavMode = "Rotate" end if if the controlDown = true then gNavMode = "Zoom" end if if the controlDown = true and the shiftDown = true then gNavMode = "Elevate" end if
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----- --ROTATE only when mouse and control are down if gNavMode = "Rotate" and the mouseDown = 1 then
-- set the mouseOld to the mouse if the mouse was just clicked. if me.pMouseIsDown = 0 then me.pMouseOld = the mouseloc
AmpAdjust = .33 RotX = mouseDif[1]*AmpAdjust RotY = mouseDif[2]*AmpAdjust
me.pRotateBufferX = me.pRotateBufferX + RotX me.pRotateBufferY = me.pRotateBufferY + RotY
-- Set the MouseIsDown flag to on me.pMouseIsDown = 1 pInterpPercent = .2 RotAngleX = me.pRotateBufferX*pInterpPercent RotAngleY = me.pRotateBufferY*pInterpPercent
-- Interpolate the DummyCamera to the DummyMouse rotateCamera(me,RotAngleX,RotAngleY)
-- reduce the rotation buffer by the amount rotated me.pRotateBufferX = me.pRotateBufferX - RotAngleX me.pRotateBufferY = me.pRotateBufferY - RotAngleY
else
RotAngleX = me.pRotateBufferX*pInterpPercent RotAngleY = me.pRotateBufferY*pInterpPercent -- Interpolate the DummyCamera to the DummyMouse rotateCamera(me,RotAngleX,RotAngleY)
me.pMouseIsDown = 0
-- reduce the rotation buffer by the amount rotated me.pRotateBufferX = me.pRotateBufferX - RotAngleX*me.pFriction me.pRotateBufferY = me.pRotateBufferY - RotAngleY*me.pFriction end if
-- -- ---- ---- ---- ---- ---- ------ -- Zoom -- get the distance of the camera to the dummy me.pCameraMagnitude = (pCamera.worldPosition- pWM.worldPosition).magnitude
if gNavMode = "Zoom" and the mouseDown = 1 then
AmpAdjust = 1 ZoomRaw = mouseDif[2]*AmpAdjust me.pZoomBuffer = me.pZoomBuffer + ZoomRaw
-- Set the MouseIsDown flag to on me.pMouseIsDown = 1
-- Zoom the camera Zoom = me.pZoomBuffer * me.pZoomLag -- if checkLimits(Zoom) then me.pCamera.translate(0,0,-Zoom) -- else -- limitRange() -- end if
else -- Zoom the camera Zoom = me.pZoomBuffer * me.pZoomLag -- if checkLimits(Zoom) then me.pCamera.translate(0,0,-Zoom) -- else -- limitRange() -- end if
me.pMouseIsDown = 0 end if
-- reduce the rotation buffer by the amount rotated me.pZoomBuffer = me.pZoomBuffer - Zoom
-- ---- ---- ---- ---- ---- ------ -- Elevate if gNavMode = "Elevate" and the mouseDown = 1 then
AmpAdjust = .5 ElevRaw = mouseDif[2]*AmpAdjust me.pElevBuffer = me.pElevBuffer + ElevRaw
-- Set the MouseIsDown flag to on me.pMouseIsDown = 1
-- Zoom the camera Elev = me.pElevBuffer * me.pZoomLag -- if checkLimits(Elev) then me. pWM.translate(0,Elev,0,#world) -- else -- limitRange() -- end if
else -- Zoom the camera Elev = me.pElevBuffer * me.pZoomLag -- if checkLimits(Elev) then me. pWM.translate(0,Elev,0,#world) -- else -- limitRange() -- end if
me.pMouseIsDown = 0 end if -- reduce the elevation buffer by the amount rotated me.pElevBuffer = me.pElevBuffer - Elev --if me.pElevBuffer < 0 then me.pElevBuffer = 0
-- ---- ---- ---- ---- ---- ------ --set the MouseOld me.pMouseOld = the mouseloc
end
--*********************************************************** -- Rotate the camera to catch up with the dummy on rotateCamera me, RotAngleX, RotAngleY --put "RotAngleY",RotAngleY pWM.rotate(-RotAngleY,0,0,#world) pWM.rotate(0,-RotAngleX,0,#world) end
--***********************************************************
on limitRange me
cam = me.pCamera --place the camera within its limits -- ------ --Far if me.pCameraMagnitude < me.pZoomLimit[1] then -- reset the zoomBuffer me.pZoomBuffer = 0 CamMagnitudefactor = me.pZoomLimit[1].float/me.pCameraMagnitude+.001 cam.transform.position = CamMagnitudefactor*cam.transform.position end if
-- ------ --Near if me.pCameraMagnitude > me.pZoomLimit[2] then -- reset the zoomBuffer me.pZoomBuffer = 0 CamMagnitudefactor = me.pZoomLimit[2].float/me.pCameraMagnitude-.001 cam.transform.position = CamMagnitudefactor*cam.transform.position
end if end
--***********************************************************
on checkLimits ( me,zoom) mResult = 0 -- get the new position that the camera will be in on the next step newCamPos = me.pCamera.transform.position + vector(0,0,-zoom) --and test to see if it is within the limits if newCamPos.magnitude > me.pZoomLimit[1] and \ newCamPos.magnitude < me.pZoomLimit[2] then mResult = 1 end if return mResult end
--***********************************************************
on checkForBreakthrough ( me,zoom,percent) mResult = 1 if me.pPositionHistory.count > 1 then -- get the new position that the camera will be in on the next step newCamPos = me.pCamera.transform.position + vector(0,0,-zoom) --and test to see if it is within the limits -- Near the min -- if newCamPos.magnitude < me.pZoomLimit[1]+ pRangeMag*.01*percent then mResult = 0 end if -- near the max if newCamPos.magnitude > me.pZoomLimit[2]- me.pRangeMag*.01*percent then mResult = 0 end if
-- return mResult end
--*********************************************************** on resetView me -- resets the camera and dummy to their initial settings global gInterpolateNode -- List that conatins child objects that control the interpolation animation for various nodes
-- Animate the camera to move to the origin.
transformList = [scene.model("Dummy_camera_Plane").transform,pInitialWMTransform] --put transformList[1].position -- transformList[2].position speed = 10 AnimIndex = gInterpolateNode.count + 1 node = scene.model("Dummy_camera_Plane") -- move the camera back to its start position. --on new (me, node, transformList,speed,indx,restriction) --gInterpolateNode[AnimIndex] = new (script "InterpolateNode", node,transformList,speed,AnimIndex,0) -- Move the World Master back to it's original orientation. node = pWM transformList = [pWM.transform,pInitialWMTransform] AnimIndex = gInterpolateNode.count + 1 gInterpolateNode[AnimIndex] = new (script "InterpolateNode", node,transformList,speed,AnimIndex,0)
-- move the camera to its initial position AnimIndex = gInterpolateNode.count + 1 node = pCamera transformList = [pCamera.transform,pCamInitialTransform] gInterpolateNode[AnimIndex] = new (script "InterpolateNode", node,transformList,speed,AnimIndex,0)
end
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD><TITLE>Lightwave and Shockwave 3D</TITLE> <META http-equiv=Content-Type content="text/html; charset=US-ASCII"> <META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD> <BODY> <DIV><SPAN class=015472502-27022004><FONT face=Arial color=#0000ff size=2>oops...</FONT></SPAN></DIV> <DIV><SPAN class=015472502-27022004><FONT face=Arial color=#0000ff size=2>I left someting out in that script I just sent. (adding it to the actor list)</FONT></SPAN></DIV> <DIV><SPAN class=015472502-27022004><FONT face=Arial color=#0000ff size=2>this line should be inserted into the constructor</FONT></SPAN></DIV> <DIV><SPAN class=015472502-27022004><FONT face=Arial color=#0000ff size=2>on new me </FONT></SPAN></DIV> <DIV><SPAN class=015472502-27022004><FONT face=Arial color=#0000ff size=2>.... just before return</FONT></SPAN></DIV> <DIV><SPAN class=015472502-27022004><FONT face=Arial color=#0000ff size=2>(the actorList).append(me)</FONT></SPAN></DIV> <DIV><SPAN class=015472502-27022004><FONT face=Arial color=#0000ff size=2 >return me</FONT></SPAN></DIV> <DIV><SPAN class=015472502-27022004><FONT face=Arial color=#0000ff size=2>end</FONT></SPAN></DIV> <DIV><SPAN class=015472502-27022004><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV> <DIV><SPAN class=015472502-27022004><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV> <DIV><SPAN class=015472502-27022004><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV> <DIV><SPAN class=015472502-27022004><FONT face=Arial color=#0000ff size=2>for your conveniece I put the entire corrected script below</FONT></SPAN></DIV> <DIV><SPAN class=015472502-27022004><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV> <DIV><SPAN class=015472502-27022004><FONT face=Arial color=#0000ff size=2>=======================================================================< /FONT></SPAN></DIV> <DIV><SPAN class=015472502-27022004><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV> <DIV><SPAN class=015472502-27022004><FONT face=Arial color=#0000ff size=2>-- CameraRotateZoom<BR>-- OOP Camera Controller. </FONT></SPAN></DIV> <DIV> </DIV> <DIV><SPAN class=015472502-27022004><FONT face=Arial color=#0000ff size=2>-- Input: the camera to be controlled</FONT></SPAN></DIV> <DIV> </DIV> <DIV><SPAN class=015472502-27022004><FONT face=Arial color=#0000ff size=2>-- Usage:<BR>-- this scsript rotates the camera around the center of the world. <BR>-- Also features ease in motion. This will be implemented by using a buffer variable that will<BR>-- store incremented mouse change. This in turn will be used to rotate a controller dummy model.<BR>-- The camera is parented to a dummy group.<BR>-- Rotation will be triggered by the user holding down the <control> key.<BR>-- Zoom will be triggered by the user holding down the <shift> key.<BR>-- Elevation mode is triggered by holding down both the <control> and the <shift> key</FONT></SPAN></DIV> <DIV> </DIV> <DIV><SPAN class=015472502-27022004><FONT face=Arial color=#0000ff size=2>-- Implementation:<BR>-- In the init script, add these lines.<BR>-- Name this script "CameraControl"<BR>-- Make sure it is a Parent script.<BR>-- -- Create a camera control object. <BR>-- gCameraControl = script("CameraControl").new(scene.camera[1])<BR>-- (the actorList).append(gCameraControl)</FONT></SPAN></DIV> <DIV> </DIV> <DIV><SPAN class=015472502-27022004><FONT face=Arial color=#0000ff size=2 >global scene<BR>global gCameraControl -- reference the instance of this class. <BR>-- Use this as a global variable in the initialize movie script to reference an instance of this class.. <BR>global gNavMode -- string: indicates the current navigation mode. Options are Rotate,Zoom,Elevate.</FONT></SPAN></DIV> <DIV> </DIV><SPAN class=015472502-27022004><FONT face=Arial color=#0000ff size=2> <DIV><BR>property pRotateBufferX -- the amount of rotation that remains to be done. Mouse action adds to this, rotation subtracts. <BR>property pRotateBufferY -- the amount of rotation that remains to be done. Mouse action adds to this <BR>property pZoomBuffer -- the amount of zooming that remains to be done.<BR>property pElevBuffer -- the amount of elevating that remains to be done.<BR>property pCamera<BR>property pMouseOld -- a reference to the last mouse loc<BR>property pMouseIsDown -- boolean used to determine if this is the mouse has just benn clicked.<BR>property pInterpPercent -- a factor that determines how much of the pRotateBuffer the camera will rotate.<BR>property pCameraMagnitude -- the distance from the camera to the dummy.<BR>property pZoomLimit -- the range in vector magniture the the camera may zoom in and out.<BR>property pFriction -- a list of min and max values that limit the amount of spin after user lets go. 0 means spin forever. 1 is normal <BR>property pZoomLag -- the interpolation factor for zooming. 0 is infinite lag, 1 is no lag.<BR>property pDummyCamInitialTransform -- the transform of the camera controller dummy at world start.<BR>property pCamInitialTransform -- the transform of the camera controller dummy at world start.<BR>property pDummy_cam_Rot_old -- float: the recorded trandoform.rotation.x of model("dummy_camera_Plane")<BR>property pWM -- the model that will be the world Master. All models will be parented to it.<BR>property pInitialWMTransform -- the initial transform of the world master, after it is adjusted to face camera.</DIV> <DIV> </DIV> <DIV>on new me,mCamera <BR> pCamera = mCamera -- the camera<BR> -- Dummy_camera: Interpolates to Dummy_mouse. the camera is parented to this.<BR> if voidP(scene.group("Cam_Master")) then<BR> pWM = scene.newGroup("Cam_Master")<BR> else<BR> pWM = scene.Group("Cam_Master")<BR> end if<BR> <BR> -- Set initial rotation of the Dummy camera to be the same as the camera, then reset the position to the origin..<BR> pWM.transform = pCamera.transform<BR> pWM.transform.position = vector(0,0,0)<BR> pWM.translate(0,30,0)<BR> pInitialWMTransform = pWM.transform.duplicate()<BR> <BR> -- Parent the camera to the "Dummy_camera"<BR> pWM.addChild(pCamera,#preserveWorld)<BR> pRotateBufferX = 0<BR> pRotateBufferY = 0<BR> pZoomBuffer = 0<BR> pMouseIsDown = 0<BR> pCameraMagnitude = (pCamera.worldPosition- pWM.worldPosition).magnitude<BR> pZoomLimit = [pCameraMagnitude*.3,pCameraMagnitude*2]<BR> pInterpPercent = .2<BR> pFriction = .5<BR> -- point the camera at the dummy<BR>  ; pCamera.pointat( pWM.worldposition)<BR> -- Record the initial transforms of the camera and its dummys to be used later in camera reset.<BR> pCamInitialTransform = pCamera.transform.duplicate()<BR> pDummyCamInitialTransform = pWM.transform.duplicate()<BR> pZoomLag = .2<BR> pDummy_cam_Rot_old = pDummyCamInitialTransform.rotation.x<BR>  ; pInit = 1<BR> (the actorList).append(me)<BR> <BR> -- This line makes the mouse rotate the world. This shows off the reflection maps as the glide over the models.<BR> -- create a World Master model that will be the parent of all the objects in the scene.<BR> --pWM = createPlane("World Master".100,100,rgb(150,255,0))<BR> <BR> -- parent all the models you want to spin to the world master<BR> -- repeat with m = 1 to scene.model.count<BR> -- if scene.model[m].name contains "Dummy" then<BR> -- nothing<BR> -- else<BR> -- pWM.addchild(scene.model(m),#preserveWorld) <BR> -- end if <BR> -- end repeat<BR> <BR> return me <BR> <BR>end</DIV> <DIV> </DIV> <DIV>---*********************************************************************** *******</DIV> <DIV> </DIV> <DIV>on stepFrame me<BR> <BR> mouseDif = the mouseloc - me.pMouseOld<BR> <BR> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -----<BR> -- Set the Navigation mode by trapping key Press events. <BR> -- <Shift> induces rotate mode, <BR> -- <control> induces zoom mode,<BR> -- <Shift> and <Zoom> induce elevate mode.<BR> if the shiftDown = true then<BR> gNavMode = "Rotate"<BR> end if<BR> if the controlDown = true then<BR> gNavMode = "Zoom"<BR> end if<BR> if the controlDown = true and the shiftDown = true then <BR> gNavMode = "Elevate"<BR> end if<BR>  ; <BR> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -----<BR> --ROTATE only when mouse and control are down<BR> if gNavMode = "Rotate" and the mouseDown = 1 then<BR> <BR> -- set the mouseOld to the mouse if the mouse was just clicked.<BR> if me.pMouseIsDown = 0 then me.pMouseOld = the mouseloc <BR> <BR> AmpAdjust = .33<BR> RotX = mouseDif[1]*AmpAdjust<BR> RotY = mouseDif[2]*AmpAdjust <BR> <BR> me.pRotateBufferX = me.pRotateBufferX + RotX <BR> me.pRotateBufferY = me.pRotateBufferY + RotY <BR> <BR> -- Set the MouseIsDown flag to on<BR> me.pMouseIsDown = 1<BR> pInterpPercent = .2<BR> RotAngleX = me.pRotateBufferX*pInterpPercent<BR> RotAngleY = me.pRotateBufferY*pInterpPercent<BR> <BR> - - Interpolate the DummyCamera to the DummyMouse<BR> rotateCamera(me,RotAngleX,RotAngleY)<BR> <BR> -- reduce the rotation buffer by the amount rotated<BR> me.pRotateBufferX = me.pRotateBufferX - RotAngleX<BR> me.pRotateBufferY = me.pRotateBufferY - RotAngleY<BR> <BR> else <BR> <BR> RotAngleX = me.pRotateBufferX*pInterpPercent<BR> RotAngleY = me.pRotateBufferY*pInterpPercent<BR> -- Interpolate the DummyCamera to the DummyMouse<BR> rotateCamera(me,RotAngleX,RotAngleY)<BR> <BR> me.pMouseIsDown = 0<BR> <BR> -- reduce the rotation buffer by the amount rotated<BR> me.pRotateBufferX = me.pRotateBufferX - RotAngleX*me.pFriction<BR> me.pRotateBufferY = me.pRotateBufferY - RotAngleY*me.pFriction<BR> end if<BR> <BR>  ; -- -- ---- ---- ---- ---- ---- ------<BR> -- Zoom<BR> -- get the distance of the camera to the dummy<BR> me.pCameraMagnitude = (pCamera.worldPosition- pWM.worldPosition).magnitude<BR> <BR> if gNavMode = "Zoom" and the mouseDown = 1 then <BR> <BR> AmpAdjust = 1<BR> ZoomRaw = mouseDif[2]*AmpAdjust<BR> me.pZoomBuffer = me.pZoomBuffer + ZoomRaw<BR> <BR> -- Set the MouseIsDown flag to on<BR> me.pMouseIsDown = 1 <BR> <BR> -- Zoom the camera <BR> Zoom = me.pZoomBuffer * me.pZoomLag <BR> -- if checkLimits(Zoom) then <BR> me.pCamera.translate(0,0,-Zoom)<BR> -- else<BR> -- limitRange()<BR> -- end if<BR> <BR> else <BR> -- Zoom the camera <BR> Zoom = me.pZoomBuffer * me.pZoomLag<BR> -- if checkLimits(Zoom) then <BR> me.pCamera.translate(0,0,-Zoom) <BR> -- else <BR> -- limitRange()<BR> -- end if<BR> <BR> me.pMouseIsDown = 0<BR> end if<BR> <BR> -- reduce the rotation buffer by the amount rotated<BR> me.pZoomBuffer = me.pZoomBuffer - Zoom<BR> <BR> -- ---- ---- ---- ---- ---- ------<BR> -- Elevate<BR> if gNavMode = "Elevate" and the mouseDown = 1 then<BR> <BR> AmpAdjust = .5<BR> ElevRaw = mouseDif[2]*AmpAdjust<BR> me.pElevBuffer = me.pElevBuffer + ElevRaw<BR> <BR> -- Set the MouseIsDown flag to on<BR> me.pMouseIsDown = 1 <BR> <BR> -- Zoom the camera <BR> Elev = me.pElevBuffer * me.pZoomLag <BR> -- if checkLimits(Elev) then <BR> me. pWM.translate(0,Elev,0,#world)<BR> -- else<BR> -- limitRange()<BR> -- end if<BR> <BR> else <BR> -- Zoom the camera <BR> Elev = me.pElevBuffer * me.pZoomLag<BR> -- if checkLimits(Elev) then <BR> me. pWM.translate(0,Elev,0,#world) <BR> -- else <BR> -- limitRange()<BR> -- end if<BR> <BR> me.pMouseIsDown = 0<BR> end if<BR> -- reduce the elevation buffer by the amount rotated<BR> me.pElevBuffer = me.pElevBuffer - Elev<BR> --if me.pElevBuffer < 0 then me.pElevBuffer = 0<BR> <BR> -- ---- ---- ---- ---- ---- ------<BR> --set the MouseOld<BR> me.pMouseOld = the mouseloc<BR> <BR>end</DIV> <DIV> </DIV> <DIV>--***********************************************************<BR>-- Rotate the camera to catch up with the dummy<BR>on rotateCamera me, RotAngleX, RotAngleY<BR> --put "RotAngleY",RotAngleY<BR> pWM.rotate(-RotAngleY,0,0,#world)<BR> pWM.rotate(0,-RotAngleX,0,#world)<BR>end</DIV> <DIV> </DIV> <DIV>--***********************************************************</DIV> <DIV> </DIV> <DIV>on limitRange me<BR> <BR> cam = me.pCamera<BR> --place the camera within its limits<BR> -- ------<BR> --Far<BR> if me.pCameraMagnitude < me.pZoomLimit[1] then <BR> -- reset the zoomBuffer<BR> me.pZoomBuffer = 0 <BR> CamMagnitudefactor = me.pZoomLimit[1].float/me.pCameraMagnitude+.001<BR> cam.transform.position = CamMagnitudefactor*cam.transform.position<BR> end if <BR> <BR> -- ------<BR> --Near<BR> if me.pCameraMagnitude > me.pZoomLimit[2] then<BR> -- reset the zoomBuffer<BR> me.pZoomBuffer = 0 <BR> CamMagnitudefactor = me.pZoomLimit[2].float/me.pCameraMagnitude-.001<BR> cam.transform.position = CamMagnitudefactor*cam.transform.position<BR> <BR> end if <BR>end</DIV> <DIV> </DIV> <DIV>--***********************************************************</DIV> <DIV> </DIV> <DIV>on checkLimits ( me,zoom)<BR> mResult = 0<BR> -- get the new position that the camera will be in on the next step<BR> newCamPos = me.pCamera.transform.position + vector(0,0,-zoom)<BR> --and test to see if it is within the limits<BR> if newCamPos.magnitude > me.pZoomLimit[1] and \<BR>newCamPos.magnitude < me.pZoomLimit[2] then<BR> mResult = 1<BR> end if<BR> return mResult <BR>end</DIV> <DIV> </DIV> <DIV>--***********************************************************</DIV> <DIV> </DIV> <DIV>on checkForBreakthrough ( me,zoom,percent)<BR> mResult = 1<BR> if me.pPositionHistory.count > 1 then<BR> -- get the new position that the camera will be in on the next step<BR> newCamPos = me.pCamera.transform.position + vector(0,0,-zoom)<BR> --and test to see if it is within the limits<BR> -- Near the min<BR> -- if newCamPos.magnitude < me.pZoomLimit[1]+ pRangeMag*.01*percent then<BR> mResult = 0<BR> end if<BR> -- near the max <BR> if newCamPos.magnitude > me.pZoomLimit[2]- me.pRangeMag*.01*percent then<BR> mResult = 0<BR> end if<BR> <BR> -- return mResult <BR>end</DIV> <DIV> </DIV> <DIV><BR>--***********************************************************<BR>on resetView me<BR> -- resets the camera and dummy to their initial settings <BR> global gInterpolateNode -- List that conatins child objects that control the interpolation animation for various nodes<BR> <BR> -- Animate the camera to move to the origin. <BR> <BR> transformList = [scene.model("Dummy_camera_Plane").transform,pInitialWMTransform]<BR> --put transformList[1].position<BR> -- transformList[2].position<BR>  ; speed = 10 <BR> AnimIndex = gInterpolateNode.count + 1<BR> node = scene.model("Dummy_camera_Plane")<BR> -- move the camera back to its start position.<BR> --on new (me, node, transformList,speed,indx,restriction)<BR> --gInterpolateNode[AnimIndex] = new (script "InterpolateNode", node,transformList,speed,AnimIndex,0)<BR> -- Move the World Master back to it's original orientation.<BR> node = pWM<BR> transformList = [pWM.transform,pInitialWMTransform]<BR> AnimIndex = gInterpolateNode.count + 1<BR> gInterpolateNode[AnimIndex] = new (script "InterpolateNode", node,transformList,speed,AnimIndex,0)<BR> <BR> - - move the camera to its initial position<BR> AnimIndex = gInterpolateNode.count + 1<BR> node = pCamera<BR> transformList = [pCamera.transform,pCamInitialTransform]<BR> gInterpolateNode[AnimIndex] = new (script "InterpolateNode", node,transformList,speed,AnimIndex,0)<BR> <BR>end</DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV><BR></FONT></SPAN> </DIV> <DIV><SPAN class=015472502-27022004><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV> <DIV><SPAN class=015472502-27022004><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV> <DIV><SPAN class=015472502-27022004><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV> <DIV><SPAN class=015472502-27022004></SPAN> </DIV></BODY></HTML>
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ Dir3d-l mailing list Dir3d-l@(protected) http://nuttybar.drama.uga.edu/mailman/listinfo/dir3d-l
|
|
 |