Animating multiple objects
Blitz3D Forums/Blitz3D Programming/Animating multiple objects
| ||
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 |
| ||
try thisGraphics3D 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 |
| ||
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. |
| ||
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? |
| ||
I didn't know the Tree[d] trees had animation? |
| ||
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. |
| ||
Yes they do, you should check it out. |
| ||
Doesn't copyentity create references to the same mesh source? I think you have to use copymesh to get unique copies Cheers |
| ||
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. |
| ||
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 |
| ||
Maybe you can use: Animate GetChild(tree, 1), 1 ? |
| ||
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 |
| ||
I've had no problems in the past using copyentity on animated entities and animating them... |
| ||
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. |
| ||
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? |
| ||
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 |
| ||
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. |
| ||
Sadly it is not working. |
| ||
Can you post your model? |
| ||
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 |
| ||
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: |
| ||
Wow thanks. I guess I posted the wrong model sorry about that. It works just how I want it, thanks man. |
| ||
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. |
| ||
Thanks JFK, I will be sure to look into buying one of those. |