3D point cloud viewer, 3Dgrid and mesh

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
kapricheski
Posts: 3
Joined: Sat Aug 09, 2014 6:19 am

3D point cloud viewer, 3Dgrid and mesh

Post by kapricheski » Mon Aug 11, 2014 2:14 pm

Hi,
I am new in this and have three questions concerning 3D point cloud viewer, 3D grid and mesh.
1. Any ideas how can I color the point cloud by y axis? I found that option for coloring the 3D grid using palette and that worked well, but it seems that cannot be used in a same way if I use pls1.PointsOptimization = PointsRenderOptimization3D.Pixels;
2. I have problems to show the point cloud data as 3D mesh. It looks strange in the viewer, I guess because the order of the points is not in a way that the triangles are connected properly. Here is the code:
private void CreateMeshSeries()
{
SurfaceMeshSeries3D mesh = new SurfaceMeshSeries3D(m_chart.View3D, Axis3DBinding.Primary,
Axis3DBinding.Primary, Axis3DBinding.Primary);

mesh.ContourPalette = CreatePalette(mesh);
mesh.WireframeType = SurfaceWireframeType.None;
mesh.InitialValue = 0;
mesh.FadeAway = 0;
//mesh.SetSize(500, 500);
//mesh.WireframeType = (SurfaceWireframeType)2;
mesh.DrawWireframeThrough = false;
mesh.WireframeLineStyle.Width = 1;
mesh.WireframeLineStyle.Color = Color.Red;
mesh.ContourLineType = ContourLineType.PalettedLine;
mesh.Fill = SurfaceFillStyle.Paletted;
mesh.ColorSaturation = 0;
m_chart.View3D.SurfaceMeshSeries3D.Add(mesh);

m_mesh = mesh;
SurfacePoint[,] gridValueTable = new SurfacePoint[500, 500];
//m_mesh.Data;
int pointsIndex = 0;
for (int iRow = 0; iRow < 500; iRow++)
{
for (int iCol = 0; iCol < 500; iCol++)
{
if (pointsIndex < points.Length)
{
gridValueTable[iCol, iRow].X = points[pointsIndex].X;
gridValueTable[iCol, iRow].Z = points[pointsIndex].Z;
gridValueTable[iCol, iRow].Y = points[pointsIndex].Y;
pointsIndex++;
}
else
{
iRow = 500;
iCol = 500;
}
}
}


m_mesh.Data = gridValueTable;
}

3. How can I get rid of the empty (value 0) cells and not show them in the viewer? Now I can see the data, but I can also see the 0 values on the edges.
3D Grid.jpg
3D Grid.jpg (153.42 KiB) Viewed 14262 times
Thanks

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: 3D point cloud viewer, 3Dgrid and mesh

Post by ArctionPasi » Mon Aug 11, 2014 8:45 pm

Hi,

I'll split the answers to several replies...

1. PointLineSeries3D doesn't have a possibility to color by value-range palette directly. You can use SurfaceMeshSeries3D for that, with WireframeType = DotsPaletted, and with no fill and no contour lines:

Code: Select all

//Add 3D surface grid
            SurfaceMeshSeries3D series = new SurfaceMeshSeries3D(m_chart.View3D, Axis3DBinding.Primary, Axis3DBinding.Primary, Axis3DBinding.Primary);
            m_chart.View3D.SurfaceMeshSeries3D.Add(series);

            //Make some random points 
            int PointCount = 100000; 
            Random rand = new Random();
            SurfacePoint[] points = new SurfacePoint[PointCount];

            for (int i = 0; i < PointCount; i++)
            {
                points[i].X = 30 + rand.NextDouble() * 60.0;
                points[i].Y = rand.NextDouble() * 100;
                points[i].Z = 30 + rand.NextDouble() * 60.0;
 
            }



            //Set mesh size as column and row count. It must be a series of at least 2x2 size. 
            int iRowCount = 10;
            int iColumnCount = PointCount / iRowCount;


            SurfacePoint[,] seriesData = new SurfacePoint[iColumnCount, iRowCount]; 
            //Store the 1D array data in 2D array 

            for (int i = 0; i < PointCount; i++)
            {
                int iRow = i / iColumnCount;
                int iCol = i % iColumnCount;
                seriesData[iCol, iRow] = points[i]; 
            }

            series.Data = seriesData;

            series.WireframeType = SurfaceWireframeType.DotsPaletted;
            series.ContourLineType = ContourLineType.None;
            series.SuppressLighting = true;
            series.ColorSaturation = 100; 
            series.Fill = SurfaceFillStyle.None; 
