multiple cameras

How would you create multiple cameras and then switch between the views(such as over the shoulder, 3rd person, 1st person, etc.)? Is there already one of the examples that does this?

Thanks,

-Brian

There are is a thread for two cameras in one window
or maybe this is more like that what you want
Hope this helps

Martin

Wouldnt it be simpler to have just one camera that can switch to multiple modes? If you dont need to have 2 active camera’s at the same time, that would be the best way to go about it.

You can write something like this:

THIRDPERSON= 1
FIRSTPERSON= 2
class View():
  def __init__(self, playermodel):
    self.camstate= THIRDPERSON

    
    base.disableMouse()

    taskMgr.add(self.thirdpersoncameratask, "CameraTask")

    #taskMgr.add(self.SpinCameraTask, "CameraTask")

  def stopCamera(self):
    taskMgr.remove('CameraTask')
  
  def SetView(self, newview):

    "Sets the View"

    #print newview

    if newview == THIRDPERSON:

	self.stopCamera()

	taskMgr.add(self.thirdpersoncameratask,'CameraTask')

	self.camstate= newview
     elif newview == FIRSTPERSON:
        self.stopCamera()
        taskMgr.add)self.firstpersoncameratask,'CameraTask')
        self.camstate= newview
    else:

	print 'Wrong View ther is no View: ', newview

  #SetView

Hope this code is correct.
Regards Martin

Ehm, hope you dont mind martin, just adding another suggestion, alot like yours but more in the OOP spirit.



class myCamera(DirectObject):

    def __init__(self):
        # set the default camera mode
        self.camMethode = self.thirdPersonCam

        # 1 sets third person mode
        self.accept('1', self.setTPCam)

        # 2 sets shoulder cam mode
        self.accept('2', self.setShoulderCam)

        # add a loop that performes the current methode
        taskMgr.add(self.cameraLoop, 'cameraLoop')
    
    def setTPCam(self):
        self.camMethode = self.thirdPersonCam

    def setShoulderCam(self):
        self.camMethode = self.shoulderCam

    def thirdPersonCam(self):
        'Your camera methodes'

    def shoulderCam(self):
        'Your camera methodes'

    def cameraLoop(self):
        self.camMethode()

Didnt mean to be cocky, just thought this would be a nice addition to the previous code.

Yeah thats good. I’ll work on my code to get it better
Thanks Martin

Thanks! I think both of those approaches would work. After I sent the post, I tought "why not just jump the camera to a different location? That’s probably what I need to do, but having set cameras may work as well…I’ll have to see what works better.

Is there a way to adjuct the far clipping plane? I don’t really need it for what I’m doing, but when I’m looking at layout, I’d like to extend it a little. Is this possible?

Thanks for all the help.

-Brian

I dont know if there is a way by setting options in panda
but you can do something like make your map a bit bigger and check if the player reaches the point where he/she will see it and stop him there.
I’m sure david knows a better way g

The far clipping plane is a property of the lens. See the page on this subject in the manual, but in a nutshell you can do something like this:


base.camLens.setFar(10000)

David

Thanks everyone for all the help. Camera issues worked out, now it’s on to the more interesting stuff of how to move the characters around.

Thanks,

Brian

Hello,

As you said, you can change the attributes (pos, hpr) of the camera.

What I did for my test, it was to define rectangles (or circles) and to relate
the attributes of the camera to those rectangles.

So, you divide your map into squares or rectangles. Each time, the
avatar enters in a new rectangle, you read the attributes and you change
the camera attributes by the new ones and you let Panda to render again
the scene. The camera wil change to the new one.

Regards.

Alberto