ModelsUnderRay not working

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

  1. #1

    Default ModelsUnderRay not working

    Hey all,

    I'm moving the load of my crane, with a bounding box around it. This moves ok
    with the crane.
    Unfort, using modelsUnderRay, the code will only stop once the building
    touches the middle of the bounding box, not the outside. How do i fix this?

    Thanks, Andy

    --------
    --LEFT--
    --------
    -- initialize a position and a direction vector
    tPosition = pCharBoundingBox.worldPosition
    --tDirection = pCharBoundingBox.transform.xAxis
    tDirection = pLoad.transform.xAxis

    -- cast the ray
    tList = member("Crane").modelsUnderRay(tPosition, tDirection, tOptionsList)

    -- -- if ray picks up models, then check for collision
    if (tList.count) then me.checkForCollision(tList[1])

    AndrewNock Guest

  2. Similar Questions and Discussions

    1. ModelsUnderRay
      Hello, I've just learnt the ModelsUnderRay technique for collision detection from the UNSW tutorial and have checked various sites to make sure...
    2. modelsUnderRay() working really slow?
      I'm using modelsUnderRay() for a two different projects I'm working on, but as soon as I activate it, both start to come to almost a complete halt....
    3. modelsUnderRay Help please!
      if i wanted to make sure a round table did not collide with a ball using modelsUnderRay would i have to use a bounding box,(as i imagine the result...
    4. modelsunderray ba*d!
      I have a couple of issues here. 1: I have a character proxy model that I controll around a 3D world. Using modelsunderray I am trying to detect...
    5. ModelsUnderRay ... again, again, again.
      English: Hi! Someone it has worked with the command modelsunderray in worlds where the walls do NOT BE necessarily oriented in the axes X and AND...
  3. #2

    Default Re: ModelsUnderRay not working

    what is the value of tOptionList?
    ensamblador Guest

  4. #3

    Default Re: ModelsUnderRay not working

    HI, thanks for the reply, here is the rest of the relevant code...

    -- build your modelList
    tModelList = [member("Crane").model("Ground"),member("Crane").mo del("Load"),
    member("Crane").model("Building04"), member("Crane").model("Target01"),
    member("Crane").model("Obstacle01")]

    -- build your optional argument list
    tOptionsList = [#maxNumberOfModels: 10, #levelOfDetail: #detailed,
    #modelList:tModelList, #maxDistance: 3]

    AndrewNock Guest

  5. #4

    Default Re: ModelsUnderRay not working

    [q]Originally posted by: AndrewNock
    Hey all,

    I'm moving the load of my crane, with a bounding box around it. This moves ok
    with the crane.
    Unfort, using modelsUnderRay, the code will only stop once the building
    touches the middle of the bounding box, not the outside. How do i fix this?

    Thanks, Andy

    2 things...
    1. From my experiemce with modelUnderRay it seem like it checks the model's
    pivot point. For example say you have a cube where the width is 50 units,
    length is 100 units, and the height is 10 units, and the pivot point is in the
    center of the cube. instead of saying this....

    collisData = modelsUnderRay( your settings)
    if collisdata.count then
    dist = collisData[1][4]
    if dist < yourModel.worldPosition then
    your code
    end if


    Instead, you need to build hover offset. Using my cube example, my hover
    distance would be half of the width, length, or height total units depending on
    which side you are detecting collision on. So lets say the width side of the
    cube is colliding with the ground. Now knowing the width of the cube is 50
    units then the additional hover offset would be 25 (width of the cube / 2). In
    other words the code would look somthing like this...

    collisData = modelsUnderRay( my settings)
    if collisdata.count then
    dist = collisData[1][4]
    hoverOffset = myCubeExample.worldPosition + 25
    if dist < hoverOffset then
    my additional code
    end if

    Just note that you cannot get an object's demenions that has been buillt in
    another 3D application

    2. I never seen using a property list for your arguments with the command
    modelsUnderRay, so this might also be causing problems as well.

    Roofy Guest

  6. #5

    Default Re: ModelsUnderRay not working

    Hi Andrew,

    When I do models underray, I basically always do it something like this:

    dirns=[vector(0,1,0),vector(1,0,0),vector(0,-1,0),vector(-1,0,0)]
    diam=20 repeat with i=1 to dirns.count
    dog=gmem.modelsunderray(pos,dirns[i],1,#detailed)
    if dog.count>0 then
    if dog[1].distance<diam then
    pos=dog[1].isectposition-dirns[i]*diam
    --anything facy here
    end if
    end if
    end repeat

    This does the four coordinates (NESW), and you can add top and bottom to the
    array.

    The "pos" is your vector position, and diam is a chosen distance that you will
    feel is close enough to your object to be considered a collision.

    It's nice because it does the lot in a onner, the only problem being that
    modelsunderray has the drawback of your being able to theoretically squeeze
    yourself through the tiniest gap, and into the wrong place if you're unlucky.

    P.S: Has anybody sorted ouit an equation to use the collision detection? I've
    tried occasionally, and always ended up back with the ray-cast.

    Cheers,

    James ([url]http://www.gamevial.com[/url])

    Sumerian Guest

  7. #6

    Default Re: ModelsUnderRay not working

    Sumerian wrote:
    > When I do models underray, I basically always do it something like
    > this:
    >
    > dirns=[vector(0,1,0),vector(1,0,0),vector(0,-1,0),vector(-1,0,0)]
    ....

    About modelsUnderRay aligned with an axis:-
    [url]http://nuttybar.drama.uga.edu/pipermail/dir3d-l/2005-November/010090.html[/url]

    Andrew (but not that one)


    Andrew Morton 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