I am using SharpDX to render a point cloud, using the following code:
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);
And in the view:
<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>
I want the points to have individual colors, but I don't even get them to be red. No matter how I set the color values in the colors list, the points are always rendered black. What am I missing?
I solved it by setting the color in the PointGeometryModel3D to a static value:
<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>
But I don't understand why this is necessary.
The point cloud is now rendered correctly including the individual colors per point.