I'll try to explain using provide code snippets so here goes;
First I got a simple object just for handling my vectors;
- Code: Select all
public:
int mapSizeX;
int mapSizeY;
mapInfo(void);
~mapInfo(void);
bool setMapSize();
bool setValueAt(const char *wMap, int x, int y, float value);
bool getValueAt(const char *wMap, int x, int y, float &Val);
bool checkMapID(const char *wMap);
GetValue looks like
- Code: Select all
bool mapInfo::getValueAt(const char *wMap, int x, int y, float &Val){
if (!mapInfo::checkMapID(wMap))
return false;
Val = mapArrays[mapID].at( y * mapSizeX +x);
return true;
}
SetValue Looks like
- Code: Select all
bool mapInfo::setValueAt(const char *wMap, int x, int y, float value){
if (!mapInfo::checkMapID(wMap))
return false;
mapArrays[mapID].at(y * mapSizeX +x) = value;
return true;
}
This objects handles the float values just to let me work them over easier and faster then getting each pixel value every time and so on, it seem to work without any issues (is there an easy way of outputing values to the log window in L3DT so I can check?) as I do get values back as intended but for some reason I can get the map to go either positive or negative
- Code: Select all
bool applyGeneration(){
maxProgress = mapVectors.mapSizeX * mapVectors.mapSizeY;
updateProg(true,"Applying heightmaps");
maxProgress = mapVectors.mapSizeX * mapVectors.mapSizeY;
for (int i = 0; i < mapVectors.mapSizeX ; i++){
for (int j = 0; j < mapVectors.mapSizeY ; j++){
float value2 = 0.0f;
if (!mapVectors.getValueAt("BASE", i, j, value2)) return false;
if (!zmap_SetPixel(zproj_GetMap("HF"),i,j,&value2)) return false;
updateProg(1);
}
}
return true;
}
Depending on the values (seems to be which ever goes highest or lowest with positive being checked first) I either get everything from 0 and up, or 0 and down, never for ex both 1.0 and -1.0, first I thought it was reseting some offset or something but I do get the outline I'm suppost to get so it's either land that becomes 0 and sea leavels become negative, or sea becomes 0 and land becomes positive.
Had a krash on one of my harddrives a few days ago so I'm still restoring stuff but I'll see if I can't do a pure copy value, return value and see what happens, any ideas where the problem might be otherwise would be great