Board index FlightGear Development Canvas

WINDOW IN WINDOW

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: WINDOW IN WINDOW

Postby Hooray » Sat Oct 17, 2015 9:49 am

www2 wrote in Sat Oct 17, 2015 9:29 am:Hooray i mean render camera views in canvas (e.g. tail cam in a aircraft)


believe it or not, I actually answered that one above 8)
tail cams are slaved cameras, so could be using code that already exists in FG, which would need to be integrated with the Canvas system, to be exposed as a dedicated Canvas element (kinda like the view manager rendering everything to a texture/osg::Geode).

There's window setup/handling code in CameraGroup.cxx which sets up these slaved views and renders the whole thing to a osg::TextureRectangle, which is pretty much what needs to be extracted and integrated with a new "CanvasCamera" element - the boilerplate for which can be seen at: http://wiki.flightgear.org/Canvas_Devel ... ew_Element

So the CameraGroup code is in $FG_SRC/Viewer/CameraGroup.cxx, where you can find a buildCamera() routine that builds a camera using a property node read from an XML file, as per $FG_ROOT/Docs/README.multiscreen: http://sourceforge.net/p/flightgear/fli ... p.cxx#l798

The whole RTT/FBO texture setup can be seen here: http://sourceforge.net/p/flightgear/fli ... p.cxx#l994

That code would be redundant in the Canvas context, i.e. could be replaced by a Canvas FBO instead.

The next step would then be wrapping the whole thing in a CanvasCamera and exposing the corresponding view parameters as properties (propertyObject) so that slaved cameras can be controlled via Canvas.

Otherwise, there is only very little else needed, because the CanvasMgr would handle updating the Camera, and render everything to the texture that you specified.
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: WINDOW IN WINDOW

Postby Hooray » Sat Oct 24, 2015 2:40 pm

trouble946 wrote in Fri Oct 16, 2015 5:58 am:The multiscreen readme only shows how to set up multiple screens in flight gear but to show different views e.g. Cockpit & helicopter no read me file shows that.

Any ideas on how


Here's an example setting up multiple views on a single screen using several slaved (offset) views:

http://wiki.flightgear.org/FlightGear_W ... r#Approach
Image

http://wiki.flightgear.org/Howto:Config ... ew_windows
Image

Also see: http://wiki.flightgear.org/index.php/FS ... dering.xml
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: WINDOW IN WINDOW

Postby www2 » Sat Oct 24, 2015 10:35 pm

@Hooray
I need to read the early text.
But i think we need soon add this to canvas for camera.
Here is some nasal moke-up code for nasal/canvas camera views.
first: here is some code that setup a basic camera setup on the 0,0,0 (x,y,z axes) and the plane model is disable.
Code: Select all
HelloCam = root.createChild("camara"); # setup the camera to canvas
HelloCam.resolution(800,600); # Set the camara resolution to 800x600 pixels.
HelloCam.planeDisable(); # This disable the plane model

This code set a camera that call from use viewport with the name "tail cam"
Code: Select all
tailCam = root.createChild("camara");
tailCam.resolution(800,600);
tailCam.selectView('Tail Cam'); # Select the viewport by name.

Some other interesting options:
Code: Select all
canvascam = root.createChild("camara");
canvascam.resolution(800,600);
canvascam.setCustomTextureSet('$fgdata/pathToNewTextures.xml'); #set a custom texture set (similar as the global texture set)
canvascam.setShaders('shaders.xml); #load a custom shader
canvascam.SetLocation(10,0,0); #set camera position to 10 meter form the center of the plan on the x axes
canvascam.SetRotation(0,90,0); #set camera rotation to 90 degree on the y axes
www2
 
Posts: 258
Joined: Thu Apr 16, 2009 1:58 pm

Re: WINDOW IN WINDOW

Postby Hooray » Sun Oct 25, 2015 4:47 pm

www2 wrote:But i think we need soon add this to canvas for camera.

yeah, it would work pretty much like you say (well, close).

As can be seen by the screen shots above, the code for doing this sort of stuff is readily available in FG.
Obviously, someone interested in this, would need to know how to patch/build FG from source, i.e. after making C++ modifications, some of this is touching OSG (cameras and offscreen rendering specifically).

Otherwise, it's relatively straightforward: CameraGroup.cxx already contains code to render a static camera to a texture, which is stored in a TextureMap named _textureTargets - internally, this is used for building the distortion camera - however, you can also exploit this to render an arbitrary camera view to a texture.

At the Canvas level, you would then have to call the equivalent of flightgear::CameraGroup::getDefault() - this would be done at the FGCanvasSystemAdapter level, i.e. adding a getter function there, which returns the TextureRectangle map.
Once you have a texture rectangle, you can also get the osg::Image for it, and that can be assigned to a Canvas image.
Admittedly, that's a little brute force, but it should only require ~30 lines of code added to SG/FG to add a static camera view as a Canvas raster image.

Ideally, something like this would be integrated with the existing view manager, i.e. using the same property names (via property objects), and then hooked up to CanvasImage, e.g. as a custom camera:// protocol (we already support canvas:// and http(s)://)

So some kind of dedicated CanvasCamera element would make sense, possibly inheriting from CanvasImage.
And it would also make sense to look at Zan's new-cameras patches, because those add tons of features to CameraGroup.cxx

This would already allow arbitrary views slaved to the main view (camera)

So as you can see, PagedLOD/CompositeViewer don't need to be involved to make this happen.
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

Previous

Return to Canvas

Who is online

Users browsing this forum: No registered users and 6 guests