Jump to content
Sign in to follow this  
Guest christian

New LandCalc program

Recommended Posts

Hi all.Here's the link for my latest Custom Landclass Calculator.It does assume a 257x257 source file, as discovered by Christian Stock to be the size needed to avoid resampling the Landclass/CUSTOM source data.It will return the Custom textures' names required to surround the vertex nearest the entered Latitude/Longitude, should the designer desire to build a CUSTOM BGL with this method.It's recommended only values #254 ( transparent ), #253 ( CUSTOM ), and #252 ( CUSTOM with seasons ) be used in making CUSTOM Landclass file. Why? Because they require the Project folder to have a 'scenery' sub-folder, and a 'texture' sub-folder. The presence of the twin 'texture' sub-folder will cause any default textures used in the BGL to disappear! So don't use mix them with default textures... build another BGL for your default-textured landclass, and place in a separate project folder ( with only a 'scenery' sub-folder ).Textures used in other Landclass BGLS ( including 'worldlc.bgl', are unaffected ).The terrain engine reads the landclass BGL. If it 'sees' the value #254, it ignores building that ground tile, and the default shows through. If it 'sees' a #253 or a #252, it searches in a local 'texture' folder for the 4 CUSTOM named textures to surround the vertex, and builds the ground-tiles surrounding the vertex.If the local 'texture' folder is absent, or the specific custom tile is not there, the terrain engine searches "C:Program FilesMicrosoft GamesFS2002SCENEDBWORLDTexture", and then searches "C:Program FilesMicrosoft GamesFS2002TEXTURE". If it's not in one of the 3 locations, the sim delivers a warning for missing textures, and leaves the ground-tile unbuilt ( grey ) in the sim.A CUSTOM texture should be a 256x256, mipped, DXT1, with alpha if a watermask is needed... just like any standard photoreal texture. The image can be obtained by using slices made by Resample. Or we may use bitmaps that we process and size ourselves. The displayed CUSTOM-textured ground tile will cover any TDF lines or polys. If the default lines or polys are to be kept, then a VTP poly BGL should be made instead, to display the CUSTOM texture.So now, we only need to figure out the structure of the TMF for Landclass, and we can build our own landclasses and photoreals with BGLC macros, and avoid resample if we desire.Dick

Share this post


Link to post
Share on other sites
Guest luissa

Hi,One think that I could not understand was the TMF LOD5 tile having 257 x 257 values and TMFViewer showing only 256 x 256. I just noticed that TMFViewer "tries to hide" the 257th column and the 257th row but their values are in the display.I prepared a data file with 257 x 257 values as in the first image. Blues values are #252 and dark values are #17. The INF file was:[Destination]DestDir = "."DestBaseFileName = "teste"NorthLat = 2.8125SouthLat = 0EastLong = 3.75WestLong = 0[source]Type = ClassU8SourceDir = "."SourceFile = "teste.raw"Lat = 2.8125Lon = 0NumOfCellsPerLine = 257NumOfLines = 257CellXdimensionDeg = 0.0146484375CellYdimensionDeg = 0.010986328125ScaleinMeters = 1.0The second shot is the top-left amplified view of TMFViewer. The third and fourth are images of the bottom-right corner. I placed a red cross where the mouse was at the moment I took the shot. As you see in the 4th image the value is #17 corresponding to the 257th row and 257th column. TMFViewer does not paint it but the "status bar" shows it.The idea that a cell (a landclass or custom LOD13 square) is represented by 4 values at the vertices is difficult for me to understand. May be FS just does what TMFViewer does: discards the the 257th row and column and shifts (right and down) the data by 1/2 of the grid size. I could verify this but checking things with FS is much more complicated (=slower) than with TMFViewer. Dick I do not follow you when you say: "The terrain engine reads the landclass BGL. If it 'sees' the value #254, it ignores building that ground tile, and the default shows through." If it reads #254 and if that is a vertex, what tile does it ignore? I am aware that when I place #252 or #253 I need the photos of the S W and SW tiles. But I am still confused.To sumarize my ideas and doubts: 1) if samples were taken at cell center's (which seems not to be the case) than only 256 x 256 values would be needed and each LOD quadrant would be self-contained. 2) if samples are at the vertices, 257 x 257 values need to be stored. If the 257th row and column are discarded the LOD quadrants will be self-contained. Otherwise the 1st column of the adjacent (to the west) LOD, for example, should be equal the 257th column. The 1st row of the "south adjacent" LOD should be equal to the 257th row.Regards, Luis

