Board index FlightGear Development Canvas

Two Images to a Texture

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.

Re: Two Images to a Texture

Postby Algernon » Wed Sep 17, 2014 5:37 pm

I've made a start documenting my prepartory work for this in a Proof of Concept section of the wiki page. Thus far, I have created a clone model to experiment on and applied the same material to all painted parts which will be subject to the dynamic changes. Once I reach the edge of my knowledge, or don't manage it, I'll perhaps ask Hooray to contribute possible solutions in the same article section to move forwards.
Algernon
FGUK - A FlightGear community in the United Kingdom and Republic of Ireland
User avatar
Algernon
 
Posts: 498
Joined: Sun Jun 27, 2010 3:55 pm
Callsign: G-ALGY
Version: 3.0
OS: W7U

Re: Two Images to a Texture

Postby Hooray » Wed Sep 17, 2014 5:44 pm

sounds good, I would appreciate if you could update the wiki over time, i.e. by adding your snippets and screen shots there (or even youtube videos) - the point being that the EF2000 doesn't seem to be part of the base package yet, so we need some way to share results and design goals.

If you're getting stuck somewhere, my original response contains a few pointers on doing image handling in canvas using stacked textures, texture maps and z-index handling: Two Images to a Texture

You can basically use a dirt texture and randomly extract segments with dirt from it and then apply it to the canvas by setting a handful of properties. The same mechanism could also be used for visualizing damage in a dog fighting scenario obviously - Nasal/Canvas don't care if you're placing dirt textures or adding bullet holes after all :D

Also, please feel free to rewrite my comments/code if you think it's not sufficiently clear.
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: 11329
Joined: Tue Mar 25, 2008 8:40 am

Re: Two Images to a Texture

Postby Algernon » Wed Sep 17, 2014 6:29 pm

I hadn't thought of bullet holes! I know someone who might quite like this idea... ;)

I have added some screenshots (currently wrestling with reducing whitespace) and the code I amalgamated from a few sources. The dialog is being created just fine, the canvas ditto, and I'm able to load in JPG or PNG images. But it doesn't seem like the placement is doing anything at the moment. Once I figure that out, I'll update the wiki.

The EF2000 is not part of the main package yet as it's license is currently CC, but almost all the elements which require that license are deprecated now - all except the voice warning system. Once I can find a suitably bossy sounding middle-aged lady to record custom ones, it's all clear to go GPL again :) That, and it's not really ready for release yet - V2.0 is expected in early 2015, but I expect to have a staged pre-release out within two weeks - if this is working then, it'll be included - and will point a link to it's own corner of the FGUK download hangar in the meantime.
Last edited by Algernon on Wed Sep 17, 2014 6:38 pm, edited 1 time in total.
Algernon
FGUK - A FlightGear community in the United Kingdom and Republic of Ireland
User avatar
Algernon
 
Posts: 498
Joined: Sun Jun 27, 2010 3:55 pm
Callsign: G-ALGY
Version: 3.0
OS: W7U

Re: Two Images to a Texture

Postby Hooray » Wed Sep 17, 2014 6:33 pm

the name used for the placement must match the name you're using in your 3D model file where you're mapping a texture to a face. Keep in mind, that any UV mapping will be applied just as well - thus, a white canvas may not easily show up on a white model - if in doubt, change the background color to something more obvious, like red, for example. You can also make the canvas blink by changing colors periodically using a timer.

Regarding the placement, you should be able to view its properties by using the property browser, I think Tom added some kind of "status" flag for all PropertyBasedElements, so you may want to check the property tree if some kind of error is shown for your placement or not.

Once you post some code & screen shots, I can help review the whol thing - even though it may be easier to use a few textures from an aircraft that is in fgdata - otherwise, I'd need to download the EF2000 first - and wiki examples/tutorials should preferably use resources/files that are available to most people...

