Actor.getCurrentAnimBundle() or getAnimBundle(str)?

I’m generating Actors and animations for them and sometimes I need to generate some Actors which will use the same animations as their parent Actor.
As animations (and Actors) are not read from eggs, I thought I could do something like Actor.getCurrentAnim() to get the AnimBundle of the current animation, but that function just returns the string name. Is there something similar to get the AnimBundle,like getCurrentAnimBundle() or getAnimBundle(str)? Or will I need to store a reference to parent Actors AnimBundles and assign them like that?

The Actor doesn’t provide an interface to directly query its AnimBundles (though you could dig through the Actor’s own internal storage objects and find it; see Actor.py).

But the Actor does provide an interface to return an AnimControl, and you can also get the AnimBundle from that:

actor.getAnimControl(animName).getAnim()

David

OK. A convenience function would be nice though, which would do that internally.
Sounds like it would be easy to add.

Yes, it would be easy to add.

I don’t think I could. The Actor class seems complex and would take me some time to digest. Maybe the person who wrote the class would notice this thread, I’m guessing it would take mere minutes if he remembers the code.

Right now it just seems too much code for something so simple:

from pandac.PandaModules import *
import direct.directbase.DirectStart
from direct.actor.Actor import Actor

base.cam.setPos(0,-40,7)

panda = Actor('panda')
panda.reparentTo(render)
panda.setX(-5)
panda.loadAnims({'anim': 'panda-walk'})
panda.loop('anim')

panda2 = Actor('panda')
panda2.reparentTo(render)
panda2.setX(5)

# too long
panda2.loadAnims({'anim': NodePath(AnimBundleNode('animbundlenode', panda.getAnimControl('anim').getAnim()))})

panda2.loop('anim')

run()

Well, how about you write your own function to hide the excess syntax?

def getActorAnim(actor, animName):
    return NodePath(AnimBundleNode('animbundlenode', actor.getAnimControl(animName).getAnim())

Really, any convenience method within Actor would look very similar, so what difference whether that method is actually within Actor or within your own class?

Or, you could save the NodePath that you construct when you construct the AnimBundleNode in the first place, and just pass it to each new Actor you create that needs to share that same animation.

David

Yeah, you’re right, it wouldn’t be different for me, but for others it would just mean reading less lines of code, if it’s in the direct package, they are less likely to actually read it with the rest of the code.

Yeah, but I don’t know how many people have the same needs as you do here. You’re the first developer I’ve ever spoken to who’s constructing his own AnimBundleNodes; if you’re loading anim files from egg files, you can just repeat the filename in each new Actor and it will automatically share them properly.

Still, I don’t mean to imply that I can guess how people will be using Panda in the future. Every interface is potentially useful to someone. :wink:

David