Board index FlightGear Development Canvas

Projecting 3D objects into 2D views (by omega95 SpaceShip2)

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.

Projecting 3D objects into 2D views (by omega95 SpaceShip2)

Postby Hooray » Tue Aug 14, 2012 5:46 pm

Subject: SpaceShipTwo V.S.S Enterprise

Hooray wrote:Image
omega95 wrote in Tue Aug 14, 2012 1:58 pm:But yes, the canvas system should be VERY useful there, and looking at the TONU display, I was thinking if the canvas system could 'project' a 3D object into 2D view (so as to create the globe) :)


I see, but no: it's currently not yet possible directly - but it could probably be added as a special mode to the canvas system, where you specify a 3D model, a view port and some transformations (i.e. via properties).

Being able to load and view/transform a 3D object would be useful for a number of things - such as aircraft previews, like the aircraft preview in fgrun. So maybe Tom is open to the idea, you better bring that up in the canvas sub forum.

Probably, 3D objects are going to be increasingly important in upcoming avionics to improve situational and spatial awareness, so preparing the canvas system for such features would probably be useful, otherwise we would need to use complicated workarounds to create vector graphics from 3D objects ...


I have added the idea to the wiki here: http://wiki.flightgear.org/Canvas_Prope ... _a_texture

EDIT: Also see: http://wiki.flightgear.org/Howto:Extend ... _3D_models
Last edited by Hooray on Sun Feb 22, 2015 8:37 pm, edited 1 time in total.
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: 11326
Joined: Tue Mar 25, 2008 8:40 am

Changelog & Progress

Postby omega95 » Wed Aug 15, 2012 3:28 am

Hey Tom, I was looking for a pretty neat feature with canvas - the ability to project 3D models into a 2D view. For example, take a look at the globe in this picture:

Image
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: Projecting 3D objects into 2D views (by omega95 SpaceShi

Postby Hooray » Wed Nov 11, 2015 7:19 pm

A few weeks ago, I got in touch with TheTom about this, specifically in order to extend the AircraftCenter, i.e. so that aircraft previews can be added to the dialog (analogous to other GUI launchers).

Tom mentioned that this would be a simple but useful change, and it turns out that he was right:

http://wiki.flightgear.org/Canvas_Sandbox#CanvasModel
Image


Something like this would also be useful for other purposes, i.e. certain avionics - I think Thorsten and Richard also mentioned that they needed something along these lines for the space shuttle (ADI ball):

Space Shuttle
Richard wrote:PFD is coming along; I think I've figured out how to do the ADI ball using a couple of SVG shapes and some translation / rotation. more news this weekend.
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: 11326
Joined: Tue Mar 25, 2008 8:40 am

Re: Projecting 3D objects into 2D views (by omega95 SpaceShi

Postby Johan G » Wed Nov 11, 2015 8:21 pm

That is something definitively worth mentioning in the newsletter. :D
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Johan G
Moderator
 
Posts: 5480
Joined: Fri Aug 06, 2010 5:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 3.0.0
OS: Windows 7, 32 bit

Re: Projecting 3D objects into 2D views (by omega95 SpaceShi

Postby Hooray » Wed Nov 11, 2015 8:41 pm

For now it's really just a (working) prototype - to be committed to simgear/flightgear, it would need to be reviewed by TheTom obviously, but we should discuss how to integrate this best and what APIs/functionality should be exposed at the property tree level, especially with concrete use-cases in mind.

For instance, I only started tinkering with this because of the revamped interest in rendering PDF files to a Canvas element, as well as scenery cameras (recently mentioned by www2) - under the hood, all 3 features have overlapping/shared requirements (in terms of Canvas code and APIs).

So far, our focus has been on using Canvas for 2D purposes, so I would prefer to have a discussion with Tom on extending Canvas::Element and coming up with a corresponding sub-class that is specifically targeting the 3D use-case.
Simply because that will be useful for any/all related elements, i.e. 3D models, 3D scenery views, tail cams etc

(I also have another working element that renders a CameraGroup texture to a Canvas)

Equally, from an interfacing standpoint, I like Tom's way of using boost/bind for the cppbind bindings, and it would be cool if we could come up with something like that for mapping OSG types (attributes/modes) /methods to properties/listener callbacks at the Canvas::Element level.

From a performance standpoint, a 3D scene is obviously going to be more complex than a typical 2D element, so I think it would be good to introduce the corresponding osg::Group nodes for handling visibility (osg::Switch), but also to check if the node is even in a visibility volume.

Internally, this is already using the SimGear APIs for deferred/paged model loading, so that this is pretty efficient, and we could even directly support LOD at the Canvas level like this, at the mere cost of having a scenegraph representation in the form of:
- osg::Switch (hide/show)
-- osgSim::VisibilityGroup (is the element visible)
--- osg::PositionAttitudeTransform (to transform it in 3D space)
----- osg::Camera (the camera itself)
------- osg::LOD handling (different levels of detail)

This could be neatly encapsulated at the Canvas::Element level using a handful of properties (Tom is already doing this with Canvas::Element by using geode/transform nodes as the top-level nodes), and it would allow us to come up with pretty efficient scene graphs at the OSG level, without having to introduce tons of Nasal callbacks to work around Canvas limitations.

But given the unclear state of the FlightGear 3.6/3.8 release, it seems we are not really in a hurry :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: 11326
Joined: Tue Mar 25, 2008 8:40 am


Return to Canvas

Who is online

Users browsing this forum: No registered users and 7 guests