SpinCameraTask. How do I spin in the opposite direction?

I’m very new to Panda3D and I’m full of questions. I hope you’ll all bear with me as I try to learn :unamused:.

I’ve been working through the tutorials and experimenting on my own a bit. And I’ve managed to write my very first script, it’s not much, it just loads a couple of my own models and spins the camera around (like in the first tutorial), yay for me! :smiley:

Now, at the moment the camera is spinning in an anti-clockwise direction (which is grand) but I’d also like to learn how to make it spin in the other direction (clockwise) too.

I’ve tried playing with some of the values, but sadly, I can’t get it to work. So I hope somebody here can point me in the right direction. Anyway, here is my script:

# spincameraclass.py
import direct.directbase.DirectStart
from pandac.PandaModules import*
from direct.showbase.DirectObject import DirectObject # To listen for events
from direct.task import Task # To use tasks
from direct.actor import Actor # To use animated actors 
import math # To use math 

class World(DirectObject):
    def __init__(self): 
       # Reposition the camera
       camera.setPos(0,-15,7) # X = left & right, Y = zoom, Z = up & down
       camera.setHpr(0,-15,0) # Heading, Pitch, Roll
       self.loadModels() # Declare/name the new class methods you're going to use.
       # Setup key controls
       self.accept("escape", sys.exit)
       # Start SpinCamera task
       taskMgr.add(self.SpinCameraTask, "SpinCameraTask") # Add this before the definition.
       # end __init__

    def loadModels(self): # Define the new class method. Define what it does.
        # Load a model
        self.box = loader.loadModel("MODELS/box2")
        # Load an environment
        self.environ = loader.loadModel("MODELS/grassplain")
        # end loadModels
    #Task to spin the camera 
    def SpinCameraTask(self,task): # Define the SpinCamera task 
        angledegrees = task.time * 50.0 # speed of rotation
        angleradians = angledegrees * (math.pi / 180.0) 
        base.camera.setHpr(angledegrees, 0, 0) 
        return Task.cont 
# end class World

world = World()


Any help would be much appreciated.


Your signature is unbearably cute. I couldn’t stop laughing.

angledegrees = task.time * 50.0 # speed of rotation

Making this value negative will make you rotate the other way.

angledegrees = task.time * -50.0

Thanks very much Nostgard (for the siggy compliment too :smiley: ).

Hehe “angledegrees = task.time * 50.0 # speed of rotation” is the one value I didn’t think to try altering, because I thought I’d figured out what it did.

Typical, it’s always the one you least suspect :unamused:.

Thanks a lot.