Professional Web Applications Themes

Orientation - Macromedia Director 3D

Hi, I'm still fairly new to Director 3D. I'm trying to program a canon that shoots a projectile based on where it is facing. The canon can be rotated in the x and z axis. From the rotation, I shoot the projectile using a fixed force. The problem is how do I get the vector of the canon? I felt that it can't be the position, rotation or scale, as I only want the vector of the canon's orientation. I'm trying to apply the above vector to this formula I found for calculating displacement: displacement = (initial velocity * time) ...

  1. #1

    Default Orientation

    Hi, I'm still fairly new to Director 3D. I'm trying to program a canon that
    shoots a projectile based on where it is facing.

    The canon can be rotated in the x and z axis. From the rotation, I shoot the
    projectile using a fixed force. The problem is how do I get the vector of the
    canon? I felt that it can't be the position, rotation or scale, as I only want
    the vector of the canon's orientation.

    I'm trying to apply the above vector to this formula I found for calculating
    displacement:
    displacement = (initial velocity * time) + (0.5 * acceleration * time * time)

    With the above, I hope to substitute the orientation vector of the canon into
    "initial velocity" to get my displacement.

    darylku Guest

  2. #2

    Default Re: Orientation

    By default, SW3D uses the -Z axis as the "forward" direction, i.e., pointAt()
    will align the node's -Z axis toward the target position (a node can be a
    model, group, camera, etc.), so something like....

    projectileVector = -cannonModel.transform.zAxis

    will give you a normalized vector. I always rotate the pivot point of the
    model in 3dsmax to match SW3D's coordinate system. So for something like a car
    in 3dsmax, I point the Z axis toward the rear, the Y axis upward, the X axis
    will point to the passenger side (starboard). Or you can always override
    defaults by changing the node's pointAtOrientation property.


    nick kang Guest

  3. #3

    Default Re: Orientation

    I have tried out the axis thing and I think I am having a misconception here.
    I'm still new to this 3D thing.

    When i hardcoded the formula:
    -- displacement = (initial velocity * time) + (0.5 * acceleration * time *
    time)
    displacement = (vector(5,10,0) * time) + (0.5 * -9.81 * time * time)

    I get a smooth parabolic trajectory for my projectile.

    I thought I could substitute the vector(5,10,0) value in place of my cannon's
    zAxis but it seems that my projectile only goes in a straight line.
    That must means that I can't use an axis as the "initial velocity" component
    in the above equation.

    1) is the model.transform.position a direction vector?

    2) how do I actually get a value that resemble vector(5,10,0) that correspond
    to my cannon's x and y rotation? I need the "initial velocity" component of the
    equation to be a variable based on my cannon's rotation.

    darylku Guest

  4. #4

    Default Re: Orientation

    try this:

    projectileDirection = -cannonModel.transform.zAxis
    projectileSpeed = 10
    gravityVector = vector(0,-9.81,0)
    initialPosition = vector(0,0,0)
    displacementPosition = initialPosition + (projectileDirection *
    projectileSpeed * time) + (0.5 * gravityVector * time * time)

    In your second equation, you're mixing scalar and vector values so you're
    probably not getting the results expected. SW3D will evaluate vector + scalar
    by adding the scalar value to each member of the vector:
    vector(1,2,3) + 10 = vector(11,12,13)

    1) no, that's the location of the model's pivot point (typically in worldspace)
    2) assuming that you have have the model created so that it's pivot is aligned
    with -Z forward, just use the cannonModel.transform.-zAxis as the directional
    vector, after you've finished rotating the cannon.

    nick kang Guest

  5. #5

    Default Re: Orientation

    have a look

    [url]http://www.director-online.com/buildArticle.php?id=1076[/url]
    [url]http://www.director-online.com/buildArticle.php?id=1078[/url]
    [url]http://www.director-online.com/buildArticle.php?id=1080[/url]
    [url]http://www.director-online.com/buildArticle.php?id=1083[/url]

    enjoy

    Greg


    "nick kang" <webforumsusermacromedia.com> wrote in message
    news:cgc7na$oh5$1forums.macromedia.com...
    > try this:
    >
    > projectileDirection = -cannonModel.transform.zAxis
    > projectileSpeed = 10
    > gravityVector = vector(0,-9.81,0)
    > initialPosition = vector(0,0,0)
    > displacementPosition = initialPosition + (projectileDirection *
    > projectileSpeed * time) + (0.5 * gravityVector * time * time)
    >
    > In your second equation, you're mixing scalar and vector values so you're
    > probably not getting the results expected. SW3D will evaluate vector +
    scalar
    > by adding the scalar value to each member of the vector:
    > vector(1,2,3) + 10 = vector(11,12,13)
    >
    > 1) no, that's the location of the model's pivot point (typically in
    worldspace)
    > 2) assuming that you have have the model created so that it's pivot is
    aligned
    > with -Z forward, just use the cannonModel.transform.-zAxis as the
    directional
    > vector, after you've finished rotating the cannon.
    >

    Greg Brant Guest

  6. #6

    Default Re: Orientation

    Thanks! That was really helpful.
    darylku Guest

Similar Threads

  1. Cfdoent Orientation
    By Fglenn in forum Macromedia ColdFusion
    Replies: 1
    Last Post: April 6th, 04:52 AM
  2. Orientation unpredictable
    By gregg_sales@adobeforums.com in forum Adobe Indesign Windows
    Replies: 0
    Last Post: June 30th, 03:24 PM
  3. Page Orientation
    By Cindy_Schmidt@adobeforums.com in forum Adobe Acrobat Windows
    Replies: 1
    Last Post: May 13th, 07:28 PM
  4. Text Orientation?????
    By betsy wallace webforumsuser@macromedia.com in forum Macromedia Director Basics
    Replies: 1
    Last Post: September 30th, 03:53 PM
  5. Help With Page Orientation
    By CWMG webforumsuser@macromedia.com in forum Macromedia Dreamweaver
    Replies: 1
    Last Post: July 14th, 02:34 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