Heightfield from raw problem ( *solved* )

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Heightfield from raw problem ( *solved* )

Postby rogermr » Fri Oct 03, 2008 12:25 am

I'm trying to create a heightfield using the Example08 and reading the info from a raw map.
So, here's the code for the new m_heightField initialization (it's all the same code, now just trying to read raw values)

Code: Select all
   char temp;
   std::ifstream inputFile("a.raw", std::ios::binary);
   // get length of file:
   inputFile.seekg (0, std::ios::end);
   int length = inputFile.tellg();
   inputFile.seekg (0, std::ios::beg);

   // determine the number of rows and cols
   int size = (int)sqrt((double)length);

   //read from file into vector
   for(int j=0;j<size; j++)
      for (int i=0; i<size; i++)
         m_heightField[j][i] = temp;

The raw file it's attached in the end, and it looks like this:


And the mesh created is:


As you can see, it looks like the mesh is correct, but on the borders, it does that strange effect, kind of making walls, like if there's too much (or to few) information... I'm not sure where the problem is.. as the code is exactly like in the example (just changing HEIGHT_SIZE to 500+1 to fit my raw).

Any advice will be helpful!

raw file
(3.99 KiB) Downloaded 214 times
Last edited by rogermr on Wed Oct 08, 2008 12:39 am, edited 1 time in total.
Posts: 4
Joined: Fri Oct 03, 2008 12:07 am

Re: Heightfield from raw problem

Postby Aphex » Fri Oct 03, 2008 10:52 am

What data type is mheightField? Looks like you have chars - it should be unsigned short (16 bits).
Posts: 144
Joined: Fri Jun 18, 2004 6:08 am
Location: UK

Re: Heightfield from raw problem

Postby JernejL » Fri Oct 03, 2008 4:15 pm

I think it is actually SIGNED int 16.
Help improving the Newton Game Dynamics WIKI
User avatar
Posts: 1531
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Heightfield from raw problem

Postby rogermr » Wed Oct 08, 2008 12:34 am

Solved! Problem was the way Photoshop exports .raw files :( 8bit raw works great (or reading bmps!)

Thanks all!
Posts: 4
Joined: Fri Oct 03, 2008 12:07 am

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 4 guests