Notifications
Clear all
[Closed] Distance constraint maxscript
Jun 17, 2014 10:47 pm
Hi, Im very new with maxscript and Im trying to make a tentacle using spring controllers, I have some part of the script working, but what I cant get is some way to limit the distance between the points so the tentacle doesnt change its lenght, the scripts working on the selected objects, so if you have a line o helpers selected you run the script and create the bones between the points. Is there any way to get a distance constraint?
fn creaHuesoEntreSelecciones ancho alto tapersito MassStrenght DragStrenght Tension Dampening =
(
bns=#()
pts = selection as array
for i = 1 to pts.count-1 do
(
crearHuesos= bonesys.createbone (pts[i].pos) (pts[i+1].pos) [0,0,1]
crearHuesos.name = ("huesito_"+i as string)
)
creaHuesoFinal=bonesys.createbone (pts[pts.count].pos) (pts[pts.count].pos) [0,0,1]
creaHuesoFinal.length=5
creaHuesoFinal.name= ("huesito_"+pts.count as string)
--AÑADE LOS HUESOS A BNS COMO ARRAY
bns = $huesito_* as array
--AÑADE LOS HUESOS A PTS COMO ARRAY
pts= selection as array
bns.width= ancho
bns.Height= alto
bns.taper= tapersito
--CREA LOS POSITION CONSTRAINT Y LOS LOOK AT CONSTRAINT A LOS HUESOS
for i = 1 to bns.count do
(
if bns[i] != bns[1] then bns[i].parent = bns[i-1]
bns[i].position.controller =position_constraint()
bns[i].position.controller.appendtarget pts[i] 100
bns[i].rotation.controller =lookAt_constraint target_axis:0 upnode_axis:2 StoUP_axis:2 lookat_vector_length:0
if bns[i] != bns[bns.count] then bns[i].rotation.controller.appendtarget pts[i+1] 100 else 0
bns[i].rotation.controller.pickupnode=pts[i]
bns[i].rotation.controller.upnode_world=false
-- bns[i].boneScaleType = #scale
-- print pts[i].pos
)
--CREA LOS POSITION SPRING CONTROLERS A LOS PUNTOS
for i= 1 to pts.count do
(
if pts[i] != pts[1] then pts[i].parent = pts[i-1]
ctrlSpring= pts[i].pos.controller= SpringPositionController()
ctrlSpring.setMass MassStrenght
ctrlSpring.setDrag DragStrenght
ctrlSpring.setTension 1 Tension
ctrlSpring.setDampening 1 Dampening
)
select bns
)
rollout CreaCadenaEntreSelecciones "CreateBones"
(
group "bone Properties"(
spinner UI_width "width" range:[1,100,2]
spinner UI_height "height"range:[1,100,2]
spinner UI_taper "taper" range:[1,100,2]
)
group "spring Properties"(
spinner UI_Mass "mass" range:[1,2000,300]
spinner UI_Drag "drag" range:[1,10,1]
spinner UI_Tension "Tension" range:[1,9999,2]
spinner UI_Dampening "dampening" range:[0.1,100,0.5]
)
button CreateBones "CreateBones"
on CreateBones pressed do
(
creaHuesoEntreSelecciones (UI_width.value) (UI_height.value) (UI_taper.value) (UI_Mass.value) (UI_Drag.value) (UI_Tension.value) (UI_Dampening.value)
)
)
createDialog CreaCadenaEntreSelecciones
1 Reply