Hemispherical camera view attempt

In a lot of three-dimensional games, I have noticed that the game camera does not let the player see what is not directly in front of the character. This is especially bad when an enemy might be walking towards you from the side. The player’s vision is like looking through a tube or a seeing as a horse wearing blinders. So I wanted to make a way to see out the corner of your eye, sort of like a fish eye camera lens, which could make it look more realistic. This is the result, using nine cameras instead of one (There used to be 25, but that let the player see a bit behind the character.) It isn’t perfect, but still kind of a cool effect. Just replace the camera in your scene with this:

[java]

viewPort.setBackgroundColor(ColorRGBA.Blue);

cam.setViewPort(0.33f, 0.66f, 0.33f, 0.66f);

cam.setLocation(new Vector3f(0f, 1f, 0f));

//[0,0.33,0.66,0.99][0.33,0.66,0.66,0.99][0.66,0.99,0.66,0.99]

//[0,0.33,0.33,0.66][0.33,0.66,0.33,0.66][0.66,0.99,0.33,0.66]

//[0,0.33,0,0.33] [0.33,0.66,0,0.33] [0.66,0.99,0,0.33]

FlyByCamera flyCam = new FlyByCamera(cam);

flyCam.setEnabled(true);

flyCam.setMoveSpeed(20);

flyCam.registerWithInput(inputManager);

CameraNode camNode = new CameraNode("", cam);

camNode.setControlDir(ControlDirection.CameraToSpatial);

rootNode.attachChild(camNode);

Camera cam8 = cam.clone();

cam8.setViewPort(0f, 0.33f, 0.66f, 0.99f);

cam8.setLocation(new Vector3f(0f, 1f, 0f));

CameraNode cam8Node = new CameraNode("", cam8);

cam8Node.setControlDir(ControlDirection.SpatialToCamera);

camNode.attachChild(cam8Node);

cam8Node.rotate(-0.8f, 1f, 0f);

ViewPort view8 = renderManager.createMainView(“Top Left”, cam8);

view8.setClearFlags(true, true, true);

view8.attachScene(rootNode);

Camera cam9 = cam.clone();

cam9.setViewPort(0.33f, 0.66f, 0.66f, 0.99f);

cam9.setLocation(new Vector3f(0f, 1f, 0f));

CameraNode cam9Node = new CameraNode("", cam9);

cam9Node.setControlDir(ControlDirection.SpatialToCamera);

camNode.attachChild(cam9Node);

cam9Node.rotate(-0.8f, 0f, 0f);

ViewPort view9 = renderManager.createMainView(“Top Left”, cam9);

view9.setClearFlags(true, true, true);

view9.attachScene(rootNode);

Camera cam10 = cam.clone();

cam10.setViewPort(0.66f, 0.99f, 0.66f, 0.99f);

cam10.setLocation(new Vector3f(0f, 1f, 0f));

CameraNode cam10Node = new CameraNode("", cam10);

cam10Node.setControlDir(ControlDirection.SpatialToCamera);

camNode.attachChild(cam10Node);

cam10Node.rotate(-0.8f, -1f, 0f);

ViewPort view10 = renderManager.createMainView(“Top Left”, cam10);

view10.setClearFlags(true, true, true);

view10.attachScene(rootNode);

Camera cam13 = cam.clone();

cam13.setViewPort(0f, 0.33f, 0.33f, 0.66f);

cam13.setLocation(new Vector3f(0f, 1f, 0f));

CameraNode cam13Node = new CameraNode("", cam13);

cam13Node.setControlDir(ControlDirection.SpatialToCamera);

camNode.attachChild(cam13Node);

cam13Node.rotate(0f, 1f, 0f);

ViewPort view13 = renderManager.createMainView(“Top Left”, cam13);

view13.setClearFlags(true, true, true);

view13.attachScene(rootNode);

Camera cam14 = cam.clone();

cam14.setViewPort(0.66f, 0.99f, 0.33f, 0.66f);

cam14.setLocation(new Vector3f(0f, 1f, 0f));

CameraNode cam14Node = new CameraNode("", cam14);

cam14Node.setControlDir(ControlDirection.SpatialToCamera);

camNode.attachChild(cam14Node);

cam14Node.rotate(0f, -1f, 0f);

ViewPort view14 = renderManager.createMainView(“Top Left”, cam14);

view14.setClearFlags(true, true, true);

view14.attachScene(rootNode);

Camera cam17 = cam.clone();

cam17.setViewPort(0f, 0.33f, 0f, 0.33f);

cam17.setLocation(new Vector3f(0f, 1f, 0f));

CameraNode cam17Node = new CameraNode("", cam17);

cam17Node.setControlDir(ControlDirection.SpatialToCamera);

camNode.attachChild(cam17Node);

cam17Node.rotate(0.8f, 1f, 0f);

ViewPort view17 = renderManager.createMainView(“Top Left”, cam17);

view17.setClearFlags(true, true, true);

view17.attachScene(rootNode);

Camera cam18 = cam.clone();

cam18.setViewPort(0.33f, 0.66f, 0f, 0.33f);

cam18.setLocation(new Vector3f(0f, 1f, 0f));

CameraNode cam18Node = new CameraNode("", cam18);

cam18Node.setControlDir(ControlDirection.SpatialToCamera);

camNode.attachChild(cam18Node);

cam18Node.rotate(0.8f, 0f, 0f);

ViewPort view18 = renderManager.createMainView(“Top Left”, cam18);

view18.setClearFlags(true, true, true);

view18.attachScene(rootNode);

Camera cam19 = cam.clone();

cam19.setViewPort(0.66f, 0.99f, 0f, 0.33f);

cam19.setLocation(new Vector3f(0f, 1f, 0f));

CameraNode cam19Node = new CameraNode("", cam19);

cam19Node.setControlDir(ControlDirection.SpatialToCamera);

camNode.attachChild(cam19Node);

cam19Node.rotate(0.8f, -1f, 0f);

ViewPort view19 = renderManager.createMainView(“Top Left”, cam19);

view19.setClearFlags(true, true, true);

view19.attachScene(rootNode);

[/java]

The one in the center with a blue background is what it would look like in a regular view.

http://img16.imageshack.us/img16/8522/cameracomparison.png

Can you attach a screenshot plz ? how is this different from a 3rd person camera ?

I added a picture. Basically, it shows on the other camera squares what you would see if you looked in that direction. In the picture, the left side is a regular camera and the right side is what you see with these nine. In the regular camera, you cannot see the wall. With this, you can see the wall in the camera to the right. Each camera shows what you would see if you looked in that direction, so if you looked to the right, you would see the wall. So it’s kind of like seeing out the corner of your eye.

Heh, I guess this would look cool using a projector with the inside of a large white “box” as screen…

I noticed there’s some seams on the view where the camera boundaries are.

I think perhaps this kind of thing is better implement in a shader.

Do we have the equations that can convert from view space to projection space for this sort of effect?

can the same thing be achieved by setting a wide camera frustum…



http://i.imgur.com/UxUtF.jpg

You’re right, that’s exactly what I wanted to do. Thanks for mentioning it.