【问题标题】:Apply color for each and every point in PointCloud Using HelixToolkit使用 HelixToolkit 为 PointCloud 中的每个点应用颜色
【发布时间】:2015-02-20 12:30:30
【问题描述】:

我在 HelixToolKit 中创建了一个点云。我需要为每个点应用颜色。当我使用 PointVisual3D 时,没有为每个点设置颜色的选项。它为整个点云设置颜色。 当我在 Helix 工具包中使用 PointGeometryModel3D(使用 SharpDX)时,我也无法为每个点设置颜色。可以为 Point Cloud 中的每个点设置颜色。

谢谢...

【问题讨论】:

  • 您找到解决方案了吗? TheTrasher 提出的代码对我不起作用(黑点)。由于您已将其标记为已接受的答案,您能解释一下您是如何使其工作的吗?

标签: c# sharpdx point-clouds helix-3d-toolkit helix


【解决方案1】:

通常,这是通过在 PointGeometryModel3D 的 PointGeometry3D 对象中设置 Colors 属性来完成的。您必须自己构建几何体。

  1. 创建渲染位置
  2. 创建颜色
  3. 告诉渲染器你的位置和颜色的顺序(在位置/颜色中列出索引)

           //create PointGeometryModel3D object
        PointGeometryModel3D pgm = new PointGeometryModel3D();
    
        //create positions
        pgm.Geometry.Positions = new HelixToolkit.Wpf.SharpDX.Core.Vector3Collection();
    
        pgm.Geometry.Positions.AddRange(
            new SharpDX.Vector3[]
            {   new SharpDX.Vector3(0,1,2), 
                new SharpDX.Vector3(1,2,3), 
                new SharpDX.Vector3(3,2,3), 
            });
    
        //create colors
        pgm.Geometry.Colors = new HelixToolkit.Wpf.SharpDX.Core.Color4Collection();
    
        pgm.Geometry.Colors.AddRange(
            new SharpDX.Color4[]
            {   
                new SharpDX.Color4(1f,0,0,1), 
                new SharpDX.Color4(0,1f,0,1), 
                new SharpDX.Color4(0,0,1f,1) 
            });
    
        //create indices
        pgm.Geometry.Indices = new HelixToolkit.Wpf.SharpDX.Core.IntCollection();
    
        pgm.Geometry.Indices.AddRange(
            new int[]
            {   
                0,
                1,
                2,
            });
    

如果它对你有用,请告诉我。我无法使用 LineGeometry3D 和不同的线条颜色。必须有一个选项可以让渲染器使用 Color 顶点而不是(单一)颜色属性。

【讨论】:

    猜你喜欢
    • 2015-05-14
    • 1970-01-01
    • 2019-07-06
    • 2022-01-24
    • 2017-06-08
    • 1970-01-01
    • 2017-02-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多