Help with Camera

Have jReality programming problems or questions? Post them here.
Post Reply
danny.lesnik
Posts: 2
Joined: Sun 21. Jun 2009, 08:28

Help with Camera

Post by danny.lesnik » Sun 21. Jun 2009, 15:48

Hello,

I'm looking for an option to move camera around object on surface around 180 degrees forward/backward, up/down and left/right according to key pressed.

Till now I have found how can I move my camera forward and backward

public void actionPerformed(ActionEvent e) {
Camera camera = CameraUtility.getCamera(viewer);
camera.setFieldOfView(........);
viewer.render();
}

How can my move camera left/right, up and down?

Your help is very appreciated.

Danny.

User avatar
steffen
Posts: 186
Joined: Fri 16. Jun 2006, 13:30
Location: TU Berlin
Contact:

Re: Help with Camera

Post by steffen » Sun 21. Jun 2009, 17:53

Hi Danny,

to move the camera, you need to edit the transformation of its SceneGraphComponent. Changing the Viewport does not move the Camera at all... I think you could do anything you want using the ShipNavigationTool (this makes a WASD navigation as in an ego shooter). In Your case cou would have to rotate the camera to look to the bottom instead of looking to the front. How did you set up your scene?

Steffen.

danny.lesnik
Posts: 2
Joined: Sun 21. Jun 2009, 08:28

Re: Help with Camera

Post by danny.lesnik » Mon 22. Jun 2009, 01:13

Hi Steffen,

Sure, that changing ViewPort does not move came...
I'm just going through samples and tutorials and what I'm trying is the following code, but it doesn't get the desired effect:

public class MyViewer
{
public static void main(String[] args) {
SceneGraphComponent world = SceneGraphUtility.createFullSceneGraphComponent("mySample");
world = read3DS(world);
ShipNavigationTool tool = new ShipNavigationTool();
world.addTool(tool);
JRViewer.display(world);
}
private static SceneGraphComponent read3DS(SceneGraphComponent scn)
{
scn = null;
try
{
scn = Readers.read(Input.getInput("http://localhost/test.jrs"));
}
catch(IOException e)
{
e.printStackTrace();
}
return scn;
}
}

User avatar
steffen
Posts: 186
Joined: Fri 16. Jun 2006, 13:30
Location: TU Berlin
Contact:

Re: Help with Camera

Post by steffen » Mon 22. Jun 2009, 13:57

Hi,

I have just comitted a new tutorial example, src-tool/de.jreality.tutorial.tool.MapNavigationToolExample. It contains two tools, and the idea is that the camera is only moved in z-direction, where the map is lying in the x-y plane and dragged in that plane with a dragging tool. Use the mouse wheel for changing the camera distance, and drag the map with the middle mouse button. I hope that helps. I suppose you should start writing your own tools, start with the dragging tool and modify it as you need it. My demo is only a quick hack which wipes out most of the transformation computed in the DraggingTool.

The example is only in the svn, not in the files from the download section. Maybe you need to set up jreality from svn.

Post Reply