I am new to panda3D, and I have an issue with a small piece of code.
I am trying to implement a function which changes the color of an object to green when the cursor is on it, and to blue when it is not (all models are initially red)
I used a piece of code found on the forum or in the manual, and adaptated it.
This is what I’ve made :
def getObjectHit(self, task): a = render.getChildren() for i in range(1,a.getNumPaths()) : print task.time," node path : ",a.getPath(i) a.getPath(i).setColor(0,0,1,1) if(base.mouseWatcherNode.hasMouse()): mpos = base.mouseWatcherNode.getMouse() self.pickedObj = None #be sure to reset this self.pickerRay.setFromLens(base.camNode, mpos.getX(),mpos.getY()) self.picker.traverse(render) for i in range(self.queue.getNumEntries()): self.pickedObj = self.queue.getEntry(i).getIntoNodePath() self.pickedObj.setColor(0,1,0,1) return Task.cont
When it starts, the models are all blue, thanks to the first for loop.
The thing is, it does change from blue to green when the cursor goes on the model, but it does not goes back to blue after.
If I set the priority of the first (blue) color change to 1, it does not turn into green.
Can you explain me what is going wrong ?