Copying animated mesh

Blitz3D Forums/Blitz3D Programming/Copying animated mesh

NTense(Posted 2003) [#1]
The code below grabs a preloaded animated mesh(b3d), and then copies it to pModel\ObjectHandle... The problem is, the animation sequences don't seem to copy over.. I tried to reextract the animation sequences from the copy, but when I run the program, I get a 'can't find animation sequences' error.. The original template model has the sequences and runs fine.. Is there something I'm missing, or do I have to specifically load a copy of every single game piece over and over since it's animated?


Function PopulateBoard()
	
	; create player pawns
	tmpmod.ModelTemplate = FindPiece("Militia")
	row = 5
	For col = -7 To 7 Step 2
		Pmodel.ModelTemplate = New ModelTemplate
		pModel = tmpmod
		PModel\ObjectHandle = CopyMesh(tmpmod\ObjectHandle)
	
		;Scale Model
		pmodelwidth# = MeshWidth(pModel\ObjectHandle)
		pmodelheight# = MeshHeight(pModel\ObjectHandle)
		pmodeldepth# = MeshDepth(pModel\ObjectHandle)
		
		; Scales Entity to height of 2.0
		;Stop
		ScaleEntity pModel\ObjectHandle, (1.0/pmodelheight#) * pModel\size#, (1.0/pmodelheight#) * pModel\size#, (1.0/pmodelheight#) * pModel\size#
		
		PModel\name$ = PModel\name$ + col
		
		; Extract Animation Sequences
		For extract = 0 To pModel\TotalAnims - 1
			ExtractAnimSeq(pModel\ObjectHandle, pModel\Anim[extract]\Start, pModel\Anim[extract]\Finish)
		Next
		
		Animate pmodel\objecthandle, 2, 0.2, 3, 20
		
		ShowEntity PModel\ObjectHandle
		PositionEntity PModel\ObjectHandle, row, .5, col
	Next
	
End Function



(tu) sinu(Posted 2003) [#2]
doesn't the copymesh command copy the actual mesh and would work like a loadmesh command ie no animations, try using copyentity.


NTense(Posted 2003) [#3]
I tried to copy entity, and 'thought that it worked', UNTIL I tried to manipulate the copies individually (ie: change which animation was playing). The problem is, copyentitiy only provided me a handle to the last entity I copied, I couldn't manipulate the other mesh animations. I went back and changed my load routine though.. I loaded each mesh individually from the source b3d file.. Ironically, the program is running smoother than when I copied the entities.. weird


(tu) sinu(Posted 2003) [#4]
depends really, were you calling copyentity when you needed one or doing all before hand. you should normally copy them first then just hide/show them.