question about the Panda3D Manual: Instancing

Hello everyone, I follow the manual, but i got an error like this:

Assertion failed: !is_empty() at line 335 of panda/src/pgraph/nodePath.cxx
Traceback (most recent call last):
File “/home/username/workspace/panda3d/src/instancing.py”, line 149, in
chorusline.reparentTo(render)
AssertionError: !is_empty() at line 335 of panda/src/pgraph/nodePath.cxx

I am wondering if there is a error in my code,but could’n figure it out.
Here is my code, I used the panda to be my actor:

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

pandaActor = Actor.Actor("models/panda-model",{"walk_a":"models/panda-walk4"})
pandaActor.loop("walk_a")
pandaActor.setPos(0,0,0)
pandaActor.setScale(0.005, 0.005, 0.005)
chorusline = NodePath()
for i in range(50):
    placeholder_q = chorusline.attachNewNode("Dancer-Placeholder")
    placeholder_q.setPos(i * 5,0,0)
    pandaActor.instanceTo(placeholder_q)
chorusline.reparentTo(render)

for i in range(3):
    placeholder_a = render.attachNewNode("Line-Placeholder")
    placeholder_a.setPos(0,i * 10,0)
    chorusline.instanceTo(placeholder_a)

run()

Thanks for the replying.

environment:
Ubuntu 7.10
Eclipse 3.3.2
Panda 1.5.3

The line:

chorusline = NodePath()

creates a NodePath that contains no node. It is like a NULL pointer; it is an error to do anything with it. You can’t attach nodes to it, and you can’t reparent it to render.

Instead, try this line:

chorusline = NodePath('chorusline')

This line has a very different meaning. Instead of a NodePath with no node, it creates a default PandaNode named ‘chorusline’, and then creates a NodePath to that node. You can then use this NodePath for all the purposes you have in mind.

Incidentally, there’s no point to the line:

chorusline.reparentTo(render)

because the line is about to be instanced to render three times below.

I’m not sure that the instancing page of the manual was really intended to be a cut-and-paste example; it was mainly trying to explain the concepts of instancing. But I suppose it can be useful to type in some code and see what it actually does. :slight_smile:

David

Oh, I got it now. Thanks! :smiley: