for (int y=0; y < nSize; y++)
{
for (int x=0; x < nSize; x++)
{
CurrVertex = y * (nSize/1) + x;
vert.x = (float)x;
vert.y = (float)(mHeightMap->mData[CurrVertex * 3]/mDivider);
vert.z = (float)y ;
uvcoord.t[0] = ((float)y /nSize),
uvcoord.t[1] = ((float)x /nSize);
vertices[CurrVertex] = vert;
texcoords[CurrVertex] = uvcoord;
++VerSize;
}
}
int idx=0;
for (y = 0; y < nSize - 1; y++)
{
for (int x=0; x < nSize - 1; x++)
{
CurrVertex = y * (nSize) + x;
indices[idx] = CurrVertex;
indices[++idx] = CurrVertex + nSize;
indices[++idx] = CurrVertex + 1;
indices[++idx] = CurrVertex + (nSize) +1;
indices[++idx] = CurrVertex;
indices[++idx] = CurrVertex + 1;
++idx;
IndSize+=6;
}
}
what''s wrong?
hi!
at first: sorry for my bad english *g*
i tried to do a brute force terrain with vertex arrays(opengl), but it doesn''t work as i should. there are strange lines from on end of the terrain to the other.
i guess i do something wrong with my indices.
I can''t see the vertex array setup, could you please post it?
I noticed that the order you store the triangles in are a little fishy, check it out.
I noticed that the order you store the triangles in are a little fishy, check it out.
here's the rendering code:
(Without the Texture Stuff, because this would be to much to post ... mulittexturing, multipass. support, it's not important anyway)
>>I noticed that the order you store the triangles in are a little fishy, check it out
That's my problem, i don't know how to do it the right way.
@Trienco
I render as triangle strip
[edited by - guts on April 19, 2003 7:24:00 AM]
[edited by - guts on April 19, 2003 7:24:25 AM]
glLoadIdentity();glPopMatrix();glPushMatrix(); glTranslatef(mPos.x, mPos.y,mPos.z);glScalef(mScale.x, mScale.y, mScale.z);glVertexPointer(3, GL_FLOAT, sizeof(CVector3), &vertices[0].x); glEnableClientState(GL_VERTEX_ARRAY); glDrawElements(GL_TRIANGLE_STRIP, IndSize, GL_UNSIGNED_INT, &indices[0]); glDisableClientState(GL_VERTEX_ARRAY);
(Without the Texture Stuff, because this would be to much to post ... mulittexturing, multipass. support, it's not important anyway)
>>I noticed that the order you store the triangles in are a little fishy, check it out
That's my problem, i don't know how to do it the right way.
@Trienco
I render as triangle strip
[edited by - guts on April 19, 2003 7:24:00 AM]
[edited by - guts on April 19, 2003 7:24:25 AM]
without looking at the vertices and indices in detail it seems youre always going left to right with your indices, never begin a new strip and shouldnt be surprised if strange lines appear between the last vertex of a line and the first of the next line. you have to do one line from left to right and the next from right to left, most likely add a dummy-triangle, because strips have a few things to consider.
first: every new point will form a triangle with the last two points.
second: the winding changes with each point (clockwise, counter clockwise)..
and of course third: cache optimized triangles lists cause less headache and are usually as fast or faster.
first: every new point will form a triangle with the last two points.
second: the winding changes with each point (clockwise, counter clockwise)..
and of course third: cache optimized triangles lists cause less headache and are usually as fast or faster.
i know it's kind of impertinent, but could you please post the source code that stores the indices in the right way?!
[edited by - guts on April 19, 2003 10:09:17 AM]
[edited by - guts on April 19, 2003 10:09:17 AM]
might not help you much, because i just ripped it out and im going bottom to top, not left to right...
int X=0;
while (X < size) {
for (Y=size; Y >= 0; --Y) {
IdxBuffer[i++]=(X*size)+Y;
IdxBuffer[i++]=((X+1)*size)+Y;
}
IdxBuffer[i++]=(++X)*size;
if (X>=size) break;
for (Y=0; Y<=size; ++Y) {
IdxBuffer[i++]=(X*size)+Y;
IdxBuffer[i++]=((X+1)*size)+Y;
}
IdxBuffer[i++]=((++X)*size)+size;
}
hope i replaced all strt with 0 and end/n with size
[edited by - Trienco on April 19, 2003 11:22:17 AM]
int X=0;
while (X < size) {
for (Y=size; Y >= 0; --Y) {
IdxBuffer[i++]=(X*size)+Y;
IdxBuffer[i++]=((X+1)*size)+Y;
}
IdxBuffer[i++]=(++X)*size;
if (X>=size) break;
for (Y=0; Y<=size; ++Y) {
IdxBuffer[i++]=(X*size)+Y;
IdxBuffer[i++]=((X+1)*size)+Y;
}
IdxBuffer[i++]=((++X)*size)+size;
}
hope i replaced all strt with 0 and end/n with size
[edited by - Trienco on April 19, 2003 11:22:17 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement