Contrain PointAt to z-axis of object

Ask a Question related to Macromedia Director 3D, Design and Development.

  1. #1

    Default Contrain PointAt to z-axis of object

    I'm trying to use the point at method but I only want the model to point at the target with one axis. How can I do this?

    Thanks.
    Mazuho Guest

  2. Similar Questions and Discussions

    1. Record simple rotate of object on Z axis
      Hi, Using CS4. Is it possible to automatically record an object turning 360 on the Z axis? At the moment, I am turning the object a couple of...
    2. null object returnd to .net client while calling axis web service
      Hi , I have a java web services (message style web service whichreturns document object) on axis and im trying to access it fromvb.net client. It is...
    3. .net recieving null object while accessing axis message style web service
      Hi, Recieving null object when message style web service isaccessed from vb.net client. SOAP messages are fine. My webservice uses the method...
    4. How to turn a 3d object around its axis?
      Hello! Im a relatively new user of Director and need some help. Does anyone have a script that makes it possible to zoom in/out of a 3D-object and...
    5. Why is my axis point not moving with my object?
      In CS I have had trouble when I drag a vector object, the axis (center point) does not follow along when I drag the image. Then when I go to scale...
  3. #2

    Default Re: Contrain PointAt to z-axis of object

    I solved it partly, by setting the .x and .y parameters of
    object.transform.rotation to 0.

    But it still doesn't work just right... When I drive past the object it gets
    rotated 180 degrees in z, resulting in the back pointing at the target instead
    of the front.

    Anyone experienced the same?

    Mazuho Guest

  4. #3

    Default Re: Contrain PointAt to z-axis of object

    Have you looked at the pointAtOrientation property of 3D objects?

    Alternatively you can do some 3D mathematics, and rotate the model by hand.
    To rotate your model, you can use the syntax:

    ??myModel.rotate(vPosition, vAxis, vAngle, #world)

    You'll need to work out vAxis and vAngle from the current orientation of the
    model:

    vPosition = myModel.worldPosition
    vZAxis = myModel.getWorldTransform().zAxis -- current

    vPointToPointAt = <some vector>
    vDirection - vPointToPointAt - vPosition -- desired

    vAxis = vZAxis.cross(vDirection)
    vAngle = angleBetween(vZAxis, vDirection)

    If vAxis has a magnitude of 0, but vAngle is not 0, then your model is
    pointing in diametrically the opposite direction: vAngle will be 180. Rotating
    your model about any axis of rotation will make it point in the right
    direction, but it will probably be tilted or upside down. You will need to
    choose your rotatition vector with care to make sure that your model ends up
    the right way up.

    openspark Guest

  5. #4

    Default Re: Contrain PointAt to z-axis of object

    I usually use a utility node (in this case, a SW3D group) for something like
    this:

    -- limit pointAt() to y-axis rotation
    -- assumptions:
    -- +y is Up
    -- pointAt() orients nodes along local negative z-axis
    gUtilGroup.transform.position = pEntityModel.transform.position
    gUtilGroup.transform.position.y = pTargetPosition.y
    gUtilGroup.pointAt(pTargetPosition, gUp)
    pEntityModel.transform.rotation = gUtilGroup.transform.rotation

    -- global dependencies (need to be defined during scene setup):
    gUtilGroup = gSW3D.newGroup("UtilGroup")
    gUp = vector(0,1,0)

    Another thing to watch out for, pointAt() will generate an "Invalid Point"
    error if the node's position coincides with the target position.

    -nick

    nick kang Guest

  6. #5

    Default Re: Contrain PointAt to z-axis of object

    Thank you guys, you really helped me out.
    Mazuho Guest

Posting Permissions

  • You may not post new threads
  • You may 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