Transparent without colour problem

May 1, 2013 at 11:42 AM
Edited May 1, 2013 at 11:45 AM
Hi
I am new to Helix and trying to create a simple box with transparent at run time with C#. I can see the box showing with transparency but there is no colour on the box. I dont know if i did anything wrong in my small piece of code:
        Objects = new ObservableCollection<Visual3D>();
        Objects.Add(new GridLinesVisual3D());
        var color = Color.FromArgb(0x80, Colors.Red.R, Colors.Red.G, Colors.Red.B);

        var b = new BoxVisual3D()
            {
                Width = 10,
                Length = 10,
                Height = 10,

            };

        var brush = new SolidColorBrush();
        brush.Color = color;
        b.Fill = brush;
        Objects.Add(b);

Thank you very much in advance.
Best regards
May 8, 2013 at 2:37 PM
  1. Did you add lights to your model?
  2. I checked the BoxVisual3D class with
<ht:BoxVisual3D Width="10" Height="10" Length="10" Fill="#80FF0000"/>
and this works fine

Note that you cannot get 100% correct visualization of transparency for a box in WPF...

You could also use the ChangeAlpha extension method: b.Fill = new SolidColorBrush(Colors.Red.ChangeAlpha(0x80))