EDIT: I haven't checked this yet, but it might be also possible that the existing Nasal/XML livery system might be conflicting with your changes here (if you're using it?) - if in doubt, I'd try to disable that by commenting out the corresponding sections in the XML/Nasal code to see if that makes a difference
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: 11329
Joined: Tue Mar 25, 2008 8:40 am

Re: Two Images to a Texture

Postby Algernon » Wed Sep 17, 2014 6:40 pm

Hooray wrote in Wed Sep 17, 2014 6:33 pm:EDIT: I haven't checked this yet, but it might be also possible that the existing Nasal/XML livery system might be conflicting with your changes here (if you're using it?) - if in doubt, I'd try to disable that by commenting out the corresponding sections in the XML/Nasal code to see if that makes a difference

Yes, I suspect this too. It will be the approach I try first when I start bugchasing after dinner :)
Algernon
FGUK - A FlightGear community in the United Kingdom and Republic of Ireland
User avatar
Algernon
 
Posts: 498
Joined: Sun Jun 27, 2010 3:55 pm
Callsign: G-ALGY
Version: 3.0
OS: W7U

Re: Two Images to a Texture

Postby Hooray » Wed Sep 17, 2014 6:42 pm

Also, is there some kind of repository where we can look at your code 3D model ? Just to be safe: there actually is a UV-mapped face called "Fuselage" in the model, right ?
Like I said, reproducing everything is a bit tedious if we don't have access to the aircraft - while using something like the ufo would lower the barrier to entry quite a bit obviously, and could still be adapted later on :D
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: 11329
Joined: Tue Mar 25, 2008 8:40 am

Re: Two Images to a Texture

Postby Algernon » Wed Sep 17, 2014 6:47 pm

Yes, I'm seeing "no match" in the Property Tree for the fuselage, but status is OK for the window.

Yes, one of the UV mapped meshes is called Fuselage. I need to have a bit of a think about how to apply this to a different aircraft available in the base package, because I won't have purpose-made textures to achieve the desired visual effect without which... well, anyway, I need to figure it out. We don't use a repository as yet, I suppose perhaps I could set one up to make the EF2000's code visible to the web and downloadable, although I don't find this very tempting as I don't need to be writing posts every week explaining that it isn't actually (anywhere near) ready for critique yet. I'll probably need a different solution for the tutorial which is... irksome, but I take your point about using common resources. I'll have a think.
Algernon
FGUK - A FlightGear community in the United Kingdom and Republic of Ireland
User avatar
Algernon
 
Posts: 498
Joined: Sun Jun 27, 2010 3:55 pm
Callsign: G-ALGY
Version: 3.0
OS: W7U

Re: Two Images to a Texture

Postby Hooray » Wed Sep 17, 2014 6:56 pm

I don't mind continuing as is, but I guess it would involve less guesswork/tinkering and troubleshooting if we could use something that everybody can easily access - otherwise, we literally depend on your screen shots/videos, property tree dumps to make any progress. Maybe there's a simple texture 3D model in the repository that we could use as a baseline ? I am sure that we can get this working within just a few days - and once you have it working, adapting it for your real aircraft should be pretty straightforward - while also lowering the barrier to entry for people wanting to experiment with this.

But like I said, we can go on like this - but it will be a bit more tedious, because we don't have access to the aircraft, and because there's only a single person familiar with its layout/design.
The code is going to be the same anyway, it's just placements that will differ and textures used obviously
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: 11329
Joined: Tue Mar 25, 2008 8:40 am

Re: Two Images to a Texture

Postby Algernon » Wed Sep 17, 2014 7:08 pm

Sure, we'll definitely need to have access to the same airframe - it's just how to get it to "everyone". I guess somewhere there's a basic web repository somewhere I could put it up, with the link only in certain places so I don't get too many complaints from people downloading the unfinished piece. I mean, it'll still startup and fly and all that, just... a few issues that might end your life in the wrong circumstances! ;)
Algernon
FGUK - A FlightGear community in the United Kingdom and Republic of Ireland
User avatar
Algernon
 
