[Closed] Bone Chain Controller
I’m looking for the most fast and accurate way to create chain of objects constrained on the spline. There is couple ways to achieve this, but because my target version is 3dsMax 2018 and above, I decided to use scripted-plugin controller. now my questions are:
1 – Is this true that: this is not good solution to create so many objects in the scene for calculating transformation? Instead we must create transformation matrix with formula?
2 – What is the most accurate mathematical formula to create transformation matrix?
3 – Is it true that we cannot solve flip problem for ALL axis and at least one axis will remain with flip problem?
This is my first try that (except for one axis -x) works fine. but new problem is that objects will move noisy on playback. where is the problem?
plugin TransformController PathConstraint
name:"PathConstraint"
classID:#(0x47db1cad, 0x4e9b5f9d)
(
parameters Params
(
Spline_Node type:#node
Steps type:#Integer
Index type:#Integer
)
on getValue do
(
if not isvalidnode Spline_Node then matrix3 1 else
(
-- Position
Pos = lengthInterp Spline_Node (Index as float / Steps)
TargetPos = lengthInterp Spline_Node ((Index + 1) as float / Steps)
-- Quaternion Rotation
TargetVector = normalize (TargetPos - Pos)
Axis = normalize (cross TargetVector [1,0,0])
Degrees = acos (dot TargetVector [1,0,0])
Rot = Quat Degrees Axis
-- Transformation Matrix
TM = matrix3 1
rotate TM Rot
translate TM Pos
TM
)
)
)
Steps = 15
with redraw off
(
delete objects
-- Spline
Spline = splineshape wirecolor:yellow
addnewSpline Spline
for P in #([0,0,0],[50,0,0],[100,0,0]) do addKnot Spline 1 #Smooth #curve P
updateShape Spline
HelperList = for i = 1 to 3 collect point box:on cross:off wirecolor:orange
addmodifier Spline (Spline_IK_Control linkTypes:2 helper_list:HelperList)
classof Spline
-- Animate Spline
animate on
(
at time 100 HelperList[2].pos = [50,0,20]
)
-- Create Objects
for i = 0 to Steps - 1 do
(
o = teapot wirecolor:white radius:5
o.transform.controller = PathConstraint Steps:Steps Index:i Spline_Node:Spline
)
)