LoadAnimSeq
BlitzMax Forums/MiniB3D Module/LoadAnimSeq
| ||
Hi, I'm currently working on a project using MiniB3D 0.51, and the only thing I'm missing is the LoadAnimSeq command. so my question to you simonh is, how hard would it be to add it? Oh, and really great work with MiniB3D! I enjoy programming with it ALOT! ^^ |
| ||
Yeah, shouldn't be too hard. I'll see if I can add it to the next release. |
| ||
Can you give this a try and see if it works OK for you? You need to paste it somewhere inside TEntity. Also, for it to work, the bones in the .b3d files should have the same names from file to file. ' load anim seq - copies anim data from mesh to self Method LoadAnimSeq(file:String) If FileType(file)=0 Then Return 0 ' mesh that we will load anim seq from Local mesh:TMesh=TModel.LoadAnimB3D:TMesh(file) If anim=False Then Return 0 ' self contains no anim data If mesh.anim=False Then Return 0 ' mesh contains no anim data no_seqs=no_seqs+1 ' expand anim_seqs array anim_seqs_first=anim_seqs_first[..no_seqs+1] anim_seqs_last=anim_seqs_last[..no_seqs+1] ' update anim_seqs array anim_seqs_first[no_seqs]=anim_seqs_last[0] anim_seqs_last[no_seqs]=anim_seqs_last[0]+mesh.anim_seqs_last[0] ' update anim_seqs_last[0] - sequence 0 is for all frames, so this needs to be increased ' must be done after updating anim_seqs array above anim_seqs_last[0]=anim_seqs_last[0]+mesh.anim_seqs_last[0] If mesh<>Null ' go through all bones belonging to self For Local bone:TBone=EachIn TMesh(Self).bones ' find bone in mesh that matches bone in self - search based on bone name Local mesh_bone:TBone=TBone(TEntity(mesh).FindChild(bone.name$)) If mesh_bone<>Null ' resize self arrays first so the one empty element at the end is removed bone.keys.flags=bone.keys.flags[..bone.keys.flags.length-1] bone.keys.px=bone.keys.px[..bone.keys.px.length-1] bone.keys.py=bone.keys.py[..bone.keys.py.length-1] bone.keys.pz=bone.keys.pz[..bone.keys.pz.length-1] bone.keys.sx=bone.keys.sx[..bone.keys.sx.length-1] bone.keys.sy=bone.keys.sy[..bone.keys.sy.length-1] bone.keys.sz=bone.keys.sz[..bone.keys.sz.length-1] bone.keys.qw=bone.keys.qw[..bone.keys.qw.length-1] bone.keys.qx=bone.keys.qx[..bone.keys.qx.length-1] bone.keys.qy=bone.keys.qy[..bone.keys.qy.length-1] bone.keys.qz=bone.keys.qz[..bone.keys.qz.length-1] ' add mesh bone key arrays to self bone key arrays bone.keys.frames=anim_seqs_last[0] bone.keys.flags=bone.keys.flags+mesh_bone.keys.flags bone.keys.px=bone.keys.px+mesh_bone.keys.px bone.keys.py=bone.keys.py+mesh_bone.keys.py bone.keys.pz=bone.keys.pz+mesh_bone.keys.pz bone.keys.sx=bone.keys.sx+mesh_bone.keys.sx bone.keys.sy=bone.keys.sy+mesh_bone.keys.sy bone.keys.sz=bone.keys.sz+mesh_bone.keys.sz bone.keys.qw=bone.keys.qw+mesh_bone.keys.qw bone.keys.qx=bone.keys.qx+mesh_bone.keys.qx bone.keys.qy=bone.keys.qy+mesh_bone.keys.qy bone.keys.qz=bone.keys.qz+mesh_bone.keys.qz EndIf Next EndIf mesh.FreeEntity() Return no_seqs End Method |