johnwhile
11 November 2010, 02:56 PM
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 !!!
http://img89.imageshack.us/img89/3709/immaginejl.th.jpg (http://img89.imageshack.us/i/immaginejl.jpg/)
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
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 !!!
http://img89.imageshack.us/img89/3709/immaginejl.th.jpg (http://img89.imageshack.us/i/immaginejl.jpg/)
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