Skip navigation
Currently Being Moderated

3D Model Size

Jun 8, 2011 2:05 PM

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,myver texlist.min().y,myvertexlist.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.

 
Replies
  • Currently Being Moderated
    Jun 10, 2011 10:41 AM   in reply to even-1

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 12, 2011 6:38 AM   in reply to even-1

    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

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points