Author Topic: Primary Flight Display HUD  (Read 4651 times)

Offline bizart

  • byte
  • *
  • Posts: 10
    • View Profile
Primary Flight Display HUD
« on: November 21, 2012, 09:46:18 am »
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:


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Primary Flight Display HUD
« Reply #1 on: November 21, 2012, 08:27:39 pm »
If that thing moving (except for the rotation)? If not, i would go with a large textured plane for this.

Offline bizart

  • byte
  • *
  • Posts: 10
    • View Profile
Re: Primary Flight Display HUD
« Reply #2 on: November 21, 2012, 08:42:09 pm »
.. 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 :)

Offline KittenKoder

  • int
  • **
  • Posts: 66
  • I Am No One Else
    • View Profile
    • Kitt Games Wiki
Re: Primary Flight Display HUD
« Reply #3 on: November 21, 2012, 09:42:56 pm »
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.

Offline bizart

  • byte
  • *
  • Posts: 10
    • View Profile
Re: Primary Flight Display HUD
« Reply #4 on: November 21, 2012, 10:28:53 pm »
.. 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 :)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Primary Flight Display HUD
« Reply #5 on: November 21, 2012, 10:46:03 pm »
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.

Offline bizart

  • byte
  • *
  • Posts: 10
    • View Profile
Re: Primary Flight Display HUD
« Reply #6 on: November 23, 2012, 04:53:51 pm »
Hi,

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

Code: [Select]
            // 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:

Code: [Select]
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!

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Primary Flight Display HUD
« Reply #7 on: November 23, 2012, 06:19:07 pm »
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.

Offline bizart

  • byte
  • *
  • Posts: 10
    • View Profile
Re: Primary Flight Display HUD
« Reply #8 on: November 23, 2012, 10:55:59 pm »
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Primary Flight Display HUD
« Reply #9 on: November 24, 2012, 08:45:54 pm »
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...

Offline bizart

  • byte
  • *
  • Posts: 10
    • View Profile
Re: Primary Flight Display HUD
« Reply #10 on: November 24, 2012, 09:49:05 pm »
.. Rotation difference issue is because variable touchTurn changes before passing to second object:

solved it this way:
Code: [Select]
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!



Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Primary Flight Display HUD
« Reply #11 on: November 25, 2012, 12:00:58 am »
Any smarter solution is welcome :)
How does this "scale representation" look like? Is it a number printed on the screen or... ???

Offline bizart

  • byte
  • *
  • Posts: 10
    • View Profile
Re: Primary Flight Display HUD
« Reply #12 on: November 25, 2012, 12:14:56 am »
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


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Primary Flight Display HUD
« Reply #13 on: November 25, 2012, 09:17:36 pm »
Just use one large texture that contains the scale values and blit the part that is relevant?

Offline bizart

  • byte
  • *
  • Posts: 10
    • View Profile
Re: Primary Flight Display HUD
« Reply #14 on: November 25, 2012, 09:56:21 pm »
.. 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 ..