Merging animation sequences

Blitz3D Forums/Blitz3D Programming/Merging animation sequences

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

ok,

Thanks for the help guys.

BTW joe, you're right about the running & strafing thing ... that was a case of Problem Exists Between Keyboard And Chair.

So would the folling code be along the right lines?
(in particular the MergeBones function at the bottom)


player = CreatePivot() 

playerMesh = LoadAnimMesh( "player.b3d" , player)	; player mesh + animated skeleton
bones = LoadAnimMesh( "bones.b3d" , player)		; just the animated skeleton (identical animation frames)

ExtractAnimSeq( playerMesh,0,20 )  ; sequence 1 = run
ExtractAnimSeq( bones,0,20 )

ExtractAnimSeq( playerMesh,21,30 ) ; sequence 2 = attack
ExtractAnimSeq( bones,21,30 )

moveSequence = 1
otherSequence = 2


Repeat
	If moveSequence <> 0 And otherSequence <> 0 Then
		Animate playerMesh, 1, 1, otherSequence
		Animate bones, 1, 1, moveSequence
		mergeSequences = True

	Else If moveSequence <> 0
		Animate playerMesh, 1, 1, moveSequence
		mergeSequences = False

	Else If otherSequence <> 0 
		Animate playerMesh, 1, 1, otherSequence
		mergeSequences = False

	Else
		mergeSequences = False

	EndIf
	
	UpdateWorld()

	If mergeSequences = True Then
		MergeBones( bones, playerMesh, "LeftUpperLeg" )		; (see below)
		MergeBones( bones, playerMesh, "RightUpperLeg" )
		MergeBones( bones, playerMesh, "LeftLowerLeg" )
		MergeBones( bones, playerMesh, "RightLowerLeg" )
		MergeBones( bones, playerMesh, "LeftFoot" )
		MergeBones( bones, playerMesh, "RightFoot" )
	EndIf
	
	RenderWorld()

	Flip()
Until KeyHit(1)

End

Function MergeBones( sourceBones, destMesh, boneName$ )
	source = FindChild( sourceBones, boneName$ )
	dest = FindChild( destMesh, boneName$ )
	PositionEntity dest, EntityX(source), EntityY(source), EntityZ(source)
	RotateEntity dest, EntityPitch(source), EntityYaw(source), EntityRoll(source)
End Function


Obviously in the 'real' game moveSequence might be anything from 1 to 5 and otherSequence might be anything from 6 to <numSequences>

Thanks again.