B3D file format animation chunks
Blitz3D Forums/Blitz3D Programming/B3D file format animation chunks
| ||
Can anyone please explain the use of the ANIM, KEYS, and BONE chunks in the b3d file format? Thanks. |
| ||
I'd be interested in an explanation too. |
| ||
Here's what it looks like to me:Node { MESH{} ANIM { int flags int frames float fps KEYS { int flags int frame float position[3] float scale[3] float rotation[4] } KEYS {} KEYS {} KEYS {}... } } But I have no idea where bones fit in, since the structure is just a vertex number and a weight. |
| ||
Erm it's hard to explain it anymore simply than the docs do, but if this is any help here's a text version of that animated .x file I gave you. BMan.txt |
| ||
Hi, The ANIM chunk doesn't contain the KEYS or BONE data, it just tells you what to expect next. I'm not sure if there's a point to having multiple short anim cycles over 1 large set of all the anim cycles, which you jsut extract in BB later (what I do, and works fine). It might be beneficial if you could animate 2 or more limbs limbs discreetly, something I've not tried, i.e find the left_upperarm entity and upper_rightarm entity, (both of which have their own seperate ANIM & KEY entrys in the B3D file) then extract their anim sequences and try animating both at the same time. Anyways: ANIM CHUNK flags frames fps END ANIM NODE CHUNK name$ position x,y,z scale x,y,z rotation quat w,x,y,z BONE CHUNK for each vert affected by this BONE the verts ID the verts weight (this bones influence on this vert) next vert END BONE // this bones KEYS KEYS CHUNK // flags tells us what key types are expected flags (1=position + 2=scale + 4=rotation) for each keyframe keyframe time position x,y,z scale x,y,z rotation quat w,x,y,z next keyframe END KEYS // next NODE....(next child bone).. ...and so on, hope I got that right, and I hope it makes some sense :) Tom |
| ||
Algo: I looked at the BMan.txt, interesting that you have multiple KEY chunks where as I just stick all mine together. Do you know if it's possible to store keys so that, as I said in my previous post, you could call 2 Animate commands for say upperbody and lowerbody atthe same time, and they'd animate discreetly? Cya Tom |
| ||
So your mesh is the parent of the hierarchy of bones it gets weighed onto. This will store multiple anim sequences in one file, or do I need to store one sequence per file? Thanks for the tips. |
| ||
The mesh is a child of the 'mothernode' as displayed below.TEXS Chunk BRUS Chunk ROOT NODE (the mothernode!:) | +-MESH Chunk | | | |-VRTS Chunk | |-TRIS Chunk | +-ANIM | +-NODE (pelvis) | | | |-BONE | |-KEYS | | | +-NODE (waist) | | | | | |-BONE | | |-KEYS | | | | | +-NODE (chest) | | | | | |-BONE | | |-KEYS | | | +-NODE (right_thigh) | | | |-BONE | |-KEYS | | | | ...right_shin and so on I store multiple anim sequences as 1 big KEYS chunk per node, then after loading in Blitz3D, I use extractanimseq() to assign my anim cycles, I can't say for sure that it's the 100% correct way to do it, but I know it works perfectly in my exporter. Tom |
| ||
Yeah, that's what I meant about parenting. Extract() requires framenumbers, right? That's no good for variable animations, or if you have a sh*tload of them! |
| ||
@halo Hmmmmmm.... I see your taking an interest in the .B3D file format. Any chance that you might be making an import .dll file for use with CShop4.1 ??? This would be awesome if you where! I can always hope & pray huh?! |
| ||
Tom, I'm pretty sure that it's not possible, apart from manually rotating the bones according to a duplicate mesh. The reason I have multiple KEY chunks is to keep the keyframes for rotation/position/scale separate. I might have a key at frame 10 in rotation but I don't want one in the other channels. Just makes animating easier and produces smaller files since most of the time position and scale aren't really used. I made this little util to show the chunks in a treeview, I've found it pretty usefull when dealing with b3d's. Download |
| ||
It appears that you cannot store multiple animation sequences in the .b3d format? Can anyone refute this? |
| ||
Pretty sure you can. Looking at the ExtractAnimSeq() docs: ExtractAnimSeq( entity,first_frame,last_frame[,anim_seq] ) anim_seq (optional) - anim sequence to extract from. This is usually 0, and as such defaults to 0 That probably refers to which ANIM chunk to grab the sequences from. |
| ||
Its been a while since I messed with the B3D format but looking back at some of my DX8 to B3D files what I seem to remember... ANIM() is used to show start of new animation sequence of one of the children of the root node or (Root Group) hierarchy structure ,this could be a bone or a mesh. To better show what I mean here is the main code from my converter whitch is structured to fit the .X format. ;;;;;;;;;;;;;;;;; ; Write B3D ; ;;;;;;;;;;;;;;;;; Function WriteBB3D( f_name$,mesh ) m1 = mesh file=WriteFile( f_name$ ) b3dSetFile( file ) ;Begine B3D Main Chunk.......................M\ b3dBeginChunk( "BB3D" ) b3dWriteInt( 1 );version WriteBRUS( );Texture & Brush ;HERE WE GO...............................? If keyframes>1 m1=nextchild(m1) End If If m1 Repeat b3dBeginChunk( "NODE" );Chunk WriteNODE( m1 );node WriteANIM( m1 );anim Mesh_Bone_Pivot( m1 );Whats' Node Type [M/B]?? WriteKEYS( m1 );keys WriteHierarchy( m1 );Hier m1 = NextChild(m1) If Not m1 Exit Forever EndIf If openfiles>0 For c=1 To openfiles b3dEndChunk() Next End If ;End B3D Main Chunk...........................M/ b3dEndChunk() ;END B3D CloseFile file openfiles=0 End Function The """ Mesh_Bone_Pivot( m1 );Whats' Node Type [M/B]?? """ is used to determin if the NEXT CHILD is a bone or a mesh. Each bone would be looked at as a seperate entity and capable of having its own animation sequences,just like as if it were a basic Hierarchy animated Model ( like MakBot ) Just insted of seperate meshes being animated its using bones. ANIMKEYS() One of my first mistakes was to load an animation sequence for each frame Bad Idea.You only need to store the keyframes,creates a much smaller file. " not for the record " " Just so I don't put my foot in my mouth here " As far as I can remember if you want to store seperate Anim seqences,you might have to start the whole file over and basickly store an entirly new seqence just as if you were creating a new Model from scratch. And yes looking at what I said you could also store multiple models in one file and Extract the ones you want. Im using this method for myself for storing multiple animated model sequences and Object's but I can't say for sure if it will work using ExtractAnimSeq() "I Havn't really thought of trying it actually." Got to look into that one. |
| ||
Just looked at the cammand ref. and here's what said ExtractAnimSeq( entity,first_frame,last_frame[,anim_seq] ) Description This command allows you to convert an animation with an MD2-style series of anim sequences into a pure Blitz anim sequence, and play it back as such using Animate. If this is true then from what I remember an MD2 style format stores animated seqences as seperate models.Its like storing the same model 10 times each with its own animations in 10 different files,its just that there all saved to one file. Looking into this more now....... Gona Play around some. This is a good topic as Im about to get into this with my new editor in about a week or so and refresing my Memory a little would be a good thing....... |
| ||
Well I thought that this....... b3dBeginChunk( "NODE" );Chunk if it were recreated in the file again it would create different sequences in the B3D file but appently not Or for that matter I can't seem to get it to work. As far as I see it the b3dBeginChunk( "NODE" ); is describing a new Chunk or Group, this Group could or would include all children meshes , bones and animations that are conected to the "Root Node" or "Parent Group". |
| ||
Ok I stepped back to far. In the example given above this formate is desined to store "Root Group" Animation information. Meaning that you could have a animated boned mesh with 2 sets of animation information One for the Mesh and one for the Bones.With this you could move the mesh with animations just like using Move Entity and have the bones animate with the moving mesh. Its somthing the Direct X formate supports and getting support for it into B3D gave me lots of trouble. It is here that using "WriteANIM( m1 )"is used to describe the whole Chunck,meaning both the mesh and Bones as one animation sequence, and like Tom said Creating a new "WriteANIM( m1 )" creates a new animation sequence in the B3D file. |
| ||
Awww this is Cool, I only have this working by hard coding it in,but Im realizing that I could offer a sort of Frame Extractor into DX8 to B3D converter that would allow you to select the frames that you wish to use as a sequence ( the Direct X formate Im working with only saves Frames not Sequences ),then when saving to the B3D format save those sequences for ya,this way when loading the B3D file insted of having to use Extract Anim Seq afterwords it will have been done for you,all you will need to do is select the sequence you want. Hmmm need to work on this,soon after Im done with the new editor. Sorry for using you post time Halo,just got carried away with this. |
| ||
Stickman, are you saying you've found a way to define multiple sequences in a b3d file? I've tried adding multiple ANIM chunks in the B3d file, but Blitz doesn't seem to recognize these as seperate sequences. Is there something I'm missing? I'd like to be able to export multiple sequences from Max without having to use ExtractAnimSeq... -Pudding |
| ||
*bump* anyone? |
| ||
NO... As fare as I know adding animated sequences is a Internal blitz thing,reading it in from a file is as fare as I Know not posible. What I was doing is loading/saving seperate animated meshes or NODES then instead of having to set the frames for each sequence you just call up the entity\NODE you wanted to animate and all the frames were loaded with it. Basicly the b3dBeginChunk( "ANIM" ) will allow for an entitys children to have there own animation settings or somthing like that. But beware you can't just add b3dBeginChunk( "ANIM" ) chunks anywere in the hierarchy as for you might get some unsatisfactory results. But forget about that Idea as for shortly after this post I realized that you lose\or don't have any transition effects between entitys every time you call up a new sequence( or entity ), NOT GOOD. In all honisty Im about to just give up on this B3D formate and go with what I origanally was going to do and write my own format with animation control. The hardest part is writing the animation controls and as I look at it now with all the time I spent Fing around with this B3D format I proboly would have been done with it by now. Don't know yet. When Im done with My new editor( witch is almost compleated ) Ill decide what I want to do. |