FlightGear WorldTerrain SkyBox Server

From FlightGear wiki
Revision as of 17:39, 4 March 2015 by Hooray (talk | contribs)
Jump to navigation Jump to search
This article describes content/features that may not yet be available in the latest stable version of FlightGear (2020.3).
You may need to install some extra components, use the latest development (Git) version or even rebuild FlightGear from source, possibly from a custom topic branch using special build settings: .

This feature is scheduled for FlightGear (unknown). 10}% completed

If you'd like to learn more about getting your own ideas into FlightGear, check out Implementing new features for FlightGear.

This article is a stub. You can help the wiki by expanding it.


FlightGear SkyBox Server
Worldserver.png
Started in 03/2013
Description FlightGear-based SkyBox server
Contributor(s)
  • chriscalef (since 03/2013)
Status Under active development as of 03/2015
Website garagegames.com

Objective

Cquote1.png I'd like to share a few screenshots demonstrating a little system I just put together. My ultimate goal here is a real-world-terrain-based MMO game using Unity for the FPS engine and FlightGear as a backend skybox server.
— chriscalef (Thu Apr 04). Flightgear and Unity3D.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png I would also like to make this skybox/terrain mechanism available to others, however, for many different types of projects.


Part of my plan here is to go off on a fork of terragear et al, at whatever level is necessary to change the interpretation of the GIS data, eg to substitute something more blasted and smoking where the urban areas are in the current flightgear world. Once I get that handled I plan to use GIS shapefiles as a format for creative game-related mapping work, so we're not limited to just the existing real world data, but can paint towns and roads wherever we want.


— chriscalef (Thu Apr 04). Re: Flightgear and Unity3D.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png Long story short, it's useful because I want to create a first person MMO game based in real life terrain, and I want to leverage flightgear's very long view distances, awesome weather and day/night simulation, GIS-based terrain texturing, tree shaders, etc. to give the player the sense of truly being immersed in a planetary scale game environment. And, ultimately, to let them play the game right in their own home town, when I get all the parts put together.


I'm really aiming larger than just making a single game here, though. Ultimately I would like to make this into an open source simulation tool / online metaverse explorer that could be used for many different purposes.


— chriscalef (Thu Apr 04). Re: Flightgear and Unity3D.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png It's also in no way locked to Unity, that's just the environment I'm focusing on right now, due to its ease of cross platform export, among other things. I have already written a terrain pager in Torque, and could just as easily pipe these skybox images there, which would result in a 100% open source solution... but only for windows or possibly Mac at the moment, no linux.
— chriscalef (Thu Apr 04). Re: Flightgear and Unity3D.
(powered by Instant-Cquotes)
Cquote2.png

Status

Cquote1.png my skybox is working pretty well now, and I have the FG textures also imported into my Unity terrain, so if I can find a quick way to determine which texture goes where in flightgear when I load a new terrain, I will be a big step forward in the process of replicating my FG experience on the Unity terrain.
Cquote2.png
Cquote1.png I'm in the process of retrofitting the above described prototype so as to allow it to save out an array of finished Unity terrains and skyboxes, using the data provided once by flightgear during development, and then page through this precompiled data at runtime. This way the end user never has to have flightgear or terragear installed, they just run the Unity game, and only the developer has to deal with the flightgear side of things.
— chriscalef (Fri Jul 26). Re: Reporting back on some LiDAR research....
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png I'm still working on my "FlightGear World Server", and the current mission is to replace my (achingly slow) skybox generator. My previous method was to rotate the camera via PropertyTree changes, and save screenshots at each cardinal direction. I finally got through the literature on CameraGroups and Cameras, however, and managed to hook up a set of five cameras which simultaneously record all five desired directions, with the correct field of view.
— chriscalef (Mon May 20). Anybody got any handy OSG image manipulation tips?.
(powered by Instant-Cquotes)
Cquote2.png

Gallery


Approach

