keep "camera" from running through walls

I’m using the collision and navigation system in the same way as David Yazel’s Quake3 level loader (dummy avatar node) for first-person navigation and it’s working fine so far, but I’m having trouble making the view get close enough to walls so that it’s right up against it, but doesn’t see through the actual geometry. For instance, when you put your head next to a wall and look straight ahead, all you see is the wall to your right, but in my program you see through the geometry on the right. In case that didn’t make sense, a screenshot:

http://www.csc.calpoly.edu/~ehdoty/thing.jpg

This is actually with some relatively small values for the size of the bounding sphere and collision node. If I make the bounds or collider node a little bigger, this doesn’t happen, but then, for instance, I can’t fit through the crack that you see straight ahead. I’d like the view node to be small so it can go wherever.

Here’s some code (from the quake3 loader) illustrating the dummy navigation node, if you’re not familiar with it:

// build a dummy node to represent the avatar for collision and movement
// purposes.  we do this by creating a branch group with set bounds around an
// avatar of 1.83 meters high.  Then we make a collider node of an ellipsoid which is
// half as wide as it is tall.

        TransformGroup aTG = new TransformGroup();
        Node n = new BranchGroup();
        n.setBoundsAutoCompute(false);
        n.setBounds(new BoundingSphere(new Point3f(0, 0.915f, 0), 0.915f));
        aTG.addChild(n);
        converter.getRoot().addChild(aTG);
        avatarNode = new ColliderNode(n, ColliderNode.CT_ELLIPSOID, ColliderNode.CT_ELLIPSOID, true, new Coord3f(0.5f, 1, 0.5f));
        cs.addCollider(avatarNode);

Do I need to modify the view somehow to make it not always be in the center of the screen so if I get close to the wall, it moves as well? I’m not sure if this is simple or more complicated than I think. Any suggestions? Thanks :slight_smile:

Um have you tried - colliderNode.setTwoSided(true);?
Just a guess I’m afraid.

I’ve had the same sort of problem I think. I’ve been testing for specific collisions between the dummy view and say a xith cube using sphereIntersect() in the Sphere class. I get the right collision detected, but only if I hit the exposed bottom of the cube, not any point on the cube e.g. the top or higher up each side - I have tried playing with the BoundingSphere and the collisionNode values of the xith cube which doesn’t seem to do anything.

[quote]Um have you tried - colliderNode.setTwoSided(true);?
[/quote]
Yeah. Doesn’t have any effect. :-/

The collisions seem to work alright… in the picture I’m just sliding along the wall just fine. I just figure since I specify the radius of the bounding sphere and collider node (ellipsoid), then I would think that it would not intersect with the wall (which is a simple quad).

I’m importing the model as an .ase file and adding the shape3Ds from it as ColliderNode.CT_GEOMETRY and they are static (isMovable = false)… and the avatar node is dynamic, of course.

It might be that what you are seeing is the geometry clipped against the near clipping plane. Try moving it closer to the camera.

Printing out your bounds manually may help to check exactly what is happening:

e.g.:

                  System.out.println("VWbounds View:" + dummyView.getVworldBounds().toString());
                  System.out.println("VWBounds Shape:" + shape.getVworldBounds().toString());
                  System.out.println("View:" + viewBounds.toString());
                  System.out.println("Shape:" + cubeBounds.toString());

If not perhaps as suggested it might be something to do with clipping.

[quote]It might be that what you are seeing is the geometry clipped against the near clipping plane. Try moving it closer to the camera.
[/quote]
Yes!! That was it, thanks. Works fine now. I didn’t even think about that :). Silly me.