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.
Help with Camera
Re: Help with Camera
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.
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.
-
- Posts: 2
- Joined: Sun 21. Jun 2009, 08:28
Re: Help with Camera
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;
}
}
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;
}
}
Re: Help with Camera
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.
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.