SharpDX 彩色点云

SharpDX colored PointCloud

我正在使用 SharpDX 渲染点云,使用以下代码:

PointsModel = new PointGeometryModel3D();
PointsModel.Geometry = new PointGeometry3D();

//create positions
PointsModel.Geometry.Positions = new Vector3Collection();
PointsModel.Geometry.Positions.AddRange(
            new SharpDX.Vector3[]
            { 
              new SharpDX.Vector3(0,0,0),
              new SharpDX.Vector3(10,0,0),
              new SharpDX.Vector3(0,10,0),
              new SharpDX.Vector3(0,0,10),
            });

//create colors
PointsModel.Geometry.Colors = new Color4Collection();
PointsModel.Geometry.Colors.AddRange(
            new SharpDX.Color4[]
            {
              new SharpDX.Color4(1f,0,0,1),
              new SharpDX.Color4(1f,0,0,1),
              new SharpDX.Color4(1f,0,0,1),
              new SharpDX.Color4(1f,0,0,1)
            });

//create indices
PointsModel.Geometry.Indices = new IntCollection();
PointsModel.Geometry.Indices.AddRange(
            new int[]
            {
              0,
              1,
              2,
              3
            });

 PointsModel.Figure = PointFigure.Rect;
 PointsModel.Size=new Size(10, 10);

并且在视图中:

<hx:Viewport3DX EffectsManager="{Binding EffectsManager1}" 
                Camera="{Binding Camera1}" BackgroundColor="#FF88AACD" 
                ZoomExtentsWhenLoaded="True">
    <hx:AmbientLight3D Color="#030303" />
    <hx:DirectionalLight3D Direction="{Binding Camera.LookDirection}" Color="White" />
    <hx:PointGeometryModel3D  Geometry="{Binding PointsModel.Geometry}" Size="{Binding PointsModel.Size}" Figure="{Binding PointsModel.Figure}">          
    </hx:PointGeometryModel3D>
  </hx:Viewport3DX>

我希望这些点具有单独的颜色,但我什至没有让它们变成红色。无论我如何设置颜色列表中的颜色值,这些点总是呈现黑色。 我错过了什么?

我通过将 PointGeometryModel3D 中的颜色设置为静态值解决了这个问题:

<hx:Viewport3DX EffectsManager="{Binding EffectsManager1}" 
            Camera="{Binding Camera1}" BackgroundColor="#FF88AACD" 
            ZoomExtentsWhenLoaded="True">
  <hx:AmbientLight3D Color="#030303" />
  <hx:DirectionalLight3D Direction="{Binding Camera.LookDirection}" Color="White" />
  <hx:PointGeometryModel3D  Geometry="{Binding PointsModel.Geometry}" 
      Size="{Binding PointsModel.Size}" 
      Figure="{Binding PointsModel.Figure}" 
      Color="{x:Static Colors.White}">          
  </hx:PointGeometryModel3D>
</hx:Viewport3DX>

但我不明白为什么这是必要的。

现在可以正确渲染点云,包括每个点的单独颜色。