Share this post


Link to post
Share on other sites

Hi Luis.In fact, the sim does display a 256x256 array... but it's built from a 257x257 vertex array!Each vertex is surrounded by groundtiles that are runtime compiled. That's how the sim 'blends' the tiles. With the use of custom textures, the blending is prevented, and you can clearly see each vertex at the corners of the tiles.We can place a single custom texture at the LOD5 corners, because the absolute corner vertex is no longer fully surrounded by textures... so only one Custom texture shows. At the top, bottom, and sides, we can place 2 adjacent textures, as the vertex there has textures to one side, but the other was not in the compiled data.That's why the edges of a landclass file are sharply cutoff... at the verticies. Because they are not fully surrounded by 'blended' textures.Each default ground tile is a compromise of the surrounding vertex assignments. In the case of photoreal, there is no compromise, because they over-rule all texture data for that LOD13 area.I'll illustrate.Pic 1 is a screenshot of my sourcefile in a paint program, 257x257, with a CUSTOM value centered at 128,128.Pic 2 is the resulting screenshot from FS2002...showing 4 tiles created by on vertex assignment of CUSTOM.Pic 3 is the source with transparent at 128,128 ( the center ), with the for surrounding verticies assigned to sand desert.Pic 4 shows FS2002 clearly leaving the center vertex unassigned, with the default LC showing through, and the 8 surrounding verticies blending their assignments to surroungind ground tiles.Pic 5 shows the source with the custom center vertex, surrounded by 4 sand desert verticies.Pic 6 is the result, as the sand blends out from the hidden vertices ( trapped under the 4 CUSTOM ground tiles assigned by one vertex ).Dick

Share this post


Link to post
Share on other sites

Here's one more JPEG to complete the set...A screenshot of the Landclass BGL's center... also the same coordinates as the center in all the above pics.It clearly shows the assignment of one texture at 128,128... the vertex that was assigned to CUSTOM, and required 4 textures, and the same vertex that was assigned to transparent, with surrounding desert.

Share this post


Link to post
Share on other sites

Thanks for the detailed explanation Richard. You just cleared up another point of confusion for me.Allen

Share this post


Link to post
Share on other sites

In the above description:Pic 5 shows the source with the custom center vertex, surrounded by 4 sand desert verticiesIt should have been 8 verticies.

Share this post


Link to post
Share on other sites
Guest luissa

>In fact, the sim does display a 256x256 array... but it's >built from a 257x257 vertex array! Hi Dick,I have no problem with this interpretation in the case of meshes with elevations defined at the vertices.But it is difficult to accept a landclass as a combination of the north, south, west and east neighbours (as it is the case if we think of it in terms of vertices). I think that the 256x256 LOD13 squares displayed by the sim correspond to the upper-left 256x256 of the 257x257 that the sim "has in memory" for each LOD5 quadrant. I believe that the sim shifts those 256x256 squares downwards and to right by 1/2 of a LOD13 edge. I think that the sim uses the 257th row and the 257th column for blending. I think that if you generate 2 adjacent (e/w) LOD5 quadrants from an input data file of 257x513 the 257th column of the leftside LOD5 will be identical to the 1st column of the rightside LOD5. And I presume that if you make these columns different from each other, the one that gets displayed is the 1st column of the rightmost LOD.Kind Regards, Luis

Share this post


Link to post
Share on other sites
Guest christian

