Primary Flight Display HUD

Started by bizart, November 21, 2012, 09:46:18 AM

Previous topic - Next topic

bizart

Hi,
I am new to Java and OpenGL..  :)

Working on several implementations of flight instruments(SVG javascript, Canvas...), figured it out that best performance on mobile could be using OpenGL..
It is more like 2D application..

What methods should I try for horizon rotations? Textured Plane? Skybox?
Is it possible to setup a Skybox with gradients?
Any example of semi-transparent scale overlays with sort of dynamic strings?

Any help will be appreciated!

Thank you in advance!

This is a view from svg js implementation:


EgonOlsen

If that thing moving (except for the rotation)? If not, i would go with a large textured plane for this.

bizart

.. Except for the rotation there is translation up and down (pitching) i.e. full sky or full ground..

Some more advanced solutions have so called "synthetic vision" with terrain rendering, but so far a simpler is better :)

KittenKoder

For the gradient texture you could make a small 32x32 BufferedImage and paint a gradient onto that using Graphics2D, then turn it into a texture pretty easily.

I forgot to check which platform again. I don't know if AE has the same ability as pure Java for the gradient painting, but it's a starting point.
When life throws you lemons, make lemon juice, then drop life into a pile of razors and pour the lemon juice over it.

bizart

.. I was thinking to draw horizon and pitch line graphics on separate overlay, so to be able to use different horizon backgrounds.. even terrain in the future..

Could it be possible to use some kind of transparency at horizon background, for future video feed background?

Any ideas are welcome :)

EgonOlsen

You could use a texture with an alpha channel, but that's tricky on transparent framebuffers if you mix it with opaque elements that intersect (in 2D) with the transparent ones.

bizart

Hi,

Working on HelloWorld example I have come up with the following at onSurfaceChanged:


            // Horizon line texture
            TextureManager.getInstance().addTexture("horizon_texture", new Texture(getResources().openRawResource(R.raw.horizon_line), true));
           
            // Horizon background texture
            TextureManager.getInstance().addTexture("horizon_background_texture", new Texture(getResources().openRawResource(R.raw.horizon_back), true));
           
            horizon_background = Primitives.getPlane(1,1.6f);
            horizon_background.setTexture("horizon_background_texture");
            horizon_background.strip();
            horizon_background.build();
            horizon_background.translate(0, 0, 0.1f);
           
            world.addObject(horizon_background);            
           
            horizon_overlay = Primitives.getPlane(1,1.6f);
            horizon_overlay.setTexture("horizon_texture");
            horizon_overlay.strip();
            horizon_overlay.build();
            horizon_overlay.setTransparency(255);

            world.addObject(horizon_overlay);

            Camera cam = world.getCamera();
            cam.moveCamera(Camera.CAMERA_MOVEOUT, 1);
            cam.lookAt(horizon_overlay.getTransformedCenter());


.. at onDrawFrame:


if (touchTurn != 0) {
horizon_background.rotateZ(touchTurn);
horizon_overlay.rotateZ(touchTurn);
touchTurn = 0;
}


.. So far i have notice few things:

- Texture gradient on horizon_background(1024x1024) has a lot of strip lines..
- Some how I cannot get how to setup correctly view from camera pointing to planes to fit on a screen(i.e. landscape) :)
- During rotation after some turns appears a difference in rotation angle between two objects

Here you can check:
http://quadrodynamics.com/HelloWorld.apk

Thank you in advance!

EgonOlsen

The gradients come from the frame buffer being only 16bit. You can either try to enable dithering in Config or configure a 32bit buffer in the surface setup of the Activity.
I'm not sure what exactly you mean with the second question and i can't spot the problem that you described in the third. Might be some inaccuracies in floating point math that add up in a way that things start to differ. Can't you simply use the same rotation matrix for all objects.

bizart

Thank you EgonOlsen!

Config.glDither = true; Actually did solve the gradients issue..

I am trying to fill the entire view area with horizon(width should fit to screen diagonal), but don't know how could handle scale on different screens?

Did you mean rotating camera? There should be fixed "layer" (bird view and speed, altitude scales)..
Any idea for sliding scales representation?

EgonOlsen

I'm not sure about the problem with filling the screen....maybe you can use the methods in Interact2D to calculate from screen coordinates back into 3D land and use that somehow to do the scaling? I've no exact idea how to do this ATM, but this might be a way...

No, i  meant to do something like obj1.setRotationMatrix(obj2.getRotationMatix());. That will assign the same matrix to both objects. Maybe that helps...

bizart

.. Rotation difference issue is because variable touchTurn changes before passing to second object:

solved it this way:

public void onDrawFrame(GL10 gl) {
if (touchTurn != 0) {
float tmp = touchTurn;
horizon_background.rotateZ(tmp);
horizon_overlay.rotateZ(tmp);
touchTurn = 0;
}


.. using same projection matrix is better and elegant way :)

For the moment I have locked to landscape orientation, and adapt scale of visual area for the device that I am testing on.
The problem is that if there is fixed size of textures for both horizon lines and background on some resolutions it would not be possible to adapt scale so both are visible and not over-scaled.. I will think of this later.. now I am finishing next overlays with roll angle visualization and bird view..

Still do not have complete idea how to handle scales representation.. I was thinking of some large semi transparent cylindrical wheel with scale textured on peripheral.. Other approach could be using polylines (or other ..) and dynamically draw scale over its visual part on screen.

Any smarter solution is welcome :)

Cheers!



EgonOlsen

Quote from: bizart on November 24, 2012, 09:49:05 PM
Any smarter solution is welcome :)
How does this "scale representation" look like? Is it a number printed on the screen or... ???

bizart

Please take a look at the first attachment.. "scales" on the left and right should be moving scales with ticks and labels (left scale represents speed so it should have range from 0 to 1000 i.e. , on the right is altitude its range should be larger from from -1000 to +1000, but it is better to be dynamic)..

This is the progress so far:
http://quadrodynamics.com/HelloWorld.apk


EgonOlsen

Just use one large texture that contains the scale values and blit the part that is relevant?

bizart

.. It seems to me that this texture (actually three of them) will be very laarge :).. let's say 10 pixels offset for tick(1000 ticks) .. than 10000 pixels for texture?!

Do not have idea how can blit part of texture ..