20,741
edits
Line 2,288: | Line 2,288: | ||
== Canvas Integration == | == Canvas Integration == | ||
{{Note|Discuss FGCanvasSystemAdapter - for the time being, check out [[Howto:Extending_Canvas_to_support_rendering_3D_models#Extending_FGCanvasSystemAdapter]] to learn more about the purpose/usage of the CanvasSystemAdapter, which basically serves as a bridge between FlightGear and SimGear, i.e. to expose FG specific APIs to Canvas (which lives in SimGear).}} | {{Note|Discuss FGCanvasSystemAdapter - for the time being, check out [[Howto:Extending_Canvas_to_support_rendering_3D_models#Extending_FGCanvasSystemAdapter]] to learn more about the purpose/usage of the CanvasSystemAdapter, which basically serves as a bridge between FlightGear and SimGear, i.e. to expose FG specific APIs to Canvas (which lives in SimGear).}} | ||
there is a dedicated FGCanvasSystemAdapter in $FG_SRC/Canvas that encapsulates the model lookup <ref>{{cite web | |||
|url = https://forum.flightgear.org/viewtopic.php?p=285343#p285343 | |||
|title = <nowiki> Re: Dual control for Boeing 777 </nowiki> | |||
|author = <nowiki> Hooray </nowiki> | |||
|date = May 15th, 2016 | |||
|added = May 15th, 2016 | |||
|script_version = 0.40 | |||
}}</ref> | |||
For instance, say you'd like to access the FlightGear view manager via the access system: you don't need to move the view manager to SimGear to accomplish this - like I mentioned previously, the correct way to access FG-level subsystems via the Canvas system is to review/extend the FGCanvasSystemAdapter to expose the corresponding APIs. | For instance, say you'd like to access the FlightGear view manager via the access system: you don't need to move the view manager to SimGear to accomplish this - like I mentioned previously, the correct way to access FG-level subsystems via the Canvas system is to review/extend the FGCanvasSystemAdapter to expose the corresponding APIs. | ||
Line 2,301: | Line 2,311: | ||
|date = Aug 29th, 2017 | |date = Aug 29th, 2017 | ||
|added = Aug 29th, 2017 | |added = Aug 29th, 2017 | ||
|script_version = 0.40 | |||
}}</ref> | |||
Or let's say, you'd like to access the CameraGroup/Viewer APIs: 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.<ref>{{cite web | |||
|url = https://forum.flightgear.org/viewtopic.php?p=261665#p261665 | |||
|title = <nowiki> Re: WINDOW IN WINDOW </nowiki> | |||
|author = <nowiki> Hooray </nowiki> | |||
|date = Oct 25th, 2015 | |||
|added = Oct 25th, 2015 | |||
|script_version = 0.40 | |||
}}</ref> | |||
Finally, to use Canvas outside FG, you would also need to look at the FGCanvasSystemAdapter in $FG_SRC/Canvas and provide your own wrapper for your own app (trivial).<ref>{{cite web | |||
|url = https://forum.flightgear.org/viewtopic.php?p=237591#p237591 | |||
|title = <nowiki> Re: Simgear-based subsystem with Canvas support? </nowiki> | |||
|author = <nowiki> Hooray </nowiki> | |||
|date = Apr 2nd, 2015 | |||
|added = Apr 2nd, 2015 | |||
|script_version = 0.40 | |script_version = 0.40 | ||
}}</ref> | }}</ref> |