[need help] loading RAW files for terrain rendering

Started by
1 comment, last by Twitchy 18 years, 1 month ago
Ok so I'm creating a game in Directx and I want to create my terrain using heightmaps... I've managed to create an area using the x and z axis but I can't seem to load the heightmap properly for it to add the values into the y axis... could anyone help me please!!
Advertisement
Why can't you load it correctly?
Some more info would help, what language are you using? How are you trying to read the RAW file? what are you doing with the data?

ok, well I'm using visual studio.net 2003 c++, I'll show the code that I've got for loading the RAW file in:

bool GObject::ReadRAWfile(const char *RAWName)
{
std::vector<BYTE> in(NumVertices);

std::ifstream inFile(RAWName, std::ios_base::binary);

if( inFile == 0)
return false;

inFile.read((char*)&in[0],
in.size());

inFile.close();

m_heightmap.resize(NumVertices);

for(int i = 0; i < in.size(); i++)
m_heightmap = in;

return true;
}

m_heightmap is a std::vector<int> declared in my class function.

The program runs but when I debug it it doesn't seem to be loading in the data, as my m_heightmap remains empty after the for loop at the end.

I have no idea why it is doing this. I just need it to be stored in the variable as I have already done the rest of the code for drawing the terrain onto the screen.

This topic is closed to new replies.

Advertisement