SetAnimTime Help

Blitz3D Forums/Blitz3D Beginners Area/SetAnimTime Help

ervin(Posted 2005) [#1]
Hi everyone.

I've almost finished working my way through the entire Blitz3D command set.
Most of it hasn't been too much trouble, and of course some bits have, like figuring out how to do what I want to do with LinePick, EntityPick etc.

Anyway, enough of my ramblings. I've searched the forums, researched the topic, tried trial n' error, but I just can't seem to figure out how to use SetAnimTime.
Does anyone happen to have any code lying around that demonstrates how to use it, and perhaps a practical example of what it might be used for?

Thanks very much for any help.


Ricky Smith(Posted 2005) [#2]
SetAnimTime allows you to manually set the current animation frame for an animated model.
Simple example below on how to scroll through the first 100 frames using the cursor keys , change model name to your own or download from Psionic's website. You can change the KeyHit commands for KeyDown to get continuous scroll.
;Ricky Smith 10/12/2005
;SetAnimTime Example - Scroll through first 100 frames of animation using
;the SetAnimTime Command. This command allows you to manually set the current
;animation frame For your model



Graphics3D 800,600,16,2
SetBuffer=BackBuffer ()
;-----------------------------------------------------------------------------
Global player
Global frame
Global camera=CreateCamera()
CameraRange camera,1,100
MoveEntity camera,0,1.5,-4
RotateEntity camera,10,0,0


light=CreateLight(1)
LightColor light,200,200,200
RotateEntity light,45,0,0


player=LoadAnimMesh("robot.b3d")
RotateEntity player,0,-90,0
Color 255,255,255		
;-----------------------------------------------------------------------------
While Not KeyHit(1)
	
	Update()
	Flip
Wend


;-----------------------------------------------------------------------------
;update gameplay
Function Update()
	If KeyHit(205) frame=frame+1
	If KeyHit(203) frame=frame-1

	If frame>100 frame=100
	If frame<0 frame=0
	
	
	
	SetAnimTime player,frame,0
	UpdateWorld 
	RenderWorld
	Text 10,10,"FRAME:"+frame
End Function
;-----------------------------------------------------------------------------


End



Ross C(Posted 2005) [#3]
SetAnimTime is a stupidly named command...


Ricky Smith(Posted 2005) [#4]
I think its because in DirectX there is no such thing as an animation "Frame" - this value is simply a Time. A "Frame" in DirectX talk usually refers to a data block or an object within the hierarchy.

"SetAnimFrame" makes more sense to us but "SetAnimTime" makes more sense to DirectX.


Ross C(Posted 2005) [#5]
Well, i suppose. But the name could still be more suitable ;)


ervin(Posted 2005) [#6]
That's absolutely fantastic. Thanks VERY much.
One more quick question if I may. How/why would I use the anim_seq parameter, which you currently have set to 0?
Thanks again.


Ricky Smith(Posted 2005) [#7]
Whe you load an animated model with LoadAnimMesh() it only has one sequence - sequence 0. Sequence 0 contains all the animation frames. You can split these into smaller sequences using the ExtractAnimSeq() command. Every time you carry out this command the sequence number increments by 1.
The idea of this is so that you can have all your animation frames for all your sequences in one file and then "extract" them to different ones within the program e.g walk ,run, hit, die etc.
You can then use the anim_seq parameter on all the animation commands to use/trigger each one seperately.
You can have your sequences in different files and then use LoadAnimSeq() to create each sequence. This works in the same way as ExtractAnimSeq() in that the sequence number is incremented each time. You can use a combination of both if you wish but I find it much easier to have all the animation frames in the main file.
Have a look at this code from the archives which explains the use of ExtractAnimSeq()

http://www.blitzbasic.com/codearcs/codearcs.php?code=660


ervin(Posted 2005) [#8]
Thanks very much for your help Smiff.
Those commands seem much easier now.