# Serious troubles creating my indexbuffer indices

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

## Recommended Posts

Hi, I'm still working on the quadtrees I mentioned earlier. I have arrived in a problem I cannot solve. I've spent about 40 hours on these 15 lines of codes, and are about to give up. Maybe someone here at GD.net can help me. I'll try to explain everything very carefully. My terrain is made from a heightmap, which is 256x256. Not bigger right now, because of texture limitations on some cards. The terrain is translated to 128x128 vertices, every step is 16 in width (128x16 = 2048, is a nice number to work with) My quadtree is ranging from [-1024,1024]x[1024,1024]. This is not really relevant at the moment though. Since I want to be able to render the terrain, by giving the offset of the vertices, the number of vertices, offset and the amount of indices, I have prepared the terrain in a different way than normal list. So, I generate the vertex list like a quad. Basically, the array looks like this: I hope this is clear.. the quad is 16x16, so the first top-left quad is 256 vertices. For example, the 2nd quad starts at 257, instead of 17! Like I've said, I've spent so many hours on this, here are a few of my attempts:
	//for (y = 0; y < 17; y++)
//	{
//		for (x = 0; x < 17; x++)
//		{
//				//pIndices[n++] = x + y * (16 + 1);					//v1
//				//pIndices[n++] = x + 1 + y * (16 + 1);					//v2
//				//pIndices[n++] = x + 1 + (y + 1) * (16 + 1);				//v4
//
//				//pIndices[n++] = x + y * (16 + 1);					//v1
//				//pIndices[n++] = x + 1 + (y + 1) * (16 + 1);				//v4
//				//pIndices[n++] = x + (y + 1) * (16 + 1);					//v3

//				int startvert = ((y*16) + x);
//				pIndices[n++] = startvert+16;	// triangle 1
//				pIndices[n++] = startvert;
//				pIndices[n++] = startvert+16+1;
//
//				pIndices[n++] = startvert+1; // triangle 2
//				pIndices[n++] = startvert+16+1;
//				pIndices[n++] = startvert;
//		}
//	}

//One of the better attempts:

//int t = 1;
//	int temp = 0;
//	for (t = 0; t < 7; t++)
//	{
//		for (y = 0; y < 16; y++)
//		{
//			//for (x = (t*16); x < ((t+1)*16); x++)
//			for (x = 0 + (16*t); x < (16*(t+1)); x++)
//			{
//				temp = (256*t);
//		/*		if (temp < 0)
//					temp = 0;*/

//				startvert = temp + ((y)*17) + x ; //(x + (16*t)) + ((y-t)*16);
//				pIndices[n++] = startvert+17;	// triangle 1
//				pIndices[n++] = startvert;
//				pIndices[n++] = startvert+17+1;
//
//				pIndices[n++] = startvert+1; // triangle 2
//				pIndices[n++] = startvert+17+1;
//				pIndices[n++] = startvert;
//			}
//		}
//	}


Often I'm just trying to render one row.. the "t" variable is doing that. Can someone please help me on this? I've been so close so many times, but everytime one thing is doing weird. Some facts: - 1 Quad is 16x16 vertices - The grid is 128x128 vertices - 8 row quads, and 8 col quads - Total of 64 quads Any help is appreciated, thanks in advance.

• 17
• 10
• 21
• 16
• 9
×

## Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!