Tried it with 129x129 maps, still the same strange results.
The code building my terrain scene nodes looks like this (need much much improvement - but i am still at beginner level

):
Code: Select all
if(TileCount == 9) //9 tiles 3x3 - currently maximum
{
//init working temp variable.
iTileTmpCounter = 1; //-> Set Counter to 1. Count up to 9.
while( iTileTmpCounter < 10) //build from 0-8 so we have 9 tiles absolute.
{
//create needed tiles
//Build Heightmap var
THCompName[iTileTmpCounter] = HTexHDir+TName+"0"+itoa(iTileTmpCounter-1,buffer,10)+HMExt;
//Build Diffuse Texturemap var - remove later when switching to shaders
TTCompName[iTileTmpCounter] = TName+"0"+itoa(iTileTmpCounter-1,buffer,10)+"D"+sTexExt;
//build conv holder
HMapConv = THCompName[iTileTmpCounter].c_str(); //works, HMapConv is temp holder for array
//build tile matrix 3x3
//row one
//first tile (0-Tile) clean without offset
if (iTileTmpCounter == 1)
{
//no offset
fTmpOffsetX = 0.0f;
fTmpOffsetY = 0.0f;
//build seg and use data stored before for it
BuildSegment(device,
driver,
smgr,
TSplitter_01,
HMapConv,
0,
iTileTmpCounter,
vector3df(fTmpOffsetX,0.0f,fTmpOffsetY),
TPXYScale,
TPZScale,
SColor(TARGB[0],TARGB[1],TARGB[2],TARGB[3]),
TPLOD,
ETPSize,
TSmooth,
TLighting,
TTCompName[iTileTmpCounter],
TDet,
TDebug);
}
//build up with offset right now
if (iTileTmpCounter == 2)
{
//X-Offset 1 tile
fTmpOffsetX = TPOffset;
fTmpOffsetY = 0.0f;
...
}
and so on up to
Code: Select all
if (iTileTmpCounter == 9)
{
...
}
//matrix looks like:
// 00 | 01 | 02
// 03 | 04 | 05
// 06 | 07 | 08
//as last action add 1 to the counter until it matches.
iTileTmpCounter = iTileTmpCounter + 1;
}
}
so it loops until the counter iTileTmpCounter is hit.
The (very basic) function BuildSegment() looks like:
Code: Select all
void BuildSegment( IrrlichtDevice* device,
IVideoDriver* driver,
ISceneManager* smgr,
ITerrainSceneNode* TSplitter,
const c8* Heightmap,
ISceneNode* Parent = 0,
s32 id = -1,
vector3df& Position = vector3df(0.0f,0.0f,0.0f),
float ScaleXZ = 50.0f,
float ScaleY = 10.0f,
SColor VTXCol = SColor(255,255,255,255),
s32 maxLOD = 5,
E_TERRAIN_PATCH_SIZE TPatch = ETPS_17,
s32 TSmoothing = 4,
bool Lighting = false,
stringc TTexture = "",
stringc TDetail = "",
bool Debug = false
)
{
//build a file
IReadFile* HMFile = device->getFileSystem()->createAndOpenFile(Heightmap);
// add terrain scene node
TSplitter = smgr->addTerrainSceneNode(
HMFile, //heightmap
Parent, // parent node
id, // node id
Position, // position
vector3df(0.f, 0.f, 0.f), // rotation
vector3df(ScaleXZ, ScaleY, ScaleXZ), // scale
VTXCol, // vertexColor
maxLOD, // maxLOD
TPatch, // patchSize
TSmoothing // smoothFactor
);
//set lighting on or off
if (Lighting == false)
{
TSplitter->setMaterialFlag(EMF_LIGHTING, false);
}
else
{
TSplitter->setMaterialFlag(EMF_LIGHTING, true);
}
TSplitter->setMaterialTexture(0,driver->getTexture(sTexTDir+TTexture));
TSplitter->setMaterialTexture(1,driver->getTexture(sTexTDir+TDetail));
TSplitter->setMaterialType(EMT_DETAIL_MAP);
TSplitter->scaleTexture(1.0f, 25.0f);
//Turn on Debug info or off
if (Debug == true)
{
TSplitter->setDebugDataVisible ( true );
}
else
{
TSplitter->setDebugDataVisible ( false );
}
}
Since I don't work on the vertices or do any other mesh modification stuff to the terrain, i don't have a clue why the terrain borders don't match... I first thought the resampling in photoshop when i scaled the bmps might have done harm to the poor image, but i put the maps together and didnt find any problem here.
I calculate the TPOffset (tile offset) like this (scaling 50.0 x and y, 10.0 z):
Code: Select all
float TPOffset = 0.0f;
TPOffset = 129*TPXYScale+6350; //for ETPS_129,
TPOffset = TPOffset*-1; //because of the mirroring...