This code has been declared by its author to be Public Domain code.
Download source code | Mid3dhandle() function by Bot Builder | 2003 |
| |
|
It's pretty simple. All it does is take the maximum and minumum of x,y,and z, calculate the average, and move the vertices in such a way that the locational handle matches the average. So basically, if you've ever been annoyed with non-center handles, positioning your object far away from where you want it, use the Mid3dhandle() function. |
Function Mid3dHandle(mesh)
ux#=-100000
uy#=-100000
uz#=-100000
lx#=100000
ly#=100000
lz#=100000
cs=CountSurfaces(mesh)
For s=1 To cs
surf=GetSurface(mesh,s)
cv=CountVertices(surf)-1
For v=0 To cv
vx#=VertexX#(surf,v)
vy#=VertexY#(surf,v)
vz#=VertexZ#(surf,v)
If vx#<lx# Then lx#=vx#
If vx#>ux# Then ux#=vx#
If vy#<ly# Then ly#=vy#
If vy#>uy# Then uy#=vy#
If vz#<lz# Then lz#=vz#
If vz#>uz# Then uz#=vz#
Next
Next
ax#=(ux#+lx#)/2
ay#=(uy#+ly#)/2
az#=(uz#+lz#)/2
PositionMesh mesh,-ax#,-ay#,-az#
End Function |
Comments |
Yep this is pretty all round usefull. Would be could as an in built function
|
Code Archives Forum