Board index FlightGear Development Scenery

Easy way to find texcoords or texture for given lat/long?

Questions and discussion about enhancing and populating the FlightGear world.

Easy way to find texcoords or texture for given lat/long?

Postby chriscalef » Sat Apr 13, 2013 9:20 pm

Hi,

I spent most of the day looking for this, but nothing obvious turned up... I'm looking for a way to find out which texture/landclass is occupying a given latitude/longitude on my scenery. The actual texcoords would be nice, but this is optional at least for now, the most important thing is just to know what texture goes where.

The reason I'm looking for this is related to this thread - 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.

I've been looking into the IntersectVisitor/NodeVisitor classes, trying to get a Drawable out of them somehow, and also poking around at globals->get_scenery()->get_terrain_branch() to see if it would offer up any data, but for the moment I'm coming up empty handed.

Any clues welcomed.

Thanks!

Chris
chriscalef
 
Posts: 276
Joined: Wed Feb 20, 2013 9:28 pm

Re: Easy way to find texcoords or texture for given lat/long

Postby chriscalef » Sun Apr 14, 2013 2:02 am

Aha, okay, answered my own question, mostly... my primary confusion was between the BVHMaterial class, which is accessible from an intersectVisitor but only has physics info like friction coefficients, and the SGMaterial class which has texture names... but you can dynamic_cast between them, like so:

Code: Select all
const SGMaterial *mat = dynamic_cast<const SGMaterial *>(bvhMat);


Still got some details to work out but it looks like I'm in business. :-)
chriscalef
 
Posts: 276
Joined: Wed Feb 20, 2013 9:28 pm

Re: Easy way to find texcoords or texture for given lat/long

Postby psadro_gm » Sun Apr 14, 2013 1:24 pm

Hi Chris,

as for texture coordinates - as long as the landclass is not a linear feature (road, stream, etc) you can actually look up the tcs from lon/lat - they are computed on a global scale in terragear, not per polygon. You can recompute in flightgear, and should get the same result.

The magic is done in sgCalcTexCoords()
8.50 airport parser, textured roads and streams...
psadro_gm
 
Posts: 751
Joined: Thu Aug 25, 2011 2:23 am
Location: Atlanta, GA USA
IRC name: psadro_*
Version: git
OS: Fedora 21

Re: Easy way to find texcoords or texture for given lat/long

Postby chriscalef » Sun Apr 14, 2013 3:56 pm

Ah, right, I did start to see how that was done, thanks for pointing it out the magic function though! Now my only problem is figuring out exactly which of the texture options got selected by the loader for one particular area of land class, apparently it picks them at random for different contiguous regions? Seeking...
chriscalef
 
Posts: 276
Joined: Wed Feb 20, 2013 9:28 pm


Return to Scenery

Who is online

Users browsing this forum: No registered users and 3 guests