The following post was made by Mike Pippin to our (now defunct) Panda3D mailing list on sourceforge.net. I am posting it here to reply to it, and so that others may contribute assistance as well.
David
Can someone explain what this set of code does and how it controls the movement
def controlCamera(self, task):
# figure out how much the mouse has moved (in pixels)
md = base.win.getPointer (0) <--------------------------What does this line do…
x = md.getX()
y = md.getY()
if base.win.movePointer(0, 100, 100): <-----------------------------What does this line do…and the following 2
self.heading = self.heading - (x - 100)0.2
self.pitch = self.pitch - (y - 100)0.2
if (self.pitch < -45): self.pitch = -45
if (self.pitch > 45): self.pitch = 45
base.camera.setHpr(self.heading,self.pitch,0)
dir = base.camera.getMat().getRow3(1) <-------------------------------What does this line do?..
elapsed = task.time - self.last
if (self.last == 0): elapsed = 0
if (self.mousebtn[0]): <------------------------------
self.focus = self.focus + dir * elapsed30 | I get that this section has something to do with movement but I
if (self.mousebtn[1]) or (self.mousebtn[2]): | dont get where the elasped time falls into the picture…
self.focus = self.focus - dir * elapsed30 <------------------------------ or how it actually works because I dont know what getMat() does
base.camera.setPos(self.focus - (dir5))
if (base.camera.getX() < -49.0): base.camera.setX(-49)
if (base.camera.getX() > 49.0): base.camera.setX( 49)
if (base.camera.getY () < -49.0): base.camera.setY(-49)
if (base.camera.getY() > 49.0): base.camera.setY( 49)
if (base.camera.getZ() < 1.0): base.camera.setZ( 1)
if (base.camera.getZ() > 49.0): base.camera.setZ( 49)
self.focus = base.camera.getPos() + (dir5)
self.last = task.time
return Task.cont
Thank you in advance for any help that anyone may be able to give me…