Board index FlightGear Development Canvas

How do I make a 2D PFD with pages

Canvas is FlightGear's new fully scriptable 2D drawing system that will allow you to easily create new instruments, HUDs and even GUI dialogs and custom GUI widgets, without having to write C++ code and without having to rebuild FlightGear.

How do I make a 2D PFD with pages

Postby diande » Sat Jul 13, 2013 8:22 pm

I want to clone the pilatus PC9M PFD.
Image

How can I code different Compass modes - like in one of the modes you can see Only half of the compass rose, in another one you can see your way points on a map into the compass. How do I do that? I want it in textures, since I am planning to use FGPanel

Also How can I mask some texture - I want to make the artificial horizon form a brown and blue texture, that tilts and hide the unnecessary part from it, so it can fit like in the image

Is there a way to make only the instrument panel like the one in the IFR Cessna, but from CANVAS - and link it remotely to the master simulation, and achieve the effect from FGPanel?

How do you mask graphics in CANVAS?
diande
 
Posts: 17
Joined: Sat Jul 06, 2013 4:50 pm

Re: How do I make a 2D PFD with pages

Postby diande » Sat Jul 13, 2013 8:36 pm

diande wrote in Sat Jul 13, 2013 8:22 pm:I want to clone the pilatus PC9M PFD.
How can I code different Compass modes - like in one of the modes you can see Only half of the compass rose, in another one you can see your way points on a map into the compass. How do I do that? I want it in textures, since I am planning to use FGPanel


it seems that into the documentation you can only code one static gague. I guess I am forced to use CANVAS?
diande
 
Posts: 17
Joined: Sat Jul 06, 2013 4:50 pm

Re: How do I make a 2D PFD with pages

Postby Hooray » Sat Jul 13, 2013 9:14 pm

Yes, you should definitely be using the canvas system.

How can I code different Compass modes - like in one of the modes you can see Only half of the compass rose, in another one you can see your way points on a map into the compass. How do I do that? I want it in textures, since I am planning to use FGPanel


it IS possible (but awkward, and not very flexible) by applying transformations to static textures, check out some of the other aircraft/airliners/bizjet and how they're doing it, or just see README.2dpanel

But again, you will almost certainly want to forget the "old" texture-based approach and directly use the canvas system instead, while there are not as many examples, it is easy to get started - especially if you should already have some scripting experience (JavaScript/HTML5). I suggest to check out the development/canvas sub forum and ask your questions there, you may also find a bunch of questions already being answered by browsing the canvas sub forum.

The canvas allows you to use SVG images drawn with Inkscape, and easily use raster images and custom drawing commands using OpenVG paths.

However, please do note that the canvas cannot currently be run in a standalone/FGPanel-fashion - there's been some talk about that, but that will at least take another 1-2 releases in my opinion. That being said, you could certainly come up with a canvas instrument panel, and then simply use in a dedicated fgfs instance, which is slaved to a corresonding master instance.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: How do I make a 2D PFD with pages

Postby Hooray » Sun Jul 14, 2013 1:33 pm

diande wrote in Sat Jul 13, 2013 8:22 pm:How do you mask graphics in CANVAS?


Texture mapping / masking is explained at: http://wiki.flightgear.org/Howto:Using_ ... xture_Maps
Some basic example code to load instrument textures from our 2D panel instruments at: http://wiki.flightgear.org/Howto:Parsin ... the_Canvas
Last edited by Hooray on Sun Jul 14, 2013 5:58 pm, edited 1 time in total.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: How do I make a 2D PFD with pages

Postby Philosopher » Sun Jul 14, 2013 2:26 pm

And in cases when the restriction bounds are not rectangles, then make a path that masks it and use the z-index property to order the clipped item below and unclipped items above (e.g. for the image of the PFD, there would be the virtual horizon with the lowest z-index, say 0, a black background above that, and all of the other instruments will be higher than the black). To use:

Code: Select all
canvasElement.set("z-index", 0);
Philosopher
 
Posts: 1593
Joined: Sun Aug 12, 2012 7:29 pm

Re: How do I make a 2D PFD with pages

Postby Hooray » Sun Jul 14, 2013 3:21 pm

right, it was only intended as an example to get the OP started - also, because I'd expect him to favor SVG files over our static textures - on the other hand, we do have a sizable library of reusable components in $FG_AIRCRAFT/Instruments obviously, and there's also the long-term plan to re-implement our 2D panel manager code in Nasal space through a custom Canvas wrapper - so we could just as well provide a little more than just that stub, I didn't bother looking into supporting the various transformations/actions - but given the flexibility and power of the canvas system, it should actually be fairly straightforward - I cannot currently think of anything "missing" here - the status looks pretty encouraging actually, I think I also remember seeing quite a bit of useful code in Tom's fgdata repo.

Coming up with a Nasal/Canvas wrapper that supports loading our 2D panels should be fairly straightforward, but would involve a fair bit of sophisticated Nasal hacking, i.e. "meta-programming" and familiarity with the canvas system and the 2D panel code obviously:

@OP:
Subject: FGPanel from CANVAS idea
diande wrote:Hooray, you are awesome :) You help me a lot. Thanks for that!
I started this morning working with FG. Can you guide me how can I replace the IFR panlel with a single Canvas sprite?


Most people here will tell you that I am usually pretty supportive and responsive, as you may have noticed. However, you previously mentioned in another thread that you were not too interested in sharing your work but would prefer to keep it private, which is frankly something that concerns me:
In other words, I'd rather spend my time supporting people who directly contribute things back in some shape or form, like for example kuijfe09, macnab or Philosopher (thanks guys!).

After all, that's the whole point of the exercise, and as long as we don't share our work, the project and community cannot benefit unfortunately ...

Thus, if you'd like to see more support in this form from my side, I'd appreciate it if we could work out some plan to either share your full work, or alternatively, come up with a generic Nasal/Canvas framework for rendering instruments that you can share with us. As you may have noticed, your effort does overlap with various planned projects - so it would make sense to coordinate things a little here.

Especially, because the shared knowledge and expertise available here, can probably save you tons of time - while we, as a community, would appreciate having someone working on stuff that is "good to have", but currently not being worked on by anybody else.

So, I'm offering personal 1:1 mentoring to help you with things (answer questions, provide code snippets etc), as long as we can work out a way to come up with a generic and reusable component here, that will be useful to the whole community, not just a single user.

As you may have noticed, we do have a few very knowledgeable people interested in related things, but most of us are already juggling tons of "side projects", which is why we usually have to switch in "mentoring mode" once we see something interesting.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: How do I make a 2D PFD with pages

Postby Philosopher » Sun Jul 14, 2013 3:35 pm

Actually I'm thinking that having a mask would be helpful even in Canvas, because then the ladder and text don't have to worry about clipping -- that's done with a path which will automatically provide a "window" to look through (while being a opaque on either side). I do agree that we are all doing so many things and that we would like to see something that will eventually be used as part of FlightGear – I'm not an expert at all, but I would find it hard to believe that there would be any legal issues with a simple PFD like this, after all, everything's pretty much being provided by FlightGear and the OP, but I could be wrong.
Philosopher
 
Posts: 1593
Joined: Sun Aug 12, 2012 7:29 pm

Re: How do I make a 2D PFD with pages

Postby Hooray » Sun Jul 14, 2013 3:45 pm

I say, there are not any legal issues to be expected at all. It's not like FlightGear is the most sophisticated simulator in the world. There's far more sophisticated software available, not just commercial flight simulators, but actual flight training software. And there are tons of payware addons for FSX and X-Plane emulating avionics, FMS, CDUs and airliner EFIS that are more sophisticated than what we'd have even if all of us were to work together on it for a full year.

In addition, avionics manufacturers have traditionally been pretty supportive and fortcoming whenever it came to bringing their own products to the flight sim world - "free advertizing" you know.

For example, the GARMIN guys actually provide the real GNS500 firmware running in an emulator, that can be connected to FSX and XPlane, at no cost!

Finally, the 9/11 terrorists were known to have received real flight training, used various flight sim products, including MSFS - none of that had any "legal" repercussions.

From experience, FG as a project will always pull the plug early, and remove contributions in case of doubt - even if they're fully covered by the GPL.

So I wouldn't worry about legal issues at all - but it is up to contributors to get in touch with manufacturers to get something in writing - it is my understanding that some of our livery designers did exactly that - Personally, I would not even had considered that necessary in the first place, there's something like "common-sense" after all. And FlightGear is not a legal entity, and its contributors are covered by the GPL, which in turn means that the FSF is there to support the project if the need arises.

Bottom line being, even if you were to spend 5 years creating a 100% realistic Boeing or Airbus CBT suitable for type-rating purposes, there would not be any legal issues, unless you're violating the copyright of someone. There's no issue recreating/replicating something, let alone a simulation of the real thing - it's not like you are going to "compete" with an avionics manufacturer just because you managed to simulate 10% of its features in a flight sim product that has ZERO commercial relevance.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: How do I make a 2D PFD with pages

Postby Johan G » Sun Jul 14, 2013 10:48 pm

A bit off topic:

In certain circumstances it would be advantageous to also have clipping by a path in canvas. Most fighter head up displays (HUD:s) have a bright circular CRT generating their symbology.

It seems like the optical path and collimator* are optimised for that circle because when viewed off centre (with the symbology shifted by the collimator to appear at the same stop on the horizon as when viewed at dead centre) the projected symbology will be clipped by the optical paths circular aperture. Sometimes the optical paths aperture is neither circular nor rectangular, some of the F-16 version for instance seem to have a clipped circle.

You obviously can not achieve this with opaque masks.

* The collimator makes the projected image appear at infinity instead of 3 ft away.
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Some YouTube videos
Johan G
Moderator
 
Posts: 6629
Joined: Fri Aug 06, 2010 6:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.4
OS: Windows 10, 64 bit

Re: How do I make a 2D PFD with pages

Postby TheTom » Sun Jul 14, 2013 11:08 pm

Johan G wrote in Sun Jul 14, 2013 10:48 pm:In certain circumstances it would be advantageous to also have clipping by a path in canvas. Most fighter head up displays (HUD:s) have a bright circular CRT generating their symbology.

You can use any arbitrary shape to place a canvas onto. For a HUD you just need to create an arbitrarily shaped polygon with your favorite 3d modeling software and place a canvas onto it. As everything drawn onto the canvas goes to an offscreen texture first, only the parts placed onto the 3d model are shown.

Johan G wrote in Sun Jul 14, 2013 10:48 pm:You obviously can not achieve this with opaque masks.

You can also draw transparent paths. With the correct blending mode you can just replace all existing contents. It's not named mask, but you can use every canvas element as a mask:

Code: Select all
# replace everything already drawn with the pixels of the path
path.set("blend-source", "one")
      .set("blend-destination", "zero");
TheTom
 
Posts: 322
Joined: Sun Oct 09, 2011 11:20 am

Re: How do I make a 2D PFD with pages

Postby Johan G » Mon Jul 15, 2013 9:41 am

TheTom wrote in Sun Jul 14, 2013 11:08 pm:For a HUD you just need to create an arbitrarily shaped polygon with your favorite 3d modeling software and place a canvas onto it... only the parts placed onto the 3d model are shown.
...
You can also draw transparent paths. With the correct blending mode you can just replace all existing contents...

Aha, thank you for those hints. At some point in the future, maybe when I have my next computer, and have installed a recent version of FlightGear, I will start try out Canvas HUD:s and displays.


To get back on topic: The PC-9M is one of my very favourite aircraft in FlightGear (with the caveat of lacking proper propeller effects) and seeing more modern cockpit instruments is something that i would look forward to. While the current instruments are enough for both VFR and IFR flying, the cockpits of most PC-9 and variants have at least a few MFD:s and very often, if not always, an EICAS display with engine and system information.

It would be favourable if the livery selection later on also would alter the cockpit since there are relatively large differences between operators.
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Some YouTube videos
Johan G
Moderator
 
Posts: 6629
Joined: Fri Aug 06, 2010 6:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.4
OS: Windows 10, 64 bit

Re: How do I make a 2D PFD with pages

Postby Philosopher » Sat Jul 20, 2013 1:11 am

Actually, Jedvaj's PC-21 has a (more or less) working version of the same PFD, but that is using textures. Anyways, it's missing the mach speed and negative vertical speed is represented as a sort of 1000's complement ;).
Philosopher
 
Posts: 1593
Joined: Sun Aug 12, 2012 7:29 pm


Return to Canvas

Who is online

Users browsing this forum: No registered users and 4 guests