Mailing List
Home
Forum Home
Softimage
Carrara
trueSpace
Dir3d-l
Maya - a powerful 3D animation and visual effects software
Macromedia Flash Development
Subjects
Subject: Cameras
Subject: scaleDown command
Subject: black out solved
Subject: Aircraft Tutorial
Subject: Mathematical XYZ ?
Subject: Re: Its done This vs That
Subject: Re: Its done first week
recommendations for screen video captures?
Subject: 3DExplorer "Oddity "
Subject: Re: New Director
Subject: ProTeam renewals
Fuel 's new websites (X post)
Blue peter create a make toy
targeting groups question
XPost: Shockwave 3D game ( sort of )
Subject: RES: RES: RES: Fish Modeling
Emitting particles from object intersection
Fuel 's new websites (X post)
Subject: Re: Texturing
Big Break Contest Videos
Subject: New Plugins
Models and Texture on my updated site
Error Installing Patch tS6 6
Subject: Plasma?
Looking for Inspiration
Subject: Weird EMail Q
Subject: Re: It 's done first week ?
Subject: Cherry not cranberry
Subject: Re: New game
Camera Animation Problem
Subject: Particle plugins?
 
Lightwave and Shockwave 3D

Lightwave and Shockwave 3D

2004-02-26       - By Thomas Williams

 Back
Reply:     1     2     3     4     5  

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>&nbsp;<SPAN
 class=125395101-27022004><FONT face=Arial color=#0000ff
 size=2>&nbsp;</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>&nbsp;<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&nbsp;in lingo, eg shininess,&nbsp;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&nbsp; 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.&nbsp;&nbsp;Texture resolution&nbsp;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>&nbsp;&gt;&nbsp;</SPAN>-manipulate the
camera</FONT></FONT></FONT>&nbsp;<SPAN class=125395101-27022004><FONT face
=Arial
color=#0000ff size=2>&nbsp;</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. &nbsp;I use a parent script to orbit and zoom the camera
around th e origin. &nbsp;I have included it at the bottom of this
script.&nbsp;</FONT></SPAN><SPAN class=125395101-27022004>&nbsp;<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&nbsp;get you&nbsp;started and give you an
idea about the&nbsp;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>&gt;&nbsp;</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>&nbsp;</SPAN></FONT></FONT></FONT></P>
<P dir=ltr><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=125395101-27022004>&nbsp;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>&nbsp;</FONT></SPAN></DIV>
 <DIV><SPAN class=125395101-27022004><FONT face=Arial color=#0000ff
 size=2></FONT></SPAN>&nbsp;</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>&nbsp;</DIV>===================================
