Skip to content

Instantly share code, notes, and snippets.

@JokerMartini
Created February 19, 2016 20:20
Show Gist options
  • Save JokerMartini/d58d084ec495a152c3aa to your computer and use it in GitHub Desktop.
Save JokerMartini/d58d084ec495a152c3aa to your computer and use it in GitHub Desktop.
Maxscript finds the center point of a mesh.
fn GetCenter pts =
(
local center = [0,0,0]
minPt = copy pts[1]
maxPt = copy pts[1]
for p in pts do
(
/* Find the min pt3 values */
if p.x < minPt.x do minPt.x = p.x
if p.y < minPt.y do minPt.y = p.y
if p.z < minPt.z do minPt.z = p.z
/* Find the max pt3 values */
if p.x > maxPt.x do maxPt.x = p.x
if p.y > maxPt.y do maxPt.y = p.y
if p.z > maxPt.z do maxPt.z = p.z
)
center = (minPt + maxPt) / 2.0
return center
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment