🔒 Locked
Loading .raws?!?
Advertisement
Original Post
can any1 help me with my terrain its like see through but not, its rendering the stuff behind the mountains so it looks see through i believe its called backface culling but help me out here. any suggestions on what to do about this i just descovered it because i for fun put in a color map and it gave it this weird thing... [Edited by - Scotto1001 on September 20, 2005 5:27:20 AM]
Hey :)
I'm not exactly sure what your problem is yet. But a good idea would be to post your terrain generation code so we can pin point your problem. Post your code between some code][/code tags (just add brackets).
BTW I'm sure you have probably done this, but one helpful hint would be to check to make sure your polygons are rendered in the right order (The Painter's Algorithm).
I'm not exactly sure what your problem is yet. But a good idea would be to post your terrain generation code so we can pin point your problem. Post your code between some code][/code tags (just add brackets).
BTW I'm sure you have probably done this, but one helpful hint would be to check to make sure your polygons are rendered in the right order (The Painter's Algorithm).
p...p..Painters Algorithim...? I thought the Zbuffer made sure one point was behind another when rendered -.-; this is getting more complicated than when i first wrote this... i had to restart my whole game engine because my hard drive crashed 2 years ago i got frustrated and quit for a year or 2 now i forget like everything... so how do i do this Painters Algorithm would the points have to change based on where the cam was?
ok its definately the order of rendered points because i flipped the cam around and the terrain looks fine
The painter's algorithm is bacisacly just rendering scene's and objects in the right order (i.e. render your background before you render your mountains, etc). Any other problems? :)
yah if i solved it by flipping my camera what about when a character in my game decides to turn around and boom we have another problem?
another question is why my terrain looks like this

when my height map is this?

[/source]
Tis my loading of the vertices code
[Edited by - Scotto1001 on September 19, 2005 7:55:34 PM]

when my height map is this?

