2014년 1월 12일 일요일

바이패드 복사 본 만들기 ver1

bips = #()
bons = #()
boneName = ""
boundingBox = undefined
bipLength = undefined
bipwidth = undefined
bipheight = undefined
objs = selection as array
cNameValue = "Bone"

fn changeName strs oldStr newStr =
(
findFlag = findstring strs oldStr
if (findFlag != undefined) do
(
changeStr = replace strs findFlag oldStr.count newStr
)
changeStr
)

if objs.count == 0 then 
(
messagebox "바이패드 노드를 하나 이상 선택하세요."
)

else
(
$'bip01'.transform.controller.figureMode = true
$'Bip01'.transform.controller.trianglePelvis = false
$'Bip01'.transform.controller.triangleNeck = true
rollout bipMirrbone "흉내 내기본 생성"
(
edittext newNameText "Bip 대신 넣을 이름" text:"Bone"
checkbox twistBon_chk "트위스트본사용" checked:false width:200
checkbox autoNeck_chk "자동본사용" checked:false width:200
Button start_btn  "실행"

on newNameText changed txt do
(
cNameValue = txt
)

on start_btn pressed do
(

for i = 1 to objs.count do
(
if((classof objs[i] == Biped_Object) and (objs[i].name != "Bip01 Footsteps")) do append bips objs[i]
)

clearSelection()

for i = 1 to bips.count do
(
boneName = bips[i].name

boneName = changeName boneName "Bip" cNameValue

boundingBox = nodeGetBoundingBox bips[i]bips[i].transform
bipLength = boundingBox[2].x
bipheight = boundingBox[2].y
bipwidth = boundingBox[2].z
madeBone = Bonesys.createBone[0,0,0][1,0,0][0,0,1]
madeBone.name = boneName
madeBone.width = bipWidth
madeBone.height = bipheight
madeBone.length = bipLength
madeBone.boxmode = on
madeBone.rotation = (inverse(biped.getTransform bips[i] #rotation))
madeBone.position = (bips[i].transform.pos)

if((autoNeck_chk.checked == true)and(matchPattern bips[i].name pattern:"*Neck" == true)) then
(
madeBone.rotation.controller= Orientation_Constraint()
madeBone.rotation.controller.appendTarget bips[i].parent 50.0
madeBone.rotation.controller.appendTarget bips[i].children[1] 50.0
)
else if((autoNeck_chk.checked == true)and(matchPattern bips[i].name pattern:"*Head" == true)) then
(
madeBone.rotation.controller= Orientation_Constraint()
madeBone.rotation.controller.appendTarget bips[i] 50.0

)
else
(
madeBone.position.controller = Position_Constraint() 
madeBone.position.controller.appendTarget bips[i] 50.0
madeBone.rotation.controller= Orientation_Constraint()
madeBone.rotation.controller.appendTarget bips[i] 50.0
)

append bons madeBone
)

for i = 1 to bips.count do
(
if(bips[i].parent != undefined) do
(
parentBip = bips[i].parent
boneName = parentBip.name

boneName = changeName boneName "Bip" cNameValue

bons[i].parent = execute("$'" + boneName + "'")
)
)

if(twistBon_chk.checked == true) do
(
if((execute  ("$'" + cNameValue + "01 L Clavicle'") != undefined) and (execute  ("$'" + cNameValue + "01 L UpperArm'") != undefined) and (execute  ("$'" + cNameValue + "01 L Forearm'") != undefined)) do
(
-- 왼쪽 어께트위스트1 더미
Point_L_UpperArmTwist02 = point()
Point_L_UpperArmTwist02.name = "Point_L_UpperArmTwist02"
Point_L_UpperArmTwist02.size = 2.0
Point_L_UpperArmTwist02.box = false
Point_L_UpperArmTwist02.cross = true
Point_L_UpperArmTwist02.rotation = (inverse(biped.getTransform $'Bip01 L UpperArm' #rotation))
Point_L_UpperArmTwist02.pos = ($'Bip01 L UpperArm'.transform.pos)
Point_L_UpperArmTwist02.parent =(execute  ("$'" + cNameValue + "01 L Clavicle'"))
Point_L_UpperArmTwist02.pos.controller = Position_Expression()
Point_L_UpperArmTwist02.parent =  (execute  ("$'" + cNameValue + "01 L UpperArm'"))
Point_L_UpperArmTwist02.wirecolor = (color 10 10 10)

-- 왼쪽 어께트위스트2 더미
Point_L_UpperArmTwist01 = point()
Point_L_UpperArmTwist01.name = "Point_L_UpperArmTwist01"
Point_L_UpperArmTwist01.size = 2.0
Point_L_UpperArmTwist01.box = true
Point_L_UpperArmTwist01.cross = false
Point_L_UpperArmTwist01.rotation = (inverse(biped.getTransform $'Bip01 L Clavicle' #rotation))
Point_L_UpperArmTwist01.pos = ($'Bip01 L Clavicle'.transform.pos)
Point_L_UpperArmTwist01.parent = (execute  ("$'" + cNameValue + "01 L Clavicle'"))
Point_L_UpperArmTwist01.rotation.controller=LookAt_Constraint()
Point_L_UpperArmTwist01.rotation.controller.appendTarget $'Point_L_UpperArmTwist02' 50.0
Point_L_UpperArmTwist01.rotation.controller.viewline_length_abs = false
Point_L_UpperArmTwist01.rotation.controller.upnode_world = false
Point_L_UpperArmTwist01.rotation.controller.pickUpNode = (execute  ("$'" + cNameValue + "01 L Clavicle'"))
Point_L_UpperArmTwist01.wirecolor = (color 10 10 10)

-- 왼쪽 어께 트위스트1,2 본
LUpperArmTwist01 = Bonesys.createBone[0,0,0][1,0,0][0,0,1]
LUpperArmTwist01.name = boneName +"01 L UpperArmTwist01"
LUpperArmTwist01.width = ((execute  ("$'" + cNameValue + "01 L UpperArm'")).width) * 0.8
LUpperArmTwist01.height = ((execute  ("$'" + cNameValue + "01 L UpperArm'")).height) * 0.8
LUpperArmTwist01.length = ((execute  ("$'" + cNameValue + "01 L UpperArm'")).length) / 4
LUpperArmTwist02 = Bonesys.createBone[(((execute  ("$'" + cNameValue + "01 L UpperArm'")).length) / 4),0,0][1,0,0][0,0,1]
LUpperArmTwist02.name = boneName + "01 L UpperArmTwist02"
LUpperArmTwist02.width = ((execute  ("$'" + cNameValue + "01 L UpperArm'")).width) * 0.8
LUpperArmTwist02.height = ((execute  ("$'" + cNameValue + "01 L UpperArm'")).height) * 0.8
LUpperArmTwist02.length = ((execute  ("$'" + cNameValue + "01 L UpperArm'")).length) / 3
LUpperArmTwist02.parent = LUpperArmTwist01
LUpperArmTwist01.rotation = (inverse(biped.getTransform $'Bip01 L UpperArm' #rotation))
LUpperArmTwist01.pos = ($'Bip01 L UpperArm'.transform.pos)
LUpperArmTwist01.parent = (execute  ("$'" + cNameValue + "01 L UpperArm'"))
LUpperArmTwist02.parent = (execute  ("$'" + cNameValue + "01 L UpperArm'"))
LUpperArmTwist01.rotation.controller=LookAt_Constraint()
LUpperArmTwist01.rotation.controller.appendTarget (execute  ("$'" + cNameValue + "01 L Forearm'"))  50.0
LUpperArmTwist01.rotation.controller.viewline_length_abs = false
LUpperArmTwist01.rotation.controller.upnode_world = false
LUpperArmTwist01.rotation.controller.pickUpNode = Point_L_UpperArmTwist01
LUpperArmTwist01.wirecolor = (color 10 10 10)
LUpperArmTwist01.boxmode = on

LUpperArmTwist02.rotation.controller=Orientation_Constraint()
LUpperArmTwist02.rotation.controller.appendTarget LUpperArmTwist01 60.0
LUpperArmTwist02.rotation.controller.appendTarget (execute  ("$'" + cNameValue + "01 L UpperArm'")) 40.0
LUpperArmTwist02.wirecolor = (color 10 10 10)
LUpperArmTwist02.boxmode = on
)

if((execute  ("$'" + cNameValue + "01 R Clavicle'") != undefined) and (execute  ("$'" + cNameValue + "01 R UpperArm'") != undefined) and (execute  ("$'" + cNameValue + "01 R Forearm'") != undefined)) do
(
-- 오른쪽 어께트위스트1 더미
Point_R_UpperArmTwist02 = point()
Point_R_UpperArmTwist02.name = "Point_R_UpperArmTwist02"
Point_R_UpperArmTwist02.size = 2.0
Point_R_UpperArmTwist02.box = false
Point_R_UpperArmTwist02.cross = true
Point_R_UpperArmTwist02.rotation = (inverse(biped.getTransform $'Bip01 R UpperArm' #rotation))
Point_R_UpperArmTwist02.pos = ($'Bip01 R UpperArm'.transform.pos)
Point_R_UpperArmTwist02.parent =(execute  ("$'" + cNameValue + "01 R Clavicle'"))
Point_R_UpperArmTwist02.pos.controller = Position_Expression()
Point_R_UpperArmTwist02.parent =  (execute  ("$'" + cNameValue + "01 R UpperArm'"))
Point_R_UpperArmTwist02.wirecolor = (color 10 10 10)

-- 오른쪽 어께트위스트2 더미
Point_R_UpperArmTwist01 = point()
Point_R_UpperArmTwist01.name = "Point_R_UpperArmTwist01"
Point_R_UpperArmTwist01.size = 2.0
Point_R_UpperArmTwist01.box = true
Point_R_UpperArmTwist01.cross = false
Point_R_UpperArmTwist01.rotation = (inverse(biped.getTransform $'Bip01 R Clavicle' #rotation))
Point_R_UpperArmTwist01.pos = ($'Bip01 R Clavicle'.transform.pos)
Point_R_UpperArmTwist01.parent = (execute  ("$'" + cNameValue + "01 R Clavicle'"))
Point_R_UpperArmTwist01.rotation.controller=LookAt_Constraint()
Point_R_UpperArmTwist01.rotation.controller.appendTarget $'Point_R_UpperArmTwist02' 50.0
Point_R_UpperArmTwist01.rotation.controller.viewline_length_abs = false
Point_R_UpperArmTwist01.rotation.controller.upnode_world = false
Point_R_UpperArmTwist01.rotation.controller.pickUpNode = (execute  ("$'" + cNameValue + "01 R Clavicle'"))
Point_R_UpperArmTwist01.wirecolor = (color 10 10 10)

-- 오른쪽 어께 트위스트1,2 본
RUpperArmTwist01 = Bonesys.createBone[0,0,0][1,0,0][0,0,1]
RUpperArmTwist01.name = boneName +"01 R UpperArmTwist01"
RUpperArmTwist01.width = ((execute  ("$'" + cNameValue + "01 R UpperArm'")).width) * 0.8
RUpperArmTwist01.height = ((execute  ("$'" + cNameValue + "01 R UpperArm'")).height) * 0.8
RUpperArmTwist01.length = ((execute  ("$'" + cNameValue + "01 R UpperArm'")).length) / 4
RUpperArmTwist02 = Bonesys.createBone[(((execute  ("$'" + cNameValue + "01 L UpperArm'")).length) / 4),0,0][1,0,0][0,0,1]
RUpperArmTwist02.name = boneName + "01 R UpperArmTwist02"
RUpperArmTwist02.width = ((execute  ("$'" + cNameValue + "01 R UpperArm'")).width) * 0.8
RUpperArmTwist02.height = ((execute  ("$'" + cNameValue + "01 R UpperArm'")).height) * 0.8
RUpperArmTwist02.length = ((execute  ("$'" + cNameValue + "01 R UpperArm'")).length) / 4
RUpperArmTwist02.parent = RUpperArmTwist01
RUpperArmTwist01.rotation = (inverse(biped.getTransform $'Bip01 R UpperArm' #rotation))
RUpperArmTwist01.pos = ($'Bip01 R UpperArm'.transform.pos)
RUpperArmTwist01.parent = (execute  ("$'" + cNameValue + "01 R UpperArm'"))
RUpperArmTwist02.parent = (execute  ("$'" + cNameValue + "01 R UpperArm'"))
RUpperArmTwist01.rotation.controller=LookAt_Constraint()
RUpperArmTwist01.rotation.controller.appendTarget (execute  ("$'" + cNameValue + "01 R Forearm'"))  50.0
RUpperArmTwist01.rotation.controller.viewline_length_abs = false
RUpperArmTwist01.rotation.controller.upnode_world = false
RUpperArmTwist01.rotation.controller.pickUpNode = Point_R_UpperArmTwist01
RUpperArmTwist01.wirecolor = (color 10 10 10)
RUpperArmTwist01.boxmode = on

RUpperArmTwist02.rotation.controller=Orientation_Constraint()
RUpperArmTwist02.rotation.controller.appendTarget RUpperArmTwist01 60.0
RUpperArmTwist02.rotation.controller.appendTarget (execute  ("$'" + cNameValue + "01 R UpperArm'")) 40.0
RUpperArmTwist02.wirecolor = (color 10 10 10)
RUpperArmTwist02.boxmode = on
)

if((execute  ("$'" + cNameValue + "01 L Forearm'") != undefined) and (execute  ("$'" + cNameValue + "01 L Hand'") != undefined)) do
(
-- 왼쪽 손목 트위스트 본
L_ForearmTwist = Bonesys.createBone[0,0,0][1,0,0][0,0,1]
L_ForearmTwist.name = cNameValue + "01 L_ForearmTwist"
L_ForearmTwist.width = ((execute  ("$'" + cNameValue + "01 L Forearm'")).width) * 0.8
L_ForearmTwist.height = ((execute  ("$'" + cNameValue + "01 L Forearm'")).height) * 0.8
L_ForearmTwist.length = ((execute  ("$'" + cNameValue + "01 L Forearm'")).length) / 4
L_ForearmTwist.rotation = (inverse(biped.getTransform $'Bip01 L Forearm' #rotation))
L_ForearmTwist.pos = ($'Bip01 L Forearm'.transform.pos)
coordsys local move L_ForearmTwist [((execute  ("$'" + cNameValue + "01 L UpperArm'")).length) - (((execute  ("$'" + cNameValue + "01 L UpperArm'")).length) / 4),0,0]
L_ForearmTwist.parent = (execute  ("$'" + cNameValue + "01 L Forearm'"))
L_ForearmTwist.rotation.controller=LookAt_Constraint()
L_ForearmTwist.rotation.controller.appendTarget (execute  ("$'" + cNameValue + "01 L Hand'")) 50.0
L_ForearmTwist.rotation.controller.viewline_length_abs = false
L_ForearmTwist.rotation.controller.upnode_world = false
L_ForearmTwist.rotation.controller.pickUpNode = (execute  ("$'" + cNameValue + "01 L Hand'"))
L_ForearmTwist.wirecolor = (color 10 10 10)
L_ForearmTwist.boxmode = on
)

if((execute  ("$'" + cNameValue + "01 R Forearm'") != undefined) and (execute  ("$'" + cNameValue + "01 R Hand'") != undefined)) do
(
-- 오른쪽 손목 트위스트 본
R_ForearmTwist = Bonesys.createBone[0,0,0][1,0,0][0,0,1]
R_ForearmTwist.name = cNameValue + "01 R_ForearmTwist"
R_ForearmTwist.width = ((execute  ("$'" + cNameValue + "01 R Forearm'")).width) * 0.8
R_ForearmTwist.height = ((execute  ("$'" + cNameValue + "01 R Forearm'")).height) * 0.8
R_ForearmTwist.length = ((execute  ("$'" + cNameValue + "01 R Forearm'")).length) / 4
R_ForearmTwist.rotation = (inverse(biped.getTransform $'Bip01 R Forearm' #rotation))
R_ForearmTwist.pos = ($'Bip01 R Forearm'.transform.pos)
coordsys local move R_ForearmTwist [((execute  ("$'" + cNameValue + "01 R UpperArm'")).length) - (((execute  ("$'" + cNameValue + "01 R UpperArm'")).length) / 4),0,0]
R_ForearmTwist.parent = (execute  ("$'" + cNameValue + "01 R Forearm'"))
R_ForearmTwist.rotation.controller=LookAt_Constraint()
R_ForearmTwist.rotation.controller.appendTarget (execute  ("$'" + cNameValue + "01 R Hand'")) 50.0
R_ForearmTwist.rotation.controller.viewline_length_abs = false
R_ForearmTwist.rotation.controller.upnode_world = false
R_ForearmTwist.rotation.controller.pickUpNode = (execute  ("$'" + cNameValue + "01 R Hand'"))
R_ForearmTwist.wirecolor = (color 10 10 10)
R_ForearmTwist.boxmode = on
)

if(((execute  ("$'" + cNameValue + "01 L Thigh'")) != undefined) and ((execute  ("$'" + cNameValue + "01 L Calf'")) != undefined)) do
(
-- 왼쪽 허벅지 트위스트 ExposeTM
ExposeTransformL = ExposeTransform()
ExposeTransformL.name = "ExposeTransform L"
ExposeTransformL.size = 1.5
ExposeTransformL.box = true
ExposeTransformL.cross = false
ExposeTransformL.rotation = (inverse(biped.getTransform $'Bip01 L Thigh' #rotation))
ExposeTransformL.pos = ($'Bip01 L Thigh'.transform.pos)
ExposeTransformL.parent = (execute  ("$'" + cNameValue + "01 L Thigh'"))
ExposeTransformL.exposeNode = (execute  ("$'" + cNameValue + "01 L Calf'"))
ExposeTransformL.useParent = false
ExposeTransformL.localReferenceNode  = (execute  ("$'" + cNameValue + "01 Pelvis'"))
ExposeTransformL.wirecolor = (color 10 10 10)

-- 왼쪽 허벅지 트위스트 더미
PointLThigh = point()
PointLThigh.name = cNameValue + "01 Point L Thigh"
PointLThigh.size = 1.0
PointLThigh.box = false
PointLThigh.cross = true
PointLThigh.pos = ($'Bip01 Pelvis'.transform.pos)
coordsys local move PointLThigh [10,0,0]
PointLThigh.parent = (execute  ("$'" + cNameValue + "01 Pelvis'"))
reactContL = PointLThigh.pos.controller = Position_reactor()
PointLThigh.wirecolor = (color 10 10 10)

-- 왼쪽 허벅지 트위스트 본
L_ThighTwist = Bonesys.createBone[0,0,0][1,0,0][0,0,1]
L_ThighTwist.name = cNameValue + "01 L_ThighTwist"
L_ThighTwist.width = ((execute  ("$'" + cNameValue + "01 L Thigh'")).width) * 0.8
L_ThighTwist.height = ((execute  ("$'" + cNameValue + "01 L Thigh'")).height) * 0.8
L_ThighTwist.length = ((execute  ("$'" + cNameValue + "01 L Thigh'")).length) / 4
L_ThighTwist.rotation = (inverse(biped.getTransform $'Bip01 L Thigh' #rotation))
L_ThighTwist.pos = ($'Bip01 L Thigh'.transform.pos)
L_ThighTwist.parent = (execute  ("$'" + cNameValue + "01 L Thigh'"))
L_ThighTwist.rotation.controller=LookAt_Constraint()
L_ThighTwist.rotation.controller.appendTarget  (execute  ("$'" + cNameValue + "01 L Calf'")) 50.0
L_ThighTwist.rotation.controller.viewline_length_abs = false
L_ThighTwist.rotation.controller.upnode_world = false
L_ThighTwist.rotation.controller.pickUpNode = (execute  ("$'" + cNameValue + "01 L Thigh'"))
L_ThighTwist.rotation.controller.upnode_ctrl = 0
L_ThighTwist.rotation.controller.StoUP_axisFlip = true
L_ThighTwist.wirecolor = (color 10 10 10)
L_ThighTwist.boxmode = on

reactContL.reactTo $'ExposeTransform L'.localPosition.controller
)

if(((execute  ("$'" + cNameValue + "01 R Thigh'")) != undefined) and ((execute  ("$'" + cNameValue + "01 R Calf'")) != undefined)) do
(
-- 오른쪽 허벅지 트위스트 ExposeTM
ExposeTransformR = ExposeTransform()
ExposeTransformR.name = "ExposeTransform R"
ExposeTransformR.size = 1.5
ExposeTransformR.box = true
ExposeTransformR.cross = false
ExposeTransformR.rotation = (inverse(biped.getTransform $'Bip01 R Thigh' #rotation))
ExposeTransformR.pos = ($'Bip01 R Thigh'.transform.pos)
ExposeTransformR.parent = (execute  ("$'" + cNameValue + "01 R Thigh'"))
ExposeTransformR.exposeNode = (execute  ("$'" + cNameValue + "01 R Calf'"))
ExposeTransformR.useParent = false
ExposeTransformR.localReferenceNode  = (execute  ("$'" + cNameValue + "01 Pelvis'"))
ExposeTransformR.wirecolor = (color 10 10 10)

-- 오른쪽 허벅지 트위스트 더미
PointRThigh = point()
PointRThigh.name = cNameValue + "01 Point R Thigh"
PointRThigh.size = 1.0
PointRThigh.box = false
PointRThigh.cross = true
PointRThigh.pos = ($'Bip01 Pelvis'.transform.pos)
coordsys local move PointRThigh [-10,0,0]
PointRThigh.parent = ((execute  ("$'" + cNameValue + "01 Pelvis'")))
reactContR = PointRThigh.pos.controller = Position_reactor()
PointRThigh.wirecolor = (color 10 10 10)

-- 오른쪽 허벅지 트위스트 본
R_ThighTwist = Bonesys.createBone[0,0,0][1,0,0][0,0,1]
R_ThighTwist.name = cNameValue + "01 R_ThighTwist"
R_ThighTwist.width = ((execute  ("$'" + cNameValue + "01 R Thigh'")).width) * 0.8
R_ThighTwist.height = ((execute  ("$'" + cNameValue + "01 R Thigh'")).height) * 0.8
R_ThighTwist.length = ((execute  ("$'" + cNameValue + "01 R Thigh'")).length) / 4
R_ThighTwist.rotation = (inverse(biped.getTransform $'Bip01 R Thigh' #rotation))
R_ThighTwist.pos = ($'Bip01 R Thigh'.transform.pos)
R_ThighTwist.parent = (execute  ("$'" + cNameValue + "01 R Thigh'"))
R_ThighTwist.rotation.controller=LookAt_Constraint()
R_ThighTwist.rotation.controller.appendTarget  (execute  ("$'" + cNameValue + "01 R Calf'")) 50.0
R_ThighTwist.rotation.controller.viewline_length_abs = false
R_ThighTwist.rotation.controller.upnode_world = false
R_ThighTwist.rotation.controller.pickUpNode = (execute  ("$'" + cNameValue + "01 R Thigh'"))
R_ThighTwist.rotation.controller.upnode_ctrl = 0
R_ThighTwist.wirecolor = (color 10 10 10)
R_ThighTwist.boxmode = on

reactContR.reactTo $'ExposeTransform R'.localPosition.controller
)
)
select bons
destroydialog bipMirrbone
)
)
createdialog bipMirrbone
)

추가 할것은 
1. 본이름을 생성할때 이름을 정할 수 있도록 할것.
2. 목이 머리와 가슴의 중간값을 유지하도록 하는것.(이건 고민좀 할것 같다.)
3. 어께 손목 허벅지등의 트위스트 본 추가 선택.

어찌어찌 다 추가 했다.
허벅지 트위스트본을  리액터메니저가 아닌 방식을 사용하는것에 대해서 구현 할까 하지만 우선 이것으로도 내가 필요한 기능은 다 구현됐다.
차후에 생각해 봐야겠다.

2014년 1월 7일 화요일

바이패드 복사 본 만들기 ver0.4

bips = #()
bons = #()
boneName = ""
boundingBox = undefined
bipLength = undefined
bipwidth = undefined
bipheight = undefined
objs = selection as array
cNameValue = "Bone"

fn changeName strs oldStr newStr =
(
findFlag = findstring strs oldStr
if (findFlag != undefined) do
(
changeStr = replace strs findFlag oldStr.count newStr
)
changeStr
)

if objs.count == 0 then 
(
messagebox "바이패드 노드를 하나 이상 선택하세요."
)

else
(
$'bip01'.transform.controller.figureMode = true
$'Bip01'.transform.controller.trianglePelvis = false
$'Bip01'.transform.controller.triangleNeck = true
rollout bipMirrbone "흉내 내기본 생성"
(
edittext newNameText "Bip 대신 넣을 이름" text:"Bone"
checkbox twistBon_chk "트위스트본사용" checked:false width:200
Button start_btn  "실행"

on newNameText changed txt do
(
cNameValue = txt
)

on start_btn pressed do
(

for i = 1 to objs.count do
(
if((classof objs[i] == Biped_Object) and (objs[i].name != "Bip01 Footsteps")) do append bips objs[i]
)

clearSelection()

for i = 1 to bips.count do
(
boneName = bips[i].name

boneName = changeName boneName "Bip" cNameValue

boundingBox = nodeGetBoundingBox bips[i]bips[i].transform
bipLength = boundingBox[2].x
bipheight = boundingBox[2].y
bipwidth = boundingBox[2].z
madeBone = Bonesys.createBone[0,0,0][1,0,0][0,0,1]
madeBone.name = boneName
madeBone.width = bipWidth
madeBone.height = bipheight
madeBone.length = bipLength
madeBone.boxmode = on
madeBone.rotation = (inverse(biped.getTransform bips[i] #rotation))
madeBone.position = (bips[i].transform.pos)
madeBone.position.controller = Position_Constraint() 
madeBone.position.controller.appendTarget bips[i] 50.0
madeBone.rotation.controller= Orientation_Constraint()
madeBone.rotation.controller.appendTarget bips[i] 50.0

append bons madeBone
)

for i = 1 to bips.count do
(
if(bips[i].parent != undefined) do
(
parentBip = bips[i].parent
boneName = parentBip.name

boneName = changeName boneName "Bip" cNameValue

bons[i].parent = execute("$'" + boneName + "'")
)
)

if(twistBon_chk.checked == true) do
(
if((execute  ("$'" + cNameValue + "01 L Clavicle'") != undefined) and (execute  ("$'" + cNameValue + "01 L UpperArm'") != undefined) and (execute  ("$'" + cNameValue + "01 L Forearm'") != undefined)) do
(
-- 왼쪽 어께트위스트1 더미
Point_L_UpperArmTwist02 = point()
Point_L_UpperArmTwist02.name = "Point_L_UpperArmTwist02"
Point_L_UpperArmTwist02.size = 2.0
Point_L_UpperArmTwist02.box = false
Point_L_UpperArmTwist02.cross = true
Point_L_UpperArmTwist02.rotation = (inverse(biped.getTransform $'Bip01 L UpperArm' #rotation))
Point_L_UpperArmTwist02.pos = ($'Bip01 L UpperArm'.transform.pos)
Point_L_UpperArmTwist02.parent =(execute  ("$'" + cNameValue + "01 L Clavicle'"))
Point_L_UpperArmTwist02.pos.controller = Position_Expression()
Point_L_UpperArmTwist02.parent =  (execute  ("$'" + cNameValue + "01 L UpperArm'"))
Point_L_UpperArmTwist02.wirecolor = (color 10 10 10)

-- 왼쪽 어께트위스트2 더미
Point_L_UpperArmTwist01 = point()
Point_L_UpperArmTwist01.name = "Point_L_UpperArmTwist01"
Point_L_UpperArmTwist01.size = 2.0
Point_L_UpperArmTwist01.box = true
Point_L_UpperArmTwist01.cross = false
Point_L_UpperArmTwist01.rotation = (inverse(biped.getTransform $'Bip01 L Clavicle' #rotation))
Point_L_UpperArmTwist01.pos = ($'Bip01 L Clavicle'.transform.pos)
Point_L_UpperArmTwist01.parent = (execute  ("$'" + cNameValue + "01 L Clavicle'"))
Point_L_UpperArmTwist01.rotation.controller=LookAt_Constraint()
Point_L_UpperArmTwist01.rotation.controller.appendTarget $'Point_L_UpperArmTwist02' 50.0
Point_L_UpperArmTwist01.rotation.controller.viewline_length_abs = false
Point_L_UpperArmTwist01.rotation.controller.upnode_world = false
Point_L_UpperArmTwist01.rotation.controller.pickUpNode = (execute  ("$'" + cNameValue + "01 L Clavicle'"))
Point_L_UpperArmTwist01.wirecolor = (color 10 10 10)

-- 왼쪽 어께 트위스트1,2 본
LUpperArmTwist01 = Bonesys.createBone[0,0,0][1,0,0][0,0,1]
LUpperArmTwist01.name = boneName +"01 L UpperArmTwist01"
LUpperArmTwist01.width = ((execute  ("$'" + cNameValue + "01 L UpperArm'")).width) * 0.8
LUpperArmTwist01.height = ((execute  ("$'" + cNameValue + "01 L UpperArm'")).height) * 0.8
LUpperArmTwist01.length = ((execute  ("$'" + cNameValue + "01 L UpperArm'")).length) / 4
LUpperArmTwist02 = Bonesys.createBone[(((execute  ("$'" + cNameValue + "01 L UpperArm'")).length) / 4),0,0][1,0,0][0,0,1]
LUpperArmTwist02.name = boneName + "01 L UpperArmTwist02"
LUpperArmTwist02.width = ((execute  ("$'" + cNameValue + "01 L UpperArm'")).width) * 0.8
LUpperArmTwist02.height = ((execute  ("$'" + cNameValue + "01 L UpperArm'")).height) * 0.8
LUpperArmTwist02.length = ((execute  ("$'" + cNameValue + "01 L UpperArm'")).length) / 3
LUpperArmTwist02.parent = LUpperArmTwist01
LUpperArmTwist01.rotation = (inverse(biped.getTransform $'Bip01 L UpperArm' #rotation))
LUpperArmTwist01.pos = ($'Bip01 L UpperArm'.transform.pos)
LUpperArmTwist01.parent = (execute  ("$'" + cNameValue + "01 L UpperArm'"))
LUpperArmTwist02.parent = (execute  ("$'" + cNameValue + "01 L UpperArm'"))
LUpperArmTwist01.rotation.controller=LookAt_Constraint()
LUpperArmTwist01.rotation.controller.appendTarget (execute  ("$'" + cNameValue + "01 L Forearm'"))  50.0
LUpperArmTwist01.rotation.controller.viewline_length_abs = false
LUpperArmTwist01.rotation.controller.upnode_world = false
LUpperArmTwist01.rotation.controller.pickUpNode = Point_L_UpperArmTwist01
LUpperArmTwist01.wirecolor = (color 10 10 10)
LUpperArmTwist01.boxmode = on

LUpperArmTwist02.rotation.controller=Orientation_Constraint()
LUpperArmTwist02.rotation.controller.appendTarget LUpperArmTwist01 60.0
LUpperArmTwist02.rotation.controller.appendTarget (execute  ("$'" + cNameValue + "01 L UpperArm'")) 40.0
LUpperArmTwist02.wirecolor = (color 10 10 10)
LUpperArmTwist02.boxmode = on
)

if((execute  ("$'" + cNameValue + "01 R Clavicle'") != undefined) and (execute  ("$'" + cNameValue + "01 R UpperArm'") != undefined) and (execute  ("$'" + cNameValue + "01 R Forearm'") != undefined)) do
(
-- 오른쪽 어께트위스트1 더미
Point_R_UpperArmTwist02 = point()
Point_R_UpperArmTwist02.name = "Point_R_UpperArmTwist02"
Point_R_UpperArmTwist02.size = 2.0
Point_R_UpperArmTwist02.box = false
Point_R_UpperArmTwist02.cross = true
Point_R_UpperArmTwist02.rotation = (inverse(biped.getTransform $'Bip01 R UpperArm' #rotation))
Point_R_UpperArmTwist02.pos = ($'Bip01 R UpperArm'.transform.pos)
Point_R_UpperArmTwist02.parent =(execute  ("$'" + cNameValue + "01 R Clavicle'"))
Point_R_UpperArmTwist02.pos.controller = Position_Expression()
Point_R_UpperArmTwist02.parent =  (execute  ("$'" + cNameValue + "01 R UpperArm'"))
Point_R_UpperArmTwist02.wirecolor = (color 10 10 10)

-- 오른쪽 어께트위스트2 더미
Point_R_UpperArmTwist01 = point()
Point_R_UpperArmTwist01.name = "Point_R_UpperArmTwist01"
Point_R_UpperArmTwist01.size = 2.0
Point_R_UpperArmTwist01.box = true
Point_R_UpperArmTwist01.cross = false
Point_R_UpperArmTwist01.rotation = (inverse(biped.getTransform $'Bip01 R Clavicle' #rotation))
Point_R_UpperArmTwist01.pos = ($'Bip01 R Clavicle'.transform.pos)
Point_R_UpperArmTwist01.parent = (execute  ("$'" + cNameValue + "01 R Clavicle'"))
Point_R_UpperArmTwist01.rotation.controller=LookAt_Constraint()
Point_R_UpperArmTwist01.rotation.controller.appendTarget $'Point_R_UpperArmTwist02' 50.0
Point_R_UpperArmTwist01.rotation.controller.viewline_length_abs = false
Point_R_UpperArmTwist01.rotation.controller.upnode_world = false
Point_R_UpperArmTwist01.rotation.controller.pickUpNode = (execute  ("$'" + cNameValue + "01 R Clavicle'"))
Point_R_UpperArmTwist01.wirecolor = (color 10 10 10)

-- 오른쪽 어께 트위스트1,2 본
RUpperArmTwist01 = Bonesys.createBone[0,0,0][1,0,0][0,0,1]
RUpperArmTwist01.name = boneName +"01 R UpperArmTwist01"
RUpperArmTwist01.width = ((execute  ("$'" + cNameValue + "01 R UpperArm'")).width) * 0.8
RUpperArmTwist01.height = ((execute  ("$'" + cNameValue + "01 R UpperArm'")).height) * 0.8
RUpperArmTwist01.length = ((execute  ("$'" + cNameValue + "01 R UpperArm'")).length) / 4
RUpperArmTwist02 = Bonesys.createBone[(((execute  ("$'" + cNameValue + "01 L UpperArm'")).length) / 4),0,0][1,0,0][0,0,1]
RUpperArmTwist02.name = boneName + "01 R UpperArmTwist02"
RUpperArmTwist02.width = ((execute  ("$'" + cNameValue + "01 R UpperArm'")).width) * 0.8
RUpperArmTwist02.height = ((execute  ("$'" + cNameValue + "01 R UpperArm'")).height) * 0.8
RUpperArmTwist02.length = ((execute  ("$'" + cNameValue + "01 R UpperArm'")).length) / 4
RUpperArmTwist02.parent = RUpperArmTwist01
RUpperArmTwist01.rotation = (inverse(biped.getTransform $'Bip01 R UpperArm' #rotation))
RUpperArmTwist01.pos = ($'Bip01 R UpperArm'.transform.pos)
RUpperArmTwist01.parent = (execute  ("$'" + cNameValue + "01 R UpperArm'"))
RUpperArmTwist02.parent = (execute  ("$'" + cNameValue + "01 R UpperArm'"))
RUpperArmTwist01.rotation.controller=LookAt_Constraint()
RUpperArmTwist01.rotation.controller.appendTarget (execute  ("$'" + cNameValue + "01 R Forearm'"))  50.0
RUpperArmTwist01.rotation.controller.viewline_length_abs = false
RUpperArmTwist01.rotation.controller.upnode_world = false
RUpperArmTwist01.rotation.controller.pickUpNode = Point_R_UpperArmTwist01
RUpperArmTwist01.wirecolor = (color 10 10 10)
RUpperArmTwist01.boxmode = on

RUpperArmTwist02.rotation.controller=Orientation_Constraint()
RUpperArmTwist02.rotation.controller.appendTarget RUpperArmTwist01 60.0
RUpperArmTwist02.rotation.controller.appendTarget (execute  ("$'" + cNameValue + "01 R UpperArm'")) 40.0
RUpperArmTwist02.wirecolor = (color 10 10 10)
RUpperArmTwist02.boxmode = on
)

if((execute  ("$'" + cNameValue + "01 L Forearm'") != undefined) and (execute  ("$'" + cNameValue + "01 L Hand'") != undefined)) do
(
-- 왼쪽 손목 트위스트 본
L_ForearmTwist = Bonesys.createBone[0,0,0][1,0,0][0,0,1]
L_ForearmTwist.name = cNameValue + "01 L_ForearmTwist"
L_ForearmTwist.width = ((execute  ("$'" + cNameValue + "01 L Forearm'")).width) * 0.8
L_ForearmTwist.height = ((execute  ("$'" + cNameValue + "01 L Forearm'")).height) * 0.8
L_ForearmTwist.length = ((execute  ("$'" + cNameValue + "01 L Forearm'")).length) / 4
L_ForearmTwist.rotation = (inverse(biped.getTransform $'Bip01 L Forearm' #rotation))
L_ForearmTwist.pos = ($'Bip01 L Forearm'.transform.pos)
coordsys local move L_ForearmTwist [((execute  ("$'" + cNameValue + "01 L UpperArm'")).length) - (((execute  ("$'" + cNameValue + "01 L UpperArm'")).length) / 4),0,0]
L_ForearmTwist.parent = (execute  ("$'" + cNameValue + "01 L Forearm'"))
L_ForearmTwist.rotation.controller=LookAt_Constraint()
L_ForearmTwist.rotation.controller.appendTarget (execute  ("$'" + cNameValue + "01 L Hand'")) 50.0
L_ForearmTwist.rotation.controller.viewline_length_abs = false
L_ForearmTwist.rotation.controller.upnode_world = false
L_ForearmTwist.rotation.controller.pickUpNode = (execute  ("$'" + cNameValue + "01 L Hand'"))
L_ForearmTwist.wirecolor = (color 10 10 10)
L_ForearmTwist.boxmode = on
)

if((execute  ("$'" + cNameValue + "01 R Forearm'") != undefined) and (execute  ("$'" + cNameValue + "01 R Hand'") != undefined)) do
(
-- 오른쪽 손목 트위스트 본
R_ForearmTwist = Bonesys.createBone[0,0,0][1,0,0][0,0,1]
R_ForearmTwist.name = cNameValue + "01 R_ForearmTwist"
R_ForearmTwist.width = ((execute  ("$'" + cNameValue + "01 R Forearm'")).width) * 0.8
R_ForearmTwist.height = ((execute  ("$'" + cNameValue + "01 R Forearm'")).height) * 0.8
R_ForearmTwist.length = ((execute  ("$'" + cNameValue + "01 R Forearm'")).length) / 4
R_ForearmTwist.rotation = (inverse(biped.getTransform $'Bip01 R Forearm' #rotation))
R_ForearmTwist.pos = ($'Bip01 R Forearm'.transform.pos)
coordsys local move R_ForearmTwist [((execute  ("$'" + cNameValue + "01 R UpperArm'")).length) - (((execute  ("$'" + cNameValue + "01 R UpperArm'")).length) / 4),0,0]
R_ForearmTwist.parent = (execute  ("$'" + cNameValue + "01 R Forearm'"))
R_ForearmTwist.rotation.controller=LookAt_Constraint()
R_ForearmTwist.rotation.controller.appendTarget (execute  ("$'" + cNameValue + "01 R Hand'")) 50.0
R_ForearmTwist.rotation.controller.viewline_length_abs = false
R_ForearmTwist.rotation.controller.upnode_world = false
R_ForearmTwist.rotation.controller.pickUpNode = (execute  ("$'" + cNameValue + "01 R Hand'"))
R_ForearmTwist.wirecolor = (color 10 10 10)
R_ForearmTwist.boxmode = on
)

if(((execute  ("$'" + cNameValue + "01 L Thigh'")) != undefined) and ((execute  ("$'" + cNameValue + "01 L Calf'")) != undefined)) do
(
-- 왼쪽 허벅지 트위스트 ExposeTM
ExposeTransformL = ExposeTransform()
ExposeTransformL.name = "ExposeTransform L"
ExposeTransformL.size = 1.5
ExposeTransformL.box = true
ExposeTransformL.cross = false
ExposeTransformL.rotation = (inverse(biped.getTransform $'Bip01 L Thigh' #rotation))
ExposeTransformL.pos = ($'Bip01 L Thigh'.transform.pos)
ExposeTransformL.parent = (execute  ("$'" + cNameValue + "01 L Thigh'"))
ExposeTransformL.exposeNode = (execute  ("$'" + cNameValue + "01 L Calf'"))
ExposeTransformL.useParent = false
ExposeTransformL.localReferenceNode  = (execute  ("$'" + cNameValue + "01 Pelvis'"))
ExposeTransformL.wirecolor = (color 10 10 10)

-- 왼쪽 허벅지 트위스트 더미
PointLThigh = point()
PointLThigh.name = cNameValue + "01 Point L Thigh"
PointLThigh.size = 1.0
PointLThigh.box = false
PointLThigh.cross = true
PointLThigh.pos = ($'Bip01 Pelvis'.transform.pos)
coordsys local move PointLThigh [10,0,0]
PointLThigh.parent = (execute  ("$'" + cNameValue + "01 Pelvis'"))
reactContL = PointLThigh.pos.controller = Position_reactor()
PointLThigh.wirecolor = (color 10 10 10)

-- 왼쪽 허벅지 트위스트 본
L_ThighTwist = Bonesys.createBone[0,0,0][1,0,0][0,0,1]
L_ThighTwist.name = cNameValue + "01 L_ThighTwist"
L_ThighTwist.width = ((execute  ("$'" + cNameValue + "01 L Thigh'")).width) * 0.8
L_ThighTwist.height = ((execute  ("$'" + cNameValue + "01 L Thigh'")).height) * 0.8
L_ThighTwist.length = ((execute  ("$'" + cNameValue + "01 L Thigh'")).length) / 4
L_ThighTwist.rotation = (inverse(biped.getTransform $'Bip01 L Thigh' #rotation))
L_ThighTwist.pos = ($'Bip01 L Thigh'.transform.pos)
L_ThighTwist.parent = (execute  ("$'" + cNameValue + "01 L Thigh'"))
L_ThighTwist.rotation.controller=LookAt_Constraint()
L_ThighTwist.rotation.controller.appendTarget  (execute  ("$'" + cNameValue + "01 L Calf'")) 50.0
L_ThighTwist.rotation.controller.viewline_length_abs = false
L_ThighTwist.rotation.controller.upnode_world = false
L_ThighTwist.rotation.controller.pickUpNode = (execute  ("$'" + cNameValue + "01 L Thigh'"))
L_ThighTwist.rotation.controller.upnode_ctrl = 0
L_ThighTwist.rotation.controller.StoUP_axisFlip = true
L_ThighTwist.wirecolor = (color 10 10 10)
L_ThighTwist.boxmode = on

reactContL.reactTo $'ExposeTransform L'.localPosition.controller
)

if(((execute  ("$'" + cNameValue + "01 R Thigh'")) != undefined) and ((execute  ("$'" + cNameValue + "01 R Calf'")) != undefined)) do
(
-- 오른쪽 허벅지 트위스트 ExposeTM
ExposeTransformR = ExposeTransform()
ExposeTransformR.name = "ExposeTransform R"
ExposeTransformR.size = 1.5
ExposeTransformR.box = true
ExposeTransformR.cross = false
ExposeTransformR.rotation = (inverse(biped.getTransform $'Bip01 R Thigh' #rotation))
ExposeTransformR.pos = ($'Bip01 R Thigh'.transform.pos)
ExposeTransformR.parent = (execute  ("$'" + cNameValue + "01 R Thigh'"))
ExposeTransformR.exposeNode = (execute  ("$'" + cNameValue + "01 R Calf'"))
ExposeTransformR.useParent = false
ExposeTransformR.localReferenceNode  = (execute  ("$'" + cNameValue + "01 Pelvis'"))
ExposeTransformR.wirecolor = (color 10 10 10)

-- 오른쪽 허벅지 트위스트 더미
PointRThigh = point()
PointRThigh.name = cNameValue + "01 Point R Thigh"
PointRThigh.size = 1.0
PointRThigh.box = false
PointRThigh.cross = true
PointRThigh.pos = ($'Bip01 Pelvis'.transform.pos)
coordsys local move PointRThigh [-10,0,0]
PointRThigh.parent = ((execute  ("$'" + cNameValue + "01 Pelvis'")))
reactContR = PointRThigh.pos.controller = Position_reactor()
PointRThigh.wirecolor = (color 10 10 10)

-- 오른쪽 허벅지 트위스트 본
R_ThighTwist = Bonesys.createBone[0,0,0][1,0,0][0,0,1]
R_ThighTwist.name = cNameValue + "01 R_ThighTwist"
R_ThighTwist.width = ((execute  ("$'" + cNameValue + "01 R Thigh'")).width) * 0.8
R_ThighTwist.height = ((execute  ("$'" + cNameValue + "01 R Thigh'")).height) * 0.8
R_ThighTwist.length = ((execute  ("$'" + cNameValue + "01 R Thigh'")).length) / 4
R_ThighTwist.rotation = (inverse(biped.getTransform $'Bip01 R Thigh' #rotation))
R_ThighTwist.pos = ($'Bip01 R Thigh'.transform.pos)
R_ThighTwist.parent = (execute  ("$'" + cNameValue + "01 R Thigh'"))
R_ThighTwist.rotation.controller=LookAt_Constraint()
R_ThighTwist.rotation.controller.appendTarget  (execute  ("$'" + cNameValue + "01 R Calf'")) 50.0
R_ThighTwist.rotation.controller.viewline_length_abs = false
R_ThighTwist.rotation.controller.upnode_world = false
R_ThighTwist.rotation.controller.pickUpNode = (execute  ("$'" + cNameValue + "01 R Thigh'"))
R_ThighTwist.rotation.controller.upnode_ctrl = 0
R_ThighTwist.wirecolor = (color 10 10 10)
R_ThighTwist.boxmode = on

reactContR.reactTo $'ExposeTransform R'.localPosition.controller
)
)
select bons
destroydialog bipMirrbone
)
)
createdialog bipMirrbone
)


=================================================================================
어께 손목 허벅지의 트위스트 본 추가기능을 넣었다.
좀더 확장성을 생각해 볼수 있지만 온라인게임에서 사용하는 최소의 본을 구현하도록 하였다.
허벅지의 트위스트 본은 리엑터메니저를 사용해야 하는 방식으로 했는데, 다음번에는 일반적인것과 아닌것을 선택할 수 있도록 해야 겠다.
트위스트 본이 생성되게 위해서는 필수 조건이 있는데,
어께 트위스트 본을 사용하려면 쇠골, 팔 상박이 선택되어야 한다.
손목 트위스트 본을 사용하려면 팔 하박, 손이 선택되어야 한다.
허벅지 트위스트 본을 사용하려면 골반, 허벅지가 선택 되어야 한다.



추가 할것은 
1. 본이름을 생성할때 이름을 정할 수 있도록 할것.
2. 목이 머리와 가슴의 중간값을 유지하도록 하는것.(이건 고민좀 할것 같다.)
3. 어께 손목 허벅지등의 트위스트 본 추가 선택.