Professional Web Applications Themes

inerty - Macromedia Director 3D

hi there! I would to know how to add inerty on my manipulated 3d objet? any tricks guys?...

Sponsored Links
  1. #1

    Default inerty

    hi there!

    I would to know how to add inerty on my manipulated 3d objet?

    any tricks guys?
    Sponsored Links
    takama2 Guest

  2. #2

    Default Re: inerty

    Imassuming your code already looks something like this

    property spritenum
    property pSpeed




    global ,your object

    on beginsprite me
    w = member(1)
    w.resetworld()

    ---------pspeed-------
    pspeed = 0




    pspeed = pspeed - .40 ---(you could play with the numbers to
    chane the feel of the object)
    if pspeed < 0 then pspeed = 0 ---(you could play with the numbers to
    chane the feel of the object)
    if pspeed > 15 then pspeed = 15 ---(you could play with the numbers to
    chane the feel of the object)

    w.model("yourobject").translate(+pspeed,0,0)--orientationspeed
    w.model("yourobject").rotate(0,0,0)--orientationspeed

    --put the keycode


    if keypressed(126) then
    pspeed = pspeed + 1
    end if



    --if keypressed(125) then
    --pspeed = pspeed - 3
    --end if
    if keypressed(125) then
    car.translate(-5,0,0)
    end if



    if keypressed(123) then
    w.model(" your object ").rotate(0,0,2,#self)
    end if


    if keypressed(124) then

    w.model(" your object ").rotate(0,0,-2,#self)
    end if

    subterenia Guest

  3. #3

    Default Re: inertia

    thx a lot !

    i don't event try but its looking good, gonna try and i ll tell you ;)

    thx again subterenia!
    takama2 Guest

  4. #4

    Default Re: inertia

    yo!

    hmmm finaly im a little confused because in my scene this is not the object
    that move but my camera by dragging the mouse...

    This thing take me plenty of time and multiple headaches but work just fine
    for visualised and interac with objects.

    Can you help me some more to adapt your code with mine?

    There is my code who i sure that some people gonna like it:

    property pThis
    property pCameraMode
    property pDragging
    property pOrigMouseLoc
    property pOldMouseLoc
    property pNewMouseLoc
    property pOrigTransform
    property pRotationPivot
    property pPivot
    property pUpBias
    property pDollyFactor


    on beginSprite(me)
    pThis = sprite(me.spriteNum)

    pCameraMode = #rotate
    pPivot = vector(0, 0, 0)
    pUpBias = vector(0, 1, 0)
    pDollyFactor = 0.1

    pRotationPivot = pPivot.duplicate()
    pDragging = false
    end


    on exitFrame
    pNewMouseLoc = the mouseLoc - pThis.loc

    if(the shiftDown) then
    pCameraMode = #pan
    else if(the commandDown) then
    pCameraMode = #dolly
    else
    pCameraMode = #rotate
    end if

    if(pDragging) then
    case pCameraMode of
    #pan:
    cameraPan()

    #dolly:
    cameraDolly()

    #rotate:
    cameraRotate()
    end case
    end if

    pOldMouseLoc = pNewMouseLoc
    end


    on mouseDown
    pDragging = true
    pOrigMouseLoc = the mouseLoc - pThis.loc
    pOldMouseLoc = the mouseLoc - pThis.loc
    pOrigTransform = pThis.camera.transform.duplicate()

    look = vector(0, -1, 0)

    end


    on mouseUp
    pDragging = false
    end


    on cameraPan()
    thisCamera = pThis.camera

    look = vector(0, 0, -1)
    oldMouseInWorld = thisCamera.spriteSpaceToWorldSpace(pOldMouseLoc +
    pThis.Loc)
    newMouseInWorld = thisCamera.spriteSpaceToWorldSpace(pNewMouseLoc +
    pThis.Loc)

    cameraPivot = worldToCamera(pRotationPivot)
    oldMouseInCamera = worldToCamera(oldMouseInWorld)
    newMouseInCamera = worldToCamera(newMouseInWorld)

    moveVector = newMouseInCamera - oldMouseInCamera

    planeParallelToFilm = findPlaneEquation(look, cameraPivot)

    intersection = findIntersectionWithPlane(oldMouseInCamera,
    planeParallelToFilm)

    origFilmPlaneDist = oldMouseInCamera.length
    translationPlaneDist = intersection.length

    ratio = translationPlaneDist/origFilmPlaneDist

    moveVector = moveVector*ratio

    thisCamera.translate(-moveVector)
    end


    on worldToCamera(worldVector)
    return pThis.camera.transform.inverse()*worldVector
    end


    on findPlaneEquation(normal, pointInPlane)
    planeEq = [:]

    planeEq.addProp(#a, normal.x)
    planeEq.addProp(#b, normal.y)
    planeEq.addProp(#c, normal.z)
    planeEq.addProp(#d, -normal.x*pointInPlane.x - normal.y*pointInPlane.y -
    normal.z*pointInPlane.z)

    return planeEq
    end


    on findIntersectionWithPlane(intersector, plane)
    t = (-plane.d) / (plane.a*intersector.x + plane.b*intersector.y +
    plane.c*intersector.z)

    return t*intersector
    end


    on cameraDolly()
    thisCamera = pThis.camera

    newMouseLoc = the mouseLoc - pThis.loc

    dollyDist = pDollyFactor*(newMouseLoc.locV - pOldMouseLoc.locV)

    thisCamera.translate(0, 0, dollyDist)
    end


    on cameraRotate()
    thisCamera = pThis.camera

    newMouseLoc = the mouseLoc - pThis.loc

    xAngle = -(newMouseLoc.locV - pOrigMouseLoc.locV)
    yAngle = -(newMouseLoc.locH - pOrigMouseLoc.locH)

    if(abs(xAngle) > 0.01) and (abs(yAngle) > 0.01) then

    thisCamera.transform = pOrigTransform

    thisCamera.rotate(pRotationPivot, pUpBias, yAngle, #world)
    thisCamera.rotate(pRotationPivot, thisCamera.transform.xAxis, xAngle,
    #world)
    end if
    end

    cheers!

    takama2 Guest

  5. #5

    Default Re: inertia

    I'm going to have a look at it some time tommorrow
    im not definately sure i will be able to work it out
    but I'll give it a try
    subterenia Guest

  6. #6

    Default Re: inertia

    You might also want to down load chrome librarys plugins
    if my memory serves me correct he has created a drag and drop behaviour
    that does exactly what you want im not sure what his website address
    is but im pretty sure if you root around on the net you will find it

    all the best with your project keep me informed

    Loki

    subterenia Guest

  7. #7

    Default Re: inertia

    You might also want to down load chrome librarys plugins
    if my memory serves me correct he has created a drag and drop behaviour
    that does exactly what you want im not sure what his website address
    is but im pretty sure if you root around on the net you will find it

    all the best with your project keep me informed

    Loki

    subterenia Guest

  8. #8

    Default Re: inertia

    hmm i got the last chrome lib and there is no such action down there... :(

    the " interpolate camera to model " do nearly the job but the resulting
    movement of the 3d object relative to dragable camera is not natural at all.

    Dam! seem that nothing is easy with shockwave, i'm good to smatch my head on
    the wall some more... outch

    takama2 Guest

  9. #9

    Default Re: inertia

    I'm sorry I havent had time to look out your code?

    I really thought the chrome library pluging would work.

    Loki
    subterenia Guest

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139