Files
gtav-src/tools_ng/wildwest/script/3dsMax/Characters/Rigging/giant/giantPrepUI.ms
T
2025-09-29 00:52:08 +02:00

1722 lines
55 KiB
Plaintext
Executable File

-- giantPrepUI.ms
-- Rockstar North
-- Matt Rennie Nov 2010
--Tool to split character meshes and then hard skin for use with giant mocap
-- tool allows pre rigged gta style characters or scanned raw meshes.
-------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------
filein "rockstar/export/settings.ms" -- This is fast
-- Figure out the project
theProjectRoot = RsConfigGetProjRootDir()
theProject = RSConfigGetProjectName()
theWildWest = RsConfigGetWildWestDir()
theProjectConfig = RsConfigGetProjBinConfigDir()
filein (RsConfigGetWildWestDir() + "script\\max\\Rockstar_North\\character\\Includes\\FN_Rigging.ms")
global sexCheckState = undefined
global LastSubRollout = 1
global initialObjectArray = #()
global volObjects = #()
global geoNo = undefined
global originalMeshToSplit = undefined
global meshToSplit = undefined
global marionetteGuiRoll = undefined
global skinOrNot = True
global objToMash = undefined
global rigBoneListStruct = undefined
global decimationAmt = undefined
global useSceneMesh = undefined
global originalMeshToSplit = undefined
struct rigBoneStruct (rb_bone, rb_Radius, rb_Length, rb_Trans)
-- rigBoneList = #($SKEL_Spine_Root, $SKEL_Spine0, $SKEL_Spine1, $SKEL_Spine2, $SKEL_Spine3, $SKEL_L_Clavicle, $SKEL_L_UpperArm, $SKEL_L_Forearm, $SKEL_L_Hand, $SKEL_L_Finger00, $SKEL_L_Finger01, $SKEL_L_Finger02, $SKEL_L_Finger10, $SKEL_L_Finger11, $SKEL_L_Finger12, $SKEL_L_Finger20, $SKEL_L_Finger21, $SKEL_L_Finger22, $SKEL_L_Finger30, $SKEL_L_Finger31, $SKEL_L_Finger32, $SKEL_L_Finger40, $SKEL_L_Finger41, $SKEL_L_Finger42, $SKEL_R_Clavicle, $SKEL_R_UpperArm, $SKEL_R_Forearm, $SKEL_R_Hand, $SKEL_R_Finger00, $SKEL_R_Finger01, $SKEL_R_Finger02, $SKEL_R_Finger10, $SKEL_R_Finger11, $SKEL_R_Finger12, $SKEL_R_Finger20, $SKEL_R_Finger21, $SKEL_R_Finger22, $SKEL_R_Finger30, $SKEL_R_Finger31, $SKEL_R_Finger32, $SKEL_R_Finger40, $SKEL_R_Finger41, $SKEL_R_Finger42, $SKEL_Neck_1, $SKEL_Head, $SKEL_Pelvis, $SKEL_L_Thigh, $SKEL_L_Calf, $SKEL_L_Foot, $SKEL_L_Toe0, $SKEL_R_Thigh, $SKEL_R_Calf, $SKEL_R_Foot, $SKEL_R_Toe0)
boneArray = #(
"SKEL_R_Finger02",
"SKEL_R_Finger01",
"SKEL_R_Finger00",
"SKEL_R_Finger12",
"SKEL_R_Finger11",
"SKEL_R_Finger10",
"SKEL_R_Finger22",
"SKEL_R_Finger21",
"SKEL_R_Finger20",
"SKEL_R_Finger32",
"SKEL_R_Finger31",
"SKEL_R_Finger30",
"SKEL_R_Finger42",
"SKEL_R_Finger41",
"SKEL_R_Finger40",
"SKEL_L_Finger02",
"SKEL_L_Finger01",
"SKEL_L_Finger00",
"SKEL_L_Finger12",
"SKEL_L_Finger11",
"SKEL_L_Finger10",
"SKEL_L_Finger22",
"SKEL_L_Finger21",
"SKEL_L_Finger20",
"SKEL_L_Finger32",
"SKEL_L_Finger31",
"SKEL_L_Finger30",
"SKEL_L_Finger42",
"SKEL_L_Finger41",
"SKEL_L_Finger40",
"SKEL_L_Toe0",
"SKEL_L_Foot",
"SKEL_L_Calf",
"SKEL_L_Thigh",
"SKEL_R_Toe0",
"SKEL_R_Foot",
"SKEL_R_Calf",
"SKEL_R_Thigh",
"SKEL_R_Hand",
"SKEL_R_Forearm",
"SKEL_R_UpperArm",
"SKEL_R_Clavicle",
"SKEL_L_Hand",
"SKEL_L_Forearm",
"SKEL_L_UpperArm",
"SKEL_L_Clavicle",
"SKEL_Head",
"SKEL_Neck_1",
"SKEL_Spine3",
"SKEL_Spine2",
"SKEL_Spine1",
"SKEL_Spine0",
"SKEL_Spine_Root",
"SKEL_Pelvis",
"SKEL_ROOT"
)
markerArray = #(
"MARKER_CONTAINER",
"Marker_Pelvis001",
"Marker_R_Thigh",
"Marker_R_Calf",
"Marker_R_Foot",
"Marker_R_Toe0",
"Marker_R_Toe0Nub",
"Marker_L_Thigh",
"Marker_L_Calf",
"Marker_L_Foot",
"Marker_L_Toe0",
"Marker_L_Toe0Nub",
"Marker_Spine0",
"Marker_Spine1",
"Marker_Spine2",
"Marker_Spine3",
"Marker_Neck1",
"Marker_Head",
"Marker_HeadNub",
"Marker_R_Clavicle",
"Marker_R_UpperArm",
"Marker_R_Forearm",
"Marker_R_Hand",
"Marker_R_Finger00",
"Marker_R_Finger01",
"Marker_R_Finger02",
"Marker_R_Finger0Nub",
"Marker_R_Finger40",
"Marker_R_Finger41",
"Marker_R_Finger42",
"Marker_R_Finger4Nub",
"Marker_R_Finger30",
"Marker_R_Finger31",
"Marker_R_Finger32",
"Marker_R_Finger3Nub",
"Marker_R_Finger20",
"Marker_R_Finger21",
"Marker_R_Finger22",
"Marker_R_Finger2Nub",
"Marker_R_Finger10",
"Marker_R_Finger11",
"Marker_R_Finger12",
"Marker_R_Finger1Nub",
"Marker_R_HandEND",
"Marker_L_Clavicle",
"Marker_L_UpperArm",
"Marker_L_Forearm",
"Marker_L_Hand",
"Marker_L_Finger10",
"Marker_L_Finger11",
"Marker_L_Finger12",
"Marker_L_Finger1Nub",
"Marker_L_Finger20",
"Marker_L_Finger21",
"Marker_L_Finger22",
"Marker_L_Finger2Nub",
"Marker_L_Finger00",
"Marker_L_Finger01",
"Marker_L_Finger02",
"Marker_L_Finger0Nub",
"Marker_L_Finger30",
"Marker_L_Finger31",
"Marker_L_Finger32",
"Marker_L_Finger3Nub",
"Marker_L_Finger40",
"Marker_L_Finger41",
"Marker_L_Finger42",
"Marker_L_Finger4Nub",
"Marker_L_HandEND",
"Marker_PelvisEND"
)
------------------------------------------------------------------------------------------------------------------------------------------------
trimArrays = #( --array of items to be trimmed followed by the items used to trim them
#("splitVol_SKEL_L_Toe0", "splitVol_SKEL_L_Foot"),
#("splitVol_SKEL_L_Foot", "splitVol_SKEL_L_Calf"),
#("splitVol_SKEL_L_Calf", "splitVol_SKEL_L_Thigh"),
#("splitVol_SKEL_L_Thigh", "TRIMMERBOX"),
#("splitVol_SKEL_R_Toe0", "splitVol_SKEL_R_Foot"),
#("splitVol_SKEL_R_Foot", "splitVol_SKEL_R_Calf"),
#("splitVol_SKEL_R_Calf", "splitVol_SKEL_R_Thigh"),
#("splitVol_SKEL_R_Thigh", "TRIMMERBOX"),
#("splitVol_SKEL_Pelvis", "splitVol_SKEL_R_Thigh", "splitVol_SKEL_L_Thigh"),
#("splitVol_SKEL_L_Finger02", "splitVol_SKEL_L_Finger01"),
#("splitVol_SKEL_L_Finger01", "splitVol_SKEL_L_Finger00"),
#("splitVol_SKEL_L_Finger00"),
#("splitVol_SKEL_L_Finger12", "splitVol_SKEL_L_Finger11"),
#("splitVol_SKEL_L_Finger11", "splitVol_SKEL_L_Finger10"),
#("splitVol_SKEL_L_Finger10"),
#("splitVol_SKEL_L_Finger22", "splitVol_SKEL_L_Finger21"),
#("splitVol_SKEL_L_Finger21", "splitVol_SKEL_L_Finger20"),
#("splitVol_SKEL_L_Finger20"),
#("splitVol_SKEL_L_Finger32", "splitVol_SKEL_L_Finger31"),
#("splitVol_SKEL_L_Finger31", "splitVol_SKEL_L_Finger30"),
#("splitVol_SKEL_L_Finger30"),
#("splitVol_SKEL_L_Finger42", "splitVol_SKEL_L_Finger41"),
#("splitVol_SKEL_L_Finger41", "splitVol_SKEL_L_Finger40"),
#("splitVol_SKEL_L_Finger40"),
#("splitVol_SKEL_R_Finger02", "splitVol_SKEL_R_Finger01"),
#("splitVol_SKEL_R_Finger01", "splitVol_SKEL_R_Finger00"),
#("splitVol_SKEL_R_Finger00"),
#("splitVol_SKEL_R_Finger12", "splitVol_SKEL_R_Finger11"),
#("splitVol_SKEL_R_Finger11", "splitVol_SKEL_R_Finger10"),
#("splitVol_SKEL_R_Finger10"),
#("splitVol_SKEL_R_Finger22", "splitVol_SKEL_R_Finger21"),
#("splitVol_SKEL_R_Finger21", "splitVol_SKEL_R_Finger20"),
#("splitVol_SKEL_R_Finger20"),
#("splitVol_SKEL_R_Finger32", "splitVol_SKEL_R_Finger31"),
#("splitVol_SKEL_R_Finger31", "splitVol_SKEL_R_Finger30"),
#("splitVol_SKEL_R_Finger30"),
#("splitVol_SKEL_R_Finger42", "splitVol_SKEL_R_Finger41"),
#("splitVol_SKEL_R_Finger41", "splitVol_SKEL_R_Finger40"),
#("splitVol_SKEL_R_Finger40"),
#("splitVol_SKEL_L_Hand", "splitVol_SKEL_L_Forearm"),
#("splitVol_SKEL_L_Forearm", "splitVol_SKEL_L_UpperArm"),
#("splitVol_SKEL_L_UpperArm", "ARMTRIMBOX"),
#("splitVol_SKEL_L_Clavicle", "splitVol_SKEL_Spine3"),
#("splitVol_SKEL_R_Hand", "splitVol_SKEL_R_Forearm"),
#("splitVol_SKEL_R_Forearm", "splitVol_SKEL_R_UpperArm"),
#("splitVol_SKEL_R_UpperArm", "ARMTRIMBOX"),
#("splitVol_SKEL_R_Clavicle", "splitVol_SKEL_Spine3"),
#("splitVol_SKEL_Head"),
#("splitVol_SKEL_Spine3", "splitVol_SKEL_Spine3"),
#("splitVol_SKEL_Spine2", "splitVol_SKEL_Spine1"),
#("splitVol_SKEL_Spine1", "splitVol_SKEL_Spine0"),
#("splitVol_SKEL_Spine0", "splitVol_SKEL_Pelvis")
)
bonesToKeep = #( --array of all bones we want to keep
"SKEL_ROOT",
"SKEL_Pelvis",
"SKEL_L_Thigh",
"SKEL_L_Calf",
"SKEL_L_Foot",
"SKEL_L_Toe0",
"SKEL_R_Thigh",
"SKEL_R_Calf",
"SKEL_R_Foot",
"SKEL_R_Toe0",
"SKEL_Spine_Root",
"SKEL_Spine0",
"SKEL_Spine1",
"SKEL_Spine2",
"SKEL_Spine3",
"SKEL_L_Clavicle",
"SKEL_L_UpperArm",
"SKEL_L_Forearm",
"SKEL_L_Hand",
"SKEL_L_Finger00",
"SKEL_L_Finger01",
"SKEL_L_Finger02",
"SKEL_L_Finger10",
"SKEL_L_Finger11",
"SKEL_L_Finger12",
"SKEL_L_Finger20",
"SKEL_L_Finger21",
"SKEL_L_Finger22",
"SKEL_L_Finger30",
"SKEL_L_Finger31",
"SKEL_L_Finger32",
"SKEL_L_Finger40",
"SKEL_L_Finger41",
"SKEL_L_Finger42",
"SKEL_R_Clavicle",
"SKEL_R_UpperArm",
"SKEL_R_Forearm",
"SKEL_R_Hand",
"SKEL_R_Finger00",
"SKEL_R_Finger01",
"SKEL_R_Finger02",
"SKEL_R_Finger10",
"SKEL_R_Finger11",
"SKEL_R_Finger12",
"SKEL_R_Finger20",
"SKEL_R_Finger21",
"SKEL_R_Finger22",
"SKEL_R_Finger30",
"SKEL_R_Finger31",
"SKEL_R_Finger32",
"SKEL_R_Finger40",
"SKEL_R_Finger41",
"SKEL_R_Finger42",
"SKEL_Neck_1",
"SKEL_Head",
"mover"
)
fromToBones = #(--this will be a dynamically generated 2d array containing the original bone (such as a roll bone) and what its weight will be moved to
#(), --this will contain the initial bone
#() --this will contain the bone to move weights to
)
skinModBones = #()
vertSkinValues = #()
boneNames = #()
geoBoneColours = #(
#("geo_Pelvis",
"geo_Spine0",
"geo_Spine1",
"geo_Spine2",
"geo_Spine3",
"geo_Head",
"geo_L_Thigh",
"geo_L_Calf",
"geo_L_Toe0",
"geo_R_Thigh",
"geo_R_Calf",
"geo_R_Toe0",
"geo_L_Clavicle",
"geo_L_UpperArm",
"geo_L_Forearm",
"geo_L_Hand",
"geo_L_Finger00",
"geo_L_Finger01",
"geo_L_Finger02",
"geo_L_Finger10",
"geo_L_Finger11",
"geo_L_Finger12",
"geo_L_Finger20",
"geo_L_Finger21",
"geo_L_Finger22",
"geo_L_Finger30",
"geo_L_Finger31",
"geo_L_Finger32",
"geo_L_Finger40",
"geo_L_Finger41",
"geo_L_Finger42",
"geo_R_Clavicle",
"geo_R_UpperArm",
"geo_R_Forearm",
"geo_R_Hand",
"geo_R_Finger00",
"geo_R_Finger01",
"geo_R_Finger02",
"geo_R_Finger10",
"geo_R_Finger11",
"geo_R_Finger12",
"geo_R_Finger20",
"geo_R_Finger21",
"geo_R_Finger22",
"geo_R_Finger30",
"geo_R_Finger31",
"geo_R_Finger32",
"geo_R_Finger40",
"geo_R_Finger41",
"geo_R_Finger42"),
#(
[0,0,0],--"geo_Pelvis",
[5,0,0],--"geo_Spine0",
[10,0,0],--"geo_Spine1",
[15,0,0],--"geo_Spine2",
[20,0,0],--"geo_Spine3",
[25,0,0],--"geo_Head",
[30,0,0],--"geo_L_Thigh",
[35,0,0],--"geo_L_Calf",
[40,0,0],--"geo_L_Toe0",
[45,0,0],--"geo_R_Thigh",
[50,0,0],--"geo_R_Calf",
[55,0,0],--"geo_R_Toe0",
[60,0,0],--"geo_L_Clavicle",
[65,0,0],--"geo_L_UpperArm",
[70,0,0],--"geo_L_Forearm",
[75,0,0],--"geo_L_Hand",
[80,0,0],--"geo_L_Finger00",
[85,0,0],--"geo_L_Finger01",
[90,0,0],--"geo_L_Finger02",
[95,0,0],--"geo_L_Finger10",
[100,0,0],--"geo_L_Finger11",
[105,0,0],--"geo_L_Finger12",
[110,0,0],--"geo_L_Finger20",
[115,0,0],--"geo_L_Finger21",
[120,0,0],--"geo_L_Finger22",
[125,0,0],--"geo_L_Finger30",
[130,0,0],--"geo_L_Finger31",
[135,0,0],--"geo_L_Finger32",
[140,0,0],--"geo_L_Finger40",
[145,0,0],--"geo_L_Finger41",
[150,0,0],--"geo_L_Finger42",
[155,0,0],--"geo_R_Clavicle",
[160,0,0],--"geo_R_UpperArm",
[165,0,0],--"geo_R_Forearm",
[170,0,0],--"geo_R_Hand",
[175,0,0],--"geo_R_Finger00",
[180,0,0],--"geo_R_Finger01",
[185,0,0],--"geo_R_Finger02",
[190,0,0],--"geo_R_Finger10",
[195,0,0],--"geo_R_Finger11",
[200,0,0],--"geo_R_Finger12",
[205,0,0],--"geo_R_Finger20",
[210,0,0],--"geo_R_Finger21",
[215,0,0],--"geo_R_Finger22",
[220,0,0],--"geo_R_Finger30",
[225,0,0],--"geo_R_Finger31",
[230,0,0],--"geo_R_Finger32",
[235,0,0],--"geo_R_Finger40",
[240,0,0],--"geo_R_Finger41",
[245,0,0]--"geo_R_Finger42",
)
)
------------------------------------------------------------------------------------------------------------------------------------------------
dupSplitVol = #()
fn dupSplitVols = --we need to duplicate each splitVol object so we dont fuck up the clean ones. THESE then become to one we use for duplicating and the SplitVol one becomes the oen which get trimmed
(
for o in objects do
(
clearSelection()
select o
if (substring o.name 1 8) == "splitVol" do
(
trimDupArr = selection as array
origName = o.name
newName = ("MASTERTRIM_"+origName)
maxOps.cloneNodes trimDupArr cloneType:#copy actualNodeList:&c newNodes:&nnl
trimmerObj = nnl[1]
trimmerObj.name = newName
appendIfUnique dupSplitVol trimmerObj
--now we need to convert the splitMesh into an epoly and triangulate it
convertTo o PolyMeshObject
select o
subObjectLevel = 1
max select all
o.EditablePoly.ConnectVertices ()
subobjectLevel = 0
)
)
)
fn hackDeleteSkinWrap thisObject=
(
--gigantic hack cos max is a gigantic piece of turd.
deleteModifier thisObject thisObject.modifiers[2] --get rid of the skin wrap now
)
fn combineIndiv origMeshName chunkMeshes = --this takes all of the split meshes and combines them into one
(
dupMeshes = #()
--first duplicate all of the pieces
for i = 1 to chunkMeshes.count do
(
origName = chunkMeshes[i].name
print ("origName = "+origName)
newName = ("dup"+(substring origName 4 20))
maxOps.cloneNodes chunkMeshes[i] cloneType:#copy actualNodeList:&c newNodes:&nnl
newNode = nnl[1]
newNode.name = newName
appendIfUnique dupMeshes newNode
deletemodifier newNode 1
)
print ("dupMeshes count = "+(dupMeshes.count as string)+". They are:")
print dupMeshes
masterObj = dupMeshes[1]
for i = dupMeshes.count to 2 by -1 do
(
print ("Attaching "+dupMeshes[i].name+" to "+masterObj.name)
masterObj.attach dupMeshes[i] masterObj
)
masterObj.name = origMeshName
currName = masterObj.name
addModifier masterObj (Skin_Wrap ())
select masterObj
-- masterObj = getNodeByName origMeshName
wrapMod = masterObj.modifiers[1]
print ("Beginning skinWrap - this can take a while!")
wrapMod.meshList = chunkMeshes
wrapMod.engine = 0
-- wrapMod.converttoskin true
execStr = ("$"+currName+".modifiers[#Skin_Wrap].convertToSkin true")
-- messagebox ("gonna try "+execStr)
print ("gonna try "+execStr)
execute execStr
-- execStr = ("deleteModifier $"+currName+" "+"$"+currName+".modifiers[#Skin_Wrap]")
-- execute execStr
print ("Skin Wrap Complete on "+masterObj.name+"!")
hackDeleteSkinWrap masterObj
for obj = chunkMeshes.count to 1 by -1 do
(
delete chunkMeshes[obj]
)
chunkMeshes = #()
messagebox "CombineIndivDone"
)
fn tmpSegMesh =
(
-- filein (RsConfigGetWildWestDir() + "script/max/Rockstar_North/character/Rigging_tools/giant/tmpColourCOmbine.ms")
)
fn killKeys =
(
objArray = objects as array
createDialog progBar width:300 height:30
for fb in objArray do
(
-- print ("deleting keys from "+fb.name)
deleteKeys fb.controller
iVal = finditem objArray fb
progBar.prog.value = (100.*iVal/objArray.count)
)
destroyDialog progBar
)
fn hideAllToKeep = --display all objects which we probably want to remove
(
max unhide all
max select all
selArr = selection as array
for i = 1 to selArr.count do
(
if classof selArr[i].baseObject == editable_poly then
(
hide selArr[i]
)
else
(
for b = 1 to bonesToKeep.count do
(
if selArr[i].name == bonesToKeep[b] do
(
hide selArr[i]
)
)
)
)
hide $Dummy01
fileName = filterstring maxfileName "."
charName = fileName[1]
charNode = getnodeByName charName
if charNode != undefined do
(
hide charNode
)
clearSelection()
messageBox "OK now ensure you delete everything except the dummy and character dummy." beep:true
)
--get the skinned verts for a mesh (theMesh) and add them to the vertSkinValues array
fn buildSkinDataArray theMesh =
(
print ("Getting vertex skin weights from " + theMesh.name)
vertSkinValues = #()
vertCount = skinOps.getNumberVertices theMesh.modifiers[#skin]
for x=1 to vertCount do
(
vertArray = #()
BNumber = skinOps.getVertexWeightCount theMesh.modifiers[#skin] x
for i = 1 to BNumber do
(
boneID = skinOps.getVertexWeightBoneId theMesh.modifiers[#skin] x i
boneName = skinOps.GetBoneName theMesh.modifiers[#skin] boneID 0
boneWeight = skinOps.getVertexWeight theMesh.modifiers[#skin] x i
tempArray = #(boneID, boneName, boneWeight)
append vertArray tempArray
)
append vertSkinValues vertArray
)
-- print ("vertex skin weights grabbed from " + theMesh.name)
)--end vertSkin
--check the vert weights for the bone we want to remove (fromBone). If found, we add the weight on the the parent bone (toBone).
fn replaceWeights fromBone toBone =
(
toBoneId = findItem skinModBones (getNodeByName toBone)
-- createDialog progBar width:300 Height: 30
-- loop through all the verts in the object
for vertNoArray=1 to vertSkinValues.count do --for every vert do
(
iVal = findItem vertSkinValues vertNoArray
-- progBar.prog.value = (100.*iVal/vertSkinValues.count)
-- Get the influence data for each vert
currentVertData = vertSkinValues[vertNoArray]
weightToMove = 0
for vertBoneArray=1 to currentVertData.count do --for every weight do
(
if fromBone == currentVertData[vertBoneArray][2] do
(
addedWeight = false
weightToMove = currentVertData[vertBoneArray][3]
--lets check the other weights on this vert for a match with our parent bone
for recheckVertBoneArray=1 to currentVertData.count do
(
if currentVertData[recheckVertBoneArray][2] == toBone do
(
-- If we have a match, then the destination bone already exists, create a composite weight
weightToAdd = currentVertData[recheckVertBoneArray][3]
weightToWrite = weightToAdd + weightToMove
currentVertData[recheckVertBoneArray][3] = weightToWrite -- set parent to new weight
currentVertData[vertBoneArray][3] = 0 -- clear child weight
addedWeight = true -- set the flag to say we've created an updated weight set.
)--end add weight loop
)
-- what if we didn't find a good parent bone?
-- we need to kill the dirty child and repalce it with the correct parent
if addedWeight != true do
(
currentVertData[vertBoneArray][2] = toBone
addedWeight = true
)--end new bone and weight loop
)--end found toBone loop
)
)
gc()
-- destroyDialog progBar
)--end replaceWeights
fn prepBoneNames geo =
(
boneNames = #()
selBoneCount = skinOps.GetNumberBones geo.modifiers[#Skin]
--get the bone name order
for sb=1 to selBoneCount do
(
singleBoneName = skinOps.GetBoneName geo.modifiers[#Skin] sb 0
append boneNames singleBoneName
)
)
--update the skinning on the LOD mesh using our filtered vertSkinValues array
fn updateLODSkin theMesh =
(
meshName = theMesh.name
for vertNum = 1 to vertSkinValues.count do
(
tempBoneArray = #()
tempWeightArray = #()
for affectingBones=1 to vertSkinValues[vertNum].count do
(
boneID = findItem boneNames vertSkinValues[vertNum][affectingBones][2]
append tempBoneArray boneID
append tempWeightArray vertSkinValues[vertNum][affectingBones][3]
)
theVert = vertNum
theSkin = theMesh.modifiers[#skin]
boneArray = tempBoneArray
weightArray = tempWeightArray
--skinOps.unNormalizeVertex theskin theVert true
skinOps.ReplaceVertexWeights theskin theVert boneArray weightArray
--skinOps.unNormalizeVertex theskin theVert false
)
-- print ("skinning updated on " + theMesh.name)
)--end updateLODSkin
fn findBoneRecursive currentBone = -- Find a bone recursively if needed, iterate up the parent tree to find a bone which exists within the bonesToKeep array
(
foundResult = findItem bonesToKeep currentBone.Name
if foundResult != 0 then
(
-- found the bone in the bonesToKeep array so return it
return currentBone
print (currentBone.Name+" doesnt need changing")
)
else
(
-- did not find the bone, so search for its parent
return findBoneRecursive currentBone.parent
print ("found that")
)
)
fn checkSkinBones = --find the bones in skin mod and see if they are toi be kept and if not record what their replacement will be
(
--clearArray
fromToBones = #(--this will be a dynamically generated 2d array containing the original bone (such as a roll bone) and what its weight will be moved to
#(), --this will contain the initial bone
#() --this will contain the bone to move weights to
)
--endClearArrays
print "starting checkSkinBones"
for i = 1 to skinModBones.count do --now add data of original bone plus its final bone into a paired array
(
myBone = findBoneRecursive skinModBones[i]
-- print myBone.name as string -- This is the upmost parent which is in the bonesToKeep array
-- print ("Appending "+sceneBones[i].name+" into fromToBones ["+(i as string)+"][1] array")
append fromToBones[1] skinModBones[i].name --put in the original bone
-- print ("Appending "+myBone.name+" into fromToBones ["+(i as string)+"][2] array")
append fromToBones[2] myBone.name --put in the bone we need to move the weight to
)
print "fromToBones array built"
)
fn buildSkinModBoneList geo = --query all bones in the skin modifier and put them into a array so we can loop trhu them
(
skinModBones = #() --ensure its empty
noOfBones = skinops.getNumberBones geo.modifiers[#Skin]
for b = 1 to noOfBones do --build the array of bones in the skin modifier
(
boneName = skinOps.GetBoneName geo.modifiers[#Skin] b 1
realBoneObj = getnodeByName boneName
appendIfUnique skinModBones realBoneObj
)
print "buildSkinModBoneList done."
)
fn runReplaceWeight geo = --using the fromToBOnes array call Stews replaceWeight script
(
tmpSel = selection as array
-- Use selection.count here Matt
-- selection[1] will also return the first item in a selection
if tmpSel.count == 1 then
(
if geo.modifiers[#Skin] != undefined then
(
max modify mode
modPanel.setCurrentObject geo.modifiers[#Skin]
buildSkinDataArray geo --build an array of all the verts in the mesh
buildSkinModBoneList geo --generate an array of all bones in the skin modifier
checkSkinBones()
print ("fromToBones count = "+(fromToBones[1].count as string))
for i = 1 to fromToBones[1].count do
(
-- compare the data in both arrays, if they do not match we need to flip.
if fromToBones[1][i] != fromToBones[2][i] then
(
replaceWeights fromToBones[1][i] fromToBones[2][i] --create arrays of the new weighting data
prepBoneNames geo
updateLODSkin geo --now we have the arrays setup do the actual skin weighting
)
)
print ("Weight switching complete")
)
else
(
messagebox ("WARNING! Selection "+geo.name+" has no skin modifier!") beep:true
)
)
else
(
messagebox ("WARNING! Please run on just one mesh") beep:true
)
)
-------------------------------------------------------------------------------------------------------------------------------------------------
fn cleanupSkel =
(
for b = 1 to boneArray.count do
(
clearSelection()
thisBone = (getNodeByName boneArray[b])
if thisBone != undefined do
(
lst = thisBone.pos.controller
if (lst[3] as string) == "SubAnim:Position_Constraint" do
(
print ("Deleting Pos on "+thisBone.name)
lst.delete 3 --delete the pos constraint
)
lst = thisBone.rotation.controller
if (lst[3] as string) == "SubAnim:LookAt_Constraint" do
(
print ("Deleting Rot on "+thisBone.name)
lst.delete 3 --delete the lookat
)
print ("cleaned controllers on "+thisBone.name)
)
)
for h = 1 to markerArray.count do
(
print ("Attempting to delete "+markerArray[h])
mrkr = (getNodeByName markerArray[h])
delete mrkr
)
)
fn removeBadBones = --this will remove all none core bones
(
max unhide all
max unfreeze all
max select all
sceneObjects = selection as array
-- clearListener()
print "Initialising skeleton node removal..."
print ("Total to test = "+(sceneObjects.count as string))
-- for obj = 1 to sceneObjects.count do
for obj = sceneObjects.count to 1 by -1 do
(
print ("Testing "+sceneObjects[obj].name+". Index = "+(obj as string))
if classof sceneObjects[obj] == BoneGeometry do
(
if substring sceneObjects[obj].name 1 4 != "SKEL" do
(
print ("Deleting bone"+sceneObjects[obj].name)
delete sceneObjects[obj]
)
)
)
max select all
sceneObjects = selection as array
for obj = sceneObjects.count to 1 by -1 do
(
if classof sceneObjects[obj] == Dummy do
(
if sceneObjects[obj].name != "Dummy01" do
(
if substring sceneObjects[obj].name 1 2 != "CS" do
(
if sceneObjects[obj].name != maxfilename do
(
if substring sceneObjects[obj].name 1 6 != "Player" do
(
print ("Deleting helper "+sceneObjects[obj].name)
delete sceneObjects[obj]
)
)
)
)
)
)
max select all
sceneObjects = selection as array
for obj = sceneObjects.count to 1 by -1 do
(
if classof sceneObjects[obj] == Col_Capsule do
(
print ("Deleting collision capsule "+sceneObjects[obj].name)
delete sceneObjects[obj]
)
)
max select all
sceneObjects = selection as array
for obj = sceneObjects.count to 1 by -1 do
(
if substring sceneObjects[obj].name 1 10 == "Constraint" do
(
print ("Deleting constraint "+sceneObjects[obj].name)
delete sceneObjects[obj]
)
)
print "Skeleton node removal complete."
)
fn combineGeo =
(
initialObjectArray = #()
volObjects = #()
originalMeshToSplit = undefined
meshToSplit = undefined
--******************************************************************************************
--FIRSTLY ATTACH ALL OF THE GEO INTO ONE PIECE
--******************************************************************************************
--need to do some error checking to ensure that the objects are picked and also that theyr are epoly
geo = $
if geo != undefined then
(
validObjs = 0
for obj in selection do
(
if (obj.baseObject as string) != ("Editable Poly") do
(
messageBox ("WARNING! "+obj.name+" is not an Editable Poly")
validObjs = 1
)
)
if validObjs == 0 do
(
--*****************************************************************************************
for obj in selection do
(
collapseStack obj --collapse the stack of the box
appendIfUnique initialObjectArray obj
)
initialObjectArraySize = initialObjectArray.count
print ("initialObjectArraySize = "+(initialObjectArraySize as string))
if initialObjectArraySize != 1 then
(
geoNo = (substring initialObjectArray[1].name 6 3)
for i = 1 to (initialObjectArray.count - 1) do
(
print ("Attaching "+initialObjectArray[i].name+" to "+initialObjectArray[initialObjectArraySize].name+"...")
initialObjectArray[initialObjectArraySize].attach initialObjectArray[i] initialObjectArray[initialObjectArraySize]
originalMeshToSplit = initialObjectArray[initialObjectArraySize]
print ("originalMeshToSplit = "+originalMeshToSplit.name)
)
)
else
(
geoNo = (substring $.name 6 3)
originalMeshToSplit = $
print ("originalMeshToSplit = "+originalMeshToSplit.name)
)
)
)
else
(
messageBox ("WARNING! Please select some geo") beep:true
)
)
FN trimSplitVols =
(
clearListener()
-- start = timeStamp()
-- clearListener()
dupSplitVols()
for tr = 1 to trimArrays.count do
(
for i = 2 to trimArrays[tr].count do
(
print (trimArrays[tr][1]+" needs to be trimmed by "+trimArrays[tr][i])
clearSelection()
if trimArrays[tr][i] == "TRIMMERBOX" then
(
if (substring trimArrays[tr][1] 15 1) == "L" then
(
trimmer = Box lengthsegs:10 widthsegs:10 heightsegs:10 length:2 width:1 height:2 mapcoords:on transform:(matrix3 [1,0,0] [0,0,1] [0,-1,0] [-0.49,1.06454,0.862417]) isSelected:on
trimmer.name = ("MASTERTRIM_TB_"+trimArrays[tr][1])
appendIfUnique dupSplitVol trimmer
select trimmer
)
else
(
trimmer = Box lengthsegs:10 widthsegs:10 heightsegs:10 length:2 width:1 height:2 mapcoords:on transform:(matrix3 [1,0,0] [0,0,1] [0,-1,0] [0.49,1.06454,0.862417]) isSelected:on
trimmer.name = ("MASTERTRIM_TB_"+trimArrays[tr][1])
appendIfUnique dupSplitVol trimmer
select trimmer
)
)
else
(
if trimArrays[tr][i] == "ARMTRIMBOX" then
(
trimBoxName = ("MASTERTRIM_TB_"+trimArrays[tr][i])
-- alreadyExists = getnodebyname trimBoxName
-- if alreadyExists != undefined do
-- (
-- delete alreadyExists
-- )
trimmer = Box lengthsegs:30 widthsegs:10 heightsegs:30 length:2 width:0.4 height:2 mapcoords:on transform:(matrix3 [1,0,0] [0,0,1] [0,-1,0] [-0.0,1.06454,0.862417]) isSelected:on
trimmer.name = trimBoxName
appendIfUnique dupSplitVol trimmer
select trimmer
)
else
(
--ok so first get the first item to be used as a trimmer and dupliocate it
-- trimmer = getNodeByName trimArrays[tr][i]
trimmer = getNodeByName ("MASTERTRIM_"+trimArrays[tr][i])
appendIfUnique dupSplitVol trimmer
select trimmer
)
)
nodeToBeTrimmed = getNodeByName trimArrays[tr][1]
--have to put trimmer into an array cos duplicate in max is dogshite
trimDupArr = selection as array
origName = trimArrays[tr][i]
newName = ("trimmer_"+(substring trimmer.Name 19 20))
maxOps.cloneNodes trimDupArr cloneType:#copy actualNodeList:&c newNodes:&nnl
trimmerObj = nnl[1]
trimmerObj.name = newName
select trimmerObj
--now to ensure we dont get clipping and nasty shit im gonna try increasing the radius
if classof trimmerObj == Cylinder do
(
trimmerObj.radius = (trimmerObj.radius * 2)
)
convertTo trimmerObj PolyMeshObject
--ok now we have duplicated the volume (so we dont loose it when we do a bool) we need to do the boolean to trim the original object
-- print ("Trimming "+trimmerObj.name)
-- trimmerBox = Box lengthsegs:1 widthsegs:1 heightsegs:1 length:2 width:1 height:2 mapcoords:on transform:(matrix3 [1,0,0] [0,0,1] [0,-1,0] [0.49,1.06454,0.862417]) isSelected:on
print ("Trimming "+nodeToBeTrimmed.name+" with "+trimmerObj.name)
boolObj.createBooleanObject nodeToBeTrimmed trimmerObj 4 5
boolObj.setBoolOp nodeToBeTrimmed 3
convertTo nodeToBeTrimmed PolyMeshObject
)
)
--now remove the masterTrim objects
for obj = dupSplitVol.count to 1 by -1 do
(
if (substring dupSplitVol[obj].name 1 11) == "MASTERTRIM_" do
(
delete dupSplitVol[obj]
)
)
-- end = timeStamp()
-- format "Processing took % seconds\n" ((end - start) / 1000.0)
)
fn createVols =
(
volObjects = #()
rigBoneListStruct = #( --array of all skeleton bones which we want to split mesh for
( rigBoneStruct rb_bone:$SKEL_Pelvis rb_Radius: 0.25 rb_Length:($SKEL_Pelvis.length * 2) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_Spine0 rb_Radius: 0.25 rb_Length:((distance $SKEL_Spine0 $SKEL_Spine1)) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_Spine1 rb_Radius: 0.25 rb_Length:($SKEL_Spine1.length * 1.4) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_Spine2 rb_Radius: 0.22 rb_Length:($SKEL_Spine2.length * 1.4) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_Spine3 rb_Radius: 0.24 rb_Length:($SKEL_Spine3.length * 0.8) rb_Trans:undefined ),
-- ( rigBoneStruct rb_bone:$SKEL_Head rb_Radius: 0.15 rb_Length:($SKEL_Head.length * 2) rb_Trans:(matrix3 [-1,0.000145016,-0.000328264] [-5.81659e-005,-0.96816,-0.250334] [-0.000354256,-0.250334,0.96816] [-0.000112729,0.0139014,1.59917]) ),
( rigBoneStruct rb_bone:$SKEL_Head rb_Radius: 0.15 rb_Length:($SKEL_Head.length * 2) rb_Trans:undefined),
( rigBoneStruct rb_bone:$SKEL_L_Thigh rb_Radius: 0.14 rb_Length:$SKEL_L_Thigh.length rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_L_Calf rb_Radius: 0.12 rb_Length:$SKEL_L_Calf.length rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_L_Foot rb_Radius: 0.1 rb_Length:($SKEL_L_Foot.length * 1.5) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_L_Toe0 rb_Radius: 0.1 rb_Length:0.25 rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_R_Thigh rb_Radius: 0.14 rb_Length:$SKEL_R_Thigh.length rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_R_Calf rb_Radius: 0.12 rb_Length:$SKEL_R_Calf.length rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_R_Foot rb_Radius: 0.1 rb_Length:($SKEL_R_Foot.length * 1.5) rb_Trans:(matrix3 [0.999233,0.0391547,3.80804e-005] [-0.00134612,0.0333794,0.999442] [0.0391315,-0.998676,0.0334067] [-0.155,0.145386,0.0342977]) ),
( rigBoneStruct rb_bone:$SKEL_R_Toe0 rb_Radius: 0.1 rb_Length:0.25 rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_L_Clavicle rb_Radius: 0.15 rb_Length:$SKEL_L_Clavicle.length rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_L_UpperArm rb_Radius: 0.1 rb_Length:$SKEL_L_UpperArm.length rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_L_Forearm rb_Radius: 0.1 rb_Length:($SKEL_L_Forearm.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_L_Hand rb_Radius: 0.05 rb_Length:$SKEL_L_Hand.length rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_L_Finger00 rb_Radius: 0.018 rb_Length:($SKEL_L_Finger00.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_L_Finger01 rb_Radius: 0.018 rb_Length:($SKEL_L_Finger01.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_L_Finger02 rb_Radius: 0.013 rb_Length:($SKEL_L_Finger02.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_L_Finger10 rb_Radius: 0.013 rb_Length:($SKEL_L_Finger10.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_L_Finger11 rb_Radius: 0.013 rb_Length:($SKEL_L_Finger11.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_L_Finger12 rb_Radius: 0.013 rb_Length:($SKEL_L_Finger12.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_L_Finger20 rb_Radius: 0.013 rb_Length:($SKEL_L_Finger20.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_L_Finger21 rb_Radius: 0.013 rb_Length:($SKEL_L_Finger21.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_L_Finger22 rb_Radius: 0.013 rb_Length:($SKEL_L_Finger22.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_L_Finger30 rb_Radius: 0.013 rb_Length:($SKEL_L_Finger30.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_L_Finger31 rb_Radius: 0.013 rb_Length:($SKEL_L_Finger31.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_L_Finger32 rb_Radius: 0.013 rb_Length:($SKEL_L_Finger32.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_L_Finger40 rb_Radius: 0.013 rb_Length:($SKEL_L_Finger40.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_L_Finger41 rb_Radius: 0.013 rb_Length:($SKEL_L_Finger41.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_L_Finger42 rb_Radius: 0.013 rb_Length:($SKEL_L_Finger42.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_R_Clavicle rb_Radius: 0.15 rb_Length:$SKEL_R_Clavicle.length rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_R_UpperArm rb_Radius: 0.1 rb_Length:$SKEL_R_UpperArm.length rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_R_Forearm rb_Radius: 0.1 rb_Length:($SKEL_R_Forearm.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_R_Hand rb_Radius: 0.05 rb_Length:$SKEL_R_Hand.length rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_R_Finger00 rb_Radius: 0.018 rb_Length:($SKEL_R_Finger00.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_R_Finger01 rb_Radius: 0.018 rb_Length:($SKEL_R_Finger01.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_R_Finger02 rb_Radius: 0.013 rb_Length:($SKEL_R_Finger02.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_R_Finger10 rb_Radius: 0.013 rb_Length:($SKEL_R_Finger10.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_R_Finger11 rb_Radius: 0.013 rb_Length:($SKEL_R_Finger11.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_R_Finger12 rb_Radius: 0.013 rb_Length:($SKEL_R_Finger12.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_R_Finger20 rb_Radius: 0.013 rb_Length:($SKEL_R_Finger20.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_R_Finger21 rb_Radius: 0.013 rb_Length:($SKEL_R_Finger21.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_R_Finger22 rb_Radius: 0.013 rb_Length:($SKEL_R_Finger22.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_R_Finger30 rb_Radius: 0.013 rb_Length:($SKEL_R_Finger30.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_R_Finger31 rb_Radius: 0.013 rb_Length:($SKEL_R_Finger31.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_R_Finger32 rb_Radius: 0.013 rb_Length:($SKEL_R_Finger32.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_R_Finger40 rb_Radius: 0.013 rb_Length:($SKEL_R_Finger40.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_R_Finger41 rb_Radius: 0.013 rb_Length:($SKEL_R_Finger41.length * 1.1) rb_Trans:undefined ),
( rigBoneStruct rb_bone:$SKEL_R_Finger42 rb_Radius: 0.013 rb_Length:($SKEL_R_Finger42.length * 1.1) rb_Trans:undefined )
)
--******************************************************************************************
--NOW CREATE THE VOLUMES FOR DETACHING THE MESH INTO PIECES
--******************************************************************************************
for i = 1 to rigBoneListStruct.count do
(
volTrans = undefined
currentObj = getNodeByName ("splitVol_"+rigBoneListStruct[i].rb_bone.name)
if currentObj != undefined do
(
delete currentObj
)
--we need to make the feet vols as cubes so this is a bit of a hack
if (rigBoneListStruct[i].rb_bone.name == "SKEL_L_Foot") then
(
splitObj = Box lengthsegs:10 widthsegs:10 heightsegs:10 length:0.4 width:0.3 height:0.125 mapcoords:on pos:[0.141602,0.0458236,0] isSelected:on
splitObj.name = ("splitVol_"+rigBoneListStruct[i].rb_bone.name)
splitObj.parent = rigBoneListStruct[i].rb_bone
)
else
(
if (rigBoneListStruct[i].rb_bone.name == "SKEL_R_Foot") then
(
splitObj = Box lengthsegs:10 widthsegs:10 heightsegs:10 length:0.4 width:0.3 height:0.125 mapcoords:on pos:[-0.141602,0.0458236,0] isSelected:on
splitObj.name = ("splitVol_"+rigBoneListStruct[i].rb_bone.name)
splitObj.parent = rigBoneListStruct[i].rb_bone
)
else
(
splitObj = Cylinder smooth:on heightsegs:8 capsegs:4 sides:8 height:rigBoneListStruct[i].rb_Length radius:rigBoneListStruct[i].rb_Radius mapcoords:on pos:[0,0,0] isSelected:on
splitObj.name = ("splitVol_"+rigBoneListStruct[i].rb_bone.name)
splitObj.parent = rigBoneListStruct[i].rb_bone
--******************************************************************************************
--NOW SORT OUT THE ALIGNMENT OF THE VOLUME
--******************************************************************************************
if rigBoneListStruct[i].rb_Trans == undefined then
(
volTrans = rigBoneListStruct[i].rb_bone.transform
splitObj.transform = ( in coordsys parent volTrans)
in coordsys parent rotate splitObj (angleaxis 90 [0,1,0])
if (substring splitObj.name 15 5) == "Spine" do
(
in coordsys world splitObj.rotation = (quat 3.65661e-007 0 -1 6.78003e-007)
)
)
else --this allows us to offset the transforms from the bone.
(
volTrans = rigBoneListStruct[i].rb_Trans
splitObj.transform = ( in coordsys parent volTrans)
)
append volObjects splitObj
)
)
)
trimSplitVols()
)
fn splitMesh origMeshName skinOrNot = --this splits the mesh into chunks based off volumes
(
createDialog progBar width:300 Height:30
undo off
(
chunkMeshes = #()
-- disableSceneRedraw()
for i = 1 to volObjects.count do
(
if (substring volObjects[i].name 17 6) == "Finger" then
(
volper = decimationAmt + (decimationAmt * 0.1)
)
else
(
volPer = decimationAmt
)
print ("originalMeshToSplit = "+originalMeshToSplit.name)
maxOps.cloneNodes originalMeshToSplit cloneType:#copy newNodes:&nnl
meshToSplit = nnl[1]
if geoNo != undefined then
(
meshToSplit.name = ("geo_"+geoNo+"_"+(subString volObjects[i].name 15 20))
)
else
(
meshToSplit.name = ("geo_"+(subString volObjects[i].name 15 20))
)
boolObj.createBooleanObject meshToSplit volObjects[i] 4 5
boolObj.setBoolOp meshToSplit 2
convertTo meshToSplit PolyMeshObject
print ("meshToSplit = "+meshToSplit.name)
print ("i = "+(i as string))
select meshToSplit
if (decimationAmt != 0) do
(
if decimationAmt == 100 do --quick hack to ensure we never decimate by 100%
(
volper = (99)
)
modPanel.addModToSelection (ProOptimizer ()) ui:on
meshToSplit.modifiers[#ProOptimizer].KeepUV = on
meshToSplit.modifiers[#ProOptimizer].OptimizationMode = 1
meshToSplit.modifiers[#ProOptimizer].Calculate = on
meshToSplit.modifiers[#ProOptimizer].VertexPercent = volPer
meshToSplit.modifiers[#ProOptimizer].Calculate = off --trying toforce a recalc as sometimes it becomes invalid
meshToSplit.modifiers[#ProOptimizer].Calculate = on
)
modPanel.addModToSelection (Cap_Holes ()) ui:on
$.modifiers[#Cap_Holes].Make_All_New_Edges_Visible = 1
$.modifiers[#Cap_Holes].Smooth_With_Old_Faces = 0
collapseStack meshToSplit
if skinOrNot == true then
(
print ("Skinning "+meshToSplit.name+" to "+(rigBoneListStruct[i].rb_Bone as string))
--skin it
modPanel.addModToSelection (Skin ()) ui:on
meshToSplit.modifiers[#Skin].bone_Limit = 1
skinOps.addBone meshToSplit.modifiers[#Skin] rigBoneListStruct[i].rb_bone 1
)
else
(
print ("Parenting "+meshToSplit.name+" to "+rigBoneListStruct[i].rb_bone.name)
meshToSplit.parent = rigBoneListStruct[i].rb_bone
)
progBar.prog.value = (100.*i/volObjects.count)
appendIfUnique chunkMeshes meshToSplit
)
)
destroyDialog progBar
if originalMeshToSplit != undefined do
(
-- delete originalMeshToSplit
)
--now do the bit that combines all splitted meshes into one and reskins
-- tmpSegMesh()
-- combineIndiv origMeshName chunkMeshes
--test
-- print ("Attempting to delete volObjects array")
-- delete volObjects
)
fn reparentRollBones = --this is a hacky way to get around parenting on thigh roll bones
(
if $RB_L_ThighRoll.parent == $Skel_Pelvis do
(
$RB_L_ThighRoll.parent = $SKEL_L_Thigh
)
if $RB_R_ThighRoll.parent == $SKEL_Pelvis do
(
$RB_R_ThighRoll.parent = $SKEL_R_Thigh
)
)
fn giantPrepUI =
(
-- riggingStageEvaluator()
--setup some stuff for the dotNet tabs magic
global giantPrepDialog
try (cui.UnRegisterDialogBar giantPrepDialog)catch()
try (destroyDialog giantPrepDialog)catch()
-- global LastSubRollout = 1
-------------------------------------------------------------------------------------------------------------------------
rollout SkinnedRoll "Skinned"
(
-- button btnRemoveWeightsAndBones "Remove Bones" width:120 height:25
--
-- on btnRemoveWeightsAndBones pressed do
-- (
-- hideByCategory.none() --ensure none of the display filters are set to hidden
--
-- max select all
--
-- selArr = selection as array
--
-- if selArr.count < 1 then
-- (
-- messageBox "please select stuff!" beep:true
-- )
-- else
-- (
-- killKeys()
--
-- reparentRollBones()
--
-- max select none
-- for i = 1 to selArr.count do
-- (
-- if classof selArr[i].baseObject == Editable_Poly do
-- (
-- if selArr[i].modifiers[#Skin] != undefined do
-- (
-- select selArr[i]
-- -- iVal = finditem selArr selArr[i]
-- -- progBar.prog.value = (100.*iVal/selArr.count)
-- print ("Replaing weights on "+selArr[i].name)
-- runReplaceWeight selArr[i]
-- )
-- )
-- )
-- -- destroyDialog progBar
-- hideAllToKeep()
-- )
-- )
)
rollout PreRiggedRoll "Pre-Rigged"
(
-- button btnCombineGeo "Init Geo" width:120 height:25
-- button btnGenVol "Generate Volumes" width:120 height:25
-- button btnSplitMesh "Prep Meshes" width:120 height:25
-- button btnCleanSkel "Clean Skeleton" width:120 height:25
-- button btnBatch "Batch Scene" width:120 height:25
--
-- spinner spinDecAmnt "Amount to Decimate by:" pos:[100,160] width:80 range:[0,100,75] type:#integer
--
-- checkBox chkSkin "Skin" checked:true tooltip:"Do you want to skin or parent the meshes?"
--
-- on PreRiggedRoll open do
-- (
-- spinDecAmnt.value = 0
-- skinOrNot == true
-- )
--
-- on chkSkin changed theState do
-- (
-- if chkSkin.state == true then
-- (
-- skinOrNot = true
-- print ("skinOrNot = "+(skinOrNot as string))
-- )
-- else
-- (
-- skinOrNot = false
-- print ("skinOrNot = "+(skinOrNot as string))
-- )
-- )
--
-- on btnCombineGeo pressed do
-- (
-- combineGeo()
-- )
-- on btnGenVol pressed do
-- (
-- createVols()
-- )
-- on btnSplitMesh pressed do
-- (
-- decimationAmt = spinDecAmnt.value
-- splitMesh skinOrNot
-- )
--
-- on btnCleanSkel pressed do
-- (
-- removeBadBones()
-- )
--
-- on btnBatch pressed do
-- (
-- --**************************************************************************************************************
-- -- THIS IS DEPENDANT UPON SELECTION SETS BEING CREATED AND NAMED *000 OR *001 ETC
-- --**************************************************************************************************************
-- for i = 1 to selectionSets.count do
-- (
-- ssName = selectionSets[i].name
-- if ssName.count == 4 do
-- (
-- if ssName != "*All" do
-- (
-- print ssName
-- clearSelection()
-- for ob = 1 to selectionSets[i].count do
-- (
-- selectMore selectionSets[i][ob]
-- )
-- maxOps.cloneNodes selection cloneType:#copy newNodes:&nnl --need to clone nodes first so we dont destroy the originals and also cos some sets may share items
-- hide selection
-- clearSelection()
-- for obj = 1 to nnl.count do
-- (
-- selectMore nnl[obj]
-- )
-- combineGeo()
-- createVols()
-- splitMesh origMeshName skinOrNot
-- removeBadBones()
--print ("LooLooLaLa "+(selection.count as string))
-- )
-- )
-- )
-- )
)
-------------------------------------------------------------------------------------------------------------------------
rollout RawMeshRoll "Raw Mesh"
(
-- checkBox chkSex "Male" checked:true tooltip:"Is this character a male?" pos:[15, 05]
--
-- button btnMergePrepSkel "Merge Prep Skel" pos:[15,30] width:120 height:25
-- button btnGenVol "Generate Volumes" pos:[15,55] width:120 height:25
-- button btnSplitMesh "Split Meshes" pos:[15,80] width:120 height:25
--
-- spinner spinDecAmnt "Decimation amount:" range:[0,100,75] type:#integer
--
-- on btnMergePrepSkel pressed do
-- (
-- if chkSex == true then
-- (
-- mergeMAXFile "X:\\gta5\\art\\peds\\Skeletons\\giantConstrainedSkel_Male.max"
-- )
-- else
-- (
-- mergeMAXFile "X:\\gta5\\art\\peds\\Skeletons\\giantConstrainedSkel_FeMale.max"
-- )
-- )
--
-- on btnGenVol pressed do
-- (
-- originalMeshToSplit = undefined
-- obToSplit = selection as array
-- if obToSplit.count ==1 then
-- (
-- originalMeshToSplit = obToSplit[1]
-- createVols()
-- )
-- else
-- (
-- messagebox "Please ensure only oone object is selected" beep:true
-- )
-- )
-- on btnSplitMesh pressed do
-- (
-- decimationAmt = spinDecAmnt.value
-- splitMesh()
--
-- --now we need to remove position and lookat constraints on skeleton then remove markers
-- cleanupSkel()
--
-- )
)--end RawMeshRoll
-------------------------------------------------------------------------------------------------------------------------
rollout skelSpotRoll "Skel Spot"
(
-- hyperlink lnkHelp "Help?" address:"https://devstar.rockstargames.com/wiki/index.php/Character_Quick_Skin_Tool" align:#right color:(color 20 20 255) hoverColor:(color 255 255 255) visitedColor:(color 0 0 255)
checkBox chkSex "Male" checked:true tooltip:"Is this character a male?" pos:[15, 05]
checkBox chkSkin "Skin Mesh?" checked:true tooltip:"Is this character a male?" pos:[80, 05]
checkBox chkRawMesh "Use Scene Mesh?" checked:true tooltip:"Use mesh from scene?" pos:[15, 20]
button btnAutoGiant "Auto Giant" pos:[15,35] width:190 height:80
spinner spinDecAmnt "Decimation amount:" range:[0,100,120] type:#integer
on skelSpotRoll open do
(
spinDecAmnt.value = 25
skinOrNot == true
)
on btnAutoGiant pressed do
(
start = timeStamp()
sexCheckState = chkSex.state
useSceneMesh = chkRawMesh.state
if useSceneMesh == true then
(
--ok we need ot pick an object from the scene to use as the scene mesh which we will sve into
selectedMeshPiece = selectByName title:"Pick rawMesh object" showHidden:true
if selectedMeshPiece == undefined then
(
messageBox ("WARNING!."+"\r\n"+"No Mesh was selected."+"\r\n" +"Ensure you uncheck the Use Scene Mesh toggle if you dont want to use a mesh from this scene.") Beep:true
)
else
(
format "You selected '%'!\n" selectedMeshPiece
selectedMeshPiece.parent = undefined --unlink the mesh
--we need to rename the picked mesh to be called $head_000_r
selectedMeshPiece.name = "head_000_r"
saveNodes selectedMeshPiece "c:\skins\animations\deformedMesh.max" quiet:true
filein (RsConfigGetWildWestDir() + "script\\max\\Rockstar_North\\character\\Rigging_tools\\giant\\autoGiantSkeletonSPot.ms")
skinOrNot = chkSkin.state
obToSplit = #("head_000_R", "Uppr_000_U", "Lowr_000_U")
originalMeshToSplit = getNodeByName obToSplit[1]
select originalMeshToSplit
createVols()
decimationAmt = spinDecAmnt.value
splitMesh originalMeshToSPlit.name skinOrNot
-- originalMeshToSplit = getNodeByName obToSplit[2]
-- select originalMeshToSplit
-- createVols()
-- decimationAmt = spinDecAmnt.value
-- splitMesh originalMeshToSPlit.name skinOrNot
--
-- originalMeshToSplit = getNodeByName obToSplit[3]
-- select originalMeshToSplit
-- createVols()
-- decimationAmt = spinDecAmnt.value
-- splitMesh originalMeshToSPlit.name skinOrNot
--kind of hacky cleanup to get rid of the feet boxes
-- lfut = getNodeByName "splitVol_SKEL_L_Foot"
-- if lfut != undefined do (delete lfut)
-- rfut = getNodeByName "splitVol_SKEL_R_Foot"
-- if rfut != undefined do (delete rfut)
end = timeStamp()
format "Processing took % minutes\n" (((end - start) / 1000.0) / 60)
)
)
else --ok we're not wanting to us a scene mesh
(
filein (RsConfigGetWildWestDir() + "script\\max\\Rockstar_North\\character\\Rigging_tools\\giant\\autoGiantSkeletonSPot.ms")
skinOrNot = chkSkin.state
obToSplit = #("head_000_R", "Uppr_000_U", "Lowr_000_U")
-- originalMeshToSplit = getNodeByName obToSplit[1]
-- select originalMeshToSplit
-- createVols()
-- decimationAmt = spinDecAmnt.value
-- splitMesh originalMeshToSplit.name skinOrNot
--
--
-- originalMeshToSplit = getNodeByName obToSplit[2]
-- select originalMeshToSplit
-- createVols()
-- decimationAmt = spinDecAmnt.value
-- splitMesh originalMeshToSPlit.name skinOrNot
--
-- originalMeshToSplit = getNodeByName obToSplit[3]
-- select originalMeshToSplit
-- createVols()
-- decimationAmt = spinDecAmnt.value
-- splitMesh originalMeshToSPlit.name skinOrNot
--kind of hacky cleanup to get rid of the feet boxes
lfut = getNodeByName "splitVol_SKEL_L_Foot"
if lfut != undefined do (delete lfut)
rfut = getNodeByName "splitVol_SKEL_R_Foot"
if rfut != undefined do (delete rfut)
end = timeStamp()
format "Processing took % minutes\n" (((end - start) / 1000.0) / 60)
)
)
)--end RawMeshRoll
--The Hookup tab rollout
-------------------------------------------------------------------------------------------------------------------------
--The Main event. The stuff that adds tabs
global giantPrepDialog_Rollouts = #(#("Skel Spot",#(skelSpotRoll)),#("Pre-Rigged",#(PreRiggedRoll)), #("Raw Mesh",#(RawMeshRoll)),#("Skinned",#(SkinnedRoll)) )
rollout giantPrepDialog "Giant Tools"
(
dotNetControl dn_tabs "System.Windows.Forms.TabControl" height:20 width:210 align:#center
subRollout theSubRollout width:230 height:595 align:#center
on dn_tabs Selected itm do
(
if LastSubRollout != (itm.TabPageIndex+1) do --do not update if the same tab clicked twice
(
for subroll in giantPrepDialog_Rollouts[LastSubRollout][2] do
(
-- print ("removing "+(subroll as string))
removeSubRollout theSubRollout subroll
)
for subroll in giantPrepDialog_Rollouts[LastSubRollout = itm.TabPageIndex+1][2] do
(
-- print ("adding "+(subroll as string))
addSubRollout theSubRollout subroll
)
)
)--end tabs clicked
on giantPrepDialog open do
(
for aTab in giantPrepDialog_Rollouts do
(dn_tabs.TabPages.add aTab[1])
if LastSubRollout == 1 do
(
for subroll in giantPrepDialog_Rollouts[1][2] do
(
addSubRollout theSubRollout subroll
)
)
if LastSubRollout == 2 do
(
for subroll in giantPrepDialog_Rollouts[2][2] do
(
addSubRollout theSubRollout subroll
)
)
)--end giantPrepDialog open
)
-------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------
createDialog giantPrepDialog 250 350 pos:[1250, 100] --main window size
cui.RegisterDialogBar giantPrepDialog minSize:[180,240] style:#(#cui_dock_all, #cui_floatable)
)
giantPrepUI()