4

How can I make a specific 3d model transparent? Is it as simple as changing the opacity of the model's material?

I tried the following:

SolidColorBrush br = (SolidColorBrush)matDif.Brush; //matDif = DiffuseMaterial
br.Opacity = 0.3;

When it tries setting the opacity it says that it is in a read-only state and cannot be changed?

skaffman
  • 398,947
  • 96
  • 818
  • 769
user159419
  • 71
  • 1
  • 4

2 Answers2

2

Try

        Color c = new Color();
        c.A = 128;
        c.R = Colors.PeachPuff.R;
        c.G = Colors.PeachPuff.G;
        c.B = Colors.PeachPuff.B;
        Material Material = new DiffuseMaterial(new SolidColorBrush(c));

works for me

Paul Rivera
  • 525
  • 1
  • 8
  • 20
1

On this page (which admittedly is XAML rather than C# it has the following:

<GeometryModel3D.Material>
    <DiffuseMaterial Brush="#8000FFFF" />
</GeometryModel3D.Material>

<GeometryModel3D.BackMaterial>
    <DiffuseMaterial Brush="#80FF0000" />
</GeometryModel3D.BackMaterial>

So it looks like you just set the Brush to an ARGB colour.

This thread on social.msdn has some interesting looking links. I haven't looked at them all, but some of them might be useful.

ChrisF
  • 134,786
  • 31
  • 255
  • 325