Professional Web Applications Themes

Measuring closest distance - Macromedia Director 3D

Hi. Need some help with a small 3d-project of mine. I'm trying to find out a way to determine the shortest distance between two models in the 3d-world. I cannot use the worldpositions, because that would give me the distance between the centerpoints of the objects. I've tried to figure out a way to compare distances between all the vertices of the objects, but it seems that you can't get the world position of vertices? Any ideas would be appreciated!...

  1. #1

    Default Measuring closest distance

    Hi.

    Need some help with a small 3d-project of mine. I'm trying to find out a way
    to determine the shortest distance between two models in the 3d-world. I
    cannot use the worldpositions, because that would give me the distance between
    the centerpoints of the objects.

    I've tried to figure out a way to compare distances between all the vertices
    of the objects, but it seems that you can't get the world position of vertices?

    Any ideas would be appreciated!

    magnus_andersson Guest

  2. #2

    Default Re: Measuring closest distance

    depending on how your models look like this way could work:

    send a ray from modelA to modelB, store the #isectposition. Send a ray from
    modelB to modelA, store again the #isectposition.

    Now you would have two points that can be used to determine the distance. If
    you use directormx2004 you can tell the ray the models that should be checked.
    In this example the ray from that is send from modelA should only check for
    modelB and vice versa. In this way other models can be between those two models.



    hondo3000 Guest

  3. #3

    Default Re: Measuring closest distance

    [q]Originally posted by: magnus_andersson
    I've tried to figure out a way to compare distances between all the vertices
    of the objects, but it seems that you can't get the world position of
    vertices?[/q]

    As well as the raycasting technique that hondo3000 suggested, you can in fact
    get the world position of the vertices by following this process:

    Create a temporary 'group' object.
    Make the group object a child of your model.
    Set the group's transform position to the vertex position.
    (The group object will now be at the same position as the vertex)
    use getWorldTransform() to get the world transform of the group object. This
    is the vertex world position.

    hope this helps!

    - Ben







    duckets Guest

  4. #4

    Default Re: Measuring closest distance

    If your models have a large number of vertices, then calculating the distance
    between each vertex of one model to each vertex of the other will require a
    high number of calculations. For example: if both models have 32 vertices, you
    will need 1024 calculations If they both have 64 vertices, you will need 4096
    calculations.

    Are your models concave? Do they have a regular form? Do you need to know
    the shortest separation precisely, or would an accurate estimate be good
    enough? Do you need to know which points are the closest, or is the distance
    that separates them enough? Is speed of calculation an important issue? Can
    you give us more details of the context in which this calculation takes place?

    Depending on your answers to these questions, there may be ways to create a
    custom solution which would work faster than a generic brute-force solution.

    openspark Guest

  5. #5

    Default Re: Measuring closest distance

    Thank you very much Ben, your solution did the trick.

    The project I'm working on is a small "room-planner". The mesuring function
    discussed here is a way for the user to get information about the distance to
    another object. The function calculates the shortest distance, and then it
    creates a "line" between the two points.

    The solution posted by Ben did everything I wanted at that point. Though,
    later on, I've recived suggestions to reCalculate the distance on each frame,
    as the user moves the objects around. It is, of course, a pretty heavy
    operation for the CPU to calculate these, for example, 1024 distances every
    1/30 second. I've tested it and it works, but the framerate decreases way to
    much, as one could guess.

    Therefore, openspark, I'm very interested in what ideas you might have and I
    will try to answer your questions.

    1. No convave models
    2. The form changes from model to model
    3. A good estimate would probably be enough
    4. I need to know the points, in order to draw a line between them
    5. Yes, speed is an important issue (if I shall use exitFrame to update, else
    it is not)

    I appreciate your interest!

    - Magnus

    magnus_andersson Guest

Similar Threads

  1. Querying a date closest to today
    By Explorer5 in forum Coldfusion Database Access
    Replies: 2
    Last Post: February 24th, 07:53 PM
  2. snap distance > pick distance impossible?
    By TonMarkus in forum Macromedia Freehand
    Replies: 1
    Last Post: July 14th, 05:53 PM
  3. Converting RGB colors to closest Pantone
    By David J in forum Macromedia Freehand
    Replies: 1
    Last Post: March 7th, 11:46 PM
  4. Measuring curves
    By mintyh in forum Macromedia Freehand
    Replies: 9
    Last Post: February 24th, 11:37 PM
  5. Measuring Lines
    By shonks webforumsuser@macromedia.com in forum Macromedia Freehand
    Replies: 2
    Last Post: October 20th, 05:40 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