  | | | Lightwave and Shockwave 3D | Lightwave and Shockwave 3D 2004-02-26 - By Thomas Williams
Back Lightwave and Shockwave 3Dbest thing you can do as a beginner is buy 'Director's Third Dimension' by Paul Catanese. It will answer nearly ALL of your questions.
As understand it the 3D artist must: -build the model in Lightwave -export W3D file -create bones -create animation
On the Director end, I need to: -apply texturing (i.e. the shark's skin)
The maping should be applied in the 3d app. The texute can also be applied there. But you will need to create the details of the shader in lingo, eg shininess, specular color, multitexute (imagine light caustics added to the skin of the shark, or possibly reflection map.All this can only be done with lingo. A common and effective trick is to use a 'light map'. That is texuremap with nice lighting 'baked' into the texture. You'll probably want to set the emissive (in lingo) to (255,255,255). No lights are necessary if you use this technique. Texture resolution should be set to powers of 2. (the exporter might do it automatically, but best to do it yourself just to be sure).
> -manipulate the camera
There are library behaviors inside director that will accomplish this. but imho they suck. I use a parent script to orbit and zoom the camera around th e origin. I have included it at the bottom of this script. Just copy and paste it into a blank script, name the script "CameraControl" and make it into a parent script. Then instantiate it from your main movie script, and then you will have instant camera control. This should get you started and give you an idea about the power of OOP and model control.
> Does anyone have a good understanding of how far the model can be developed in Lightwave before it must be exported to Director for further work? Will bones be imported along with the W3D model?
sorry I have no experience with lightwave, but other on this list do. maybe they can help .
Thomas
==========================================================================
-- 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
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> <P><SPAN class=125395101-27022004><FONT size=2>best thing you can do as a beginner is buy 'Director's Third Dimension' by Paul Catanese. It will answer nearly ALL of your questions. </FONT></SPAN> <P><FONT face=Arial size=2></FONT></P><FONT face=Arial size=2>As understand it the 3D artist must:</FONT> <BR><FONT face=Arial size=2>-build the model in Lightwave</FONT> <BR><FONT face=Arial size=2>-export W3D file</FONT> <BR><FONT face=Arial size=2>-create bones</FONT> <BR><FONT face=Arial size=2>-create animation</FONT> </P></DIV> <BLOCKQUOTE dir=ltr style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px"> <P><FONT face=Arial size=2>On the Director end, I need to:</FONT> <BR><FONT face=Arial size=2>-apply texturing (i.e. the shark's skin)</FONT> <SPAN class=125395101-27022004><FONT face=Arial color=#0000ff size=2> </FONT></SPAN></P></BLOCKQUOTE> <P dir=ltr><SPAN class=125395101-27022004><FONT face=Arial color=#0000ff size=2>The maping should be applied in the 3d app. </FONT> <FONT face =Arial color=#0000ff size=2>The texute can also be applied there. But you will need to create the details of the shader in lingo, eg shininess, specular color, multitexute (imagine light caustics added to the skin of the shark, or possibly reflection map.All this can only be done with lingo. A common and effective trick is to use a 'light map'. That is texuremap with nice lighting 'baked' into the texture. You'll probably want to set the emissive (in lingo) to (255,255,255). No lights are necessary if you use this technique. Texture resolution should be set to powers of 2. (the exporter might do it automatically, but best to do it yourself just to be sure) . </FONT></SPAN></P><SPAN class=125395101-27022004><FONT face=Arial color=#0000ff size=2></FONT></SPAN> <P dir=ltr><BR><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN class=125395101-27022004> > </SPAN>-manipulate the camera</FONT></FONT></FONT> <SPAN class=125395101-27022004><FONT face =Arial color=#0000ff size=2> </FONT></SPAN></P> <P dir=ltr><SPAN class=125395101-27022004><FONT face=Arial color=#0000ff size=2>There are library behaviors inside director that will accomplish this. but imho they suck. I use a parent script to orbit and zoom the camera around th e origin. I have included it at the bottom of this script. </FONT></SPAN><SPAN class=125395101-27022004> <FONT face =Arial color=#0000ff size=2>Just copy and paste it into a blank script, name the script "CameraControl" and make it into a parent script. Then instantiate it from your main movie script, and then you will have instant camera control. </FONT></SPAN><FONT face=Arial><FONT color=#0000ff><FONT size=2>T<SPAN class=125395101-27022004>his should get you started and give you an idea about the power of OOP and model control. </SPAN></FONT></FONT></FONT></P> <P dir=ltr><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN class=125395101-27022004></SPAN></FONT></FONT></FONT><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN class=125395101-27022004>> </SPAN>Does anyone have a good understanding of how far the model can be developed in Lightwave before it must be exported to Director for further work? Will bones be imported along with the W3D model?<SPAN class=125395101-27022004> </SPAN></FONT></FONT></FONT></P> <P dir=ltr><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN class=125395101-27022004> sorry I have no experience with lightwave, but other on this list do. maybe they can help .</SPAN></FONT></FONT></FONT></P> <BLOCKQUOTE dir=ltr style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px"> <DIV><SPAN class=125395101-27022004><FONT face=Arial color=#0000ff size=2> </FONT></SPAN></DIV> <DIV><SPAN class=125395101-27022004><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV></BLOCKQUOTE> <DIV dir=ltr><SPAN class=125395101-27022004><FONT face=Arial color=#0000ff size=2> <DIV><SPAN class=125395101-27022004><FONT face=Arial color=#0000ff size=2>Thomas</FONT></SPAN></DIV> <DIV><SPAN class=125395101-27022004></SPAN> </DIV>=================================== =======================================</FONT></SPAN></DIV> <DIV dir=ltr><SPAN class=125395101-27022004><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV> <DIV dir=ltr><SPAN class=125395101-27022004> <FONT face=Arial color= #0000ff size=2>-- CameraRotateZoom<BR>-- OOP Camera Controller. </FONT></SPAN></DIV> <DIV> </DIV> <DIV dir=ltr><SPAN class=125395101-27022004><FONT face=Arial color=#0000ff size=2>-- Input: the camera to be controlled</FONT></SPAN></DIV> <DIV> </DIV> <DIV dir=ltr><SPAN class=125395101-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 dir=ltr><SPAN class=125395101-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 dir=ltr><SPAN class=125395101-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=125395101-27022004><FONT face=Arial color=#0000ff size=2> <DIV dir=ltr><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 dir=ltr>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> <BR> return me <BR> <BR>end</DIV> <DIV> </DIV> <DIV dir=ltr>---******************************************************************** **********</DIV> <DIV> </DIV> <DIV dir=ltr>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 dir=ltr>--***********************************************************<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 dir=ltr>--***********************************************************</DIV> <DIV> </DIV> <DIV dir=ltr>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 dir=ltr>--***********************************************************</DIV> <DIV> </DIV> <DIV dir=ltr>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 dir=ltr>--***********************************************************</DIV> <DIV> </DIV> <DIV dir=ltr>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 dir=ltr><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 dir=ltr> </DIV> <DIV> </DIV> <DIV dir=ltr><BR></FONT></SPAN> </DIV></BODY></HTML>
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ Dir3d-l mailing list Dir3d-l@(protected) http://nuttybar.drama.uga.edu/mailman/listinfo/dir3d-l
|
|
 |