This topic is 4371 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Share on other sites
Just in a quick glance, It looks like you are loading an 8 bit raw file, are you saving your heightmap as 8 bit .raw?

yes I am

Share on other sites
when I run the code it seems that in[] doesn't seem to get the values from the file at all.

Share on other sites
Just use D3DX to load it up as textures. There is no point anyway in writing code to read a file format.

Share on other sites
I would but unfortunately this is for a project and I'm not allowed to use D3DX as it does all of the work for you and the terrain will play a major part in my game.

Share on other sites
My terrain system is about 1100 lines of code, of which approximately 10 are dedicated to loading the heightmap from file.

Hardly "all" the work.

Share on other sites
Quote:
 Original post by PromitMy terrain system is about 1100 lines of code, of which approximately 10 are dedicated to loading the heightmap from file.Hardly "all" the work.

I suppose your's is a much more complex terrain system, I just don't understand why mine doesn't load the file

Share on other sites
Well first of all, does in hold the correct data?

Share on other sites
that's my main problem, when I debug through, it doesn't seem to store any information at all

Share on other sites
See if the loop is running, perhaps by setting a breakpoint, or using a Message box. It could be that it isnt even running the loop. For me whenever I do a <vector>.size() the compiler complains about the type is invalid, so I cast it to int

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

I dont know if it matters, but it seems to make the compiler happy.

The only other thing that can be happening is no info is being loaded into the in vector.

Share on other sites
thanks I will try it. And let you know what happens

Share on other sites
Hi,

Are you sure NumVertices has a value?

I have rewritten your code slightly below and it works fine in place of my terrain loader, it should fill your height map as it does mine.

bool GObject::ReadRAWfile(const char *RAWName){	vector<BYTE> in;	ifstream inFile(RAWName, ios::binary);	// File invalid	if( inFile == 0)		return false;	// Read until EOF	while(!inFile.eof())	{		m_heightmap.push_back(inFile.get());	}		// Close file	inFile.close();	return true;}

Hope that helped.

Share on other sites
yeah thanks for everything guys... really helped me out loads, I can now carry on with other stuff that I need to get finished