3 Replies Latest reply on Jun 12, 2011 6:38 AM by Necromanthus

    3D Model Size

    even-1 Level 1

      Hi,

       

      With this script i want to find out the size of 3d model. But it does not work correctly: some models has the same size like in 3d program, other has a diferent size. Specialy by models with more than 1 mesh is the size calculation not corect. What is wrong on my script?

       

        myworld = member("3dmember")
        myworld.model (1).addModifier(#meshdeform)


      myvertexlist = (myworld.model[1].meshdeform.mesh[1].vertexlist)
        maxmin = [myvertexlist.max().x,myvertexlist.min().x,myvertexlist.max().y,myvertexlist.min().y,myve rtexlist.max().z,myvertexlist.min().z]

       

          repeat with n = 1 to myworld.model[1].meshdeform.mesh.count
          Nvertexlist = (myworld.model[1].meshdeform.mesh[n].vertexlist)
          if Nvertexlist.max().x > getAt(maxmin, 1) then
            setAt maxmin, 1, Nvertexlist.max().x
          end if
          if Nvertexlist.min().x < getAt(maxmin, 2) then
            setAt maxmin, 2, Nvertexlist.min().x
          end if
          if Nvertexlist.max().y > getAt(maxmin, 3) then
            setAt maxmin, 3, Nvertexlist.max().y
          end if
          if Nvertexlist.min().y < getAt(maxmin, 4) then
            setAt maxmin, 4, Nvertexlist.min().y
          end if
          if Nvertexlist.max().z > getAt(maxmin, 5) then
            setAt maxmin, 5, Nvertexlist.max().z
          end if
          if Nvertexlist.min().z < getAt(maxmin, 6) then
            setAt maxmin, 6, Nvertexlist.min().z
          end if
        end repeat

       

        SizeX = getat (maxmin, 1) - getat (maxmin, 2)
        SizeY = getat (maxmin, 3) - getat (maxmin, 4)
        SizeZ = getat (maxmin, 5) - getat (maxmin, 6)

       

        put SizeX * 2.54
        put SizeY * 2.54
        put SizeZ * 2.54

       

       

      Thanks for any ideas.

        • 1. Re: 3D Model Size
          Necromanthus Level 2

          Don't waste your time with this kind of  scripts.

          Click on Window / Object Inspector and drag the W3D member into that window.

          See the models and check out the boundingSphere property for each one.

          The last number shows the sphere’s radius.

          That's more than enough to get an idea about their size.

          At runtime use "transform.scale" to tune up their size (if needed).

           

          cheers

          • 2. Re: 3D Model Size
            even-1 Level 1

            Sure, boundingSphere is the easy way to control the object size, but it is not enough for working with real objects like furniture, wich has accurately definded height, width and length sizes. Imagine scenario: you import wrong scaled model into 3d world, you know the real sizes(height, width, length) of the model. Which scale factor you need to correct the model size?

            • 3. Re: 3D Model Size
              Necromanthus Level 2

              even-1 wrote:

               

              Imagine scenario: you import wrong scaled model into 3d world, you know the real sizes(height, width, length) of the model. Which scale factor you need to correct the model size?

               

              I never had to deal with that scenario in the past 10 years.

              Simply because I own the sources of the 3D models.

              A W3D file is not a source file and Director Shockwave is not a 3D modeler.

               

              cheers