help! how2 apply collision poly on 'camera' or 'base.camera'

i used the collision spheres as common ones, and i cant just simply get bounds from it coz its not a model…am i right?
so how should i make collision sphere or collision node on base.camera?

or should i just put one object attached to the moving camera wherever it goes and let this object be the one with collision polygon or node?

if repeated thread please at least attach the link to me, thanks.

Sorry, I can’t really understand your question. None of the words you use seem to have any reference to my understanding of Panda.

“i used the collision spheres as common ones”–common? common to what?

“i cant just simply get bounds from it coz its not a model”–you can call getBounds() on a collision node, or a collision sphere, or a NodePath containing a collision sphere. So I don’t know what you mean here.

“so how should i make collision sphere or collision node on base.camera?”

Maybe like this:

cnode = CollisionNode('cnode')
cnode.addSolid(CollisionSphere(0, 0, 0, 1))
cnodePath = base.camera.attachNewNode(cnode)

David

yo David!! u’re the savior!

lets say i got a map, the doors are seperate models.
i can now control the camera to walk as FPS.
i would like to make a list of information displayed out whenever the camera reaches a door. so can …Davaid or any of you here…
teach me how to attach the collision shpere on the camera?
yes i’ve called getBounds, is it this function is to get the information on how big is the sphere to be? coz the code in getBounds is to get the center and the radius of the model to make the sphere on it …i guess.
but there was error, i used the codes in bvwdemo of its setCollision() and replace ‘self.panda’ to camera.

Ah, I understand. Yes, the getBounds() call in the bvw demo is returning the bounding volume of the panda model: that is, it is used to figure out how big the collision sphere should be, so that it will fit around the panda.

But, the camera has no geometry, and so its bounding volume is empty. You can’t use same the trick to figure out how big a sphere should be that will fit around the camera. Just make up a sphere. In my example above, I’ve made up a sphere of radius 1, centered on (0, 0, 0).

The easiest way to attach the camera to the controls, though, is just to reparent the camera to the panda in the bvw demo. Something like:

base.camera.reparentTo(panda)

I’m not sure exactly what the panda node is called in that demo program, but that’s the general idea. You can probably keep exactly the same code other than this one line change.

David

Impressive!
Now i’ve encounter another problem.
I have created 3 diff model of maps and all are loaded once the world is constructed/initiated, and located very far from each other in terms of setPos(). Now i need to make the camera to ‘teleport’ to front door of another map once collision happens. It did teleport to another map but why it is not in expected setPos and setHpr, meaning that it is not at the front door?
what i did is let the collision event be calling out a function, where inside the function is camera.setPos() and camera.setHpr().

Your camera is no longer parented to render, so you can’t just set the camera to a new position. Instead, you should set the thing the camera is parented to (e.g. the panda) to the new position.

Think of each node of the scene graph as being a platform you can stand on. The platform moves around and carries everything on it along with it. When you parent the camera to the panda, that means that whenever the panda walks around, it carries the camera along with it.

But it also means that when you set the camera to position (0, 0, 0), it means (0, 0, 0) relative to the panda, not to the overall scene. And when you set it to (x, y, z), it means (x, y, z) relative to the panda, not to the overall scene–so if you want to move the camera to (x, y, z) in the overall scene, that’s not the way to do it. But move the panda to (x, y, z) in the overall scene, and it will take the camera with it.

David

thou i dont really catch it but i tried and tried it still wont work.
i got 8 days left to present it.

this is where i reparent it in my load model function:

def LoadModelz(self):
                self.prg = Actor("models/smiley")
		self.prg.reparentTo(camera)
		self.prg.setScale(0.05)
		camera.reparentTo(render)
                onef.firstfloor()
                twof.secondfloor()
                #gf.groundfloor()

my codes of making cameras turn left right and move to front and back are all controlling the ‘camera’ instead of ‘base.camera’ through some posInterval tricks from bvwdemo.

collision spheres are applied on ‘camera’ and other models that are to be hit by ‘camera’.

the event call out when collision hit as below:

def toff(self,cEntry):
                globalvar.walky = -100
                globalvar.camX = -6.5
                globalvar.camY = 36.5
                globalvar.camZ = -100
                globalvar.camH = 90
                globalvar.camP = 0
                globalvar.camR = 0
                ##camera.reparentTo(render)
                ##camera.setPos(globalvar.camX,globalvar.camY,globalvar.camZ)#(3.2,43,-100)
                ##camera.setHpr(Vec3(globalvar.camH,globalvar.camP,globalvar.camR))#(Vec3(90,0,0))
                self.prg.setPos(globalvar.camX,globalvar.camY,globalvar.camZ)#(-3,34.2,0)
                self.prg.setHpr(Vec3(globalvar.camH,globalvar.camP,globalvar.camR))#(Vec3(185,0,0))

no matter i change it to setPos the ‘camera’ or ‘self.prg’(the dummy model) it still wont work.
and i noticed that the size of collision sphere and the direction of collision are the only that made differences. seems like it only changed the Z value of setPos(X,Y,Z).

Should i change all controls to the dummy model(even the turn left right posInterval) and only reParent the ‘camera’ to the model? and even the collision sphere sticks on the dummy model?

Nodes inherit the transform of their parents, not the other way around. So if self.prg is a child of camera, there’s no way that moving self.prg around will move the camera around.

If you want to move the camera around, you can either (a) operate on camera directly, or (b) operate on a node that is a parent of camera (not a child of camera).

Note that in case (a), at least, you must call base.disableMouse() at least once in your application, so that Panda’s default camera manipulation system won’t interfere with your own efforts.

David