Vertex Animation exporting from MAX
Moderators: GSH, VSMIT, Red Devil, Commando
- MrTwosheds
- Recycler
- Posts: 3059
- Joined: Sat Feb 19, 2011 8:37 am
- Location: Outer Space
- Contact:
Re: Vertex Animation exporting from MAX
3dsMax 7
Does it every time.
Does it every time.
Re: Vertex Animation exporting from MAX
OK error understood now. I bet that that version of max doesn't support dotNetControls. That was used to create the multi-line text area to copy the text from. It needs another output method then. I will whip something up quick.
Try this, you will have to open the MaxScript Listener first and be sure you clear all the text out of it before you run this. It will add some extra crap too and even a " on either side of the bit you want, but you should be able to recognize what you will want to copy out and into the XSI vs the rest of the random output from the script.
Try this, you will have to open the MaxScript Listener first and be sure you clear all the text out of it before you run this. It will add some extra crap too and even a " on either side of the bit you want, but you should be able to recognize what you will want to copy out and into the XSI vs the rest of the random output from the script.
Code: Select all
sXSIData = ""
envelopeCount = 0
setOfAll = $*
for obj in setOfAll do
(
skinModifier = obj.modifiers[#skin]
if (skinModifier != undefined) do -- check for skin modifier
(
PrepareMaxForSkinOps obj
for i=1 to skinOps.GetNumberBones skinModifier do
(
envelopeCount += 1
boneName = skinOps.GetBoneName skinModifier i 0
sXSIData += " SI_Envelope {\r\n"
sXSIData += " \"frm-" + obj.name + "\";\r\n"
sXSIData += " \"frm-" + boneName + "\";\r\n"
vertArray = getAffectedVerts skinModifier i
sXSIData += " " + vertArray.count as string + ";\r\n"
for j=1 to vertArray.count do
(
vertNumber = vertArray[j]
vertNumber -= 1
weight = getVertexWeightFromWorldBone skinModifier vertArray[j] i
weight *= 100
sXSIData += " " + vertNumber as string + ";" + weight as string + ";,\r\n"
)
sXSIData += " }\r\n"
)
)
)
if (envelopeCount > 0) then
(
sXSIData = "SI_EnvelopeList {\r\n " + envelopeCount as string + ";\r\n" + sXSIData + "}"
print sXSIData
)
Function PrepareMaxForSkinOps _pNode =
(
-- Select @_pNode if needed.
if not _pNode.IsSelected do
(
Select _pNode
)
-- Unfreeze @_pNode if needed.
if _pNode.IsFrozen do
(
Unfreeze _pNode DoLayer:true
)
-- Set Modify Panel active if needed.
if GetCommandPanelTaskMode() != #modify do
(
SetCommandPanelTaskMode mode:#modify
)
-- Set @_pNode skin modifier as current object in modpanel if needed.
if ModPanel.GetCurrentObject() != _pNode.skin do
(
ModPanel.SetCurrentObject _pNode.skin
)
)
fn getAffectedVerts skinMod boneID=
(
vertAr=#()
numVerts=skinOps.getNumberVertices skinMod
for i = 1 to numVerts do
(
numBoneAffectVert=skinOps.GetVertexWeightCount skinMod i
for boneNum = 1 to numBoneAffectVert do
(
sysBoneID=skinOps.GetVertexWeightBoneID skinMod i boneNum
if sysBoneID==boneID then append vertAr i
)
)
vertAr
)
fn getVertexWeightFromWorldBone skinMod vertID boneID=
(
weight = 0
countBones = skinOps.GetVertexWeightCount skinMod vertID
for i = 1 to countBones do
(
if boneID == skinOps.GetVertexWeightBoneID skinMod vertID i then
(
weight = skinOps.GetVertexWeight skinMod vertID i
break
)
)
weight
)
- MrTwosheds
- Recycler
- Posts: 3059
- Joined: Sat Feb 19, 2011 8:37 am
- Location: Outer Space
- Contact:
Re: Vertex Animation exporting from MAX
Pasted into envelope.ms, opened maxscript listener, run script, nothing at all happens.
Got an Idiots guide?
Got an Idiots guide?
Re: Vertex Animation exporting from MAX
You need to actually have skins and bones in the model. If you do, no idea. The print command should be working. Before it didn't die till it got to the line to generate the output display. Only thing I could do is try to do it remotely on your PC to see why it isn't working. I cant use that version of MAX here.MrTwosheds wrote:Pasted into envelope.ms, opened maxscript listener, run script, nothing at all happens.
Got an Idiots guide?
- MrTwosheds
- Recycler
- Posts: 3059
- Joined: Sat Feb 19, 2011 8:37 am
- Location: Outer Space
- Contact:
Re: Vertex Animation exporting from MAX
Which means what exactly? I had used the skin modifier, with ordinary objects, collapsed and saved, as a tutorial showed. I have seen mention of bones in places in Max, but as usual they are there in a "you already know how to use this so no logical layout is required" manner.You need to actually have skins and bones in the model
It does seem to me that the skin tool is very much designed with figure type models in mind, I had a fair amount of trouble getting it to do "Tank"
Re: Vertex Animation exporting from MAX
Is the skin modifier still in the list, it sort of needs to be. You said collapsed. Technically you would want to collapse the modifier stack to just Editable Mesh, and then put the skin on top of that. If the skin is on top you can right click the option under it and tell it to collapse up to that point. The skin modifier still has to be in the list.
- MrTwosheds
- Recycler
- Posts: 3059
- Joined: Sat Feb 19, 2011 8:37 am
- Location: Outer Space
- Contact:
Re: Vertex Animation exporting from MAX
Right that's what I did wrong then.
- MrTwosheds
- Recycler
- Posts: 3059
- Joined: Sat Feb 19, 2011 8:37 am
- Location: Outer Space
- Contact:
Re: Vertex Animation exporting from MAX
Tried again, got this.
-- Error occurred in Obj loop
-- Frame:
-- skinModifier: Skin:Skin
-- Obj: $Editable_Mesh:turret_y @ [-0.000919,-0.547622,1.887849]
-- PrepareMaxForSkinOps: undefined
-- Error occurred during fileIn in <File:D:\3dsmax\scripts\envelope.ms>
>> MAXScript FileIn Exception: -- Type error: Call needs function or class, got: undefined <<
-- Error occurred in Obj loop
-- Frame:
-- skinModifier: Skin:Skin
-- Obj: $Editable_Mesh:turret_y @ [-0.000919,-0.547622,1.887849]
-- PrepareMaxForSkinOps: undefined
-- Error occurred during fileIn in <File:D:\3dsmax\scripts\envelope.ms>
>> MAXScript FileIn Exception: -- Type error: Call needs function or class, got: undefined <<
Re: Vertex Animation exporting from MAX
It is saying that the function 'PrepareMaxForSkinOps' doesn't exist, but it does. it is one of the pile of functions on the bottom of the script.MrTwosheds wrote:Tried again, got this.
-- Error occurred in Obj loop
-- Frame:
-- skinModifier: Skin:Skin
-- Obj: $Editable_Mesh:turret_y @ [-0.000919,-0.547622,1.887849]
-- PrepareMaxForSkinOps: undefined
-- Error occurred during fileIn in <File:D:\3dsmax\scripts\envelope.ms>
>> MAXScript FileIn Exception: -- Type error: Call needs function or class, got: undefined <<
That function selects the object then selects the skin modifier so that it can access its data.
- MrTwosheds
- Recycler
- Posts: 3059
- Joined: Sat Feb 19, 2011 8:37 am
- Location: Outer Space
- Contact:
Re: Vertex Animation exporting from MAX
Does the capital S of SkinOps matter, some places it is S others s
Re: Vertex Animation exporting from MAX
No, skinOps is a variable, PrepareMaxForSkinOps is a function.MrTwosheds wrote:Does the capital S of SkinOps matter, some places it is S others s
EDIT: try this:
Code: Select all
sXSIData = ""
envelopeCount = 0
setOfAll = $*
for obj in setOfAll do
(
skinModifier = obj.modifiers[#skin]
if (skinModifier != undefined) do -- check for skin modifier
(
PrepareMaxForSkinOps obj
for i=1 to skinOps.GetNumberBones skinModifier do
(
envelopeCount += 1
boneName = skinOps.GetBoneName skinModifier i 0
sXSIData += " SI_Envelope {\r\n"
sXSIData += " \"frm-" + obj.name + "\";\r\n"
sXSIData += " \"frm-" + boneName + "\";\r\n"
vertArray = getAffectedVerts skinModifier i
sXSIData += " " + vertArray.count as string + ";\r\n"
for j=1 to vertArray.count do
(
vertNumber = vertArray[j]
vertNumber -= 1
weight = getVertexWeightFromWorldBone skinModifier vertArray[j] i
weight *= 100
sXSIData += " " + vertNumber as string + ";" + weight as string + ";,\r\n"
)
sXSIData += " }\r\n"
)
)
)
if (envelopeCount > 0) then
(
sXSIData = "SI_EnvelopeList {\r\n " + envelopeCount as string + ";\r\n" + sXSIData + "}"
print sXSIData
)
fn PrepareMaxForSkinOps _pNode =
(
-- Select @_pNode if needed.
if not _pNode.IsSelected do
(
Select _pNode
)
-- Unfreeze @_pNode if needed.
if _pNode.IsFrozen do
(
Unfreeze _pNode DoLayer:true
)
-- Set Modify Panel active if needed.
if GetCommandPanelTaskMode() != #modify do
(
SetCommandPanelTaskMode mode:#modify
)
-- Set @_pNode skin modifier as current object in modpanel if needed.
if ModPanel.GetCurrentObject() != _pNode.skin do
(
ModPanel.SetCurrentObject _pNode.skin
)
)
fn getAffectedVerts skinMod boneID=
(
vertAr=#()
numVerts=skinOps.getNumberVertices skinMod
for i = 1 to numVerts do
(
numBoneAffectVert=skinOps.GetVertexWeightCount skinMod i
for boneNum = 1 to numBoneAffectVert do
(
sysBoneID=skinOps.GetVertexWeightBoneID skinMod i boneNum
if sysBoneID==boneID then append vertAr i
)
)
vertAr
)
fn getVertexWeightFromWorldBone skinMod vertID boneID=
(
weight = 0
countBones = skinOps.GetVertexWeightCount skinMod vertID
for i = 1 to countBones do
(
if boneID == skinOps.GetVertexWeightBoneID skinMod vertID i then
(
weight = skinOps.GetVertexWeight skinMod vertID i
break
)
)
weight
)
- MrTwosheds
- Recycler
- Posts: 3059
- Joined: Sat Feb 19, 2011 8:37 am
- Location: Outer Space
- Contact:
Re: Vertex Animation exporting from MAX
Did the same again.
-- Error occurred in Obj loop
-- Frame:
-- PrepareMaxForSkinOps: undefined
-- Obj: $Editable_Mesh:turret_y @ [-0.000919,7.422085,2.949151]
-- skinModifier: Skin:Skin
-- Error occurred during fileIn in <File:D:\3dsmax\scripts\envelope.ms>
>> MAXScript FileIn Exception: -- Type error: Call needs function or class, got: undefined <<
-- Error occurred in Obj loop
-- Frame:
-- PrepareMaxForSkinOps: undefined
-- Obj: $Editable_Mesh:turret_y @ [-0.000919,7.422085,2.949151]
-- skinModifier: Skin:Skin
-- Error occurred during fileIn in <File:D:\3dsmax\scripts\envelope.ms>
>> MAXScript FileIn Exception: -- Type error: Call needs function or class, got: undefined <<
Re: Vertex Animation exporting from MAX
Try this:
Code: Select all
sXSIData = ""
envelopeCount = 0
setOfAll = $*
fn PrepareMaxForSkinOps _pNode =
(
-- Select @_pNode if needed.
if not _pNode.IsSelected do
(
Select _pNode
)
-- Unfreeze @_pNode if needed.
if _pNode.IsFrozen do
(
Unfreeze _pNode DoLayer:true
)
-- Set Modify Panel active if needed.
if GetCommandPanelTaskMode() != #modify do
(
SetCommandPanelTaskMode mode:#modify
)
-- Set @_pNode skin modifier as current object in modpanel if needed.
if ModPanel.GetCurrentObject() != _pNode.skin do
(
ModPanel.SetCurrentObject _pNode.skin
)
)
fn getAffectedVerts skinMod boneID=
(
vertAr=#()
numVerts=skinOps.getNumberVertices skinMod
for i = 1 to numVerts do
(
numBoneAffectVert=skinOps.GetVertexWeightCount skinMod i
for boneNum = 1 to numBoneAffectVert do
(
sysBoneID=skinOps.GetVertexWeightBoneID skinMod i boneNum
if sysBoneID==boneID then append vertAr i
)
)
vertAr
)
fn getVertexWeightFromWorldBone skinMod vertID boneID=
(
weight = 0
countBones = skinOps.GetVertexWeightCount skinMod vertID
for i = 1 to countBones do
(
if boneID == skinOps.GetVertexWeightBoneID skinMod vertID i then
(
weight = skinOps.GetVertexWeight skinMod vertID i
break
)
)
weight
)
for obj in setOfAll do
(
skinModifier = obj.modifiers[#skin]
if (skinModifier != undefined) do -- check for skin modifier
(
PrepareMaxForSkinOps obj
for i=1 to skinOps.GetNumberBones skinModifier do
(
envelopeCount += 1
boneName = skinOps.GetBoneName skinModifier i 0
sXSIData += " SI_Envelope {\r\n"
sXSIData += " \"frm-" + obj.name + "\";\r\n"
sXSIData += " \"frm-" + boneName + "\";\r\n"
vertArray = getAffectedVerts skinModifier i
sXSIData += " " + vertArray.count as string + ";\r\n"
for j=1 to vertArray.count do
(
vertNumber = vertArray[j]
vertNumber -= 1
weight = getVertexWeightFromWorldBone skinModifier vertArray[j] i
weight *= 100
sXSIData += " " + vertNumber as string + ";" + weight as string + ";,\r\n"
)
sXSIData += " }\r\n"
)
)
)
if (envelopeCount > 0) then
(
sXSIData = "SI_EnvelopeList {\r\n " + envelopeCount as string + ";\r\n" + sXSIData + "}"
print sXSIData
)
- MrTwosheds
- Recycler
- Posts: 3059
- Joined: Sat Feb 19, 2011 8:37 am
- Location: Outer Space
- Contact:
Re: Vertex Animation exporting from MAX
That worked!
Hmmm.
"SI_EnvelopeList {
etc
}
}"
Don't think the 2 " want to be there. Not greatly important as long as the user knows to not copy them.
Hmmm.
"SI_EnvelopeList {
etc
}
}"
Don't think the 2 " want to be there. Not greatly important as long as the user knows to not copy them.
Re: Vertex Animation exporting from MAX
Yea they are there because of the sucky output method I had to use when the dotnetcontrol wasn't working for you.