SKIN modifier issue or alternative

also in http://forums.cgsociety.org/showthread.php?f=98&t=936192

Hi, i have a big problem of crash when i utilize the skin modifier in my script
This is a small description of my script:

Struct MeshClass
(
    filename = "", Faces=#(),FacesIndex=#(),FacesName=#(),VertsData=#(),TVertsData=#(),
    WeightsData=#(), -- bone1_idx ; bone2_idx ; %bone1
    NormalData=#(),BoneMesh=#(),BoundingSphere=#(),TextureData=#(),SkeletonData=#(),
    fn deleteProp =
    (
        Faces=FacesIndex=FacesName=VertsData=TVertsData=NormalData= undefined
    ),
    fn AssignWeight Weight_Arrar Obj_Array=
    (
         st = timeStamp()
        format "Drawing weight bone...\n"
        progressStart "Drawing weight bone"
        cont = Obj_Array.count
        listen = stringStream ""
        for i=1 to cont do
        (
            progressUpdate ((i*100.0/cont) as integer)
            format "obj%\n" i
            obj = Obj_Array[i]
            weight = Weight_Arrar[i]
            if obj.numverts != weight.count do (MessageBox "Attention, error in the object" ; return False)
 
            theskin = Skin()
            theskin.rigid_vertices = false
            select obj
            max modify mode
            addModifier obj theskin
            skinops.buttonInclude theskin
            for i=1 to SkeletonData.count do
            (
                skinOps.addbone theskin (getNodeByName SkeletonData[i].Bone.name ) 1
            )
            nbone = skinops.getNumberBones theskin
            obj.selectedVerts = #{1..obj.numverts}
            skinOps.resetSelectedVerts theskin
            nverts = skinops.getNumberVertices theskin
 
            for i = 1 to obj.numverts do skinOps.ReplaceVertexWeights theskin i 1 1.0
            update obj geometry:true normals:true
            redrawViews()    
            format "%\t%\t%" obj.name obj.modifiers[#Skin] nbone to:listen
        )
        close listen
        format "%\n" (listen as string)
        ok
    ),
    fn readMesh =
    (
    -- a function that import data from a binary file
    ),
    fn buildgeometry =
    (
    -- after readMesh() i build the object with all information, only bone assignment must be assigned after, a "Weight_Arrar" and "Obj_Array" was generate to store all mesh and relative vertex's weight
        deleteProp()
        AssignWeight Weight_Arrar Obj_Array
        --enableSceneRedraw()
        --redrawViews()
        clearSelection()
    )
)

This script work, there aren't error message but when i clic on the scene there are a crash !!!

I have made a lot of variant but it crash everytime... so I decided starting my own skin modifier as a plugin ... but is very frustrating this issue

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Budi G's picture

hmm..., I think something

hmm..., I think something about your first post currently

I found the problem, the cause are:
progressUpdate() , progressStart "" and progressEnd()

yes me too...
maybe you should be check one by one your script commands.
I suggest you try something into one object before assign into multiple objects

Here I found one a problem again
about addbone on your scripts

for i=1 to SkeletonData.count do
(
   skinOps.addbone theskin (getNodeByName SkeletonData[i].Bone.name ) 1
)

to ensure a command like this:

skinOps.addbone theskin (getNodeByName SkeletonData[i].name ) 1

without '.bone'

johnwhile's picture

hi, thanks for answer ! I

...

Twcenter.net modder and tool creater

johnwhile's picture

i make a little check, this

i make a little check, this is the synthetic code:

FOR LOOP
...
theskin = Skin()
theskin.rigid_vertices = false
select obj                        
addModifier obj theskin
max modify mode
checkmod = modPanel.getCurrentObject()
format "CURRENT: %\n" checkmod
if checkmod==undefined then error.e -- make a "stop error"
skinops.buttonInclude theskin
...

Listener:

CURRENT: Skin:Skin --loop1
CURRENT: undefined --loop2

the problem is on second loop, the checkmod = modPanel.getCurrentObject() return undefined but is not possible... why max crash in the modifier pannel ????

Twcenter.net modder and tool creater

Budi G's picture

hi Jhon ... I think, you

hi Jhon ...
I think, you should do to ensure the selection/objects as array

Just a little rewrite :

max modify mode -- assume it do not need looping
 
sel = selection as array
 
for obj in sel do -- looping
(
  theskin = Skin rigid_vertices:false
  select obj                        
  addModifier obj theskin
  checkmod = modPanel.getCurrentObject()
  format "CURRENT: %\n" checkmod
)
johnwhile's picture

NO SORRY, the problem isn't

NO SORRY, the problem isn't the ProgressBar...
i make the simple function:

function AssignWeight obj weight SkeletonData=
(
    try
    (
        max modify mode
        select obj
        subObjectLevel = 0
        Local theskin = Skin()
        addModifier obj theskin
        Local theskin = obj.modifiers[#Skin]
        subobjectLevel = 1
        modPanel.setCurrentObject obj.modifiers[#Skin]
        subobjectLevel = 1
        skinOps.addbone theskin (getNodeByName SkeletonData[1].Bone.name ) -1
        update obj
        obj.selectedVerts = #{1..obj.numverts}
        skinOps.resetSelectedVerts theskin
        update obj
        subObjectLevel = 0
        deselect obj
    )
    catch getCurrentException()
)

the script don't make error, but the bone aren't added in the list and when i clic on object the 3dstudio crash !!!!
I don't undertand why... all is correct.
If i use the only function:
 addModifier obj theskin
without all other "skinOps." function, 3dstudio don't crash... the problem is on "skinOps.addbone", it don't work !!!!

Twcenter.net modder and tool creater

Budi G's picture

in your code

in your code :

skinOps.addbone theskin (getNodeByName SkeletonData[1].Bone.name ) -1

I think you should be get the node name correctly.
let's us focus to getNodeByName function :

(getNodeByName SkeletonData[1].Bone.name)

are you sure for this ? because the result of SkeletonData[1].Bone.name should be as string of an object name. if it's not as string you will getting error.

then my solution is such as :

SkeletonData[1].name  -- without ".bone" function

addbone is such as :

skinOps.addbone theskin (getNodeByName SkeletonData[1].name ) -1

and that is working correctly for me to adding the bone into skin modifier,and then in the next command the skinops function will working correctly.

johnwhile's picture

no, SkeletonData[1].Bone.name

no, SkeletonData[1].Bone.name is an array of bone, is correct...
I try this:

(
	-- random scene screator
	objArray = for i=1 to 3 collect box pos:[i*20-40,0,0] length:5 width:5 height:5
	boneArray = for i=1 to 3 collect point pos:objArray[i].pos showLinks:true
	for i=2 to boneArray.count do boneArray[i].parent = boneArray[i-1]
 
	-- issue
	for obj in objArray do
	(
		theskin = Skin()
		select obj
		max modify mode
		addModifier obj theskin
		subobjectLevel = 0
		for i=1 to boneArray.count do skinOps.addbone theskin (getNodeByName boneArray[i].name ) 1
		skinOps.updateMirror theskin
		deselect obj
	)
 
)

and it work correctly, so i don't understand why in my script this simple operation don't work... is very frustrating!

Twcenter.net modder and tool creater

johnwhile's picture

---

I put my script in a essential version, the script apply the skin() modifier and if you clic ok in the queryBox the script add the bones in the skins witout error.
BUT:
when i clic on box objects the 3dstudio crash !?! WHY ???

AttachmentSize
mesheditor_-_essential.zip 3.62 KB

Twcenter.net modder and tool creater

Budi G's picture

I've tried your scripts

I've tried your scripts Jhon.
as you said... that's right.
when I click on box objects the 3dstudio crash.

so why ?

I've got a clue, maybe it's can help you.
create bone by 'bone() methods in 3dsmax 4 and higher, it is not possible to create a bones system using IK controllers on the bones' nodes.
I guess you should look back on mxs reference for details.

if you addbone into skin modifier of box objects by manually then you can not find the bone objects in listbox.

I suggest you to using "BoneSys.create" methods, such:

BoneSys.create <point3>startpos <point3>endpos  <point3>zAxis

simply to compare bone() vs BoneSys.create such as:

thebone = bone pos:[0,0,0] -- create bone by bone() methods
obj = box() -- create box
----------------------
select obj
max modify mode
skinmod = skin()
addmodifier obj skinmod
theskin = obj.modifiers[#skin]
skinOps.addbone theskin thebone 1

and it does'nt work correctly then the 3dsmax crash.

by this:

thebone = BoneSys.create [0,0,0] [10,0,0] [0,0,1]-- create bone by BoneSys.create methods
obj = box() -- create box
----------------------
select obj
max modify mode
skinmod = skin()
addmodifier obj skinmod
theskin = obj.modifiers[#skin]
skinOps.addbone theskin thebone 1

and it work correctly.

johnwhile's picture

Perfect, thanks, in fact i

Perfect, thanks, in fact i utilized the Point() and work.
I can't utilize BoneSys because it have a fixed position, sometime the game bone system have a rotations and positions movement (free joint), the max BoneSys only relative rotations for children bone.

Twcenter.net modder and tool creater

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.