Professional Web Applications Themes

A reverse Modelunderloc? - Macromedia Director 3D

Is there a way of returning a 2D reference (ie on the 3d sprite) from a model in a 3d environment? Basically I want to create an 2D overlay on the sprite to indicate the position of a 3d object....

  1. #1

    Default A reverse Modelunderloc?

    Is there a way of returning a 2D reference (ie on the 3d sprite) from a model in a 3d environment?

    Basically I want to create an 2D overlay on the sprite to indicate the position of a 3d object.
    kingdegen Guest

  2. #2

    Default Re: A reverse Modelunderloc?

    Hi there,

    Check out worldSpaceToSpriteSpace( ) that should do the job nicely.

    The returned point is relative the the top left of the camera's rect. Be
    careful, as it returns void if the object's centre is off camera.

    Hope that helps

    Rix


    Richard Guest

  3. #3

    Default Re: A reverse Modelunderloc?

    Thanks. An odd thing had happened though. I'm overlaying some text to indicate
    a postion, and when it starts it is viisble. It stays with the model, But when
    the camera moves so that the model is out of view and then back again, the text
    doesn't reappear.

    I swear I'm being unlucky, I've had so many odd problems recently. Text isn't
    updating on screen, debugger is kicking up an error with the first handler in a
    script where there is no problems (I had to put a dummy handler that doesn't
    get called just to be able to run the app in authoring mode..).
    I'm having to find workarounds to problems that shouldn't be there... I going
    to learn C++ after my finals are through...

    kingdegen Guest

  4. #4

    Default Re: A reverse Modelunderloc?

    Hi there,

    "kingdegen" <webforumsusermacromedia.com> wrote in message
    news:c5v6uu$660$1forums.macromedia.com...
    > Thanks. An odd thing had happened though. I'm overlaying some text to
    indicate
    > a postion, and when it starts it is viisble. It stays with the model, But
    when
    > the camera moves so that the model is out of view and then back again, the
    text
    > doesn't reappear.
    Maybe you are setting the overlay loc to void when the object is off screen
    ? This might make the loc unusable. Only update the overlay loc when the
    worldSpaceToSpriteSpace() returns successfully.

    That's all I can suggest at the moment.

    Rix


    Richard Guest

  5. #5

    Default Re: A reverse Modelunderloc?

    Here's a snippet of the code
    on enterframe
    vector0 = member("world").model("mymodel").worldposition
    pos2d = sprite(1).camera.worldSpaceToSpriteSpace(vector0)
    if pos2d <> void then
    member("world").camera(1).addOverlay(member("world ").Texture("sign" ),
    pos2d, 0)
    end if
    end

    on exitframe
    member("world").camera(1).removeOverlay(1)
    end

    If the "mymodel" is in view when the camera starts then the overlay is visible.
    If "mymodel" moves but is still visible then the overlay follows the model
    If "mymodel" moves out of the camera view then void is returned and the
    overlay is not visible.
    But when "mymodel" is back in the cameras view, so that the
    worldSpaceToSpriteSpace returns a x & y point the overlay does not reappear....

    kingdegen Guest

  6. #6

    Default Re: A reverse Modelunderloc?

    I found a solution!!!!

    A slight adjustment...

    on enterframe
    vector0 = member("world").model("mymodel").worldposition
    pos2d = sprite(1).camera.worldSpaceToSpriteSpace(vector0)
    if pos2d <> void then
    [h]member("world").camera(1).removeOverlay(1)[/h]
    member("world").camera(1).addOverlay(member("world ").Texture("sign"
    ), pos2d, 0)
    end if
    end

    And now it works!!!!

    No why did moving it from exitframe to before the .addoverlay in enterframe
    cause it not to disappear???
    Director has many, many quirks...

    kingdegen Guest

  7. #7

    Default Re: A reverse Modelunderloc?

    Hi there,

    I think it was a logical order problem rather than a Director glitch.

    Instead of creating and deleting the overlay every frame you can create it
    just once on beginSprite, and then just update it's backdrop.loc property.
    That should speed it up too.

    Cheers

    Richard


    Richard Guest

  8. #8

    Default Re: A reverse Modelunderloc?

    I knew there had to be a way to move the overlay. The Help file didn't have
    that under overlay. But can't use that unless I can set the overlay to a
    specific index.

    The reason is because I want to track say 4 models with overlays. And I
    already have an overlay as a border. I track the overlays by using a repeat loop

    on enterframe
    repeat with i = 1 to 4
    vector0 = member("world").model("mymodel" & i).worldposition
    pos2d = sprite(1).camera.worldSpaceToSpriteSpace(vector0)
    if pos2d <> void then
    member("world").camera(1).removeOverlay( i + 1) -- Because the first overlay
    stays (It's a border)
    member("world").camera(1).addOverlay(member("world ").Texture("sign" & i),
    pos2d, 0)
    end repeat
    end if
    end

    kingdegen Guest

  9. #9

    Default Re: A reverse Modelunderloc?

    kingdegen wrote:
    > The reason is because I want to track say 4 models with overlays. And I
    > already have an overlay as a border. I track the overlays by using a repeat loop
    Hi. You might want to explore Toxi´s overlay manager [url]www.toxi.co.uk[/url] >
    overlay manager.

    HTH,
    --
    Agustín María Rodríguez | [email]agustinOnWine.com.ar[/email] | [url]www.OnWine.com.ar[/url]

    Agustín María Rodríguez Guest

Similar Threads

  1. Reverse like query?
    By Rune in forum MySQL
    Replies: 8
    Last Post: January 27th, 01:55 PM
  2. modelUnderLoc
    By yogeshhungama in forum Macromedia Director 3D
    Replies: 1
    Last Post: August 31st, 04:48 PM
  3. reverse framebuster
    By Christian Adelbrecht in forum Macromedia Dynamic HTML
    Replies: 0
    Last Post: October 27th, 09:38 AM
  4. Reverse DNS lookup
    By willjay in forum SCO
    Replies: 3
    Last Post: July 7th, 01:57 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