[Noob] Types of Nodes

Hi, i’ve been having problems with removing pieces from a game I am making. It uses the chessboard tutorial but has been greatly modified. I know that in order to remove pieces i have to do something with nodes.
Can someone explain the differences between all the different node typed(PandaNode, NodePath, TreeNode). If there is some other class i should know to do this, please inclue.

Someone correct me if I’m wrong.
NodePath = (the path to) the node on the Scene Graph.
PandaNode = the node itself. You can get this by doing nodepath.node()

You would generally use NodePath and not worry about PandaNode. (I never heard of TreeNode) On the NodePath you can set position, scaling, rotation, reparent it to other nodes, etc.

ok. I don’t know if you’re familiar with the chessboard tutorial, but how do i access the top node?
I know that you aren’t supposed to ask for code, but i’m going to. How would i make it so I can remove a piece from the board?

Here is what i have…a method remove(int squareNumber)…this should then find the piece that is in that square. I know how to find which piece should be there, but graphically I can’t remove it.

I’m also guessing that you need to somehow have a tag inside the piece that is specific to each piece using .setTag(str(squareNumber))
hopefully someone can help me :slight_smile:

The top node is called render.
Just treat render the way you would do with other NodePaths, like
render.setScale(2)

I assume you are talking about “Tut-Chessboard.py” in the Panda3D samples directory. The following lines are from this sample. It is where the chessboard “pieces” are loaded:

    #For each square
    self.squares = [None for i in range(64)]
    self.pieces = [None for i in range(64)]
    for i in range(64):
      #Load, parent, color, and position the model (a single square polygon)
      self.squares[i] = loader.loadModelCopy("models/square")
      self.squares[i].reparentTo(self.squareRoot)
      self.squares[i].setPos(SquarePos(i))
      self.squares[i].setColor(SquareColor(i))

So you want to remove the i-th square? I haven’t tested, but this should work:

    np = self.squares[i]
    np.removeNode( )

enn0x

ok, so i understand all of that, but now I am having problems with having the seperate piece class. What you suggested in the previous post removed the playing board. So i added the following…

s.piecesRoot = render.attachNewNode("piecesRoot")

and in the piece class i added…

s.obj.reparentTo(s.piecesRoot)

the problem is that the s.piecesRoot is private and the Piece class can’t access it.
How do i allow the Piece to access this?

ok, i figured out how to solve the problem. after each players turn i had to create the piece inside the World class. so the piece class became totally useless.