Trading Info With X-Plane 

If you wish to generate your own ".env" files rather than use World-Maker, that is fine, but you must be a programmer to write a program to do the job.

The env files are in binary form, with byte order being native to the machine the file is being generated on. (Either Mac (MSBF) or IBM (LSBF)).

Start off with:

=>The character 'a' or 'i', depending on whether you are generating the file on an Apple or an IBM.
=>The integer '6', which indicates the format version.

Then, we output the lat, lon, and elevation for each point in the square degree of lat and lon that the file defines. The points start at the lower-left hand corner of the square degree of lat/lon, and work from left to right and then go up a row towards the top, etc.

Here is the source code from World-Maker that outputs the data:

#define gnd_sect_iDIM 150 // max allowable index, used for x-plane and world-maker
#define gnd_sect_jDIM 200 // max allowable index, used for x-plane and world-maker

for(j=0;j<=gnd_sect_jDIM;j++)
for(i=0;i<=gnd_sect_iDIM;i++)
{
xint code=
((si-i)*100000000 ) // si-i is how far from the lower-left corner this large-area texture is in polygons to the right, if it is a large-area texture.
+((sj-j)* 10000000 ) // sj-j is how far from the lower-left corner this large-area texture is in polygons to the top, if it is a large-area texture.
+((tex_app_size-1)*1000000)// tex-app-size is the size of the large-area covered by the texture, from 1 to 10.
+((is_city [i][j] )?200000:0)
+((is_water[i][j] )?100000:0)
+((planest [i][j][1][0][0]-planest[i][j][0][0][0]>0.5)? 40000:0) // tex no rotation
+((planest [i][j][0][0][0]-planest[i][j][0][1][0]>0.5)? 30000:0) // tex rotated CW 90
+((planest [i][j][0][0][0]-planest[i][j][1][0][0]>0.5)? 20000:0) // tex rotated CW 180
+((planest [i][j][0][1][0]-planest[i][j][0][0][0]>0.5)? 10000:0) // tex rotated CW 270
+((planetex[i][j]));

ouf.write((char*)&planelat[i][j],sizeof(xflt));
ouf.write((char*)&planelon[i][j],sizeof(xflt));
ouf.write((char*)&planey [i][j],sizeof(xflt));
ouf.write((char*)&code ,sizeof(xint));
}


"XINT" is simply type int.
The lat and lon are the latitude and longitude of each vertex in the grid, of course.
"Planey" is the elevation of the vertex.
"is_water" is obvious, and "planetex" is the custom texture number that this polygon uses, if any.
This vertex is for the lower-left (south-west) corner of the polygon that uses the listed texture.


for(n=0;n<obsDIM;n++)
if(intrange(obj_type[n],obj_contower,obj_custom))
{
if(!fltbox(obj_lat[n],obj_lon[n],msc.map_latfile-0.1,msc.map_lonfile-0.1,msc.map_latfile+1.1,msc.map_lonfile+1.1))
MACIBM_alert("Object latitude and longitude out of the scenery file area!","","","",t_alert);

if(intrange(obj_type[n],obj_contower,obj_stacks)){
ouf.write((char*)&obj_type[n],sizeof(xint));
ouf.write((char*)&obj_lat [n],sizeof(xflt));
ouf.write((char*)&obj_lon [n],sizeof(xflt));
ouf.write((char*)&obj_hddz[n],sizeof(xflt));}

if(obj_type[n]==obj_custom){
ouf.write((char*)&obj_type[n],sizeof(xint));
ouf.write((char*)&obj_lat [n],sizeof(xflt));
ouf.write((char*)&obj_lon [n],sizeof(xflt));
ouf.write((char*)&obj_hddz[n],sizeof(xflt));
ouf.write((char*)&obj_name[n],sizeof(xchr)*strNETDIM);} // was namedim in older files
}

int nn=99;
ouf.write((char*)&nn,sizeof(xint));

for(n=0;n<custexDIM;n++)
{
xint this_cus_tex_used=Xfals;
for(j=0;j<=gnd_sect_jDIM;j++)
for(i=0;i<=gnd_sect_iDIM;i++)
if(planetex[i][j]==t_cus_terrain_start+n)this_cus_tex_used=Xtrue;

if(!this_cus_tex_used) // if a given tex is not used
C_to_C("Untitled",msc.texpath[n]); // then be neat and nuke the name from the list!

ouf.write((char*)msc.texpath[n],sizeof(xchr)*strNETDIM);
}


where:

#define strNETDIM 150
#define strDIM 500
#define custexDIM 500

type is the type of obstacle,

building = 2,
radio tower = 3,
power-line tower = 4,
cooling tower = 5,
smoke stacks = 6

lat and lon are the lat and lon of the obstacle, dz is the height of the obstacle, and i and j are the horizontal and vertical data point indices of the lower-left-hand corner of the quadrilateral that the obstacle falls on.

then, make sure to put a long set to '99' at the end... this is needed to tell x-plane to stop lookig for obstacle in the file. You must do this or X-Plane will hang in an infinite loop looking for more obstacles! Remember, this is all done in binary file mode.

whew!

(next section)