3 Replies Latest reply on Feb 6, 2007 7:04 AM by duckets

    Getting the size from a model

    SuperTank
      Hello
      How can I 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. Re: Getting the size from a model
          duckets Level 1
          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
          • 2. Re: Getting the size from a model
            tedalde2 Level 2
            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 farthest-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.
            • 3. Re: Getting the size from a model
              duckets Level 1
              I thought I had something like this lying around somewhere. Sure enough, here it is (attached below).

              Enjoy!