How to plot 3D colored points with Helix toolkit

…衆ロ難τιáo~ 提交于 2019-12-23 23:40:20

问题


I create a simple 3D viewer with Helix toolkit.

I want to plot 3D points which is colored.

I referred to the sample project "SimpleDemo" which is contained in the Example folder (HelixToolkit.Wpf.SharpDX).

This is my XAML:

<hx:PointGeometryModel3D x:Name="points" 
         Geometry="{Binding Points}" 
         Transform="{Binding Model1Transform}" 
         Color="{x:Static sdx:Color.White}" />

And drawing core is below.

        var points = new PointGeometry3D();
        var col = new Color4Collection();
        var ptPos = new Vector3Collection();
        var ptIdx = new IntCollection();

        for(int y = 0; y < height; y++) {
            for(int x = 0; x < width; x++) {
                if(depth[y * width + x] < 1000 && depth[y * width + x] > 0) {
                    ptIdx.Add(ptPos.Count);
                    ptPos.Add(new Vector3(x, height - y, (-depth[y * width + x] / 3.0f) + 800));
                    col.Add(rnd.NextColor().ToColor4());
                }
            }
        }

        points.Positions = ptPos;
        points.Indices = ptIdx;
        points.Colors = col;
        Points = points;

This program, Some cases are good work.(ex. deal with 200 x 200 points). But other case are not good (ex. deal with 500 x 300 points)

It can draw 3D point which is not colored (black).

Why does it not work properly?

Comments:

  • A good work image (colored):

  • A not good work image (not colored):

来源:https://stackoverflow.com/questions/28334282/how-to-plot-3d-colored-points-with-helix-toolkit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!