=======================================</FONT></SPAN></DIV>
<DIV dir=ltr><SPAN class=125395101-27022004><FONT face=Arial color=#0000ff
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr><SPAN class=125395101-27022004>&nbsp;<FONT face=Arial color=
#0000ff
size=2>-- CameraRotateZoom<BR>-- OOP Camera Controller. </FONT></SPAN></DIV>
<DIV>&nbsp;</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>&nbsp;</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
&lt;control&gt; key.<BR>-- Zoom will be triggered by the user holding down&nbsp
;
the &lt;shift&gt;&nbsp;key.<BR>-- Elevation mode is triggered by holding down
both the &lt;control&gt; and the &lt;shift&gt; key</FONT></SPAN></DIV>
<DIV>&nbsp;</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>--&nbsp;
-- Create a camera control object. <BR>--&nbsp; gCameraControl =
script("CameraControl").new(scene.camera[1])<BR>--&nbsp; (the
actorList).append(gCameraControl)</FONT></SPAN></DIV>
<DIV>&nbsp;</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>&nbsp;</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&nbsp; -- the amount of zooming that
remains to be done.<BR>property pElevBuffer&nbsp; -- 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
--&nbsp; 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 --&nbsp; the transform
of the camera controller dummy at world start.<BR>property pCamInitialTransform
--&nbsp; 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>&nbsp;</DIV>
<DIV dir=ltr>on new me,mCamera&nbsp;&nbsp;&nbsp; <BR>&nbsp; pCamera = mCamera -
-
the camera<BR>&nbsp; -- Dummy_camera: Interpolates to Dummy_mouse. the camera
is
parented to this.<BR>&nbsp; if voidP(scene.group("Cam_Master"))
then<BR>&nbsp;&nbsp;&nbsp; pWM = scene.newGroup("Cam_Master")<BR>&nbsp;
else<BR>&nbsp;&nbsp;&nbsp; pWM = scene.Group("Cam_Master")<BR>&nbsp; end
if<BR>&nbsp; <BR>&nbsp; -- Set initial rotation of the Dummy camera to be the
same as the camera, then reset the position to the origin..<BR>&nbsp;
pWM.transform = pCamera.transform<BR>&nbsp; pWM.transform.position =
vector(0,0,0)<BR>&nbsp; pWM.translate(0,30,0)<BR>&nbsp; pInitialWMTransform
=&nbsp; pWM.transform.duplicate()<BR>&nbsp; <BR>&nbsp; -- Parent the camera to
the "Dummy_camera"<BR>&nbsp; pWM.addChild(pCamera,#preserveWorld)<BR>&nbsp;
pRotateBufferX = 0<BR>&nbsp; pRotateBufferY = 0<BR>&nbsp; pZoomBuffer =
0<BR>&nbsp; pMouseIsDown = 0<BR>&nbsp; pCameraMagnitude =
(pCamera.worldPosition- pWM.worldPosition).magnitude<BR>&nbsp; pZoomLimit =
[pCameraMagnitude*.3,pCameraMagnitude*2]<BR>&nbsp; pInterpPercent&nbsp; =
.2<BR>&nbsp; pFriction = .5<BR>&nbsp; -- point the camera at the dummy<BR>&nbsp
;
pCamera.pointat( pWM.worldposition)<BR>&nbsp; -- Record the initial transforms
of the camera and its dummys to be used later in camera reset.<BR>&nbsp;
pCamInitialTransform = pCamera.transform.duplicate()<BR>&nbsp;
pDummyCamInitialTransform =&nbsp; pWM.transform.duplicate()<BR>&nbsp; pZoomLag
=
.2<BR>&nbsp; pDummy_cam_Rot_old = pDummyCamInitialTransform.rotation.x<BR>&nbsp
;
pInit = 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp; return me <BR>&nbsp;
<BR>end</DIV>
<DIV>&nbsp;</DIV>
<DIV
dir=ltr>---********************************************************************
**********</DIV>
<DIV>&nbsp;</DIV>
<DIV dir=ltr>on stepFrame me<BR>&nbsp; <BR>&nbsp; mouseDif = the mouseloc -
me.pMouseOld<BR>&nbsp; <BR>&nbsp;
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -----<BR>&nbsp; -- Set the
Navigation mode by trapping key Press events. <BR>&nbsp; -- &lt;Shift&gt;
induces rotate mode, <BR>&nbsp; -- &lt;control&gt; induces zoom mode,<BR>&nbsp;
-- &lt;Shift&gt; and &lt;Zoom&gt; induce elevate mode.<BR>&nbsp; if the
shiftDown = true then<BR>&nbsp;&nbsp;&nbsp; gNavMode = "Rotate"<BR>&nbsp; end
if<BR>&nbsp; if the controlDown = true then<BR>&nbsp;&nbsp;&nbsp; gNavMode =
"Zoom"<BR>&nbsp; end if<BR>&nbsp; if the controlDown = true and the shiftDown =
true then <BR>&nbsp;&nbsp;&nbsp; gNavMode = "Elevate"<BR>&nbsp; end if<BR>&nbsp
;
<BR>&nbsp; -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -----<BR>&nbsp;
--ROTATE only when mouse and control are down<BR>&nbsp; if gNavMode = "Rotate"
and the mouseDown = 1 then<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; -- set
the mouseOld to the mouse if the mouse was just clicked.<BR>&nbsp;&nbsp;&nbsp;
if&nbsp; me.pMouseIsDown = 0 then&nbsp; me.pMouseOld = the mouseloc&nbsp;
<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; AmpAdjust =
.33<BR>&nbsp;&nbsp;&nbsp; RotX = mouseDif[1]*AmpAdjust<BR>&nbsp;&nbsp;&nbsp;
RotY = mouseDif[2]*AmpAdjust&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;
<BR>&nbsp;&nbsp;&nbsp; me.pRotateBufferX = me.pRotateBufferX + RotX
<BR>&nbsp;&nbsp;&nbsp; me.pRotateBufferY = me.pRotateBufferY +
RotY&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; -- Set the
MouseIsDown flag to on<BR>&nbsp;&nbsp;&nbsp; me.pMouseIsDown =
1<BR>&nbsp;&nbsp;&nbsp; pInterpPercent = .2<BR>&nbsp;&nbsp;&nbsp; RotAngleX =
me.pRotateBufferX*pInterpPercent<BR>&nbsp;&nbsp;&nbsp; RotAngleY =
me.pRotateBufferY*pInterpPercent<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; -
-
Interpolate the DummyCamera to the DummyMouse<BR>&nbsp;&nbsp;&nbsp;
rotateCamera(me,RotAngleX,RotAngleY)<BR>&nbsp;&nbsp;&nbsp;
<BR>&nbsp;&nbsp;&nbsp; -- reduce the rotation buffer by the amount
rotated<BR>&nbsp;&nbsp;&nbsp; me.pRotateBufferX = me.pRotateBufferX -
RotAngleX<BR>&nbsp;&nbsp;&nbsp; me.pRotateBufferY = me.pRotateBufferY -
RotAngleY<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp; else <BR>&nbsp;&nbsp;&nbsp;
<BR>&nbsp;&nbsp;&nbsp; RotAngleX =
me.pRotateBufferX*pInterpPercent<BR>&nbsp;&nbsp;&nbsp; RotAngleY =
me.pRotateBufferY*pInterpPercent<BR>&nbsp;&nbsp;&nbsp; -- Interpolate the
DummyCamera to the DummyMouse<BR>&nbsp;&nbsp;&nbsp;
rotateCamera(me,RotAngleX,RotAngleY)<BR>&nbsp;&nbsp;&nbsp;
<BR>&nbsp;&nbsp;&nbsp; me.pMouseIsDown = 0<BR>&nbsp;&nbsp;&nbsp;
<BR>&nbsp;&nbsp;&nbsp; -- reduce the rotation buffer by the amount
rotated<BR>&nbsp;&nbsp;&nbsp; me.pRotateBufferX = me.pRotateBufferX -
RotAngleX*me.pFriction<BR>&nbsp;&nbsp;&nbsp; me.pRotateBufferY =
me.pRotateBufferY - RotAngleY*me.pFriction<BR>&nbsp; end if<BR>&nbsp; <BR>&nbsp
;
--&nbsp; -- ---- ---- ---- ---- ---- ------<BR>&nbsp; -- Zoom<BR>&nbsp; -- get
the distance of the camera to the dummy<BR>&nbsp; me.pCameraMagnitude =
(pCamera.worldPosition- pWM.worldPosition).magnitude<BR>&nbsp; <BR>&nbsp; if
gNavMode = "Zoom" and the mouseDown = 1&nbsp; then&nbsp; <BR>&nbsp;&nbsp;&nbsp;
<BR>&nbsp;&nbsp;&nbsp; AmpAdjust = 1<BR>&nbsp;&nbsp;&nbsp; ZoomRaw =
mouseDif[2]*AmpAdjust<BR>&nbsp;&nbsp;&nbsp; me.pZoomBuffer = me.pZoomBuffer +
ZoomRaw<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; -- Set the MouseIsDown
flag
to on<BR>&nbsp;&nbsp;&nbsp; me.pMouseIsDown = 1&nbsp;&nbsp;&nbsp;
<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; -- Zoom the
camera&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Zoom = me.pZoomBuffer *
me.pZoomLag&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; --&nbsp;&nbsp;&nbsp; if
checkLimits(Zoom) then&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;
me.pCamera.translate(0,0,-Zoom)<BR>&nbsp;&nbsp;&nbsp; --&nbsp;&nbsp;&nbsp;
else<BR>&nbsp;&nbsp;&nbsp; --&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
limitRange()<BR>&nbsp;&nbsp;&nbsp; --&nbsp;&nbsp;&nbsp; end
if<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp; else <BR>&nbsp;&nbsp;&nbsp; -- Zoom the
camera&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Zoom = me.pZoomBuffer *
me.pZoomLag<BR>&nbsp;&nbsp;&nbsp; -- if checkLimits(Zoom)
then&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;
me.pCamera.translate(0,0,-Zoom) <BR>&nbsp;&nbsp;&nbsp; --&nbsp;&nbsp;&nbsp;
else&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; --&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
limitRange()<BR>&nbsp;&nbsp;&nbsp; --&nbsp;&nbsp;&nbsp; end
if<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; me.pMouseIsDown = 0<BR>&nbsp;
end if<BR>&nbsp; <BR>&nbsp; -- reduce the rotation buffer by the amount
rotated<BR>&nbsp; me.pZoomBuffer = me.pZoomBuffer - Zoom<BR>&nbsp; <BR>&nbsp;
-- ---- ---- ---- ---- ---- ------<BR>&nbsp; -- Elevate<BR>&nbsp; if gNavMode =
"Elevate" and the mouseDown = 1 then<BR>&nbsp;&nbsp;&nbsp;
<BR>&nbsp;&nbsp;&nbsp; AmpAdjust = .5<BR>&nbsp;&nbsp;&nbsp; ElevRaw =
mouseDif[2]*AmpAdjust<BR>&nbsp;&nbsp;&nbsp; me.pElevBuffer = me.pElevBuffer +
ElevRaw<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; -- Set the MouseIsDown
flag
to on<BR>&nbsp;&nbsp;&nbsp; me.pMouseIsDown = 1&nbsp;&nbsp;&nbsp;
<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; -- Zoom the
camera&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Elev = me.pElevBuffer *
me.pZoomLag&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; -- if checkLimits(Elev)
then&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; me.
pWM.translate(0,Elev,0,#world)<BR>&nbsp;&nbsp;&nbsp; --
else<BR>&nbsp;&nbsp;&nbsp; -- limitRange()<BR>&nbsp;&nbsp;&nbsp; -- end
if<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp; else <BR>&nbsp;&nbsp;&nbsp; -- Zoom the
camera&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Elev = me.pElevBuffer *
me.pZoomLag<BR>&nbsp;&nbsp;&nbsp; --&nbsp;&nbsp;&nbsp; if checkLimits(Elev)
then&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; me.
pWM.translate(0,Elev,0,#world) <BR>&nbsp;&nbsp;&nbsp; --&nbsp;&nbsp;&nbsp;
else&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; --&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
limitRange()<BR>&nbsp;&nbsp;&nbsp; --&nbsp;&nbsp;&nbsp; end
if<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; me.pMouseIsDown = 0<BR>&nbsp;
end if<BR>&nbsp; -- reduce the elevation buffer by the amount rotated<BR>&nbsp;
me.pElevBuffer = me.pElevBuffer - Elev<BR>&nbsp; --if me.pElevBuffer &lt; 0
then
me.pElevBuffer = 0<BR>&nbsp; <BR>&nbsp;
-- ---- ---- ---- ---- ---- ------<BR>&nbsp; --set the MouseOld<BR>&nbsp;
me.pMouseOld = the mouseloc<BR>&nbsp; <BR>end</DIV>
<DIV>&nbsp;</DIV>
<DIV dir=ltr>--***********************************************************<BR>-
-
Rotate the camera to catch up with the dummy<BR>on rotateCamera me, RotAngleX,
RotAngleY<BR>&nbsp; --put "RotAngleY",RotAngleY<BR>&nbsp;
pWM.rotate(-RotAngleY,0,0,#world)<BR>&nbsp;
pWM.rotate(0,-RotAngleX,0,#world)<BR>end</DIV>
<DIV>&nbsp;</DIV>
<DIV dir=ltr>--***********************************************************</DIV>
<DIV>&nbsp;</DIV>
<DIV dir=ltr>on limitRange me<BR>&nbsp; <BR>&nbsp; cam = me.pCamera<BR>&nbsp;
--place the camera within its limits<BR>&nbsp; -- ------<BR>&nbsp;
--Far<BR>&nbsp; if me.pCameraMagnitude &lt; me.pZoomLimit[1]&nbsp; then
<BR>&nbsp;&nbsp;&nbsp; -- reset the zoomBuffer<BR>&nbsp;&nbsp;&nbsp;
me.pZoomBuffer = 0&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; CamMagnitudefactor
=
me.pZoomLimit[1].float/me.pCameraMagnitude+.001<BR>&nbsp;&nbsp;&nbsp;
cam.transform.position = CamMagnitudefactor*cam.transform.position<BR>&nbsp;
end
if&nbsp; <BR>&nbsp; <BR>&nbsp; -- ------<BR>&nbsp; --Near<BR>&nbsp; if
me.pCameraMagnitude &gt; me.pZoomLimit[2] then<BR>&nbsp;&nbsp;&nbsp; -- reset
the zoomBuffer<BR>&nbsp;&nbsp;&nbsp; me.pZoomBuffer = 0&nbsp;&nbsp;&nbsp;
<BR>&nbsp;&nbsp;&nbsp; CamMagnitudefactor =
me.pZoomLimit[2].float/me.pCameraMagnitude-.001<BR>&nbsp;&nbsp;&nbsp;
cam.transform.position =
CamMagnitudefactor*cam.transform.position<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp; end
if&nbsp; <BR>end</DIV>
<DIV>&nbsp;</DIV>
<DIV dir=ltr>--***********************************************************</DIV>
<DIV>&nbsp;</DIV>
<DIV dir=ltr>on checkLimits ( me,zoom)<BR>&nbsp; mResult = 0<BR>&nbsp; -- get
the new position that the camera will be in on the next step<BR>&nbsp;
newCamPos
= me.pCamera.transform.position + vector(0,0,-zoom)<BR>&nbsp; --and test to see
if it is within the limits<BR>&nbsp; if newCamPos.magnitude &gt;
me.pZoomLimit[1] and \<BR>newCamPos.magnitude &lt; me.pZoomLimit[2]
then<BR>&nbsp;&nbsp;&nbsp; mResult = 1<BR>&nbsp; end if<BR>&nbsp; return
mResult
<BR>end</DIV>
<DIV>&nbsp;</DIV>
<DIV dir=ltr>--***********************************************************</DIV>
<DIV>&nbsp;</DIV>
<DIV dir=ltr>on checkForBreakthrough ( me,zoom,percent)<BR>&nbsp; mResult =
1<BR>&nbsp; if me.pPositionHistory.count &gt; 1 then<BR>&nbsp;&nbsp;&nbsp; --
get the new position that the camera will be in on the next
step<BR>&nbsp;&nbsp;&nbsp; newCamPos = me.pCamera.transform.position +
vector(0,0,-zoom)<BR>&nbsp;&nbsp;&nbsp; --and test to see if it is within the
limits<BR>&nbsp;&nbsp;&nbsp; -- Near the min<BR>&nbsp;&nbsp;&nbsp;
--&nbsp;&nbsp;&nbsp; if newCamPos.magnitude &lt; me.pZoomLimit[1]+
pRangeMag*.01*percent then<BR>&nbsp;&nbsp;&nbsp; mResult = 0<BR>&nbsp; end
if<BR>&nbsp; -- near the max <BR>&nbsp; if newCamPos.magnitude &gt;
me.pZoomLimit[2]- me.pRangeMag*.01*percent then<BR>&nbsp;&nbsp;&nbsp; mResult =
0<BR>&nbsp; end if<BR>&nbsp; <BR>&nbsp; --&nbsp; return mResult <BR>end</DIV>
<DIV>&nbsp;</DIV>
<DIV
dir=ltr><BR>--***********************************************************<BR>on
resetView me<BR>&nbsp; -- resets the camera and dummy to their initial settings
<BR>&nbsp; global gInterpolateNode -- List that conatins child objects that
control the interpolation animation for various nodes<BR>&nbsp; <BR>&nbsp; --
Animate the camera to move to the origin.&nbsp; <BR>&nbsp; <BR>&nbsp;
transformList =
[scene.model("Dummy_camera_Plane").transform,pInitialWMTransform]<BR>&nbsp;
--put transformList[1].position<BR>&nbsp; -- transformList[2].position<BR>&nbsp
;
speed = 10 <BR>&nbsp; AnimIndex =&nbsp; gInterpolateNode.count + 1<BR>&nbsp;
node = scene.model("Dummy_camera_Plane")<BR>&nbsp; -- move the camera back to
its start position.<BR>&nbsp; --on
new&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
(me, node, transformList,speed,indx,restriction)<BR>&nbsp;
--gInterpolateNode[AnimIndex] = new (script "InterpolateNode",
node,transformList,speed,AnimIndex,0)<BR>&nbsp; -- Move the World Master back
to
it's original orientation.<BR>&nbsp; node = pWM<BR>&nbsp; transformList =
[pWM.transform,pInitialWMTransform]<BR>&nbsp; AnimIndex =&nbsp;
gInterpolateNode.count + 1<BR>&nbsp; gInterpolateNode[AnimIndex] = new (script
"InterpolateNode", node,transformList,speed,AnimIndex,0)<BR>&nbsp; <BR>&nbsp; -
-
move the camera to its initial position<BR>&nbsp; AnimIndex =&nbsp;
gInterpolateNode.count + 1<BR>&nbsp; node = pCamera<BR>&nbsp; transformList =
[pCamera.transform,pCamInitialTransform]<BR>&nbsp; gInterpolateNode[AnimIndex]
=
new (script "InterpolateNode", node,transformList,speed,AnimIndex,0)<BR>&nbsp;
<BR>end</DIV>
<DIV>&nbsp;</DIV>
<DIV dir=ltr>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV dir=ltr><BR></FONT></SPAN>&nbsp;</DIV></BODY></HTML>

__ ____ ____ ____ ____ ____ ____ ____ ____ ____
Dir3d-l mailing list
Dir3d-l@(protected)
http://nuttybar.drama.uga.edu/mailman/listinfo/dir3d-l