[Solved] Isometric camera?

Hello again!

I downloaded, installed and finished the basic Panda3D tutorials. I actually just moved here after spending 2 weeks in Irrlicht. I’m not good in C++ and new to Python, so I’ve been thinking how could I add Isometric camera to my game? I’ve been searching the forum and found some information :

def load_camera(self):
    lens = OrthographicLens()       
    base.camNode.setLens( lens )
    base.camera = cam

But this didn’t came out as I expected :

How could I make an isometric camera come out like this :

I hope I am not asking for too much. Thanks.

Seems to me like all you need to do is place the camera correctly. Doing it from the code in a “change and reload” manner might be a little inconvenient so you might try this:

base.cam.place()

It should allow you to find the right spot for the camera fairly easily.

You might also try first placing the camera correctly (including height above the ground) and then using NodaPath.lookAt(x, y, z) method. It’s very useful.

You probably want to place it at a 45 degrees angle.

That was a really fast reply and also very helpful. The :

base.cam.place()

code didn’t really work with my current code, so I used another one :

lens = OrthographicLens()
lens.setFilmSize(30, 25 )
base.cam.place()
base.cam.node().setLens(lens)

But now, when I run the file my model looks like this :

It doesn’t matter if I change setFilmSize variables to higher or lower ones. It’s really hard to use

base.cam.place()

with such problem (100% I wrote something wrong in camera code).

Thanks again.

EDIT

Would something like base.cam.setRotation(x,y,z) would work?

I’d go for simplistic. Move the camera up and call lookAt at a node or at a (0,0,0) point

base.cam.setZ(5)
base.cam.lookAt(yourNode)
#or base.cam.lookAt(0,0,0)

Twix: the reason why it looks so strange is because the camera is “inside” the panda. and the near-clip-plane is cutting away some parts of the panda. move the camera out of the panda. and things will look better.

Is isometric at a 45 degree angle? If so, something like this would work:

base.camera.setPos(10, 10, 10)
base.camera.lookAt(0, 0, 0)

you dont have any shrinking persp lines (parallel projection). so what you could try is, set the camera far from the focused object and if you have the possiblity to zoom just to zoom into. on that way you getting close to a parallel projection.

greetz
dirk

btw. merry christmas everyone

Hey guys, thanks for sharing your ideas with me. You were right, it was really the problem with camera being placed inside the panda. It’s fixed now, thanks! I’ve been editing the tutorial from manual. Current code looks like this :

import direct.directbase.DirectStart
from pandac.PandaModules import *
 
from direct.task import Task
from direct.actor import Actor
from direct.interval.IntervalGlobal import *
import math
 
#Load the first environment model
environ = loader.loadModel("models/environment")
environ.reparentTo(render)
environ.setScale(0.25,0.25,0.25)
environ.setPos(-8,42,0)
 
#Load the panda actor, and loop its animation
pandaActor = Actor.Actor("models/panda-model",{"walk":"models/panda-walk4"})
pandaActor.setScale(0.005,0.005,0.005)
pandaActor.reparentTo(render)
pandaActor.loop("walk")

#Create the four lerp intervals needed to walk back and forth
pandaPosInterval1= pandaActor.posInterval(13,Point3(0,-10,0), startPos=Point3(0,10,0))
pandaPosInterval2= pandaActor.posInterval(13,Point3(0,10,0), startPos=Point3(0,-10,0))
pandaHprInterval1= pandaActor.hprInterval(3,Point3(180,0,0), startHpr=Point3(0,0,0))
pandaHprInterval2= pandaActor.hprInterval(3,Point3(0,0,0), startHpr=Point3(180,0,0))
 
#Create and play the sequence that coordinates the intervals
pandaPace = Sequence(pandaPosInterval1, pandaHprInterval1,
  pandaPosInterval2, pandaHprInterval2, name = "pandaPace")
pandaPace.loop()

pandaPos = pandaActor.getPos()

# Camera
cam = Camera("Isometric")
base.cam.setPos(pandaPos+20) 
base.cam.lookAt(pandaActor)

run()

What I’ve been trying to do was to make the camera follow panda since it is moving. I thought that this code will do the trick,

base.cam.setPos(pandaPos+20) 
base.cam.lookAt(pandaActor)

but it does not. I’m again doing something wrong, since I’m completely new to Python and Panda3D. I also feel like asking too much already…

Thanks everybody for your helpful replies.

base.cam.setPos(pandaPos+20) 
base.cam.lookAt(pandaActor)

This is what you are using but it should look like:

base.cam.setPos(pandaActor.getPos()+20) 
base.cam.lookAt(pandaActor.getPos())

Or at least That is what I think the code is off the top of my head!

Thanks Chia_Pet for your reply, but it wasn’t the problem. I just needed to define a task like this :

def centerCamera(task):
    base.cam.setPos(pandaActor.getPos())
    return Task.cont

taskMgr.add(centerCamera, "centerCamera")

Now it works great, maybe it will help someone.