Hi there,
New Panda3D user, still getting the hang of it.
My basic code is:
#all the import stuff
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
#initialisation modules
self.man = self.loader.loadModel("models/slacker")
self.man.reparentTo(render)
self.man.setScale(0.025, 0.025, 0.025)
self.man.setPos(-30,0,0)
class Hello(DirectObject.DirectObject):
def __init__(self):
self.accept('mouse1',self.printHello)
def printHello(self):
print "Hello"
h = Hello()
app = MyApp()
run()
What I would like to do is be able to have the “slacker” model print its location when I click on the screen.
In an earlier version of the code I did it in the MyApp method to see if it worked:
self.textObject = OnscreenText(text = 'Man is' + str(self.man.getPos()), pos = (-0.5, 0.02), scale = 0.07)
But that happened on initialisation.
I am not sure how I can have the event manager listen out for a mouse click and then access to the methods/attributes in “man”. I’m still getting my head around how I can have all these different class references all link to one another or if everything/most things are intended to happen in MyApp.
I messed around trying to have self.accept(‘mouse1’, event_name(object_reference)) in the MyApp code and then the Hello class would then have access to it, but it always said the command didn’t exist (so I figured because it appeared lower, it couldn’t “see it”) but then it didn’t seem possible to reorganise the code.
I read the Task and Even Handling manual but it wasn’t really clear on this point, so I was hoping for some “human” clarification on this if possible.
Thanks.