2

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):

Good

  • A not good work image (not colored):

Bad

Emond
  • 50,210
  • 11
  • 84
  • 115
kazuoni
  • 21
  • 1
  • 4
  • Can you post images or further description of "good" and "not good'? I don't quite understand the explanation above. – NextInLine Feb 05 '15 at 04:07
  • Thank you for your comments. Add images. I found the other case. During good work, if I move window, it turns not good work... Of course, points position is updated. but points color is only black. – kazuoni Feb 05 '15 at 05:23
  • I don't see something obviously wrong in the snippet above, but I have a couple of thoughts on debugging this. (1) Use a single color, like red. Do you see that color? (2) Are good cases all where `width == height` (200x200, 300x300, etc)? If so, your width and height variables might be mixed up. (3) Are good cases all where `width * height <= C` (100x400 works, and 400x100 works, but 400x400 does not)? If so, then you have some issue related to your total size. I'm not familiar with Helix, only SharpDX, so my comments are based on that experience. – NextInLine Feb 05 '15 at 14:57
  • Many many thanks. (1) Just as you say, the way using only one color like red is available! (2, 3) Sorry for not explaining enough... Points number changes constantly because there is the depth condition (0 < depth < 1000). Depth points update every frame (device is kinect). – kazuoni Feb 06 '15 at 01:06
  • So if you use a color like red, then your first and second images are both red instead of black? If so, then `rnd.NextColor().ToColor4()` isn't working as you expect it to. – NextInLine Feb 06 '15 at 16:44
  • ohh... Just as you say, [ rnd.NextColor().ToColor4() ] is not working... I can not understand these workings...OK. I will change a method which changes point color ! Thank you very much !!! – kazuoni Feb 07 '15 at 01:39
  • 2
    Have you found the solution for this? I'm experimenting a similar issue (black points). – Sturm Oct 21 '15 at 21:30

0 Answers0