Board index FlightGear Development Canvas

Raster Image showing up as a white box  Topic is solved

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.

Raster Image showing up as a white box  

Postby omega95 » Thu Jul 24, 2014 2:01 am

Image

This SVG path works fine, as it loads the SVG:
Code: Select all
path: "/Aircraft/A380/Models/Instruments/SD/fuel/fuel.svg",


But unfortunately, this doesn't:
Code: Select all
sd.objects.createChild("image")
              .setFile("/Aircraft/A380/Models/Instruments/SD/fuel/fuel_raster.png")
              .setSize(100, 200)
              .setTranslation(200, 400);


The image is a PNG image.

NOTE - The A380 is in a separate aircraft directory with just my projects, does that affect this?
Merlion Virtual Airlines - the experience of a flight time...
Get high quality aircraft, airports, video tutorials or development tools from my hangar.
omega95
 
Posts: 1223
Joined: Sat Jul 30, 2011 12:59 am
Location: -unknown-
Callsign: MIA0001, OM-EGA
IRC name: omega95
Version: 2.12 git
OS: Ubuntu 13.04

Re: Raster Image showing up as a white box

Postby omega95 » Thu Jul 24, 2014 2:02 am

Aha, just found this error in the console:
Code: Select all
canvas::Image: reading '/Aircraft/A380/Models/Instruments/SD/fuel/fuel_raster.png' denied
Merlion Virtual Airlines - the experience of a flight time...
Get high quality aircraft, airports, video tutorials or development tools from my hangar.
omega95
 
Posts: 1223
Joined: Sat Jul 30, 2011 12:59 am
Location: -unknown-
Callsign: MIA0001, OM-EGA
IRC name: omega95
Version: 2.12 git
OS: Ubuntu 13.04

Re: Raster Image showing up as a white box

Postby Hooray » Thu Jul 24, 2014 7:25 am

as usual, it's a good idea to run a forum search prior to posting: you are missnig the png plugin that would allow OSG to open/render your PNG images ...
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: 11437
Joined: Tue Mar 25, 2008 8:40 am

Re: Raster Image showing up as a white box

Postby TheTom » Thu Jul 24, 2014 9:36 am

The png plugin is definitely available and working (the close icon of the canvas window is a png...). Probably you want to use a relative path instead of an absolute path. The directory Aircraft directly in the root of your filesystem probably does not exist and is also not allowed by IORules. If a path is not allowed by IORules 'access denied' is reported, independend whether the file exists or not.
TheTom
 
Posts: 321
Joined: Sun Oct 09, 2011 10:20 am

Re: Raster Image showing up as a white box

Postby Hooray » Thu Jul 24, 2014 9:39 am

right, sorry - I completely missed that, didn't even look at the path there ... sorry!
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: 11437
Joined: Tue Mar 25, 2008 8:40 am

Re: Raster Image showing up as a white box

Postby omega95 » Thu Jul 24, 2014 2:38 pm

Code: Select all
/Aircraft/A380/Models/Instruments/SD/fuel/fuel.svg


This path seems to work fine though - interesting.

Anyway, what should the path be relative to? The nasal file? The aircraft file?

EDIT -

I set the path relative to the aircraft directory -
Code: Select all
Models/Instruments/SD/fuel/engine_l.png


And that works fine, thank you very much! Now I just need to solve the freetype font error.

Image

Also, looks like "z-index" works. :)
Last edited by omega95 on Thu Jul 24, 2014 3:04 pm, edited 3 times in total.
Merlion Virtual Airlines - the experience of a flight time...
Get high quality aircraft, airports, video tutorials or development tools from my hangar.
omega95
 
Posts: 1223
Joined: Sat Jul 30, 2011 12:59 am
Location: -unknown-
Callsign: MIA0001, OM-EGA
IRC name: omega95
Version: 2.12 git
OS: Ubuntu 13.04

Re: Raster Image showing up as a white box

Postby Hooray » Thu Jul 24, 2014 3:03 pm

Usually, $FG_ROOT or $FG_AIRCRAFT

