Quote:
One question though... how do you re-calculate the normals for the terrain/entity
once youve finished setting all the vertex heights?
You posted code of how you do the 'edges', but what about the main-body of the entity?

Mabe when you fix the normals you forget the frame? Or are using the wrong frame? (use .frame to be sure you are editing normals for the frame the entity is at at this moment)

first I use my algorithm to load random height for each height-data array

for(x=0;x<32;x++)
{
for(y=0;y<32;y++)
{
diamond_square_fractals(x*32,y*32,random(200)+25);
}
}

then i load the hieght data to each terrain vertex:
for(x=0;x<32;x++)
{
for(y=0;y<32;y++)
{
load_to_terrain(Terrain[x][y],x*32,y*32);
}
}

after that is done I just set the normals with ent_fixnormals:
for(x=0;x<32;x++)
{
for(y=0;y<32;y++)
{
c_updatehull(Terrain[x][y],Terrain[x][y].frame);
ent_fixnormals(Terrain[x][y],Terrain[x][y].frame);//BODY NORMALS
}
}

(NOTE: code up to here is how i got the ugly shadows on the edges)

Then all I have to do is fix the corners and edges with my functions:
for(x=0;x<32;x++)
{
for(y=0;y<32;y++)
{
avg_normals_NE(x,y);//CORNER NORMALS
avg_normals_NW(x,y);//CORNER NORMALS
avg_normals_SE(x,y);//CORNER NORMALS
avg_normals_SW(x,y);//CORNER NORMALS
avg_normals_N(x,y);//SIDE NORMALS
avg_normals_E(x,y);//SIDE NORMALS
avg_normals_S(x,y);//SIDE NORMALS
avg_normals_W(x,y);(x,y);//SIDE NORMALS

}
}
NOTE: notice I dont have any wait calls in between my loops for function calls (and I dont have any wait() inside those functions either).

EDIT: after posting and seeing the result I have to say... WOW what a colorfull post!

Last edited by Carlos3DGS; 11/02/11 13:03.

"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1