So I was trying to see if I can distort some geometry using some sort of equation using max script. Spherical projections would work for nearly every type of geometry so I tried using
Stereographic Projection.
And emulated the equation in max script.
rollout projectRollout "Project"
(
button projectbtn "Project"
on projectbtn pressed do
(
convertTo $ PolyMeshObject
modPanel.addModToSelection (Edit_Poly ()) ui:on
obj = $
subobjectLevel = 1
modPanel.setCurrentObject $.modifiers[#Edit_Poly]
for i = 1 to obj.GetNumVertices() do
(
print(obj.GetVertex i)
vert = obj.GetVertex i
x = vert.x/1 - vertz
y = vert.y/1 - vertz
z = 0
newvert = [x,y,z]
print newvert
polyop.setVert obj i newvert
)
update obj
)
)
createdialog projectRollout
I tried to do it in 3d space rather then 2d space in max script and got this error.
Should I be doing something like this in UV space? I would think that having the Z be 0 would still give me the same effect. And if I was to have it be in UV space, how would I go about converting UV space geometry into 3D space like how textools does it?
Replies
You may want to add a "with redraw off" context to speed things up and "with undo on" to reduce program granularity.
But some of the meshes really mess up when it attempts to move a vertice to 30 different locations. Is there a way to split these vertices when this happens? Or a way to make each faces its own element?
Something like:
It's not tested but should work, at least give you an idea.
Another optimization trick is with polyOp methods aliases. I don't know if it is the same for GetVertex, but some of these functions actually are slow and lead to memory leaks/bloat. Functions aliases solve the issue:
I experienced this issue with almost all methods which actually query the geometry database for some information, like get vertex position and get face normal or center.
as divisions/mul come first in math, but the equation presented is different