Animating multiple objects

Blitz3D Forums/Blitz3D Programming/Animating multiple objects

Oiduts Studios(Posted 2010) [#1]
I feel kind of dumb for not knowing something that at least "seems" simple. I cannot figure out how to animate multiple objects at the same time; in my case trees. I am using the default tree in Tree[d]. I have tried multiple variations including types. Every time I either end up with one tree at the origin animating and all of the other trees turn invisible. If I just load all the trees up without animating then everything works out fine. I even tried repositioning the object but the will not show. I am not sure if they disappear or they are just all flung to the origin. Help me please.
Graphics3D 640,480 ,32,2
SetBuffer BackBuffer() 

ClearTextureFilters
TextureFilter "_alpha",4+8
tree=LoadAnimMesh("tree2.b3d") : HideEntity tree

Type Tree1
	Field Entity
End Type
Global Trees1.Tree1[5]

For i = 0 To 5
	t.Tree1 = New Tree1
	t\Entity = CopyEntity(tree)
	PositionEntity t\Entity, Rand(-15,15), 0, Rand(-15,15)
	Trees1[i] = t
	Animate Trees1[i]\Entity, 1
Next

piv=CreatePivot()
camera=CreateCamera(piv) 
PositionEntity camera,0,12,-20
light=CreateLight() 


While Not KeyDown( 1 ) 
	
	dx#=(GraphicsWidth()/2-MouseX())*0.001
	dy#=(GraphicsHeight()/2-MouseY())*0.001
	If MouseDown(1) Then TurnEntity piv,0,MouseXSpeed(),0
	MoveEntity camera,0,0,MouseZSpeed()
	If MouseDown(3) Then MoveEntity camera,-dx#,dy#,0
	
UpdateWorld
RenderWorld
Flip 

Wend 

End 



Matty(Posted 2010) [#2]
try this

Graphics3D 640,480 ,32,2
SetBuffer BackBuffer() 

ClearTextureFilters
TextureFilter "_alpha",4+8
tree=LoadAnimMesh("tree2.b3d") : HideEntity tree ;NOTE HideEntity tree will also mean all trees copied from this will be hidden unless they are manually unhidden as well.

Type Tree1
	Field Entity
End Type
;Global Trees1.Tree1[5] ;<------------- NOT NEEDED

For i = 0 To 5
	t.Tree1 = New Tree1
	t\Entity = CopyEntity(tree)
	Showentity t\Entity		;<-------------------------- I ADDED THIS LINE
	PositionEntity t\Entity, Rand(-15,15), 0, Rand(-15,15)
;	Trees1[i] = t	; <------------------ NOT NEEDED
	Animate t\Entity,1 ;	Animate Trees1[i]\Entity, 1 ;<------------------------- REPLACED WITH THIS
Next

piv=CreatePivot()
camera=CreateCamera(piv) 
PositionEntity camera,0,12,-20
light=CreateLight() 


While Not KeyDown( 1 ) 
	
	dx#=(GraphicsWidth()/2-MouseX())*0.001
	dy#=(GraphicsHeight()/2-MouseY())*0.001
	If MouseDown(1) Then TurnEntity piv,0,MouseXSpeed(),0
	MoveEntity camera,0,0,MouseZSpeed()
	If MouseDown(3) Then MoveEntity camera,-dx#,dy#,0
	
UpdateWorld
RenderWorld
Flip 

Wend 

End 




Oiduts Studios(Posted 2010) [#3]
Sorry but it did the exact same thing.
NOTE HideEntity tree will also mean all trees copied from this will be hidden unless they are manually unhidden as well.

By the way, if you hide an entity and then copy it using copyentity, then any commands used on the original entity (like; hideentity, entitycolor, entityposition, etc) will not be applied to the new entitys.


Oiduts Studios(Posted 2010) [#4]
I just threw the Psionic ninja in there and it worked fine. I guess the animating tree has some issues. Has anyone ran into anything with the Tree[d] trees?


Matty(Posted 2010) [#5]
I didn't know the Tree[d] trees had animation?


Matty(Posted 2010) [#6]
Actually you will find that copying a hidden entity results in the resultant entity being hidden. Other things like position do not get applied, but hiding does (at the time of copying) - if you hide the original entity after copying then the copies will not become hidden too.


Oiduts Studios(Posted 2010) [#7]
Yes they do, you should check it out.


_Skully(Posted 2010) [#8]
Doesn't copyentity create references to the same mesh source?

I think you have to use copymesh to get unique copies

Cheers


Matty(Posted 2010) [#9]
Yes that's right Skully but it is possible to animate each copy individually using the standard blitz animate commands on each entity. It only becomes an issue when you start moving vertices around manually or repositioning the mesh.


Oiduts Studios(Posted 2010) [#10]
I can not seem to find the problem. Searching on google, here, and frecle, I have only found 1 post with the same problem. But no one could answer him. Could someone please try this out. I would greatly appreciate it.

PS: by the way, for any reason, no matter how the code is set up, any animated tree will go to the origin. Even if I reposition it.

edit #2 : If the tree is not animated, it can be moved in the loop. If I animate it at all, it cannot be moved. If I animate it then STOP the animation, the tree still cannot be moved, it sticks to the origin. As in, if the animate command shows up, it pretty much tells the tree to stay at 0,0,0 :o


Warner(Posted 2010) [#11]
Maybe you can use:
Animate GetChild(tree, 1), 1
?


Jiffy(Posted 2010) [#12]
Copyentity copies have no animation.

Graphics3D 640,480 ,32,2
SetBuffer BackBuffer() 

ClearTextureFilters
TextureFilter "_alpha",4+8
tree=LoadAnimMesh("tree.b3d") : HideEntity tree

Type Tree1
	Field Entity
End Type

For i = 0 To 5
	t.Tree1 = New Tree1
	t\Entity = CopyEntity(tree)
	PositionEntity t\Entity, Rand(-15,15), 0, Rand(-15,15)
Next

piv=CreatePivot()
camera=CreateCamera(piv) 
PositionEntity camera,0,12,-20
light=CreateLight()

While Not KeyDown( 1 ) 
	
	dx#=(GraphicsWidth()/2-MouseX())*0.001
	dy#=(GraphicsHeight()/2-MouseY())*0.001
	If MouseDown(1) Then TurnEntity piv,0,MouseXSpeed(),0
	MoveEntity camera,0,0,MouseZSpeed()
	If MouseDown(3) Then MoveEntity camera,-dx#,dy#,0
	
	If KeyHit (57) ;space
		t.tree1=First Tree1
		For t = Each Tree1
			Animate t\Entity, 1
			q=Animating(t\Entity)
			If (q) EntityColor t\Entity,$ff,0,0
			t= After t
		Next
		tested=True
	EndIf

UpdateWorld
RenderWorld
Flip 

Wend 

End 



Matty(Posted 2010) [#13]
I've had no problems in the past using copyentity on animated entities and animating them...


Jiffy(Posted 2010) [#14]
Well, the demo I posted copies fine & display ok till you animate them, then they glitch. At this point it's pretty much in the tree3d written b3ds I guess.


Ross C(Posted 2010) [#15]
What version of blitz are you using? The only possible reason, outside of blitz being buggy, that i can think of is the bones are being moved, of the mesh in question.

Oh, also, does the tree have bones?


Oiduts Studios(Posted 2010) [#16]
Oh, also, does the tree have bones?

I'm not sure and do not know how to check if there are. I have narrowed down the situation though, as stated in my last post. It would be fantastic if someone with Tree[d] could test it out, it is free you know. I have version 1.104


Warner(Posted 2010) [#17]
edit #2 : If the tree is not animated, it can be moved in the loop. If I animate it at all, it cannot be moved. If I animate it then STOP the animation, the tree still cannot be moved, it sticks to the origin. As in, if the animate command shows up, it pretty much tells the tree to stay at 0,0,0 :o

Maybe you could try use Animate as follows:
For i = 1 to CountChildren(tree)
Animate GetChild(tree, i)
Next

Or else, use a pivot to place the trees.


Oiduts Studios(Posted 2010) [#18]
Sadly it is not working.


Warner(Posted 2010) [#19]
Can you post your model?


Oiduts Studios(Posted 2010) [#20]
Here it is, remember I did not make this. Also, I have no programs as of now that can edit it. But I do have Tree[d].

http://www.mediafire.com/file/n53m4kgtnny/tree3.b3d


Warner(Posted 2010) [#21]
This model has no animation? Anyway, I found tree[d] and installed it, and exported the default tree to .b3d. Indeed, it cannot be moved when the animation is playing. The only approach I can think of is using a pivot to move the model:



Oiduts Studios(Posted 2010) [#22]
Wow thanks. I guess I posted the wrong model sorry about that. It works just how I want it, thanks man.


jfk EO-11110(Posted 2010) [#23]
You may use Fragmotion (free nagware), Ultimate Unwrap 3D or B3D Tweaker to examine and edit fishy B3Ds. Sometimes they contain additional top handle pivots, incorrect hierarchy etc.


Oiduts Studios(Posted 2010) [#24]
Thanks JFK, I will be sure to look into buying one of those.