Professional Web Applications Themes

collision detection - Macromedia Director 3D

Hi all! I'm trying to make a doom like game in the 3d engine of director, and have some collision questions. Well just one for now but theire will be more soon. Here it is; how can I see that one object collides with one other. For example I want director to detect that a the user is in front of a door and that if he presses a button it will open....

Sponsored Links
  1. #1

    Default collision detection

    Hi all!

    I'm trying to make a doom like game in the 3d engine of director, and have some collision questions. Well just one for now but theire will be more soon. Here it is; how can I see that one object collides with one other. For example I want director to detect that a the user is in front of a door and that if he presses a button it will open.


    Sponsored Links
    Seph webforumsuser@macromedia.com Guest

  2. #2

    Default Re: collision detection

    Hi!

    First you must to enable models for detect collisions

    Scene.model[x].addmodifier(#collision)

    now you will have access to collision properties

    scene.model[x].collision.Property

    if you want detect if the player is in front of someting you must create a transparent object that defines an area around the door.

    scene.model[x].collision.stcollisioncallback(#myfunction, me)

    in this way, whenever model[x] (your player) collide with any other object with collision enabled myfunction will run

    I hope you have understood, my english is very bad.

    Fivan


    fivan webforumsuser@macromedia.com Guest

  3. #3

    Default Re: collision detection

    Hi!

    First you must to enable models for detect collisions

    Scene.model[x].addmodifier(#collision)

    now you will have access to collision properties

    scene.model[x].collision.Property

    if you want detect if the player is in front of someting you must create a transparent object that defines an area around the door.

    scene.model[x].collision.stcollisioncallback(#myfunction, me)

    in this way, whenever model[x] (your player) collide with any other object with collision enabled myfunction will run

    I hope you have understood, my english is very bad.

    Fivan


    fivan webforumsuser@macromedia.com Guest

  4. #4

    Default Re: collision detection

    to Seph : but be sure that Director's collision modifier is damn slow or better say unusable - especially for game like Doom... ;)


    Demonator webforumsuser@macromedia.com Guest

  5. #5

    Default Re: collision detection

    "if you want detect if the player is in front of someting you must create a transparent object that defines an area around the door."

    I am fairly new to this so tell me to shut up if I'm wrong but, wouldn't it be better on frame rate and easier to program by adding a small object and using:

    if camVector.distanceTo(pDoorSwitchTrigger.worldPosit ion) < 100 then ?

    to detect if the camera is next to an object?

    Only use a more advanced collision code if you have to?


    Michaelcov webforumsuser@macromedia.com Guest

  6. #6

    Default Re: collision detection

    Michaelcov, you're vector idea sounds really good, but I have no Idea how to do it. I've tryed a few different ways, but all gave me a error. Here are two different ways;
    if w.model("CharDummy").worldPosition = w.model("TriggerObject").worldPosition < 100 then
    put "x"
    end if
    &
    vector1 = w.model("CharDummy").vector
    vector2 = w.model("TriggerObject").vector
    if vector1.distanceTo(vector2.worldPosition) < 100 then
    put "x"
    end if

    By the way, Fivan you're english doesn't seem bad, or a least not worse as mine.

    Thanx for the help so far everybody



    Seph webforumsuser@macromedia.com Guest

  7. #7

    Default Re: collision detection


    i have made a little test with the collisionmodifier, you can see it when
    you gotonetpage: [url]http://kisd.de/~lutz/digitalag/games/cubes2.htm[/url]
    there i put on the collision on and off, if the distance between two models
    is smaller then a variable.

    the code of this is not optimized and the *.dir file is about 7MB to
    download, i am sorry about this but till now i had not the time to opimize
    it. this shockwave3D was made without any concept as i startet and finally
    it works but i think you can read the code. DOWNLOAD >>> click right mouse
    and save --- [url]http://kisd.de/~lutz/homepage/html/directdownload.html[/url] ---

    you can use the arrowkeys for going forwart and backward, rotating left and
    right. use the keys w = going up, s = going down, a = steer left, d = steer
    right.
    there are some more keys i think q,e,r,f but you will see what they are good
    for.

    every time the cubes become transparent (softwarerenderer) or red wire
    (hardwarerenderer) the collision of the camere objekt and the collision of
    the cube that is near to the camera.

    i hope that it will help you.


    [url]http://kisd.de/~lutz/digitalag/games/cubes2.htm[/url]
    [url]http://kisd.de/~lutz/homepage/html/directdownload.html[/url]


    hondo3000 webforumsuser@macromedia.com Guest

  8. #8

    Default Collision Detection

    Hi there people,

    I've created a world in max 6 and have imported the file into Director mx
    2004. I've got the cursor keys working so i can run around my world of
    dinosaurs:D. The problem is, I have to use collision detection in director
    though. Could someone please tell me how i'm supposed to do it for an object,
    at least then I can implement it on all my objects. I'm new to director so
    please act as if I'm thick, thanks. If it helps, my camera is called cam and
    the first wall is called wall1.

    ShiviSchuey Guest

  9. #9

    Default Re: Collision Detection

    read up on the collision modifier in the director doentation, and
    investigate the havok xtra. imho the collision modifier is easier to implement,
    but the havok xtra is far more robust. [url]http://oldsite.havok.com/xtra/[/url]

    Ex Malterra Guest

  10. #10

    Default Collision Detection

    Good day

    A collision detector is used to (obviously) detect a collision, but how can I
    detect if there is no collision? I want to perform an action when an object is
    not colliding with another object. (I want to create this action without
    Havok!)
    Can you help me?

    Vincent is Schattig Guest

  11. #11

    Default Re: Collision Detection

    have a look at this zipped dir file, there you will see one method.

    [url]http://kisd.de/~lutz/crap/collision.zip[/url]

    its done with a collision callback handler, its very simple , just have a look.


    hondo3000 Guest

  12. #12

    Default Re: Collision Detection

    Thank you, but I am searching for a more direct approach than used in your
    example. A syntax more like :

    If collision = false then....

    I need this by the way to make gravity. I want to make a ball role and if
    there is a continues gravity while the ball is on te ground, it will not role
    anymore. So I need to detect if there is collision so I can put gravity on when
    the ball has no underground (>>there is no collicion)

    Vincent is Schattig Guest

  13. #13

    Default Re: Collision Detection

    Thanks Hondo3000, I'd been putting the go #next in the collision handler, without success.
    Altering a variable there and checking it in the exitFrame routine did the trick.
    optics42 Guest

  14. #14

    Default Re: Collision Detection

    to optics:
    yes there was a technote about going to a maker or something similar and that
    it will not work in the collisioncallback handler. but i am not sure about it
    ?

    to Vincent:
    i dont know what you are thinking about. if you know when a collision happens
    then you even know when no collision happens.

    if collision=true then
    nothing
    else
    do something
    end if




    hondo3000 Guest

  15. #15

    Default Collision detection

    Hello.
    I want to make 3d aplication where you can move through a building created in
    3d studio max. This aplication is for the imobiliare market. The problem is
    that if i want o make a building with furniture the 3d objects contain too many
    polygons and the collision detection will slow it very much (the raycast way).
    What is the optimal collision detection algorithm? Do you know a tutorial for
    something like this?
    If i want to make an building editor, meaning that the user has a building and
    some other objects made in 3d studio max (a furniture library). The user should
    put the furniture objects where he wants to in the building. is this possible
    in macromedia director? can u help me with some tips? maybe with a tutorial
    somewhere (if you know one)...
    Thank you for your time.
    Cheers.:confused;

    DANGH_b Guest

  16. #16

    Default Re: Collision detection

    DANGH_b wrote:
    > Hello.
    > I want to make 3d aplication where you can move through a building created in
    > 3d studio max. This aplication is for the imobiliare market. The problem is
    > that if i want o make a building with furniture the 3d objects contain too many
    > polygons and the collision detection will slow it very much (the raycast way).
    > What is the optimal collision detection algorithm? Do you know a tutorial for
    > something like this?
    > If i want to make an building editor, meaning that the user has a building and
    > some other objects made in 3d studio max (a furniture library). The user should
    > put the furniture objects where he wants to in the building. is this possible
    > in macromedia director? can u help me with some tips? maybe with a tutorial
    > somewhere (if you know one)...
    > Thank you for your time.
    > Cheers.:confused;
    >
    Hi. It´s very unlikely that you need all your visible geometry included
    in the raycasting. A good optimization technique is to build proxy
    geometry. If you have a chair you might do a box around it and check
    collisions against the box.

    For avoiding that extra geometry on the scene, you can make a group
    with the proxy geometry and addToWorld() the group before performing the
    raycasting and then removeFromWorld() the group.

    Using modelsUnderRay() in Director MX2004 allows you to choose which
    models participate in the collision. For earlier versions, the best
    approach is to make a group with the visible ´high poly´ geometry,
    remove it from world and add it after the raycasting. Here´s an example
    of the pre 2004 technique:

    -- if the UP key is pressed
    if keyPressed(126) then
    pCamera.transform.translate(2 * camTransfZ.x, 0, 2 * camTransfZ.z)

    -- remove visible geometry from the world
    pGroupOfModelsNotColliding.removeFromWorld()
    --add proxy geometry
    pGroupOfProxyMesh.addToWorld()
    tList = pMember.modelsUnderRay(cameraPos, camTransfZ,1,#detailed)
    -- add visible geometry back to the world
    pGroupOfModelsNotColliding.addToWorld()
    --remove proxy geometry
    pGroupOfProxyMesh.removeFromWorld()

    -- if there are models in front of the camera check for collisions
    if tList.count then
    me.checkForCollision(tList[1])
    end if
    end if

    Hope that helps,
    --
    Agustín María Rodríguez | Partner
    Methanoia Studio | [url]http://www.methanoia.com[/url]
    ---------------------------------------------------
    [url]www.onwine.com.ar[/url] > Macromedia Director demos & code
    Agustín María Rodríguez Guest

  17. #17

    Default Collision Detection

    Hi.

    I try to handle collisions on a screen.

    I use modelsUnderRay method to control the collisions.

    To handle +ve X axis I use the below code and that works.
    collisionListX = p3Dmember.modelsUnderRay(boxPos,
    pCharacter.transform.xAxis,3, #detailed)

    I try to handle Y axis and I write this code, but that one does not work.
    collisionListY = p3Dmember.modelsUnderRay(boxPos,
    pCharacter.transform.yAxis,3, #detailed)

    Can somebody help me.

    Thanks....






    acelep Guest

  18. #18

    Default Re: Collision Detection

    I assume that there is a mesh which you expecting your ray to detect. What
    direction are the normals to this mesh facing? If they are facing away from
    the ray, then the ray will not detect the surface of the mesh.

    A ray will only detect a mesh the first time it encounters the mesh. If you
    have a mesh in the shape of a Z, for example, and fire a ray at it from below,
    the ray may pass through the mesh three times, but only the first "impact" will
    be detected.

    If a ray goes precisely through the vertex of a mesh, it may not be detected:
    you can see a demonstration of this
    http://nonlinear.openspark.com/tips/3D/missvertex/ It might help to fire your
    ray at a slight angle to the yAxis.

    openspark Guest

  19. #19

    Default Re: Collision Detection

    thanks for your reply openSpark.
    acelep Guest

Similar Threads

  1. Using ModelsUnderRay Collision detection
    By Roofy in forum Macromedia Director 3D
    Replies: 1
    Last Post: June 28th, 04:45 AM
  2. 3d collision detection
    By needhelp2005 in forum Macromedia Director 3D
    Replies: 0
    Last Post: May 9th, 10:33 PM
  3. Breaking Collision Detection
    By HTiARW in forum Macromedia Director 3D
    Replies: 2
    Last Post: May 2nd, 03:49 PM
  4. Havok Collision Detection
    By Rastermaster in forum Macromedia Director 3D
    Replies: 3
    Last Post: March 8th, 07:40 PM
  5. Collision detection Problem
    By saraInfoWave webforumsuser@macromedia.com in forum Macromedia Director 3D
    Replies: 1
    Last Post: October 13th, 01:53 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