Cquote1.png what I'm primarily doing is using flightgear to draw skyboxes for the Unity (or other FPS style) engine.


All I get out of flightgear is five textures, which draw to the front, back, sides and top of the skybox. The local terrain in Unity I'm actually handling on my own, at much higher resolution than flightgear's terrain (10m instead of 90m(?) for flightgear), although I would like to figure out how to also export the terrain height data from flightgear for the rest of the world beyond my current 50km area of high res data.

I would also like to be able to lift the terrain texture for a given area out of flightgear and inform Unity of it, but I'm taking it one step at a time...


— chriscalef (Thu Apr 04). Re: Flightgear and Unity3D.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png the way I have it designed at the moment is all over a TCP/IP socket, so we should be pretty much free and clear - the flightgear end stays GPL, and the other end doesn't have to really care, it just sends a world position and gets textures back through the socket.
— chriscalef (Thu Apr 04). Re: Flightgear and Unity3D.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png There may be some overlap when it comes to objects - I may end up converting some of the .ac files in flightgear into FBX or collada, so I can load them into Unity, but more often I think I'll be going the other way and adding my FBX game models into flightgear, ala this thread.


As it is now, though, I can run and run across 2500 square km of area, and wherever I go I can refresh the skybox to see flightgear's view of my position. Only a very limited region of terrain has to be actually instantiated in Unity at any given time.


— chriscalef (Thu Apr 04). Re: Flightgear and Unity3D.
(powered by Instant-Cquotes)
Cquote2.png


Cquote1.png This is all done using Unity C# scripts, opening up sockets to communicate with A) a tiny little terrain server I wrote in C++, which accepts a starting latitude/longitude and a width/height of the area, and returns height data from a giant ten-meter-resolution height data file I made from DEM maps. In Unity I have a 3x3 set of tiny terrains (640m each) which page across the landscape, loading new data and moving as necessary to stay in front of the player. And then, B) a modified flightgear instance, which takes a socket connection from which it reads latitude, longitude, and elevation, and returns five screenshots taken at 90 degree angles to each other, with a 90 degree field of view.


The result was actually better than I expected, although the lighting comes out pretty sharply different between the different camera angles. There is no hiding the fact that I'm painting to a skybox - but for a first pass, it's actually pretty entertaining anyway.


— chriscalef (Thu Apr 04). Flightgear and Unity3D.
(powered by Instant-Cquotes)
Cquote2.png

Implementation

Issues

Cquote1.png it's still using the chunky 90m terrain, and my height sampling gets glitchy here and there (hence the needle problem down by the corner of the skybox). It's also slower than cold molasses when it comes to making the skyboxes and doing the terrain sampling, but I have a long list of planned optimizations and improvements going forward from here. Even as is, however, it should still be adequate for a player moving at normal human speed.
— chriscalef (Fri Apr 19). Re: Flightgear and Unity3D.
(powered by Instant-Cquotes)
Cquote2.png


Roadmap

Cquote1.png There are several flightgear related tasks remaining to figure out. (Warning, gross understatement.) It would work much better if I could somehow turn off rendering for everything within a certain radius of the camera, so I would not accidentally fill half my sky with one tree. :-P The best solution would be to somehow cut out the exact square that I'm rendering locally in Unity, but I'm quite willing to accept cheap hacks and half measures at this point.


I also need to figure out a quick & easy way to raycast for a terrain height at any given place in the flightgear world. And figure out enough of terragear to know how the terrain textures are placed. And on and on and on... but I thought some folks here might get a laugh out of this little project, at least.


— chriscalef (Thu Apr 04). Flightgear and Unity3D.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png Rendering is done for a near camera and a far camera anyway, so I think all you need to do is not to render the near camera, and that's it... (I think this was specified somewhere in camera_group.cxx ).
— Thorsten (Fri Apr 05). Re: Flightgear and Unity3D.
(powered by Instant-Cquotes)
Cquote2.png