[osg-users] TriangleStrip mesh is not smooth...

Robert Osfield robert.osfield at gmail.com
Mon Jun 4 01:27:18 PDT 2018


Hi Mike,

You "kind of" specify how you are setting the vertex data but make no
mention of the way you pass this data to the OSG, or how you set up
your primitive data.  What you have told us doesn't really tell us how
you are building the mesh, just hints about part of what you are
doing.

As a general comment, it kinds seems like an odd thing that are doing,
shifting and replacing rows for some reason is not normally how one
manages terrain.   Could you take a step back and explain what you are
trying to achieve in your application w.r.t terrain, and why you have
adopted the approach you have.  I ask this as it may well be that you
are trying to solve the problem in completely the wrong way.  As I
don't know what you actually trying to achieve I can't provide any
guidance on this.

Cheers,
Robert.

On 3 June 2018 at 18:36, Mike Raider <miketimmons at gmail.com> wrote:
> 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
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


More information about the osg-users mailing list