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

clicking and Dragging models around a terrain

2003-12-17       - By welchc@(protected)

 Back
Reply:     1     2     3  


I've been trying to figure out how to click and drag models around a
surface. I will eventually add a terrain follow script to the dragged
object so it sticks to the surface. But, right now I'm having difficulty
canniblising a script by Alex da Franca (constainDrag.dir). He is using X
as the up axis. (It seems all the 'cool' coders use X up). So, I, not being
as cool as the others, need Z to be my up axis. I can almost make it work
but the model only moves along the y and not the x (or maybe its the other
way around). I don't want the model to go up or down (Z) as I will have the
terrain follow script deal with that.

I've pasted the script below. Could someone take a look at it and maybe
point out where I am going wrong or point me in the right direction?
Thanks!--Carl

property pSprite, pMember
property pLeftTop
property pCam
property pModel
property pOffset -- offset from clickloc to clicked models worldpos

on beginSprite me
 pSprite = sprite(me.spriteNum)
 pMember = pSprite.member
 pLeftTop = point(pSprite.left, pSprite.top)
 pCam = pSprite.camera
 pModel = void
end beginSprite

on mouseDown me
 pModel = pCam.modelunderloc((the clickloc - pLeftTop))
 if ilk(pModel) = #model then
   if pModel.name <> "terrain" then
     pOffset = (the clickloc - pLeftTop) - pCam.worldSpaceToSpriteSpace
(pModel.worldposition)
   else
     pModel = void
   end if
 end if
end


on mouseUp me
 pModel = void
end

on mouseUpOutside me
 pModel = void
end

on exitframe me
 if ilk(pModel) = #model then
   shift = the shiftdown
   camPos = pCam.worldposition

   --    if shift then vHeight = pModel.worldposition.z -- vertical drag
   --    else vHeight = pModel.worldposition.x -- horizontal drag

   vHeight = pModel.worldposition.x
   --    vHeight = pModel.worldposition.z
   p = pCam.spriteSpaceToWorldSpace((the mouseLoc - pLeftTop - pOffset))

   put "p" && P
   v = p - camPos
   --    v = camPos - p
   v.normalize()
   put "v" && v
   if shift then -- vertical drag

  --   if v[3] <> 0 then -- if the vector is parallel to the x-y plane we
can't divide by 0
  --     f = (p[3] - vHeight) / v[3]
   --    newWP = p - (v * f)
   --    newWP[2] = pModel.worldposition.y
   --    pModel.worldposition = newWP
     end if

   else -- horizontal drag
     if v[1] <> 0 then -- if the vector is parallel to the x-z plane we
can't divide by 0

       f = (p[1] - vHeight) / v[1]
       pModel.worldposition = p - (v * f)
     end if
   end if
 end if
end


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