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

  1. #1

    Default 2d to 3d

    Hi
    I have a Director MX2004 movie which allows users to create a floor plan and
    add furniture shapes in 2d, then display a 3d world shwoing the furniture in
    the "room".
    In the 3d world, I've created a plane and added a texture which is the 2d
    floorplan sprite as drawn by the user. Could someone advise how best to
    scale and position the floorplan and the furniture objects in the 3d world
    in the same relative positions as the user has put them in 2d?


    Charlie Allgrove Guest

  2. #2

    Default Re: 2d to 3d

    Charlie Allgrove wrote:
    > Hi
    > I have a Director MX2004 movie which allows users to create a floor plan and
    > add furniture shapes in 2d, then display a 3d world shwoing the furniture in
    > the "room".
    > In the 3d world, I've created a plane and added a texture which is the 2d
    > floorplan sprite as drawn by the user. Could someone advise how best to
    > scale and position the floorplan and the furniture objects in the 3d world
    > in the same relative positions as the user has put them in 2d?
    >
    >
    Hi. Two quick ideas comes to mind. Use spriteSpaceToWorldSpace()
    function to convert 2D coordinates into 3D or work with percentages.
    Suppose that your 2D floorplan sprite is 200x200 pixels, then 100 pixels
    = 0,5, 200px = 1 and so on...

    Now suppose that your 3D floorplan is made of 1500x1500 3d units. Then
    when the user clicks on the middle of the 2D sprite, that will be
    traduced as 0.5x0.5 of the 2D sprite, now you multiply that number for
    the 3D units (1500*0.5) and you get 750x750.

    You´ll probably have to apply offsets and make tweaks but the main idea
    is that you convert the 2D value to 0..1 by doing for example
    clickedPointX / float(spriteWidth) and then you multiply it by the with
    of the 3D floorplan.

    Hope that helps,
    --
    Agustín María Rodríguez

    [url]www.onwine.com.ar[/url] > Macromedia Director demos & code
    Agustín María Rodríguez Guest

  3. #3

    Default Re: 2d to 3d

    Thanks for that...I'll have a play and see how I get on!


    Charlie Allgrove Guest

  4. #4

    Default Re: 2d to 3d

    Hi

    I think I'm getting somewhere...but I'm new(ish) to Director and I'm not
    entirely certain about 3d units vs 2d units...

    I'm creating a plane in the 3d world and setting the width and length of the
    modelResource to a maximum of 320x240px with a scale of 1.
    Are these the 3dunits?
    I'm then taking the 2d positions of the furniture elements and converting
    them to the same point in the 3d world according to a calculated scale
    factor, but the positions do not appear to be correct...

    Any ideas gratefully received

    Charlie

    "Agustín María Rodríguez" <agustin@onwine.com.ar> wrote in message
    news:e5hh5j$bfh$1@forums.macromedia.com...
    > Charlie Allgrove wrote:
    >
    >> Hi
    >> I have a Director MX2004 movie which allows users to create a floor plan
    >> and add furniture shapes in 2d, then display a 3d world shwoing the
    >> furniture in the "room".
    >> In the 3d world, I've created a plane and added a texture which is the 2d
    >> floorplan sprite as drawn by the user. Could someone advise how best to
    >> scale and position the floorplan and the furniture objects in the 3d
    >> world in the same relative positions as the user has put them in 2d?
    >
    > Hi. Two quick ideas comes to mind. Use spriteSpaceToWorldSpace() function
    > to convert 2D coordinates into 3D or work with percentages. Suppose that
    > your 2D floorplan sprite is 200x200 pixels, then 100 pixels = 0,5, 200px =
    > 1 and so on...
    >
    > Now suppose that your 3D floorplan is made of 1500x1500 3d units. Then
    > when the user clicks on the middle of the 2D sprite, that will be traduced
    > as 0.5x0.5 of the 2D sprite, now you multiply that number for the 3D units
    > (1500*0.5) and you get 750x750.
    >
    > You´ll probably have to apply offsets and make tweaks but the main idea is
    > that you convert the 2D value to 0..1 by doing for example clickedPointX /
    > float(spriteWidth) and then you multiply it by the with of the 3D
    > floorplan.
    >
    > Hope that helps,
    > --
    > Agustín María Rodríguez
    >
    > [url]www.onwine.com.ar[/url] > Macromedia Director demos & code

    Charlie Allgrove Guest

  5. #5

    Default Re: 2d to 3d

    Charlie Allgrove wrote:
    > Hi
    >
    > I think I'm getting somewhere...but I'm new(ish) to Director and I'm not
    > entirely certain about 3d units vs 2d units...
    >
    > I'm creating a plane in the 3d world and setting the width and length of the
    > modelResource to a maximum of 320x240px with a scale of 1.
    > Are these the 3dunits?
    > I'm then taking the 2d positions of the furniture elements and converting
    > them to the same point in the 3d world according to a calculated scale
    > factor, but the positions do not appear to be correct...
    If you don´t have it, download and install 3DPI
    ([url]http://www.3dpi-director.com/[/url]). Use it for picking a model and change
    its position. Every time you press the increase/decrease button for the
    position value, you´re moving the model one 3D unit.

    It doesn´t have anything to do with the 3D sprite size. To know the
    boundaries of your 3D floorplan, move any model to the top left of the
    floorplan and watch its position in the 3DPI xtra, then move it to the
    bottom right position of the floorplan and check it´s position. You´ll
    get values like this:

    dummy model´s position when placed top left: vector(25, 80, 15)
    dummy model´s position when placed bottom right: vector(75, 180, 15)

    Suppousing you got those values, now you know that the floorplan´s
    width is 50 units (75 - 25) and its height is 100 (180 - 80).

    Now suppouse that you click on the 2D floorplan and you get 0.25 on X
    axis and 0.5 on the Y axis. With those values you can now find the 3D
    equivalent position:

    x_3D_pos = topLeft3DVector.x + floorPlanWidth * 2D_XclickedProportion
    x_3D_pos = 25 + 50 * 0.25
    x_3D_pos = 25 + 12.5
    x_3D_pos = 37.5

    and y_3D_pos would be 130, that is: 80 of offset + (100 of width * 0.5
    of 2Dfloorplan proportion).

    I hope this isn´t too messy for you.

    Regards,
    --
    Agustín María Rodríguez

    [url]www.onwine.com.ar[/url] > Macromedia Director demos & code
    Agustín María Rodríguez 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