I decided i wanted a Cal3d Loader for Minib3d, mainly just because i like the Cal3d format a lot.
Anyhoo so far i have got it so i can load the XSF Skeleton file and an XMF Mesh file into Minib3d. Here is where it's at currently.

My next phase is to get the bone's shown above weighted to the vertices. I am having some difficulty locating how this is done exactly in minib3d when a b3d file is loaded. I did find however in the TModel.bmx file under bone nodes and anim anim_surfaces are created and then the vertices in those surfaces are assigned weights and bone ids. I have more or less emulated this so far in my code e.g.
Method WeighCal3DMesh()
Local i,l,e
Local bo_bone:TBone
Local influence:TList
Local influ:C3DInfluence
If bones.length = 0 Then Return False
mesh.anim=True
mesh.anim_seqs_first[0]=0
mesh.anim_seqs_last[0]=0
For Local surf:TSurface=EachIn mesh.surf_list
Local anim_surf:TSurface=New TSurface
For e = 0 To numsubmesh-1
If submeshes[e].surface = surf Then submeshes[e].animsurf = anim_surf
Next
ListAddLast(mesh.anim_surf_list,anim_surf)
anim_surf.no_verts=surf.no_verts
anim_surf.vert_coords=surf.vert_coords[..]
anim_surf.vert_bone1_no=anim_surf.vert_bone1_no[..surf.no_verts+1]
anim_surf.vert_bone2_no=anim_surf.vert_bone2_no[..surf.no_verts+1]
anim_surf.vert_bone3_no=anim_surf.vert_bone3_no[..surf.no_verts+1]
anim_surf.vert_bone4_no=anim_surf.vert_bone4_no[..surf.no_verts+1]
anim_surf.vert_weight1=anim_surf.vert_weight1[..surf.no_verts+1]
anim_surf.vert_weight2=anim_surf.vert_weight2[..surf.no_verts+1]
anim_surf.vert_weight3=anim_surf.vert_weight3[..surf.no_verts+1]
anim_surf.vert_weight4=anim_surf.vert_weight4[..surf.no_verts+1]
' transfer vmin/vmax values for using with TrimVerts func after
anim_surf.vmin=surf.vmin
anim_surf.vmax=surf.vmax
Next
influence = GenerateInfluenceList()
For influ = EachIn influence
If influ.weight#>influ.submesh.animsurf.vert_weight1[influ.v]
influ.submesh.animsurf.vert_bone4_no[influ.v]=influ.submesh.animsurf.vert_bone3_no[influ.v]
influ.submesh.animsurf.vert_weight4[influ.v]=influ.submesh.animsurf.vert_weight3[influ.v]
influ.submesh.animsurf.vert_bone3_no[influ.v]=influ.submesh.animsurf.vert_bone2_no[influ.v]
influ.submesh.animsurf.vert_weight3[influ.v]=influ.submesh.animsurf.vert_weight2[influ.v]
influ.submesh.animsurf.vert_bone2_no[influ.v]=influ.submesh.animsurf.vert_bone1_no[influ.v]
influ.submesh.animsurf.vert_weight2[influ.v]=influ.submesh.animsurf.vert_weight1[influ.v]
influ.submesh.animsurf.vert_bone1_no[influ.v]=influ.ID
influ.submesh.animsurf.vert_weight1[influ.v]=influ.weight#
Else If influ.weight#>influ.submesh.animsurf.vert_weight2[influ.v]
influ.submesh.animsurf.vert_bone4_no[influ.v]=influ.submesh.animsurf.vert_bone3_no[influ.v]
influ.submesh.animsurf.vert_weight4[influ.v]=influ.submesh.animsurf.vert_weight3[influ.v]
influ.submesh.animsurf.vert_bone3_no[influ.v]=influ.submesh.animsurf.vert_bone2_no[influ.v]
influ.submesh.animsurf.vert_weight3[influ.v]=influ.submesh.animsurf.vert_weight2[influ.v]
influ.submesh.animsurf.vert_bone2_no[influ.v]=influ.ID
influ.submesh.animsurf.vert_weight2[influ.v]=influ.weight#
Else If influ.weight#>influ.submesh.animsurf.vert_weight3[influ.v]
influ.submesh.animsurf.vert_bone4_no[influ.v]=influ.submesh.animsurf.vert_bone3_no[influ.v]
influ.submesh.animsurf.vert_weight4[influ.v]=influ.submesh.animsurf.vert_weight3[influ.v]
influ.submesh.animsurf.vert_bone3_no[influ.v]=influ.ID
influ.submesh.animsurf.vert_weight3[influ.v]=influ.weight#
Else If influ.weight#>influ.submesh.animsurf.vert_weight4[influ.v]
influ.submesh.animsurf.vert_bone4_no[influ.v]=influ.ID
influ.submesh.animsurf.vert_weight4[influ.v]=influ.weight#
EndIf
Next
End Method
but yea i move the bones and nothing is weighted. Is there something else i'm not doing?
|