Posts: 498
Joined: Sun Jun 27, 2010 3:55 pm
Callsign: G-ALGY
Version: 3.0
OS: W7U

Re: Two Images to a Texture

Postby Hooray » Wed Sep 17, 2014 7:10 pm

You could check if the main issue for now disappears once you disable the Nasal/XML livery system - if that's the case, we're still good to go like this, and you won't need to share any of your work prematurely :mrgreen:
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: 11329
Joined: Tue Mar 25, 2008 8:40 am

Re: Two Images to a Texture

Postby Algernon » Wed Sep 17, 2014 8:48 pm

Yes, that was it. It's working now that livery swapping is disabled, but the texture appears oversized and it looks like the UV coordinates are not doing anything...

Image
Algernon
FGUK - A FlightGear community in the United Kingdom and Republic of Ireland
User avatar
Algernon
 
Posts: 498
Joined: Sun Jun 27, 2010 3:55 pm
Callsign: G-ALGY
Version: 3.0
OS: W7U

Re: Two Images to a Texture

Postby Hooray » Wed Sep 17, 2014 8:55 pm

thanks for the update - given that we don't have access to your system, it would be great to include more info in those screen shots - like you did originally with the Canvas dialog.
I *guess* that the Canvas code may now be conflicting with the UV map in the 3D model - is that an *.ac model, or do you have some simple way to post it here ?
Without additional information, I'd suggest to play with it a bit more by changing resolution/size and maybe rotation the canvas to see what is going on.
Like I said earlier, we're in uncharted waters here - nobody has done this previously, so it's definitely interesting, but we may be in for a surprise here eventually - so far, I find the results pretty good actually.

For starters, I'd suggest to work with textures that can be more easily recognized, i.e. some checker pattern or red as a color, to see what could be going on - otherwise, there's too much guessing involved, which is tedious for us given that we don't have access to your aircraft. So if you are hoping for more specific advice, open the texture in GIMP/photoshop and use some pattern for each different face that we can more easliy identify to see what's going on
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: 11329
Joined: Tue Mar 25, 2008 8:40 am

Re: Two Images to a Texture

Postby Algernon » Wed Sep 17, 2014 9:18 pm

I'm currently playing with setting up a GIT repository for the aircraft so that anybody can get it who needs it, hopefully that will make things easier. I will also look into changing the textures to an easily recognisable pattern for testing purposes.
Algernon
FGUK - A FlightGear community in the United Kingdom and Republic of Ireland
User avatar
Algernon
 
Posts: 498
Joined: Sun Jun 27, 2010 3:55 pm
Callsign: G-ALGY
Version: 3.0
OS: W7U

Re: Two Images to a Texture

Postby Hooray » Wed Sep 17, 2014 9:21 pm

I'd just copy the livery texture to a new file and fill each part with a separate pattern/color to see what's going on - that will tell us if we can work around the issue by editing the model, the texture, the Nasal code - or if we need to look at the C++ code
So far, this could be just a simple matter of changing scale/transforming the texture a bit (hopefully)
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: 11329
Joined: Tue Mar 25, 2008 8:40 am

Re: Two Images to a Texture

Postby Algernon » Wed Sep 17, 2014 9:29 pm

I already solved it :) The issue was that I'd specified a window a quarter of the size of the canvas - and because the canvas is created within the window, I guess that caused the resolution problem. Making the window the same size as the texture fixed it. So I guess the next thing is - how to create a canvas that isn't in a dialog window.
Algernon
FGUK - A FlightGear community in the United Kingdom and Republic of Ireland
User avatar
Algernon
 
Posts: 498
Joined: Sun Jun 27, 2010 3:55 pm
Callsign: G-ALGY
Version: 3.0
OS: W7U

PreviousNext

Return to Canvas

Who is online

Users browsing this forum: No registered users and 14 guests