problem with setting vertices blend weight

Started by
4 comments, last by billybob 21 years, 8 months ago
well, my terrain is coming out good, i know the triangles can blend together but i can''t make the vertices set that to happen. the way its set up, it generates sets of three vertices in a triangle, and what i need to happen is to set all the other vertices on that same spot-of different triangles, to the same blend weights. this sounds trivial, but i cannot do it. i''m going to try a brute force find all vertices on the same point method, but does anyone have any other ideas?
Advertisement
ok, i just tried the brute force method, this is OBVIOUSLY not the way to go as it was taking about 20 minutes before i endtasked it. i can''t believe something this simple is getting me down after setting up something as complicated as directx. how in the hell do i set all the vertices on that point to the same blend weight?
Umm, this can be tricky, can you tell us details how you store your terrain? Do you mean you''re trying to find all the triangles that share a vertex and set that vertex to a certain value?
Without seeing how you''re managing things it''s difficult to comment or advise. Why not consider generating all the vertices, and building the triangles around them so the vertices are automatically shared instead of trying to match up the triangles?


Read about my game, project #1


John 3:16
there is a load routine to fill terrain_HeightMap[x][y] with random values for now, soon to be a file loader.

for(yread = 0; yread < terrain_y - 1; yread++)
{
ty = ty + terrain_Tex;
if(ty > 1)
{
ty = 0;
}
tx = 0;
for(xread = 0; xread {
tx = tx + terrain_Tex;
if(tx > 1)
{
tx = 0;
} //if the texel coords go past 1, start repeating
h1 = terrain_HeightMap[xread][yread];
h2 = terrain_HeightMap[xread+1][yread];
h3 = terrain_HeightMap[xread+1][yread+1];
h4 = terrain_HeightMap[xread][yread+1];
//upper right triangle
terrain[vert].x = float(xread);
terrain[vert].y = float(yread);
terrain[vert].z = float(h1);
terrain[vert].nx = 0.0f;
terrain[vert].ny = 1.0f;
terrain[vert].nz = 0.0f;
terrain[vert].tu1 = float(tx);
terrain[vert].tv1 = float(ty);
terrain[vert].tu2 = float(tx);
terrain[vert].tv2 = float(ty);
terrain[vert].tu3 = float(tx);
terrain[vert].tv3 = float(ty);


here is setting everything for a terrain vertex, there are 5 more but i didn''t include them because they are more or less the same, just a few +1''s here and there. i took out the blend weight setter, becuase it was doing no good, but i can''t set the triangles to share a common vertice, because some things about the vertice need to be different. like the texture coordinates, the way i set it up (i did not know that you could wrap textures, i thought the texture coords couldn''t go past 0 or 1). there are a few other things where the vertice share an xyz but not something else. i need to set the terrain[vert].specular = D3DCOLOR and set that for ALL the vertices on that particular x,y. i think i might ahve to create some kind of buffer to remember which ones it needs to set, but this is way beyond what i expected.
also, a is there a way to ''unallocate'' arrays? there is a VERY large one that after the terrain is loaded, does absolutley nothing...
int *p;

p=new int[10000000];

delete [] p;

int **d;
d=new int *[height]
for i = 0 to height
d=new int[width;


for i=0 to height
delete [] d;<br><br>delete [] d; </i> <br><br><hr><br><b>Read about my game, <a href="http://web.ukonline.co.uk/dextersoft">project #1</a><br> </b> <br><hr><br><i>John 3:16 </i>

This topic is closed to new replies.

Advertisement