Hi All,

Thanks for all your help everyone...

Best regards

Neil

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of James Newton
Sent: 18 September 2001 17:54
To: [EMAIL PROTECTED]
Subject: Re: <lingo-l> Child/Parent


Neil Evans <[EMAIL PROTECTED]>
> I am trying to make the camera the child of the sphere so I can
> use it for collision detection etc

Hi Neil,

Here's a beginSprite() handler in a behavior that I use to to a
walkthrough with a camera.  I use a box model with #mesh collision
detection so that it can move inside other meshes.  A box has fewer
meshes than a sphere, so collision detection is faster.  (A custom built
mesh cube would probably be slightly faster still).

The visibility of the model is set to #none, so that none of its faces,
inside or out, are rendered.

The camera should sit at the center of the model, so the model must
first be moved to where the camera is.  I use the #preserveWorld
argument for the addChild() command so that the camera doesn't move when
it becomes a child of the box.

The rest of the behavior manipulates the box, not the camera.  I use the
property name pCamera for the box to underline this.


Cheers,

James


----------------------------------------------------------------------


property pCamera -- box model used as parent of the sprite's camera

on beginSprite(me) ---------------------------------------------------
  -- ACTION: Make the camera the child of a small invisible box model,
  -- to which the collision modifier is attached in #mesh mode
  --------------------------------------------------------------------

  tSprite            = sprite(me.spriteNum)
  tMember            = tSprite.member
  tName              = string(me) -- unique name
  tResource          = tMember.newModelResource(tName, #box)

  -- Make the box big enough for collision detection
  tResource.width    = 4
  tResource.height   = 4
  tResource.length   = 4

  -- Create an invisible model at the same position as the camera
  pCamera            = tMember.newModel(tName, tResource)
  pCamera.visibility = #none
  pCamera.transform  = tSprite.camera.transform
  pCamera.addChild(tSprite.camera, #preserveWorld)

  -- Add the collision modifier in #mesh mode
  pCamera.addModifier(#collision) -- resolve = TRUE, enabled = TRUE
  pCamera.collision.mode = #mesh
end beginSprite



[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]


[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to