[SOURCE] int count=0; for (int z=0;z<NumCells;z++) { pos.x=MinBounds.x; for (int x=0;x<NumCells;x++) { verts[count].x = (float)x * step; verts[count].z = (float)z * step; verts[count].y = (float)File.get(); verts[count].color = ReturnColor (FileC.get()); // // Increment x across pos.x+=step; count++; } // Increment Z down pos.z-=step; }[/SOURCE]Tis my loading of the vertices code
[Edited by - Scotto1001 on September 19, 2005 7:55:34 PM]
.......no help but ive idetified the problem its not in the way i arranged my verticies its how File.get (); is reading it in so maybe a better question is how do i load a .raw using ifstream? get() isnt walking through each pixel of the heightmap right so what do i gotta do?
This definetly looks like a depth buffering problem. Check the following things:
(1) In your presentation parameters, is EnableAutoDepthStencil set to true? If not, enable it. Also, make sure you set a compatable AutoDepthStencilFormat, such as D3DFMT_D16 or D3DFMT_D24S8.
(2) Is the ZEnable render state set to D3DZB_TRUE?
(1) In your presentation parameters, is EnableAutoDepthStencil set to true? If not, enable it. Also, make sure you set a compatable AutoDepthStencilFormat, such as D3DFMT_D16 or D3DFMT_D24S8.
(2) Is the ZEnable render state set to D3DZB_TRUE?
By looking at your last post with pics. I would guess that some how you are reading in the map data in a bit off. It looks if you cut your map in half & then took the left & moved it to the right and take right & move it to the left.
I would take another look at your loading section and see if you are reading in late or early.
I would take another look at your loading section and see if you are reading in late or early.
Hi there Scotto1001,
How are you doing?
The Problem
Terrain being cut in the middle
The Solution
When reading Raw files and generating a grid for your terrain there are a few things you need to make sure of.
1) Your Raw file must be in the format of 2^n+1
e.g. a 512x512 map should have a 513x513 raw file since along the x and z axiz
you have 513 vertices.
2) Number of vertices in a terrain should be calculate as such :
int numVertices = terrainWidth * terrainHeight;
e.g. int numVertices = 513x513
3) Number of indices in a terrain are done in a similar fashion the the number
of primitives on a terrain. Let's say you want to generate indices for the
example terrain.
Demo Code
Reading from a raw file
I hope this helps buddy.
How are you doing?
The Problem
Terrain being cut in the middle
The Solution
When reading Raw files and generating a grid for your terrain there are a few things you need to make sure of.
1) Your Raw file must be in the format of 2^n+1
e.g. a 512x512 map should have a 513x513 raw file since along the x and z axiz
you have 513 vertices.
2) Number of vertices in a terrain should be calculate as such :
int numVertices = terrainWidth * terrainHeight;
e.g. int numVertices = 513x513
3) Number of indices in a terrain are done in a similar fashion the the number
of primitives on a terrain. Let's say you want to generate indices for the
example terrain.
Demo Code
terrainWidth = 256;terrainHeight = 256;numTerrainVertices = terrainWidth * terrainHeight;numTerrainPrimitives = (terrainWidth - 1) * (terrainHeight - 1) * 2;//Generating Verticesfor (int y = 0; y < terrainHeight; y++) { for (int x = 0; x < terrainWidth; x++) { pVertexData[pos].x = (float)x * cellScale; pVertexData[pos].y = getScaledHeight(aHeightMap[pos]); pVertexData[pos].z = (float)y * cellScale; pVertexData[pos].u1 = (float)((terrainWidth - 1) - y) / (terrainWidth - 1); pVertexData[pos].v1 = (float)(x) / (terrainHeight - 1); pVertexData[pos].u2 = (float)((terrainWidth - 1) - y) / (terrainWidth - 1); pVertexData[pos].v2 = (float)(x) / (terrainHeight - 1); pos++; }}//Generating Indicesfor (int y = 0; y < (terrainHeight - 1); y++) { for (int x = 0; x < (terrainWidth - 1); x++) { *pIndexData++ = y * terrainWidth + x; //v1 *pIndexData++ = y * terrainWidth + x + 1; //v2 *pIndexData++ = (y + 1) * terrainWidth + x + 1; //v4 *pIndexData++ = y * terrainWidth + x; //v1 *pIndexData++ = (y + 1) * terrainWidth + x + 1; //v4 *pIndexData++ = (y + 1) * terrainWidth + x; //v3 }}Reading from a raw file
unsigned char* aHeightMap = new unsigned char[numTerrainVertices]; { ifstream f(heightmap, ios::binary); f.read(reinterpret_cast<char*>(aHeightMap), numTerrainVertices);}I hope this helps buddy.
Its gotta be how PaintShopPro saved my .raw I follow your code armadon and i got the same result split in 2 and shifted. yet when i make a simple dos program to put it all into numbers i get what my terrain should look like so it is my code...
Hi there Scotto1001,
How are you doing?
The Problem
Terrain split in the middle
The Solution
The most regular occurance of this effect is caused in the fact that you are setting your terrain in the format of n^2 rather than n^2+1.
Once again do the following checks.
1) Terrain Width and Height must be in the following format: N^2+1
e.g. 513x513
2) The number of terrain vertices : terrainWidth * terrainHeight;
3) The number of terrain primitives: ((terrainWidth - 1) * (terrainHeight - 1)) * 2;
This means that you will have 513 vertices in the X and Z.
PS: I have uploaded a Raw File for you to use, Make sure that PaintShopPro isn't
saving it in interleaved order. This might cause some fan effect.
This Raw file works perfectly and is saved as a 257x257 raw file. Test your terrain with it.
I hope this helps buddy.
How are you doing?
The Problem
Terrain split in the middle
The Solution
The most regular occurance of this effect is caused in the fact that you are setting your terrain in the format of n^2 rather than n^2+1.
Once again do the following checks.
1) Terrain Width and Height must be in the following format: N^2+1
e.g. 513x513
2) The number of terrain vertices : terrainWidth * terrainHeight;
3) The number of terrain primitives: ((terrainWidth - 1) * (terrainHeight - 1)) * 2;
This means that you will have 513 vertices in the X and Z.
PS: I have uploaded a Raw File for you to use, Make sure that PaintShopPro isn't
saving it in interleaved order. This might cause some fan effect.
This Raw file works perfectly and is saved as a 257x257 raw file. Test your terrain with it.
I hope this helps buddy.
Wow i have got to be the dumbest person on earth at least after math class i could see that n^2 ment Squared hey it works now thx a freaking ton man sry im so slow =( also in study hall i thought of a way to create a shadow map im gonna test it out... =D you made my day!
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement