Entity Animation question

Blitz3D Forums/Blitz3D Beginners Area/Entity Animation question

tyoud(Posted 2011) [#1]
From the manuals, there's this example (modified slightly for some clarity)

mesh=LoadAnimMesh("model.b3d") ;anim sequence 0.
ExtractAnimSeq( mesh,0,30 ) ;anim sequence 1: frames 0...30 are 'run'
ExtractAnimSeq( mesh,31,40 ) ;anim sequence 2: frames 31...40 are 'jump' etc  etc...

Animate mesh,3,1,2 ;play one-shot jump anim 


The code makes perfect sense, and things do work exactly as it suggests.

But I was looking inside of my meshes' .b3d file, and just a few kilobytes in, I find a section labelled "ANIM" and then bits labelled "SEQS" and I can see the names for each animation "Walk" "Run" "Stand" etc, and around them are the bytes for the start and stop frames...

And I'm kind of left wondering why the animated meshes don't work more like this (making up the AnimSequence() function as an example)

Animate mesh,3,1,GetAnimSequenceFromMesh("Jump", "model.b3d")


Do other people have these kinds of tags in their .b3d files? If the file has these tags, why doesn't it use it? It is more flexible for sure to have ExtractAnimSequence() type functions where you can hand code the start and stop times, but that's pretty tedious, when it's already there in the file!

Maybe the tags are there because I exported the model using the tool called 'fragMOTION'?

Let me know if there's any interest in a snippet of code after I find a good way to read in the values, save them to some kind of structure, and then not type in all of these values by hand.

Last edited 2011


Yasha(Posted 2011) [#2]
If the file has these tags, why doesn't it use it?


My guess is backward compatibility. The B3D format was only developed partway through Blitz's released product life cycle - originally it only supported X, 3DS and MD2, so all of the "standard mesh" animation commands were originally written to handle 3DS and X meshes (I assume 3DS and X don't provide this information, not having studied the formats - if they do too, then I really have no idea).

You can find some B3D loading/saving functions in the code archives ( http://www.blitzbasic.com/codearcs/codearcs.php?code=1794 , http://www.blitzbasic.com/codearcs/codearcs.php?code=866 ), if you want a head start on the snippet.


tyoud(Posted 2011) [#3]
Wow thanks for the snippets - the code is there, just commented out:

		Select chunk$
		Case "SEQS"
			
		;	b3dseq.sequence=New sequence
		;	b3dseq\name$=b3dReadString()
		;	b3dseq\fstart%=b3dReadInt()
		;	b3dseq\fend%=b3dReadInt()
		;	b3dseq\seq%=ExtractAnimSeq (mesh,b3dseq\fstart%,b3dseq\fend%)
		;	b3dseq\gui_id=AddListBoxItem( lstSeq, 0, b3dseq\seq% + " - " + b3dseq\name$)



There's the name$, the fstart% (frame start), and fend% (frame end)


tyoud(Posted 2011) [#4]
Hi I was just going to post a follow-up.

I wound up making a small C utility to read out ANIM SEQS, and it worked great. Not as ideal as Blitz3D code would be. I do intend to use snippets like these later.

The big improvement in my code came when I used the hashC code snippet to store animation sequences by name into a hash array and call them by name. I think that that method will scale really well if I ever get to hundreds of models, each with hundreds of animations. I'll be able to code up animations like so: Animate,mymodel,1,get_hash(HoL, "mymodel_Run") and it should just work.

Thanks very much for the help.