Hi,
this is what i was able to do:
rotate the camera in a circular motion.
this is what i want to achieve:
rotate the camera on a mouse click in a circular motion to face any object placed in the center.
i tried playing with the “H” factor of the HPR leaving me with the current code which rotates my camera too fast around its own axis and also the circular path around the object. This is my second panda program. Pl. guide.
Here’s the code as it exists now:
import direct.directbase.DirectStart
from direct.task import Task
from direct.actor import Actor
from pandac.PandaModules import*
from direct.showbase.DirectObject import DirectObject
import math
import sys
environ = loader.loadModel(“models/environment”)
environ.reparentTo(render)
environ.setScale(0.15,0.15,0.15)
environ.setPos(-8,42,0)
class World(DirectObject):
def __init__(self):
base.disableMouse()
self.angle= 90
self.mov = 0
self.accept("arrow_left", self.SpinCamLeft)
def SpinCamLeft(self):
base.camera.setPos(math.sin(self.angle)*50, math.cos(self.angle)*50,4)
self.angle+= 0.1
self.mov += 6
if self.mov > 360:
self.mov = 0
base.camera.setHpr(self.mov,0,0)
if self.angle > 360:
self.angle= 0
def SpinCamRight(self):
base.camera.setPos(-(math.sin(self.angle)*10), -(math.cos(self.angle)*10),3)
self.angle-= 0.1
if self.angle > 360:
self.angle= 0
world = World()
run()