Actor / Non-Actor Problem

Hi,

I have got a problem with Actors. I have got an egg-file which contains the Armature with the Model which shall be deformed and besides of them it contains some Empties and independent Models.

[...]

<Group> Armature {
  <DART> { 1 }
  <Group> Cube.001 {
    <Tag> sound { ../sounds/submachinegun.wav }
    <Tag> DCS { 1.0 }
    <DCS> { 1 }
    <VertexPool> Cube.001 {

[...]

<Group> Cube.002 {
  <Transform> {
    <Matrix4> {
      1.000000 0.000000 0.000000 0.000000
      0.000000 1.000000 0.000000 0.000000
      0.000000 0.000000 1.000000 0.000000
      7.392756 3.228260 -0.106865 1.000000
    }
  }
  <Tag> DCS { 1.0 }
  <Tag> particle { ../particles/liquid.ptf }
[...]

I need to find the Cubes in my script to read the Tags ( particle / sound … )
The Problem is when the Model contains an Armature the method findAllMatches("**/*") does only find the Armature and neither the deformed Cube nor the independent one… the independent one isn’t even rendered…

The Problem is the dart Tag of the Armature

<Group> Armature {
  <DART> { 1 }
  <Group> Cube.001 {

When I remove the dart Tag the find Methods can find all Objects as they should find… but then the animations can’t be played anymore…

I need a solution to find the Cubes when I have an animated Model loaded as Actor…
Does anyone know a solution for that?

TIA, blenderkid

The problem lies in the Actor class which loads only rigged models.
A possible solution is loading the model separately with loader.loadModel() and passing that to actor so that it can filter its needed armature.

Here a sample:

model = loader.loadModel("path/to/model")
actor = Actor(model, okMissing=False)
particle_empties = model.findAllMatches("**/particle ?*")
if not particle_empties.isEmpty():
    particles_np = actor.attachNewNode("particles")
    particle_empties.reparentTo(particle_np)

That’s basically it.

There’s another possibility for more generic workaround that involves LoaderOptions in a way so that you strip the armature of the ‘model’ and attach everything what’s left to the actor, but I haven’t investigated that yet.

Thank you so much Nemesis,

It almost works now. I can find the independent models and Empties now, but I still can’t find the Models assigned to the Armature. E.g. “Cube” is assigned to the Armature but it still can’t be found.

But now the problem is almost solved =)
Thank you so much.

Any idea how to find the animated Model (boned Model… dunno how to call it ^^)?

blenderkid

hmm =/

Just noticed that the model playing the animation is doubled, one time in the loader.loadModel and one time as Actor…
I need to remove the models loaded by the loadModel method, which are also loaded by the Actor… but how?

blenderkid

Extract what you need out of it and drop the reference. everything not parented to render/render2d/hidden without reference will be garbage collected.

Anyway, I wouldn’t care too much about that anyway. You don’t render two same things anyway and it’s presistent in memory as long as there’s one left.

You said you have an animated model packed together with some static ones. Why don’t you declare it all as one actor and play the animations on subparts? This implies that the whole thing is meant to belog together. In any other case it’s more advisable to make one egg file per model.

Oh and just by the way: store animations separately. I made bad experiences packing all into single eggs.

hmm?
What shall be reparented to render? the model or the actor?
or both?
When I reparent both, there are the animated Models doubled.

And I still can’t find the animated Models neither in the Actor nor in the loader.loadModel…

tia, blenderkid

I don’t pack them as one Actor, because I need to find the separate Models and so far Idk how to find models in Actors…
idk if that is possible

This shall help you:
panda3d.org/manual/index.php/Multi-Part_Actors

Oh and reparent only the actor to render. From model you only extract what you need with findAllMatches() and reparent the needed things to actor.

This mixes up the inheritance given in the blend file a bit and gives you the following hierarchy:

                     /  particle_effect_1
render - your_actor --  some_static_stuff
                     \  another_thing

Ok =)

Now the only thing I have trouble with is finding the animated Model.

I have:

Actor -> Skeleton -> Cube

But when I try to actor.findAllMatches("**/*") it says:

render/Armature/__Actor_modelRoot
render/Armature/__Actor_modelRoot/-GeomNode

But it can’t find the Cube.
Does anyone have a solution for that?
And I need to find the animated one, not the static one of loader.loadModel, tho that isn’t found either.

TIA, blenderkid