• Create Account

Need scary sound effects or creepy audio loops for your next horror-themed game? Check out Highscore Vol.3 - The Horror Edition in our marketplace. 50 sounds and 10 loops for only \$9.99!

### #Actualkavaari

Posted 08 June 2012 - 05:17 AM

I changed the grid creation code to more efficient one. I took the code almost straight from Riemers example, so there shouldn't be much errors in that, but still the problem exist, it's driving me crazy!

int iCounter = 0;
//Vertices
for (int x = 0; x < numSideTiles+1; x++)
for (int z = 0; z < numSideTiles+1; z++)
{
float xPos = x * spacing;
float zPos = z * spacing;

vertices[x + z * (numSideTiles + 1)] = new PositionNormalTextured() { Position = new Vector4(xPos, 0, zPos, 1.0f), Normal = normal, UV = new Vector2(x, z) };
}
//Indices
for (int x = 0; x < numSideTiles; x++)
for (int z = 0; z < numSideTiles; z++)
{
ushort lowerLeft = (ushort)(x + z * (numSideTiles+1));
ushort lowerRight = (ushort)((x + 1) + z * (numSideTiles + 1));
ushort topLeft = (ushort)(x + (z + 1) * (numSideTiles + 1));
ushort topRight = (ushort)((x + 1) + (z + 1) * (numSideTiles + 1));

indices[iCounter++] = topLeft;
indices[iCounter++] = lowerRight;
indices[iCounter++] = lowerLeft;

indices[iCounter++] = topLeft;
indices[iCounter++] = topRight;
indices[iCounter++] = lowerRight;

}


Here is a picture of 5x5 quad, and as you can see it's a little different.

I'm thinking the problem is somewhere else than in the loop.

### #1kavaari

Posted 08 June 2012 - 05:16 AM

I changed the grid creation code to more efficient one, I took the code almost straight from Riemers example, so there shouldn't be much errors in that, but still the problem exist, it's driving me crazy!

int iCounter = 0;
//Vertices
for (int x = 0; x < numSideTiles+1; x++)
for (int z = 0; z < numSideTiles+1; z++)
{
float xPos = x * spacing;
float zPos = z * spacing;

vertices[x + z * (numSideTiles + 1)] = new PositionNormalTextured() { Position = new Vector4(xPos, 0, zPos, 1.0f), Normal = normal, UV = new Vector2(x, z) };
}
//Indices
for (int x = 0; x < numSideTiles; x++)
for (int z = 0; z < numSideTiles; z++)
{
ushort lowerLeft = (ushort)(x + z * (numSideTiles+1));
ushort lowerRight = (ushort)((x + 1) + z * (numSideTiles + 1));
ushort topLeft = (ushort)(x + (z + 1) * (numSideTiles + 1));
ushort topRight = (ushort)((x + 1) + (z + 1) * (numSideTiles + 1));

indices[iCounter++] = topLeft;
indices[iCounter++] = lowerRight;
indices[iCounter++] = lowerLeft;

indices[iCounter++] = topLeft;
indices[iCounter++] = topRight;
indices[iCounter++] = lowerRight;

}


Here is a picture of 5x5 quad, and as you can see it's a little different.