[osg-users] TriangleStrip mesh is not smooth...
Mike Raider
miketimmons at gmail.com
Sun Jun 3 10:36:26 PDT 2018
Hi,
Thank you Robert...
Here is how I create the mesh:
float column_x_loc = -(LAND_WIDTH * LAND_TRIANGLE_WIDTH)/2;
float column_z_loc = -(LAND_DEPTH * LAND_TRIANGLE_DEPTH)/2
float column_y_loc = DETAIL_TERRAIN_FLOOR;
for (int c = 0;c < LAND_WIDTH;c++)
{
for (int r = 0; r < LAND_DEPTH;r++)
{
(*terrain)[thisIndex][0] = column_x_loc;
(*terrain)[thisIndex][1] = column_z_loc;
(*terrain)[thisIndex][2] = column_y_loc;
(*terrain_colors)[thisIndex][0] = 46.0f/256.0f;
(*terrain_colors)[thisIndex][1] = 76.0f/256.0f;
(*terrain_colors)[thisIndex][2] = 100.0f/256.0f;
(*terrain_colors)[thisIndex][3] = 0.3f;
column_z_loc += LAND_TRIANGLE_DEPTH;
thisIndex++;
}
}
On an update I move all of the rows back one and replace the 1 row with new data.
I use a transparent_weight value to have older data disappear as it is updated.
float transparent_weight = 1.0;
float transparent_adjustment = 0.02;
for (int r = 0; r < LAND_DEPTH - 1; r++)
{
transparent_weight = 0.1;
for (int c = 1;c < 50; c++)
{
col_index = (c * LAND_WIDTH);
(*terrain)[col_index + r][2] = (*terrain)[col_index + r + LAND_WIDTH][2];
(*terrain_colors)[col_index + r][0] = (*terrain_colors)[col_index + r + LAND_WIDTH][0];
(*terrain_colors)[col_index + r][1] = (*terrain_colors)[col_index + r + LAND_WIDTH][1];
(*terrain_colors)[col_index + r][2] = (*terrain_colors)[col_index + r + LAND_WIDTH][2];
(*terrain_colors)[col_index + r][3] = transparent_weight;//(*terrain_colors)[col_index + r + LAND_WIDTH][3];
transparent_weight += transparent_adjustment;
}
}
The data at the first row is always smooth. I get missing triangles only in the middle or rear of the terrain.
Any suggestions are welcome. I have the program working the way I want if I can get this mesh problem solved.
Thank you again!
Cheers,
Mike
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=73930#73930
More information about the osg-users
mailing list