BTW: Regarding the Nasal code shown in the first screen shot: your code would be more flexible if you were using vectors and hashes for all those engines - that should help generalize your code quite a it , while also reducing the amount of code, and it would allow you to easily reuse the same code on other aircraft, including even twin-engine aircraft. Other aircraft developers could then also adopt your work and help maintain it over time. The main steps are detailed here: http://wiki.flightgear.org/Howto:Coding ... #Objective
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: 11437
Joined: Tue Mar 25, 2008 8:40 am

Re: Raster Image showing up as a white box

Postby TheTom » Thu Jul 24, 2014 3:14 pm

http://wiki.flightgear.org/Resolving_Paths

omega95 wrote in Thu Jul 24, 2014 2:38 pm:
Code: Select all
/Aircraft/A380/Models/Instruments/SD/fuel/fuel.svg


This path seems to work fine though - interesting.


I think the nasal resolvepath() first tries to append to path to all search directories, irrespective if it is an absolute path or not, and only if it does not find a file by this, tries if it is an absolute path.
TheTom
 
Posts: 321
Joined: Sun Oct 09, 2011 10:20 am

Re: Raster Image showing up as a white box

Postby omega95 » Thu Jul 24, 2014 3:40 pm

BTW: Regarding the Nasal code shown in the first screen shot: your code would be more flexible if you were using vectors and hashes for all those engines


Does make it easier and that's what I ended up doing but it's not really going to help with other aircraft. This is really specific to the A380 (4-engine modern Airbus Aircraft). The new A330neo and A350s have a similar instrument but they're twin-engine and that's not really going to work easily as the SVG is made specifically for the A380 - as in the fuel tanks, lines etc. A new SVG file would have to be made anyway for these aircraft. I did make a generalized ECAM class though, and the 2 ECAM instruments on the A380 (E/WD and SD) are instances of the ECAM. :)
Merlion Virtual Airlines - the experience of a flight time...
Get high quality aircraft, airports, video tutorials or development tools from my hangar.
omega95
 
Posts: 1223
Joined: Sat Jul 30, 2011 12:59 am
Location: -unknown-
Callsign: MIA0001, OM-EGA
IRC name: omega95
Version: 2.12 git
OS: Ubuntu 13.04

Re: Raster Image showing up as a white box

Postby Hooray » Thu Jul 24, 2014 3:51 pm

Regarding the SVG file, you can simply come up with a convenient naming convention and directly use the element IDs as keys for your hash lookups - that's the way the ND code is structured, and how it gets away with relatively little code. Once you come up with a sane naming convention, you can also directly associate it with each engine - thus, people would only need to edit the SVG file and add their own elements to match your convention, and it would just work.
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: 11437
Joined: Tue Mar 25, 2008 8:40 am

Re: Raster Image showing up as a white box

Postby omega95 » Thu Jul 24, 2014 4:24 pm

Well, that's similar to what I have. Each SD page's hash has a path variable and it load it according to the page that is loaded. And the SVG elements are named in the file itself, I just had a list of elements that needed to be cached on there.
Merlion Virtual Airlines - the experience of a flight time...
Get high quality aircraft, airports, video tutorials or development tools from my hangar.
omega95
 
Posts: 1223
Joined: Sat Jul 30, 2011 12:59 am
Location: -unknown-
Callsign: MIA0001, OM-EGA
IRC name: omega95
Version: 2.12 git
OS: Ubuntu 13.04

Re: Raster Image showing up as a white box

Postby Hooray » Thu Jul 24, 2014 4:27 pm

actually, if done consequently, your whole update() method could be greatly simplified by using a simple foreach() loop for things like fuel consumption/tank quantities etc - no need to have there any copy/paste code whose difference is merely a property index - remember: /engines/engine == /engines/engine[0] when it comes to properties, so can be trivially updated using a foreach() or forindex() loop - if there's any other differences, you merely need to wrap custom variables in a closure.
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: 11437
Joined: Tue Mar 25, 2008 8:40 am


Return to Canvas

Who is online

Users browsing this forum: No registered users and 1 guest