Getting worldPosition of group of models

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

  1. #1

    Default Getting worldPosition of group of models

    Hi,

    I have troubles getting the position of a group of models. The group
    consists of a bunch of box models created with Lingo. Director documentation
    says I can use worldPosition with a group, but all it returns is
    vector(0,0,0). If I target a single model directly, it does return the correct
    vector.

    Is it not possible to get the worldPosition of a group of models, or am I
    missing something?

    Wriker Guest

  2. Similar Questions and Discussions

    1. "group by" - order of rows in group
      this is simple example: TABLE SCHEMA: create table my_table( id int unsigned not null auto_increment primary key, project varchar(255) not...
    2. 3D models
      just a quick question, what do you guys think is the best software to use when designing 3D models for use in director or flash?
    3. May 29 Sydney Developers Group study group
      On Monday 29th May, we'll be studying Actionscript 3. Please read the articles prior to the meeting (see <a target=_blank...
    4. Offsetting a model's worldPosition in modelsUnderRay
      Im using the modelsUnderRay to project a beam from my moving model to detect collisions. Its working just fine, but what I would like is to be able...
    5. cfgrid inside a <cfoutput query="myQuery" group="GROUP">
      Is it possible to use a cfgrid inside a cfoutput with a query and a group. When I try do that I get the following error: INVALID_CHARACTER_ERR:...
  3. #2

    Default Re: Getting worldPosition of group of models

    the group is not automatically the average worldposition of all models you put in. you have to calculate the position of the group by hand before you put the models in.

    regards!
    hondo3000 Guest

  4. #3

    Default Re: Getting worldPosition of group of models

    I was afraid of that, I guess I'm still thinking too much "in sprites".

    I think I'll best just get the worldPosition of one of the models in the group and do some math from there.
    Wriker Guest

  5. #4

    Default Re: Getting worldPosition of group of models

    you can group sprites ?
    :-)

    in fact the it is the naming, that may confuse.
    a group is a node, just like a model, a camera and a light. a node has a
    transform and a parent and an array of children.
    there are some other common properties of nodes like for example all of them
    have a property userdata.
    a group is just the minimum node type with no further "features". a model can
    have a modelresource as a feature and several properties, which determine how
    the modelresource gets rendered.
    that's it more or less.
    you could completely ignore groups and use models with void modelresources
    instead of groups. they act and behave exactly the same.
    but in no case it would make sense, if the transform of the group changed,
    depending on the transforms of its children.
    what you would want means, you move a child in the group and the position of
    the group in the world would magically change?
    You wouldn't have much fun with that, for sure.

    a?ex Guest

  6. #5

    Default Re: Getting worldPosition of group of models

    What I was trying do to, by the way, is rotate the group of models around an
    axis that is on the outside of the group -- i.e. like opening a door. To open a
    door that opens to the left, I need an axis that is on the leftmost position of
    the door. If it opens to the right, the axis is on the right side.

    When working with sprites, you can easily get the leftpos or the rightpos of a
    sprite, but that's not so easy in 3-D. ;-)

    Wriker Guest

  7. #6

    Default Re: Getting worldPosition of group of models

    [q]Originally posted by: Wriker
    What I was trying do to, by the way, is rotate the group of models around an
    axis that is on the outside of the group -- i.e. like opening a door. To open a
    door that opens to the left, I need an axis that is on the leftmost position of
    the door. If it opens to the right, the axis is on the right side.

    When working with sprites, you can easily get the leftpos or the rightpos of a
    sprite, but that's not so easy in 3-D. ;-)[/q]

    Acutally there is a simple way of doing this in 3d. There are 2 things you can
    do.

    1. if you know where this outside of the group axis is located, then do this...

    yourGroup.rotate(yourOutsideAxisPosition, whichAxisYouWantToRotateAbout,
    yourAngle)

    2. if you do not know the outside position, then do this...
    2a. before you do anything, and if you do not have 3DPI, I would recommend
    downloading it at [url]http://www.3dpi-director.com/[/url]. In there you will find the
    link to download and also a link for the tutorials. Otherwise continue to the
    next step.

    2b. create a new box in 3DPI, and then play with its position so that the new
    box is located to the position of where you want this some known outside
    position to be and note down the position where you have placed you new box.
    Note... this does not accually create the new box for you. You will need to put
    the below script that I give you to acually create the box.

    2c. in your behaviour script that controls the rotation, place this following
    line of code at the very top of the behaviour script before any of the handlers
    that get called...

    property pModel

    2d. before accessing the rotation in your behaviour script, setup the
    following script inside your on beginSprite handler

    --create a new modelresource and make the visabillty not to be viewable by
    setting the last argument to #none
    mr = member("your3DMember").newModelResource("NameOfMod elResource", #box,
    #none)
    mdl = member("your3DMember").newModel("NameOfNewModel", mr)
    mdl.trasnsform.position = the position that you have noted from 3DPI
    pModel = mdl

    2e. By doing the above script, you have created an invisable box that can be
    used as an axis like a door hinge. You would use its position in replace of the
    position of what is your outside of the group position like so...

    yourGroup.rotate(pModel.transform.position, yourAxisYouWantToRotateAbout,
    yourAngle)

    also note that the "yourAxisYouWantToRotateAbout" is a vector that says you
    either want the object to rotate along the x axis which would be set to
    vector(1, 0, 0), or along the yAxis which is set to vector(0, 1, 0), or along
    the z axis which is set to vector(0, 0, 1), or a combintation like so...
    example vector(1, 1, 0) will rotate an object along both the x and y axises.

    HTH,
    roofy

    Roofy 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