Wednesday, 13 March 2013

Box-based Spheres

So you primitive sphere has nasty pinching and wasteful geometry... and while your geosphere may be more efficient, it's not very nice for unwrapping. So I prefer to use box-based spheres. Quadded, with 8 tripoles, and unwrapped neatly into six square segments, they're generally nicer to work with. But they're a bit of a fiddle to create, using a box, turbosmooth and spherify modifier. So I made a script that makes them for you, replacing an existing sphere...

SCENARIO
  • You want to make box-based spheres easily
USAGE
  • create a sphere the conventional way and select it
  • run script
  • a new box-based sphere is created at the object's location
  • if DeleteObject setting is true, the old object will be deleted
  • adjust box segments and turbosmooth iterations as desired


  
  
-- USAGE
-- create a sphere the conventional way and select it
-- run script
-- a new box-based sphere is created at the object's location
-- if DeleteObject setting is true, the old object will be deleted
-- adjust box segments and turbosmooth iterations as desired

-- SETTINGS
DeleteObject = true -- should the selected object(s) be deleted?

objarray = getcurrentselection()
max modify mode

for obj in objarray do (
 -- get size
 lengthx = (obj.max.x - obj.min.x)
 lengthy = (obj.max.y - obj.min.y)
 lengthz = (obj.max.z - obj.min.z)
 size = (lengthx + lengthy + lengthz) / 3 * 1.18
 
 newsphere = Box lengthsegs:1 widthsegs:1 heightsegs:1 length:size width:size height:size mapcoords:on pos:[obj.center.x,obj.center.y,(obj.center.z - (size / 2))] isSelected:on
 newsphere.pivot = newsphere.center
 select newsphere
 TS = TurboSmooth ()
 TS.iterations = 3
 modPanel.addModToSelection (TS) ui:on
 modPanel.addModToSelection (Spherify ()) ui:on
 newsphere.wirecolor = obj.wirecolor
 
 if DeleteObject then (delete obj)
)
  

No comments:

Post a Comment