entity and its child

Blitz3D Forums/Blitz3D Programming/entity and its child

I save a b3d model with 3dsmax.
Inside the model there some cube that moving along a path.
i use findchild to find the child and use animate but
blitz say that entity has no animation.
Ok this is because the entity isn't root.
HOw can extract the animation for each entity

You should loop through the root's animation, and then use SetAnimKey on each child.

ok! i will try this.many thanks

NOw i have setup setanimkey entity,1 for each entity there is in b3d file, but when i use animate blitz say entity has no animation

Other than with SetAnimKey, LoadAnimMEsh is not thought to load multiple animations in one file. They have to be played all together as one animation. Solution: save them seperately, then load them in blitz and parent them to a pivot. This way you can animate each child.

I load each entity in memory using type, than i use setanimkey for each entity (it is the same frame for all entities...). BUt not works.... I just know of separate saving....

I converted the LoadAnimMesh example and tested it on a .b3d animated mesh. It needs a .b3d file, and a 'subobject' needs to be defined. It works, but it might need some adjustments to fit your model.
; 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

; Load anim mesh
robot=pLoadAnimMesh("file.b3d")

;animate object
Animate robot, 1

;determine animation length
length = AnimLength(robot)

;this is the subobject that will be animated
sub = GetChild(robot, 1)

;loop through animation
For i = 1 To length
	
	;set animation time
	SetAnimTime robot, i	
	;set animation keys
	iSetAnimKey robot, i
	
Next

;add sequence to subobject
AddAnimSeq sub, length

;stop animation for original object
Animate robot, 0
;test animation for subobject
Animate sub, 1, 1, 0

;main loop
While Not KeyDown(1)

UpdateWorld ; Update anim - without this our anim mesh will freeze
RenderWorld ; Render everything
Flip ; Show everything

Wend

End

;recursive setanimkey
Function iSetAnimkey(mesh, key#)
	
	SetAnimKey(mesh, key)
	For i = 1 To CountChildren(mesh)
		iSetAnimKey(GetChild(mesh, i), key)
	Next
	
End Function

;protected loadanimmesh
Function pLoadAnimMesh(f$)

	If FileType(f$) <> 1 Then RuntimeError "file '" + f$ + "' not found"
	Return LoadAnimMesh(f$)

End Function


Ok there is all of i asked but how define a subobjects in max