Change camera behavior in jMonkey - java

I am writing a program that is supposed to display 3D point clouds. For this purpose, I am using the jMonkeyEngine. Unfortunately, I do not like the default camera behavior of jMonkey. Especially the mouse dragging and mouse wheel do not really do what I want. What I want is them to behave like in the pcd viewer of the PointCloudLibrary.
Mouse wheel: Should be faster, and the the effect of the turning directions should be switched.
Mouse dragging: In jMonkey it seems like mouse dragging changes the camera viewing direction in the world. I am not sure what exactly happens in the pcd viewer, but I believe the camera is moved through the world while fixating the centroid of the displayed point cloud.
How can I change the behavior of the camera to fullfil my wishes? :)

1.
In the simpleInit() method (where 100 is an abritrary number):
getFlyByCamera().setZoomSpeed(100);
getFlyByCamera().setDragToRotate(true);
Note, that zooming doesn't actually change the position of the camera, just the FOV.
2.
The normal behavior of the camera is to rotate around its own axis. By offseting the location of the camera as well, the effect you want can be achieved. In simpleUpdate():
cam.setLocation(cam.getDirection().negate().multLocal(cam.getLocation().length()));
I consider the answer to the second question a bit of a quick hack. But it does the trick.

Related

How to change the point of rotation of bodies in BOX2d/LIBGDX?

I have got a player set up and I am trying to make an arm for my character. The shapes are all created using either PolygonShapes or CircleShapes and I have made it so it points towards the mouse but I want to change the the point of rotation from this:
to this:
(Please forgive my crude drawings)
Ok, so i used a revolute joint which allowed to me set an anchor elsewhere, however, how do i rotate it towards the mouse position as the applyTorque method uses torque instead of radians?

Java WorldWind : translate whole globe

I am doing extensive use of Java WorldWind and have difficulties to implement some more feature with 3d rendering. At first, I had huge difficulties with zoom and BasicOrbitView, as zoom actually changes point of view elevation, which changes the horizon and hence is not a zoom. I solved that using FOV parameter. Decreasing this parameter performs a real zoom, as visualized object is only modified by an homothetic transformation. I explain that to let know the level of details I hide behind words such as "zoom" or "translate".
Now I have a second issue with "translate": I want to translate the whole earth along screen X and Y axis without horizon change or whatever. Objective is to combine both FOV change with translation change to zoom on some earth edges.
Zooming on some earth edge is possible using roll and pitch, at the condition that the edge is located up on your screen, which forbids to have pole north up, zooming at earth edge on equator for example (if not clear I will provide illustrations). So this attempt was unsuccessful. I worked a lot on BasicOrbitView.setOrientation method unsuccessfully.
I also tried to modify the OpenGL view matrices behind the View, trying to multiply it with a 4x4 matrix describing a translation, unsuccessfully (execution crashes during worldwind subroutines).
Have you an idea on how to implement that translation in worldwind ?

Andengine Parallax Background

Background:
I am making a 2D side-scroller.
When the player touches the screen, the player moves forward (the camera follows the player).
I cannot find an answer to this question although it seems rather straightforward.
Question:
How can I get my parallax background to scroll only when my player moves?
(example code would make things much easier for me)
I am using autoparallaxbackground but it seems that it simply just scrolls at the rates you pass in, with no regard to the camera. Moreover, I am not fully sure of the difference between autoparallaxbackground and parallaxbackground.
Any help is appreciated!
AutoParallaxBackground extends ParallaxBackground, adding one simple feature: automatically changing mParallaxValue with time. As you may imagine, if you don't need your background constantly moving, you may use ParallaxBackground as your base class, and then use setParallaxValue(final float pParallaxValue) to manually adjust the position.

Zoom in on a point in an image in with VTK

I have an image in VTK that I'm viewing with vtkImageViewer2, and I want to zoom in on a point the user clicks on. I am working in Java. Does anyone know how to do this?
Thanks
I realize you ask for Java, but my experience doing this has been with c++; equivalent java syntax should work, minus the customizability.
Take a look at these examples for picking and zooming. Also, if you set the interactor style to 'image', the mouse wheel should cause a zoom to wherever the cursor is. You probably don't want to do literally what you asked, but rather either do rubberband zoom or have the mousewheel for zooming. Clicking should do something, not just change the view.
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Images/PickingAPixel2
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/RubberBandZoom
Depending on what you mean by zoom you want to either change the position and direction of the camera (likely) or change the frustum (unlikely).
Have a look at the methods setPosition() and setFocalPoint() in class vtkCamera. Here is the documentation of vtkCamera:
http://www.vtk.org/doc/nightly/html/classvtkCamera.html

Drawing unobscured health bars in a Java 3D scene

So I'm working on a game in Java 3D and I'm implementing health bars that hover above units.
I started by drawing a quad at a 3D point above the unit's location and applying a Billboard behavior to make it always face the camera.
But the problem I'm stuck with is that the health bars are sometimes obscured by other scenery.
So I'm considering the following options:
Overriding the Z / depth buffer value for the health bar pixels to make the renderer think they're closer to the camera than anything it renders afterwards.
I tried renderingAttributes.setDepthTestFunction(RenderingAttributes.ALWAYS). While it makes the renderer draw the health bar on top of anything it drew in the same area earlier, it doesn't help when the other scenery is drawn on top of the health bar later.
Is there a better way for doing this in Java 3D?
Projecting the 3D locations of the health bars onto a 2D plane in front of the camera. Sounds doable, but before I set off reinventing all the math required for this, maybe someone can point out an existing solution.
Switching from Java 3D to something like LWJGL or jMonkeyEngine (not just for this issue, but general complaints about Java 3D being dead, etc). Although I'm not even sure whether they're more flexible for this particular problem. And from what I've read, one of the worst mistakes in game dev is switching the engine in mid-development.
Use the painter's algorithm: draw the health bars after you've drawn the rest of the scene (and with Z testing turned off, of course).

Categories