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

2018-06-07 Thread Christian Buchner
Updating a mesh in real time could be done using some a displacement
mapping in a vertex shader. The height field can be then updated as a
texture.

The base mash would be essentially static and flat, but the z coordinate is
updated on the GPU based on texture input.

Christian




2018-06-04 19:33 GMT+02:00 Mike Raider :

> Hi,
>
> "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"
>
> I am just starting to develop a 3D app my usual domain is deep learning
> and searching.  I saw a demo of OSG using a simple terrain and thought I
> could turn my boring 2D app into a sexy 3D app.  I underestimated the
> effort involved.  I use linux named pipe message queue to send real time
> data from my java application to my osg application.  Once in osg I fill my
> terrain matrix as data is received.  The shifting of rows is to move data
> from front to back as data is received.  It works very well and much better
> than my old 2D user interface.
>
> I started this tread trying to solve a mesh problem and fixed that problem
> by cleaning my original data much better.  Now my terrain is looking very
> nice.  Thank you for your comments that made me stop and look at data again.
>
> Your comment 'this is not normally how one manages terrain'.  Probably,
> what approach would you suggest to build a 3d mesh that is filled in real
> time?  Can you point me to an example?
>
> ...
>
> Thank you!
>
> Cheers,
> Mike
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=73960#73960
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


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

2018-06-04 Thread Mike Raider
Hi,

"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"

I am just starting to develop a 3D app my usual domain is deep learning and 
searching.  I saw a demo of OSG using a simple terrain and thought I could turn 
my boring 2D app into a sexy 3D app.  I underestimated the effort involved.  I 
use linux named pipe message queue to send real time data from my java 
application to my osg application.  Once in osg I fill my terrain matrix as 
data is received.  The shifting of rows is to move data from front to back as 
data is received.  It works very well and much better than my old 2D user 
interface.

I started this tread trying to solve a mesh problem and fixed that problem by 
cleaning my original data much better.  Now my terrain is looking very nice.  
Thank you for your comments that made me stop and look at data again.

Your comment 'this is not normally how one manages terrain'.  Probably, what 
approach would you suggest to build a 3d mesh that is filled in real time?  Can 
you point me to an example?

... 

Thank you!

Cheers,
Mike

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=73960#73960





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


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

2018-06-04 Thread Robert Osfield
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  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@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


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

2018-06-03 Thread Mike Raider
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@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


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

2018-06-03 Thread Robert Osfield
Hi Mike,

You don't provide any details about how you've created the mesh,
whether you've loaded it from some loader, you've use some util from
the OSG or other 3rd party tool or done it by hand yourself.  Given we
know nothing about how you've created the mesh there isn't much can do
to help advice how to resolve the issues.

Robert.



On 3 June 2018 at 17:30, Mike Raider  wrote:
> Hi,
>
> I have a TriangleStrip mesh that I use for a simple data collection app to 
> show data changes in real time.
>
> Most of the time the mesh looks very clean and smooth.  However, sometimes 
> the triangles look like spikes and not smooth.  I do not understand why the 
> mesh is broken by the spikes.  Can you suggest a solution?  Also my mesh is 
> only 500 x 500 triangle, is there a better way to implement a mesh this size?
>
>
> ...
>
> Thank you!
>
> Cheers,
> Mike[/img]
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=73927#73927
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org