find part of model from the Actor.

Hello,

I generate normal mapping on a man model except his hair.
So I ignore a shader on the man’s hair.
See my code below,

self.man = loader.loadModel("man.bam")      
self.man.reparentTo(render)
self.man.setShaderAuto()
self.man.find("**/hair").setShaderOff()

It’s thrown an error.

self.man.find("**/hair").setShaderOff()
AssertionError: !is_empty() at line 3590 of panda/src/pgraph/nodePath.cxx

The egg file show as below.

<Group> character {
  <Dart> { 1 }
  <Group> hair {
    <VertexPool> hair.verts {
      <Vertex> 0 { .....

I search for the solution on this forum and see someone remove " { 1 }" to fix it.

<Group> character {
  <Group> hair {
    <VertexPool> hair.verts {
      <Vertex> 0 { .....

Then I remove " { 1 }" and it work. I can refer to the hair model.
But when I load this model as Actor.See the code below.

self.man = Actor()
self.man.loadModel("man.bam")
self.man.loadAnims({'stand0' : "man_stand1.bam"})
self.man.reparentTo(render)
self.man.setShaderAuto()
self.man.loop('stand0')
self.man.find("**/hair").setShaderOff()

The error appear.

:Actor(warning): man.bam is not a character!

    self.man.loop('stand0')
  File "C:\Panda3D-1.7.0\direct\actor\Actor.py", line 1555, in loop
    for control in self.getAnimControls(animName, partName):
  File "C:\Panda3D-1.7.0\direct\actor\Actor.py", line 1849, in getAnimControls
    allowAsyncBind = allowAsyncBind)
  File "C:\Panda3D-1.7.0\direct\actor\Actor.py", line 2341, in __bindAnimToPart
    bundle = self.__commonBundleHandles[subpartDef.truePartName].getBundle()
KeyError: 'modelRoot'

But if I insert " { 1 }" as native egg file, it can loop animation without an error.
How can I loop an animation and find the part of model in the same egg(bam) file?
Or I has to modify the path in the “find()”'s parameter.

Please give me an advise.
Thanks in advance.

  • ola -

In my code I use something like this for Actors:

model.find('**/**.objectname')

I think I got it from one of the example scripts. Give that a try.

Edit:
Actually, I think this might just be because of the way I named the objects in my own EGG files, so it is probably not useful.

Use:

egg-optchar -o new.egg -flag hair=hair man.egg

to pre-process man.egg into new.egg, and flag the “hair” node for runtime access.

David

Thanks for your both reply.

model.find('**/**.hair')

The code above not work for me.
But very thank you for your advise.

The egg-optchar is work!

egg-optchar -d ./opt_char -flag hair=hair man.egg man_stand1.egg

Thank you very much!

  • ola -