well I think the reason the terrain seems to be a triangle is that your rendering only half or a part of your triangles.
This is probably again related to your use of the array to keep the vertices. It may be related to the way your accessing the arrays that would be causing the stretched triangle and only part of the terrain being render (the "rectangluar" effect)
I would look over and make sure your parsing through the array of vertices correctly, and also make sure your using the correct size for each vertex structure(x,y,z, normal, extra info) .
several problems with my terrain generator
Looking over your code....it seems correct
Except I notice your doubling the size of the terrain by putting x*2 and z*2 for the x and z locations. BUT on your texture coordinates, your only using z and x as in :
m_pMapIndex[count].tu0 = ((x)/m_nWidth);
m_pMapIndex[count].tv0 = 1.0f-((z)/m_nHeight);
you need to double those values too. But that shouldn''t make a big difference in the look
also in FillIB(), the line:
m_dwNumTris = m_nWidth * m_nHeight;
is not correct...if you have a 3x3 grid of points you will have 8 triangles not 9 (using your formula). The acutal number of triangles is:
m_dwNumTris = (m_nWidth-1) * (m_nHeight-1) * 2
That would probably be way your only rendering half the terrain.
Hope that helps.
Except I notice your doubling the size of the terrain by putting x*2 and z*2 for the x and z locations. BUT on your texture coordinates, your only using z and x as in :
m_pMapIndex[count].tu0 = ((x)/m_nWidth);
m_pMapIndex[count].tv0 = 1.0f-((z)/m_nHeight);
you need to double those values too. But that shouldn''t make a big difference in the look
also in FillIB(), the line:
m_dwNumTris = m_nWidth * m_nHeight;
is not correct...if you have a 3x3 grid of points you will have 8 triangles not 9 (using your formula). The acutal number of triangles is:
m_dwNumTris = (m_nWidth-1) * (m_nHeight-1) * 2
That would probably be way your only rendering half the terrain.
Hope that helps.
Sorry if I wasnt clear about that Pactuul...I emailed you some screenshots of whats going on...
EDIT: Pactuul you posted before i sent the email...i'll try that.
[edited by - Sheep on May 5, 2002 2:51:27 PM]
EDIT: Pactuul you posted before i sent the email...i'll try that.
[edited by - Sheep on May 5, 2002 2:51:27 PM]
hahaha! thanks alot! the triangle is still sticking out, but now the terrain is sized correctly....somewhat...when I do the number of tri''s * 2, it wider, but still longer...if I multiply by 6 its even more square like...any ideas why this happens?
that triangle sticking out is where I think GetCell(x,z) is returning an invalid number. Since the triangle looks like its at the end corner, it might be near the end of the array, so make sure your generating correct heights for ALL those points, cause I think you might accidently be leaving off the last one.
Wow! You were right! It was in the GetCell(x,y) function! but now I still have my problem with this:
m_dwNumTris = ((m_nWidth-1) * (m_nHeight-1)) * 2;
That makes the terrain more square-like than before, but not quite. Then I tryed multiplying it by 6 instead of 2 and it became even more square like, but not quite. What do I have to do to make it a square??? Thanks for your help so far...
m_dwNumTris = ((m_nWidth-1) * (m_nHeight-1)) * 2;
That makes the terrain more square-like than before, but not quite. Then I tryed multiplying it by 6 instead of 2 and it became even more square like, but not quite. What do I have to do to make it a square??? Thanks for your help so far...
hmmm well I think that algo isn't quite right either:
m_dwNumTris = ((m_nWidth-1) * (m_nHeight-1)) * 2;
thinking about it: try dropping the -1's on the equation.
Better YET: to definately make sure, in your FillIB() do this
And of course delete the other m_dwNumTris code that modifies it.
[edited by - Pactuul on May 6, 2002 11:32:27 AM]
m_dwNumTris = ((m_nWidth-1) * (m_nHeight-1)) * 2;
thinking about it: try dropping the -1's on the equation.
Better YET: to definately make sure, in your FillIB() do this
for ( int z = 0; z < m_nHeight; z ++ ) { for (int x = 0; x < m_nWidth; x ++) { // create vertex index from co-ordinate WORD index= x + (z * m_nWidth ); m_pdwIndices[count]=index; m_pdwIndices[count+1]=index+m_nWidth; m_pdwIndices[count+2]=index+1; count+=3; m_pdwIndices[count]=index+m_nWidth; m_pdwIndices[count+1]=index+m_nWidth+1; m_pdwIndices[count+2]=index+1; count+=3; m_dwNumTris += 2; //change! } }
And of course delete the other m_dwNumTris code that modifies it.
[edited by - Pactuul on May 6, 2002 11:32:27 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement