Board index FlightGear Development Canvas

Problems with the canvas for dynamic loading of the livery

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.

Problems with the canvas for dynamic loading of the livery

Postby abassign » Thu Nov 29, 2018 3:14 pm

It seems I have a problem with the canvas. I am using canvas to make the livery of the G91-R1B. I made a simple procedure in NASAL for dynamic loading of the livery:

Code: Select all
var id_prec = 0;
ca = canvas.new({"name": "Arm_fuselage",
                    "size": [4096,4096],
                    "view": [4096,4096],
                    "mipmapping": 1});
ca.addPlacement({"node": "A__G91_fuselage_canopy"});
ca.addPlacement({"node": "A__G91_fuselage_int.weapon.door.004"});
ca.addPlacement({"node": "F_canopY_ant"});
ca.addPlacement({"node": "F_CANPOPY.005"});
ca_root = ca.createGroup();
ca_child = ca_root.createChild("image").setSize(4096,4096);

setlistener("sim/G91/liveries/active/ID", func {
    var id = props.globals.getNode("sim/G91/liveries/active/ID",1).getValue();
    var livery_001 = props.globals.getNode("sim/G91/liveries/active/livery_001",1).getValue();
    print(livery_001);
    ca_child.setFile(livery_001);
    id_prec = id;
}, 1, 0);


The listener listens to the modifying of the livery at the end of the configuration of the poerty-tree always configured by the dialog that activates the livery:
This is the dialog example code:
Code: Select all
...
                <binding>
                    <command>nasal</command>
                    <script>
                        setprop("sim/G91/liveries/active/livery_001","Aircraft/G91-R1B_HD/Models/Liveries/pan_1_001.png");
                        setprop("sim/G91/liveries/active/livery_002","Aircraft/G91-R1B_HD/Models/Liveries/pan_1_002.png");
                        setprop("sim/G91/liveries/active/luminosity",0.0);
                        setprop("sim/G91/liveries/active/reflective",0.0);
                        setprop("sim/G91/liveries/active/ID",1);
                    </script>
                </binding>
...


In these three examples of livery we note that these do not change (but the effect configurations change proving that the selection procedure works correctly) and the names and paths of the images I send to the NASAL application are correct as they are printed before the actual assignment to the canvas of the image and match perfectly those I want to load ... Only one of the NASAL procedures (they are all identical) works well and is the one that modifies the livery of the horizontal tail planes, as you can see.

This should be the livery of the Italian military acrobatic team, it should be all blue, but as you can see it is the military livery that is loaded by default, but the horizontal tail plane is correct!

Image

This is the military livery and it is correct, is also the first livery loaded (if load as before livery some other livery this will be displayed correctly, but only in the case that it is the default)

Image

With this livery the plane should be all silver ...

Image

It should be noted that the first loading also takes place by means of the same procedure and is CORRECT for all the objects present in the scene. At this point I suspect that I do something wrong with NASAL ... but it is also true that what I do, for the horizontal queues works! AND IT IS EXACTLY THE SAME CODE!
Can someone help me to unveil the mystery?
Thanks for all.
Developer of the program https://wiki.flightgear.org/Julia_photoscenery_generator
FDM developer of the G91R1B aircraft https://wiki.flightgear.org/FIAT_G91R1B
JSBSim collaborator
abassign
 
Posts: 947
Joined: Mon Feb 27, 2012 6:09 pm
Location: Italy (living 5 Km from airport LIME)
Callsign: I-BASSY
Version: 2020.4
OS: Ubuntu 20.10

Re: Problems with the canvas for dynamic loading of the live

Postby abassign » Fri Nov 30, 2018 12:43 am

SOLVED! ... BUT ...

The nodes inserted in the addPlacement method are global references. The nodes are managed by a database WITHOUT the reference of the .ac file that contain them because for the canvas + NASAL it is not clear the behavior of global and local objects, it puts everything together in a completely unstructured way. I seem to be back to programming in Basic Commodore 64! So I had to write and a new NASAL script that contains all the nodes trusting the fact that they actually have different names. At this point everything worked well.

I do not want to criticize, but it would be better to explain correctly how are the references of the NASAL variables with the canvases. Currently they seem very confusing!
Developer of the program https://wiki.flightgear.org/Julia_photoscenery_generator
FDM developer of the G91R1B aircraft https://wiki.flightgear.org/FIAT_G91R1B
JSBSim collaborator
abassign
 
Posts: 947
Joined: Mon Feb 27, 2012 6:09 pm
Location: Italy (living 5 Km from airport LIME)
Callsign: I-BASSY
Version: 2020.4
OS: Ubuntu 20.10

Re: Problems with the canvas for dynamic loading of the live

Postby Hooray » Mon Dec 03, 2018 5:23 pm

Maybe I am misunderstanding something, but as far as I can tell, the misconception is on your end - A Canvas is just an invisible texture, it needs to be added to the "scene" (aircraft/cockpit, scenery, GUI or livery) via so called "placements".

That being said, I don't find this particularly constructive, unless you can indeed point out an actual issue/bug:
for the canvas + NASAL it is not clear the behavior of global and local objects, it puts everything together in a completely unstructured way. I seem to be back to programming in Basic Commodore 64! So I had to write and a new NASAL script that contains all the nodes trusting the fact that they actually have different names. At this point everything worked well.


I am not sure if you are familiar with the underlying concepts involved here, but I would suggest to back up such claims with "evidence", otherwise it might be considered offending (maybe without you meaning that).

If you can post a self-contained snippet of code that may help us determine what problem you are facing, ideally including comments explaining what you are trying to do, and expecting to see.

it would be better to explain correctly how are the references of the NASAL variables with the canvases. Currently they seem very confusing!


Then try to tell us what you mean, so that we can check whether there is an actual bug or if you are simply misunderstanding how properties and Nasal references are handled.
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


Return to Canvas

Who is online

Users browsing this forum: No registered users and 3 guests