Hi Luis and Dick,Thanks, Dick, for finally expaining to me why M$ uses this 257x257 array.Luis, the 257th lines DO get displayed in FS2002. When I was doing my first landclasses, I followed the same logic that you stick to, since this is really sensible. I used SampleIsCentred=1 and a 256x256 array, only to get the dreaded black borders, which correspond to row and column 257. I never understood why it is 257, but just accepted it. I actually thought M$ couldn't be bothered with treating elevations and textures differently, but now I see how it all makes sense...Dick has now explained it wonderfully. Rather than having the textures sitting in between the elevation points, they do in fact sit on the elevation points. This is done, so the textures on the borders can blend. What we really have is 1/2 cell + 255 cells + 1/2 cell. This really makes a lot of sense and I can't believe, I couldn't figure that out myself. Thanks, Dick. The SampleIsCentered switch is probably an old remnant from when M$ was still experimenting with things. I found that it doesn't do anything, and now it makes sense, because textures just aren't centred...Now the only thing left to test is what happens with multiLOD source files? Does resampler and FS2002 know that no blending is necessary at the borders where the LOD quads join, or does it stick to 257. I would assume it sticks to 257, but we should check...Cheers, Christian

Share this post


Link to post
Share on other sites

Hi Christian!You were right all along! 257.It seems the landclass assignment is to the vertex... the same LOD5 vertex used in making mesh at that resolution. The tile is then built during runtime by blending the texture to the four corners of the world. :)I noted in CFS2, the CUSTOM tiles are blended as well, unlike FS2002... same BGL, same textures, but blended by it's terrain engine, like any other texture assignment.I think Gerrish Grey pointed out the blending is done with masking textures of the ?????????m.bmp style, in FS2002. I had no luck with making them for custom textures. It doesn't seem to work.I was able to display custom textures with the defaults, in a single landclass BGL, by copying the custom textures to "C:Program FilesMicrosoft GamesFS2002SCENEDBWORLDTexture", for display purposes.Autogen can be made for the textures, and displayed with the landclass BGL... just like any CUSTOM BGL. ( VTPs don't seem to allow autogen to anything other than the default textures, when called through the "terraintextures.cfg" ).Dick:-beerchug

Share this post


Link to post
Share on other sites
Guest vlada stoje

Hi Dick and all,I was curious about the strange behavior of the tiles - vertexes, so tried the new Custom Landclass Calculator immediately to create a test pattern. Calculator works perfectly, thanks! In the bgl there is exactly the same pattern as in the input raw data:http://www.volny.cz/stoje/scen/vl01w.jpgbut in the FS I can just validate your findings also in the Prague area:http://www.volny.cz/stoje/scen/vl01fs.jpgSo the precision of the bgl control files will be probably little bit limited?Cheers

Share this post


Link to post
Share on other sites
Guest luissa

Hi Vlada,I tried something like you and got similar results. My aim was to create a photo scenery with scatered custom tiles/photos. So I made a raw full of #254 except on the few locations where I placed #252.The result was a kind of "ghost" to the south to the east and to the south east. I can not determine from your pictures if that is the case in your situation. For example if I wanted just one tile which I represent by O I get O plus 3 extra tiles represented by X:---XO---XXSince to place one tile 0 I need those 3 neighbor tiles X I had to consider that in creating my scatered BGL photo file. Here was what I wanted (to follow my post you need a constant width font):------O------O---OOOO---OOOO---OOFortunately this was an island and I could add sea tiles without problem. So I changed my project adding 2 sea tiles marked by S to get:-----SO-----SO---OOOO---OOOO---OOAnd because of that "ghost" I set my raw file as:------O------O----OOO----OWith these 6 #252 I got 14 photo tiles showing in the sim.Kind Regards,Luis

Share this post


Link to post
Share on other sites
Guest luissa

>Dick has now explained it wonderfully. Rather than having >the textures sitting in between the elevation points, they >do in fact sit on the elevation points. This is done, so the >textures on the borders can blend. What we really have is >1/2 cell + 255 cells + 1/2 cell. Hi Christian,I placed a single LOD5 in the midle of the ocean and I noted that sea tiles (tile=LOD13) outside this LOD5 get affected in strange ways. Something that is surely related to blending.Also, when my raw file was a "chess" type one, the squares of the "chess board" were not centered with "elevations points". If I number the tiles displayed by the sim as:(1,1) (1,2) ... (1, 256)(2,1) (2,2) ... (2, 256)...(256,1)(256,2) ... (256,256)then tile (1,1) corresponds to raw position (1,1). The NW corner of this (1,1) cell (and not its center as it could be implied from your message) coincides with the NW corner of the LOD5 block. Aparently I could not see any of (?, 257) or (257,?) raw values. Kind Regards, Luis

Share this post


Link to post
Share on other sites
Guest vlada stoje

Hi Luis,Yes this is the same case. Quite unexpected behavior, isn't it? All "real" landclass values affect only one tile, but these 252 and 253 must be something extra and affect four tiles from one vertex, GRRRR! I admire Dick that he was able to explain this mystery!Kind Regards

Share this post


Link to post
Share on other sites

Hi Vlada and Luis.Looking at the illustration below, if we assign the vertex 128,128 a Value of #252 or #253 ( Custom texture ), the same rule applies:Ground tiles 0, 1, 2, and 3 will all be affected by the vertex assignment. All the other verticies will affect the tiles they corner as well, and that controls the blending ( so that 4 verticies always affect each ground tile ).However, if just one of the verticies cornering a tile is assigned as custom landclass, then that vertex must be surrounded by 4 custom textures, and there will be no blending of those four tiles. With 128,128 assigned as Custom, ground tiles 0, 1, 2, and 3 will all be custom textures.http://ftp.avsim.com/dcforum/User_files/3d96491d189836ed.jpgA few weeks ago I had been stumped trying to get just one photoreal ground tile to show... and found there must always be a minimum of 4 tiles ( unless I was at the edge or corner of the LOD5 area). Now I know why. We assign the landclass value to a vertex, not a cell, and that's why 4 tiles are affected, as vertex 128,128 above affects ground tiles 0, 1, 2, and 3.Now that we know the rules, and my landcalc tool tells us the name, we don't really need to use Resample's CUSTOM function anymore... unless we really want it to slice the textures for us. We can just make the more flexible ClassU8 landclass. Making Vlada's example above would be impossible with a single CUSTOM resampling BGL, but is easy with the LandClass method.One last problem is what if we really want just one ground tile as custom? We could use VTP polygons to display the texture. Also, I haven't experimented with value #255. That number is used to pad BGLs when the source is smaller than 257x257. Perhaps that ( OR SOME OTHER NUMBER ) will eliminate the custom 'blend' into THE tiles that it touches. Otherwise, we will eventually be forced to use VTP polys, as our designs become more complicated.Dick

Share this post


Link to post
Share on other sites
Guest christian

Hi Luis,I did a final test, which should settle it now...After some thinking, I realised that you also may be right, so the thing to test was:case 1: 1/2 + 255 + 1/2 with both sides blending (vertex)or case 2: 256 + 1 with only texture 257 blending (centred)I did a LOD quad with 257x257, filled it with water and put a border of forest around it 1 pixel wide (ie pixels 1 and 257 are forest, rest water).To my amazement there was no forest at all. Of course, water doesn't blend it's texture, so no surprise, doh. However, and indication that case 1 correct, otherwise there should have been forest at the top and left border.Back to photoshop, replace water with crops. This time the forest border is there, left, right, top, bottom. Case 1 wins...Like rhumba said, the landclass gets mapped onto the vertex and not into the centre.This raises a new question now: I said that a LOD is 257 cells, but in fact FS2002 only displays 255 cells and two cells are mergers. Do we have make our source files with 255 cells and on the border put landclass numbers that match the numbers on the neighbour cells? Ie do we have to double up borders? I guess this is what this outcome suggests...Also, if the border doesn't match the neighbouring LOD quad border, it looks ugly. The borders don't match, ie the textures don't merge. You get a very narrow strip of one landclass.Cheers, Christian

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...