Hi, iwe been struggling with a somewhat geometry math related situation.
I got such good help here last time i asked a question so i thought id ask another.
I tried searching through the forums but i couldnt find a similar working solution for maxscript.
So the main goal is to basically replicate the looptools->space function in graphitemodelingtools (3ds max) in maxscript.
I already wrote a function some time ago that gives me arrays of sorted vertex loops from edgeloop selections.
Sorted as in for an open loop the first array index is the first vert on the edgeloop, second index is the second vert in the edgeloop and so on.
But im at a loss about how to determine the new positions for the verts.
I got as far as determining the total length of the edgeloop by using PolyOp.GetVert to get vert position.
Then adding to the distance via distance "last vertex position" "vertex postion".
Then getting the even distance between each vert by dividing with the amount of verts in the set.
The issue now is that how do i determine the actual new worldspace position each vertex should get along the loop.
unfinished code snippet:
Note the AspDev.GetVertPosition/AspDev.SetVertPosition are just wrappers for polyop.GetVert/SetVert.
for vertSet in sortedVertSets do
(
local vertCount = vertSet.count
local loopLength = 0
local pvPos
--finish calls to getVertPosition
local vPosArray = for vert in vertSet collect
(
vPos = AspDev.GetVertPosition modOrObj vert node:node
if classOf pvPos == point3 do loopLength += (distance pvPos vPos)
--store last vPos
pvPos = vPos
--finally collect current vPos to vPosarray
vPos
)
local pointA = vPosArray[1]
local pointB = vPosArray[vertCount]
--this should have the correct spacing distance??
local loopSpacing = loopLength / vertCount
--what now?
--batch setVert op
AspDev.SetVertPosition modOrObj vertSet vPosArray node:node
)
Thanks in advance
Replies
maybe just drop in some interpolation function and sample it the desired steps?
Keep in mind that im not very knowledgable about math equations.
Thanks for the link btw. Had not seen these exact implimentations before.
Im imagining building a mxs struct that builds and caches the interpolation curve from the points. Can then be called to evaluate a point along the curve. Kindof like the animationCurve class in unity3D. I know this kindof thing would be much faster if implimented in c++ or even dotnet. But im trying to stick to pure mxs for this project for simplicity.
I'm not sure how different that'd be from a standard smooth curve by default but I imagine you could weight it by edge length or something.
Maybe try creating an animation curve instead. The auto tangents prevent overshoot. Then convert the trajectory to a max spline, then use interpCurve3D to get a position on the path.
He provided me with a simple interpolation method that factored in each changed position in the spacing in addition to total length.