Professional Web Applications Themes

Getting the size from a model - Macromedia Director 3D

Hello How I can get the size of a model (from a *.w3d-file). The model does not contain the properties width, height or length, so I guess that I have to measure the distance between the models vertices. But I can't seem to think of a good way to do it in. I guess a loop of some kind? But it would seem rather unomptimized to actually loop through each and every vertex point in the model I wan't measured. Any suggestions?...

  1. #1

    Default Getting the size from a model

    Hello
    How I can get the size of a model (from a *.w3d-file). The model does not
    contain the properties width, height or length, so I guess that I have to
    measure the distance between the models vertices.
    But I can't seem to think of a good way to do it in. I guess a loop of some
    kind? But it would seem rather unomptimized to actually loop through each and
    every vertex point in the model I wan't measured.

    Any suggestions?

    SuperTank Guest

  2. #2

    Default Re: Getting the size from a model

    You can quickly get the bounding sphere radius of a model using this:

    theRadius = scene("myScene").model("car").boundingSphere[2]

    Otherwise, if you want the axis-aligned width, length and height, you will
    have to add the meshdeform modifier, and loop through every vertex.

    - Ben

    duckets Guest

  3. #3

    Default Re: Getting the size from a model

    The closest thing to model's dimensional properties is the model's
    boundingSphere property. It gives a radius of an imaginary sphere that contains
    all the vertices of the model; the sphere's diameter is the distance between
    the two hest-apart vertices. However it includes the model's children in
    the sphere. Set yourModel.debug = TRUE to see it.

    You could loop through each model, add a mesh deform modifier, go through each
    mesh[ ].vertexlist, keep track of each max and min x, y, and z value, the
    calculate w, l, h from that. It would take a little time... you probably
    wouldn't want to do it every frame. But you could do it on a keypress or
    something.

    tedalde2 Guest

  4. #4

    Default Re: Getting the size from a model

    I thought I had something like this lying around somewhere. Sure enough, here
    it is (attached below).

    Enjoy!



    on getModelSize cModel

    cmodel.addModifier(#meshDeform)

    maxVertices = void

    repeat with meshNum=1 to cmodel.meshdeform.mesh.count

    repeat with vertexNum = 1 to
    cmodel.meshdeform.mesh[meshNum].vertexList.count

    cvertex = cmodel.meshdeform.mesh[meshNum].vertexList[vertexNum]

    if voidp(maxVertices) then

    maxVertices = cVertex.duplicate()
    minVertices = cVertex.duplicate()

    else

    if cVertex.x > maxVertices.x then
    maxVertices.x = cVertex.x
    end if
    if cVertex.y > maxVertices.y then
    maxVertices.y = cVertex.y
    end if
    if cVertex.z > maxVertices.z then
    maxVertices.z = cVertex.z
    end if

    if cVertex.x < minVertices.x then
    minVertices.x = cVertex.x
    end if
    if cVertex.y < minVertices.y then
    minVertices.y = cVertex.y
    end if
    if cVertex.z < minVertices.z then
    minVertices.z = cVertex.z
    end if
    end if

    end repeat
    end repeat

    xSize = maxVertices.x-minVertices.x
    ySize = maxVertices.y-minVertices.y
    zSize = maxVertices.z-minVertices.z

    return [#x:xSize,#y:ySize,#z:zSize]

    end

    duckets Guest

Similar Threads

  1. New release of Config-Model, first draft for Xorg model
    By Dominique in forum PERL Modules
    Replies: 2
    Last Post: September 24th, 03:22 PM
  2. New release of Config::Model with fstab model example
    By Dominique Dumont in forum PERL Modules
    Replies: 0
    Last Post: May 22nd, 12:08 PM
  3. model showing in 3d editor but not in castmember model list
    By Gianpiero Colagiacomo in forum Macromedia Director 3D
    Replies: 1
    Last Post: May 6th, 02:05 AM
  4. Problem picking model under another model
    By Bazmati webforumsuser@macromedia.com in forum Macromedia Director 3D
    Replies: 5
    Last Post: October 6th, 12:37 PM
  5. Model within model transform.position, intersection, overlapping models
    By Zafada webforumsuser@macromedia.com in forum Macromedia Director 3D
    Replies: 0
    Last Post: August 30th, 12:30 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