Professional Web Applications Themes

Interaction with a 3D Cube - Macromedia Director 3D

I?m developing a webpage where it has to be a 3D cube, and each of its faces has to point to a different URL. I have already constructed and shaded the cube. I have also coded the part of the rotation of the cube. But I still not find the part where the click on a certain face lead me to a specified URL. I wrote this code in order to find the way to know wich face has been clicked: ************************************************** ****************************** ************************************************** * on mouseUp me returnData = member("3D").camera[1].modelsUnderLoc(the mouseLoc,#detailed) member("TXTcara").text = "You clicked on face " && ...

  1. #1

    Default Interaction with a 3D Cube

    I?m developing a webpage where it has to be a 3D cube, and each of its faces
    has to point to a different URL. I have already constructed and shaded the
    cube. I have also coded the part of the rotation of the cube. But I still not
    find the part where the click on a certain face lead me to a specified URL.

    I wrote this code in order to find the way to know wich face has been clicked:




    ************************************************** ******************************
    ************************************************** *

    on mouseUp me
    returnData = member("3D").camera[1].modelsUnderLoc(the mouseLoc,#detailed)
    member("TXTcara").text = "You clicked on face " && returnData[1].faceID
    end


    ************************************************** ******************************
    *************************************************
    where TXTcara is a textfield on the stage where I print which face has been
    clicked



    But it always says me that I clicked on face 1 or face 2. I mean a cube has 6
    faces... and this code says that it has only two!!

    How can I cerainly know wich face has been clicked??

    The cube was constructed as a box.

    Bukue Guest

  2. #2

    Default Re: Interaction with a 3D Cube

    the face is the polygon and not the face of the cube.
    if you use the built-in modelresource than each face of the cube has a
    seperate shader (look at the models shaderlist). I am pretty sure, you will
    assign different shaders to the different clickable cube faces. so you will
    need to get the shader which was clicked on.
    this information is the #meshID of the picking data which is returned by the
    picking functions (modelunderloc and modelunderray), if set to #detailed.

    so in your case:

    on mouseUp me
    returnData = member("3D").camera[1].modelsUnderLoc(the mouseLoc,#detailed)
    member("TXTcara").text = "You clicked on face " && returnData[1].meshID
    end



    I guess your snippet is a fast sample to point out the problem, but just in
    case...you should check, if a model was hit in the first place and often the
    above behavior is on the 3-D sprite and if you have only one camera you could
    get away with all the hardcode (member name, camera index etc.) with:

    on mouseUp me
    sp = sprite(me.spritenum)
    ml = the mouseLoc - point(sp.left, sp.top)
    cam = sp.camera
    returnData = cam.modelsUnderLoc(ml, #detailed)
    if count(returnData) > 0 then member("TXTcara").text = "You clicked on face
    " && returnData[1].meshID
    end


    a?ex Guest

  3. #3

    Default Re: Interaction with a 3D Cube

    Thank you very much!! It works perfect!! =D
    Bukue Guest

Similar Threads

  1. cube surfaces
    By clive306 in forum Macromedia Director 3D
    Replies: 9
    Last Post: July 9th, 12:17 PM
  2. Damn Cube!
    By rlragona in forum Macromedia Freehand
    Replies: 9
    Last Post: April 9th, 08:59 PM
  3. create 3d cube
    By neville2 webforumsuser@macromedia.com in forum Macromedia Director Basics
    Replies: 3
    Last Post: January 14th, 12:39 AM
  4. selecting cube faces
    By jellyfishjam webforumsuser@macromedia.com in forum Macromedia Director 3D
    Replies: 2
    Last Post: October 16th, 05:27 PM
  5. Cube mapping possible in SW3D
    By markus halbritter in forum Macromedia Director 3D
    Replies: 2
    Last Post: August 24th, 06:15 AM

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