3D scatter points with palette coloring. See ContourPalette property of surfaceMeshSeries3D
3D scatter points with palette coloring. See ContourPalette property of surfaceMeshSeries3D
ScatterPoints3DwithPaletteColoring.jpg (160.37 KiB) Viewed 14256 times
Is this good? :geek:
LightningChart Support Team, PT

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: 3D point cloud viewer, 3Dgrid and mesh

Post by ArctionPasi » Mon Aug 11, 2014 8:57 pm

2. The data is probably just in wrong order. The order must be so that they form adjacent nodes, like here:
Mesh nodes
Mesh nodes
mesh.jpg (22.04 KiB) Viewed 14256 times
LightningChart Support Team, PT

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: 3D point cloud viewer, 3Dgrid and mesh

Post by ArctionPasi » Mon Aug 11, 2014 9:02 pm

3. The trash you are seeing there with 0 values is called Z fighting, the bottom plane hits the same depth buffer coordinate than surface.

You can set "empty" values to e.g. -100, ensure it's less than Y axis minimum. Set View3D.ClipContents = True, and it will make a sharp cut on axis range edges.
LightningChart Support Team, PT

kapricheski
Posts: 3
Joined: Sat Aug 09, 2014 6:19 am

Re: 3D point cloud viewer, 3Dgrid and mesh

Post by kapricheski » Thu Aug 14, 2014 1:07 pm

Hi,
Thanks for the reply it was really helpful. I still have one problem to change the values for the palette of colors. I always get from 0 to 100 if I color the points using mesh as you explained. Can you please explain how can I set that using maximum and minimum custom values.
Cheers

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: 3D point cloud viewer, 3Dgrid and mesh

Post by ArctionPasi » Thu Aug 14, 2014 8:16 pm

Nice to know it helped. :P

Code: Select all

  series.ContourPalette.Steps.Clear();//Clear existing steps 
            series.ContourPalette.Steps.Add(new PaletteStep(series.ContourPalette, Color.Red, 30)); //Add step1
            series.ContourPalette.Steps.Add(new PaletteStep(series.ContourPalette, Color.Yellow, 50)); //Add step2
            series.ContourPalette.Steps.Add(new PaletteStep(series.ContourPalette, Color.Lime, 150)); //Add step3
            series.ContourPalette.MinValue = 0; //this is the minimum value you see in the legend box.
            series.ContourPalette.Type = PaletteType.Uniform; //Sharp transition, not gradient 
Then it looks like
Uniform palette with 3 steps.
Uniform palette with 3 steps.
dotsWithUniformPalette.jpg (159.16 KiB) Viewed 14168 times
LightningChart Support Team, PT

kapricheski
Posts: 3
Joined: Sat Aug 09, 2014 6:19 am

Re: 3D point cloud viewer, 3Dgrid and mesh

Post by kapricheski » Mon Aug 18, 2014 3:55 pm

Thanks again for the quick reply. It might be too much but I have one more question concerning the size of the points :)
At the moment I use pixeloptimization to set the point to 1 pixel. This looks good in the 3D viewer if I have huge number of points, but if the density is not so high then the points are difficult to see in the viewer. Is there any option to increase the point size to 2 or more pixels?
Thanks again

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: 3D point cloud viewer, 3Dgrid and mesh

Post by ArctionPasi » Tue Aug 19, 2014 1:31 pm

With 'pixeloptimization', are you referring to View3D.PointLineSeries3D[0].PointsOptimization = Pixels?

Surface series don't have that optimization. Surface has WireframeType, and you can select DotsPaletted there. They render unfortunately in one pixel size, and there's properties to change that.

When you don't have many points, please use PointLineSeries3D, and set PointsOptimization = None. Then set PointStyle.Shape = Box. Like that, you get bigger points there. Note however that this approach is heavy, and shouldn't be used with large point counts because it needs a lot of memory and GPU power to update smoothly. Set LineVisible = false, and PointsVisible = true.

Each PointLineSeries can have only one color. To use several colors, spawn several series. To color by Y value (value-range palette), use surface.ContourPalette.GetColorByValue() and apply that color to pointLineSeries3D.Material.DiffuseColor.
LightningChart Support Team, PT

Post Reply