Notifications
Clear all

[Closed] Problem with skin and bones

 xcx

Ok. Here’s what I try to do. I have biped and I need to create mesh what looks like a biped (no problem there) and skin it. Example evey vertex in copied mesh head shoud be skinned to biped head with weight 1 and mesh hand shoud be skinned biped hand with weight 1 and so on. Little hard to explain but I hope than you get idea. Heres code now, but it gives me error.

 curr_ver = 0
 nodes = selection as array
 foo = editable_mesh()
 for o in nodes do (attach foo (copy o))
 
 select foo
 mySkin = (Skin())
 modPanel.addModToSelection mySkin
 for i in 1 to nodes.count do
 (
     skinOps.addBone mySkin (nodes[i]) 0
 )

 subObjectLevel = 1    
 mySkin.filter_vertices = on    
 
 for i in 1 to nodes.count do
 (
     skinOps.SelectBone mySkin i
     
     for j in 1 to (getNumVerts nodes[i].mesh) do
     (
         curr_ver = curr_ver+1
         skinOps.SelectVertices mySkin #{curr_ver}
         mySkin.Effect = 1.0
     )
 )

Whats wrong?

1 Reply
 xcx

Ok. I got it work. Real problem is skin modifier itself not my code. Modifiers seems to need little reselecting time to time. Here’s working code


  	(
  		max modify mode	
  		
  		curr_ver = 0
  		nodes = selection as array
  		foo = editable_mesh()
  		for o in nodes do (attach foo (copy o))
  		
  		clearSelection()
  		select foo
  		
  		mySkin = (Skin())
  		modPanel.addModToSelection mySkin
  		for i in 1 to nodes.count do
  		(
  			skinOps.addBone mySkin (nodes[i]) 0
  		)
  		
  		clearSelection()
  		select foo
  		
  		subObjectLevel = 1	
  		mySkin.filter_vertices = on	
  		
  		for i in 1 to nodes.count do
  		(
  			skinOps.SelectBone mySkin i
  			
  			for j in 1 to (getNumVerts nodes[i].mesh) do
  			(
  				curr_ver = curr_ver+1
 				skinops.setVertexWeights mySkin curr_ver i 1.0
  			)
  		)
  	)