AsaMovshovitz
05-24-2008, 08:05 AM
Hi,
I started working on this script to learn a little about maxscript which is very new to me
and have a little problem in one of the steps.
it is a very basic start of a arm and leg ik setup based on a few points in space.
button 1 creates a few point which I place where ever the joints are.
button 2 creates 2 bone chains (based on a code I found in the threads by PEN)
button 3 align the bones to the points (this is were the I have a problem)
button 4 creates IK chains and controls.
on step 3, when I align the bones to the position of the the points they break up but still holding the hierarchy.
does anybody knows why that might happen?
Thanks
Asa
here the script
code:
--01 create points for leg and
--02 create bones
--03 align bones create ik
--04 create controls
------------------------------------------------------------------------
rollout test_buttons "create rig"
(
button theButton "points" width:80 height:25
button createButton "Create Bone" width:80 height:25
button alignButton "align bone" width:80 height:25
button controlsButton "controls" width:80 height:25
----------------------------------------------------------------------
--create points
on theButton pressed do
for i = 1 to 3 do
(
p = point pos:[i*25,0,0]
p2 = point pos:[0,0,i*-25]
)
-----------------------------------------------------------------------------
--create bones
--for i = 1 to 3 do
on createButton pressed do
(
(
joints=#()
stPos=#([0,0,0],[0,-25,-100],[0,0,-200],[0,0,-205])
dir=[0,1,0]
)
(
jointsC=#()
stPosC=#([0,0,0],[100,50,0],[180,-40,0],[188.944,-45,0])
dirC=[0,0,1]
)
for i = 1 to 3 do
(
b=boneSys.createBone stPos[i] stPos[i+1] dir
if i>1 then b.parent=joints[i-1]
append joints b
)
for i = 1 to 3 do
(
c=boneSys.createBone stPosC[i] stPosC[i+1] dirC
if i>1 then c.parent=jointsC[i-1]
append jointsC c
)
)
-------------------------------------------------------------------------------
on alignButton pressed do
(
$Bone01.pos = $point01.pos
$Bone02.pos = $point03.pos
$Bone03.pos = $point05.pos
$Bone04.pos = $point02.pos
$Bone05.pos = $point04.pos
$Bone06.pos = $point06.pos
iksys.ikchain $Bone01 $Bone03 "IKHISolver"
iksys.ikchain $Bone04 $Bone06 "IKHISolver"
)
on controlsButton pressed do
(
for i = 1 to 2 do
(
for i = 1 to 2 do
(
circle radius:10
)
$Circle01.pos=$Point05.pos
$Circle02.pos=$Point06.pos
select $'IK Chain01'
$.parent = $Circle01
select $'IK Chain02'
$.parent = $Circle02
)
)
)
createDialog test_buttons 150 150
I started working on this script to learn a little about maxscript which is very new to me
and have a little problem in one of the steps.
it is a very basic start of a arm and leg ik setup based on a few points in space.
button 1 creates a few point which I place where ever the joints are.
button 2 creates 2 bone chains (based on a code I found in the threads by PEN)
button 3 align the bones to the points (this is were the I have a problem)
button 4 creates IK chains and controls.
on step 3, when I align the bones to the position of the the points they break up but still holding the hierarchy.
does anybody knows why that might happen?
Thanks
Asa
here the script
code:
--01 create points for leg and
--02 create bones
--03 align bones create ik
--04 create controls
------------------------------------------------------------------------
rollout test_buttons "create rig"
(
button theButton "points" width:80 height:25
button createButton "Create Bone" width:80 height:25
button alignButton "align bone" width:80 height:25
button controlsButton "controls" width:80 height:25
----------------------------------------------------------------------
--create points
on theButton pressed do
for i = 1 to 3 do
(
p = point pos:[i*25,0,0]
p2 = point pos:[0,0,i*-25]
)
-----------------------------------------------------------------------------
--create bones
--for i = 1 to 3 do
on createButton pressed do
(
(
joints=#()
stPos=#([0,0,0],[0,-25,-100],[0,0,-200],[0,0,-205])
dir=[0,1,0]
)
(
jointsC=#()
stPosC=#([0,0,0],[100,50,0],[180,-40,0],[188.944,-45,0])
dirC=[0,0,1]
)
for i = 1 to 3 do
(
b=boneSys.createBone stPos[i] stPos[i+1] dir
if i>1 then b.parent=joints[i-1]
append joints b
)
for i = 1 to 3 do
(
c=boneSys.createBone stPosC[i] stPosC[i+1] dirC
if i>1 then c.parent=jointsC[i-1]
append jointsC c
)
)
-------------------------------------------------------------------------------
on alignButton pressed do
(
$Bone01.pos = $point01.pos
$Bone02.pos = $point03.pos
$Bone03.pos = $point05.pos
$Bone04.pos = $point02.pos
$Bone05.pos = $point04.pos
$Bone06.pos = $point06.pos
iksys.ikchain $Bone01 $Bone03 "IKHISolver"
iksys.ikchain $Bone04 $Bone06 "IKHISolver"
)
on controlsButton pressed do
(
for i = 1 to 2 do
(
for i = 1 to 2 do
(
circle radius:10
)
$Circle01.pos=$Point05.pos
$Circle02.pos=$Point06.pos
select $'IK Chain01'
$.parent = $Circle01
select $'IK Chain02'
$.parent = $Circle02
)
)
)
createDialog test_buttons 150 150
