PositionMesh Problem with animated B3D

Blitz3D Forums/Blitz3D Programming/PositionMesh Problem with animated B3D

The distortion has to do with the bones, that are still in their original position. I've tried to apply PositionMesh on Class="Mesh" objects and PositionEntity on the rest, however the model was still distorted.
I think some bones are affecting the entire model and some other bones are only relative to other bones. Did you consider using PositionEntity on the entire model ?
If you want to move the animated model to combine it with other models, you can stick them together on a parent bone maybe. Maybe you could create new animation keys, and move them ?
This code adds a pivot as a parent to the animated mesh, and then creates new animation keys, including the parent pivot. Finally you can call "animate" on the pivot instead of the mesh.
; LoadAnimMesh Example
; --------------------

; In this example we will demonstrate the use of the LoadAnimMesh command.

; Quite simply, we will load an anim mesh from file, animate it, and then view it.

Graphics3D 640,480
SetBuffer BackBuffer()

camera=CreateCamera()
PositionEntity camera,0,20,-100 ; position camera so that robot will be in view when loaded

light=CreateLight()
RotateEntity light,90,0,0

;create base pivot
pivot = CreatePivot()

; Load anim mesh
robot = LoadAnimMesh("c:\_Xfiles\emo.b3d")
robot2 = LoadAnimMesh("c:\_Xfiles\emo.b3d")
; set pivot as parent
EntityParent robot, pivot
EntityParent robot2, pivot

Animate robot, 1
Animate robot2, 1
; get length
ll = AnimLength(robot)
; loop through all frames
For i# = 0 To ll
	; set animation to this position
	SetAnimTime robot, i
	SetAnimTime robot2, ll-i
	; move the pivot
	PositionEntity robot, 25, 0, 0
	; create new animation keys for all children
	iSetAnimKey pivot, i
Next
; add animation sequence to pivot
ok = AddAnimSeq(pivot, ll)
; animate pivot
Animate pivot, 1

While Not KeyDown(1)
TurnEntity pivot, 0, 1, 0
UpdateWorld ; Update anim - without this our anim mesh will freeze
RenderWorld ; Render everything
Text 0, 0, EntityX(pivot)
Flip ; Show everything

Wend

End

Function isetanimkey(mesh, t#)
	SetAnimKey mesh, t
	For i = 1 To CountChildren(mesh)
		g = GetChild(mesh, i)
		isetanimkey g, t
	Next
End Function