Quote: "Am I understanding you correctly that a boundry for a terrain square texture does not have to be between pixels and the texturing will handle this correctly. If so then I am worrying about nothing. "
I have just tried it and things look to be OK, but it was just a simple and not accurate test.
This has highlighted a problem with the "Terrain" commands within the current Dark SDK.
When one creates a terrain using the "Terrain" commands, it looks like the inbuilt code actually chops off some of the terrain from the top edge.
Using the same texture and heightmap in both set of tests.
Produce the same terrain by "Matrix" method.
void CreateWorld( void )
{
// make the 3D world
dbColorBackdrop ( dbRGB ( 0, 100, 255 ));
dbFogDistance ( 200000.0f ); // Give a 200KM sight distance
dbFogColor ( 100, 250 , 0 );// void dbFogColor ( int iG, int iB, 0 )....Red does not work
if (dbFogAvailable ( ))
dbFogOn ( );
dbLoadImage ( "Terrainmap.png" , 2 );
dbMakeMemblockFromImage ( 7, 2 );
int WorldXNodes = dbMemblockDword ( 7, 0); // number of X direction nodes/pixels
int WorldZNodes = dbMemblockDword ( 7, 4); // number of Z direction nodes/pixels
int WorldColorDepth = dbMemblockDword ( 7, 8);
int WorldXSegments = WorldXNodes - 1;
int WorldZSegments = WorldZNodes - 1;
dbMakeMatrix ( 2, 255000, 255000, WorldXSegments, WorldZSegments );
// raise each node to its correct height
for (int x = 0; x < WorldXNodes; x++ )
{
for (int y = 0; y < WorldZNodes; y++ )
{
int z = (WorldZNodes-1) - y;// Picture and mesh go opposite direction in the y / z values
dbSetMatrixHeight ( 2, x, z, 100 * dbMemblockByte ( 7, 12 + (WorldColorDepth / 8)*(x + (WorldXNodes * y))));// using only value from one color
}
}
// skin each terrain square
dbPositionMatrix ( 2, 0, 0, 0 );
dbLoadImage ( "Terraintexture.png", 4 );
dbPrepareMatrixTexture ( 2, 4, WorldXSegments, WorldZSegments );
for (int x = 0; x < WorldXSegments; x++ )
{
for (int y = 0; y < WorldZSegments; y++ )
{
int z = (WorldZSegments - 1) - y;
dbSetMatrixTile ( 2, x, z, x+1 + ((WorldXSegments) * y) );
}
}
dbUpdateMatrix ( 2 );
dbSetObjectFog ( 2, 1 );
}
Now creating the same terrain using the inbuilt "Terrain" method.
void CreateWorld( void )
{
// make the 3D world
dbColorBackdrop ( dbRGB ( 0, 100, 255 ));
dbFogDistance ( 200000.0f ); // Give a 200KM sight distance
dbFogColor ( 100, 250 , 0 );// void dbFogColor ( int iG, int iB, 0 )....Red does not work
if (dbFogAvailable ( ))
dbFogOn ( );
dbSetupTerrain ( );
dbMakeObjectTerrain ( 2 );
dbLoadImage ( "Terraintexture.png", 4 );
dbLoadImage ( "Terraindetail.png", 5 );
dbSetTerrainHeightMap ( 2, "Terrainmap.png" ); // currently using a 250x250 KM terrain
/**************************************************************************
* Terrain Grid Nodes is same size as Pixel numbers in the TerrainHeightMap.
* A 1024 x 1024 TerrainHeightMap makes a 1023 x 1023 Terrain Grid.
* Unit sizes of 1 Game unit = 1 meter is a good choice.
* Therefore scale up terrain to get a world of required size.
* UPDATE - THIS INFORMATION IS LOOKING TO BE NOT QUIET CORRECT -
**************************************************************************/
dbSetTerrainScale ( 2, 1000.0f, 100.0f, 1000.0f ); // make Terrain Grid around 1024 x 1000 = ~1000Km a side
dbSetTerrainLight ( 2, 1.0f, -0.25f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f );
dbSetTerrainTiling ( 2, 2 );
dbSetTerrainSplit ( 2, 4 );//MAKES GAME A BIT JERKY IF WE SPLIT INTO MORE BITS
dbSetTerrainTexture ( 2, 4, 5 );
dbBuildTerrain ( 2 );
dbSetObjectFog ( 2, 1 );
}
both images were captured with the camera rotated right by 90deg so in actuality the left side of the pictures are the top of the terrains.
It shows that creating the terrains using the inbuilt "Terrain" commands tends to cut off the top couple of terrain squares and square textures.
Now I can understand why I had so much trouble coupling "Terrain" based objects with matrix based support graphics like oceans and ocean bottoms.
Something for others to be careful of.