Professional Web Applications Themes

Camera moves slowly back to origin - Macromedia Director 3D

I'm moving a camera around in a 3d room. When I move left/right/up/down (using seperate sprites), I want the camera to move back to it's original position (like a piece of elastic). Any ideas on how to script this?...

Sponsored Links
  1. #1

    Default Camera moves slowly back to origin

    I'm moving a camera around in a 3d room. When I move left/right/up/down (using
    seperate sprites), I want the camera to move back to it's original position
    (like a piece of elastic).

    Any ideas on how to script this?

    Sponsored Links
    Nickname Guest

  2. #2

    Default Camera moves slowly back to origin

    I'm moving a camera around in a 3d room. When I move left/right/up/down (using
    seperate sprites), I want the camera to move back to it's original position
    (like a piece of elastic).

    Any ideas on how to script this?

    Nickname Guest

  3. #3

    Default Camera moves slowly back to origin

    I'm moving a camera around in a 3d room. When I move left/right/up/down (using
    seperate sprites), I want the camera to move back to it's original position
    (like a piece of elastic).

    Any ideas on how to script this?

    Nickname Guest

  4. #4

    Default Re: Camera moves slowly back to origin

    Check out the 'interpolateTo' function. Specifically, you need something like:

    myCam.transform.interpolateTo(originalTransform,80 )

    Each time the above line is executed, 'myCam' will move 80 percent of the
    remaining distance towards 'originalTransform'. originalTransform should be a
    duplicate of the camera's starting transform.

    hope this helps!


    - Ben


    duckets Guest

  5. #5

    Default Re: Zoom In/Out

    Yes, the 'zoom' feature of real-life cameras is the equivalent of the field of
    view of director 3d camera objects. Physically moving the camera forwards and
    backwards towards the target is actually called 'dollying' in real life.

    To narrow the field of view by one degree per frame, you could use something
    like this:

    if gZoomIn then pCamera.fieldofview =pCamera.fieldofview - 1

    You'll want to limit it to a minimum though, which can easily be achieved by
    using the 'max' command:

    if gZoomIn then pCamera.fieldofview =max(30,pCamera.fieldofview - 1)

    The above line will zoom in, but keep the field of view from going lower than
    30 degrees. The matching 'zoom out' would look like this:

    if gZoomOut then pCamera.fieldofview =min(120,pCamera.fieldofview + 1)


    hope this helps!

    - Ben






    duckets Guest

  6. #6

    Default Re: Restrict angle of camera rotation

    You might want something like this: Set up a property 'r'. Set it to zero on
    start. Then (each frame) modify that property when panning left or right,
    rather than rotating the camera directly, eg:

    r = r + (gPanRight-gPanLeft)

    Then limit 'r' to your chosen rotation limits:

    r = max(-90, min(90, r ))

    Then set your camera's rotational value directly:

    pCamera.transform.rotation.z = r

    (you may need to change which axis of your camera's rotation to change,
    depending on the orientation of your world).

    - Ben


    duckets Guest

  7. #7

    Default Re: Zoom In/Out

    Ahhhh, great thanks, that's working now. I was halfway there!!
    Nickname Guest

  8. #8

    Default Re: Camera moves slowly back to origin

    Firstly, thanks for getting back to me.

    I'm having a bit of trouble implementing this.....

    I mousedown on a sprite to move l/r/u/d, when I release the mousebutton I want
    the camera to move slowly back to where it started.

    In my 3d file (called 'Tube') I have Camera01, Tube01 and Sphere01. I control
    the camera with seperate sprites with Global scripts.

    An example of this is:

    Sprite behaviour:
    On mousedown me
    gPanLeft = True

    In my 3D Behaviour I have:
    if gPanLeft then pCamera.rotate(-1,0,0)

    From the Duckets example above...

    - I presume I change 'myCam' to 'Camera01'
    - I need to set the 'originalTransform' value, do I do this as a property in
    'beginSprite'
    - If I place that code within the 3D behaviour, do I need to make a global
    reference to the sprite behaviour? (eg 'if gNoButton then
    Camera01.transform.interpolateTo(pOriginalTransfor m,80)

    Or am I totally way off the mark with this!?!?!?!?!?!?!?!?




    Nickname Guest

  9. #9

    Default Re: Camera moves slowly back to origin

    [q]Originally posted by: Nickname is none
    - I presume I change 'myCam' to 'Camera01'
    - I need to set the 'originalTransform' value, do I do this as a property in
    'beginSprite'
    - If I place that code within the 3D behaviour, do I need to make a global
    reference to the sprite behaviour? (eg 'if gNoButton then
    Camera01.transform.interpolateTo(pOriginalTransfor m,80)
    Or am I totally way off the mark with this!?!?!?!?!?!?!?!?
    [/q]

    You're pretty much there. The 'myCam' variable is the equivalent of what you
    have as 'pCamera'. That is, it's supposed to be a variable in which you have
    previously placed a reference to your camera, something like this: pCamera =
    member("tube").camera("camera01"), so you can change the line to:

    pCamera.transform.interpolateTo(originalTransform, 80)

    Define 'originalTransform' as a property at the top of your 3d behaviour, and
    in the beginsprite handler of it, do this:

    originalTransform = pCamera.transform.duplicate()

    And finally, you'll just need to check whether none of your control buttons
    are being pressed, eg:

    if not (gPanLeft or gPanRight or gPanUp or gPanDown) then
    pCamera.transform.interpolateTo(pOriginalTransform ,80)
    end if

    hope this sorts it out for you,

    - Ben



    duckets Guest

  10. #10

    Default Re: Restrict angle of camera rotation

    Damnit!! I'm having trouble with this as well....

    These are the relevant parts I have at the moment:

    Movie script:
    on startmovie
    set pRestrict = 0
    end

    3D world behaviour:
    property pRestrict

    on begineSprtie me
    pRestrict = pRestrict + (gPanRight-gPanLeft)
    pRestrict = max(-90, min(90, pRestrict))
    end

    on controlCamera me
    if gPanLeft then pCamera.transform.rotation.y = pRestrict
    end

    This has stopped the camera from panning at all! I have a feeling it might be
    glaringly obvious!!! Can anyone help (Mr Duckets?).

    Nickname Guest

  11. #11

    Default Re: Camera moves slowly back to origin

    That is perfect!!!! I've changed the speed to 1 to slow it down a bit.

    You're a genius, thanks!!!!
    Nickname Guest

Similar Threads

  1. Rotating a camera left/right and up/down while targeting the origin
    By Kevin Fink in forum Macromedia Director 3D
    Replies: 1
    Last Post: August 23rd, 09:49 PM
  2. page origin
    By Brian Pylant in forum Macromedia Freehand
    Replies: 2
    Last Post: August 11th, 02:58 PM
  3. [ANN] RMagick moves to RubyForge
    By Tim Hunter in forum Ruby
    Replies: 0
    Last Post: July 26th, 11:21 PM

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