private void InitialiseStyles() { //set sensible defaults AmbientColour = new RgbaColour(0, 0, 0, 1); DiffuseColour = new RgbaColour(0, 0, 0, 1); SpecularColour = new RgbaColour(0, 0, 0, 1); EmissiveColour = new RgbaColour(0, 0, 0, 1); SpecularShininess = 0f; if (_surfaceStyle != null) { ((INotifyPropertyChanged)_surfaceStyle).PropertyChanged += SurfaceStyle_PropertyChanged; foreach (var surfaceStyle in _surfaceStyle.Styles) { var shading = surfaceStyle as IIfcSurfaceStyleShading; var rendering = surfaceStyle as IIfcSurfaceStyleRendering; if (rendering != null) { AmbientColour = new RgbaColour(rendering.SurfaceColour, rendering.Transparency); if (rendering.DiffuseColour != null) { var diffuseColour = rendering.DiffuseColour as IIfcColourRgb; if (diffuseColour != null) { DiffuseColour = new RgbaColour(diffuseColour, rendering.Transparency); } else { DiffuseColour = AmbientColour * (IfcNormalisedRatioMeasure)rendering.DiffuseColour; } } else { DiffuseColour = AmbientColour; } if (rendering.SpecularColour != null) { var specularColour = rendering.SpecularColour as IIfcColourRgb; if (specularColour != null) { SpecularColour = new RgbaColour(specularColour, rendering.Transparency); } else { SpecularColour = AmbientColour * (IfcNormalisedRatioMeasure)rendering.SpecularColour; } } if (rendering.SpecularHighlight is IfcSpecularExponent) { SpecularShininess = (IfcSpecularExponent)rendering.SpecularHighlight; } else { SpecularShininess = 0; } } else if (shading != null) { AmbientColour = new RgbaColour(shading.SurfaceColour, shading.Transparency); } else if (surfaceStyle is IIfcSurfaceStyleLighting) { //TODO implement this function } else if (surfaceStyle is IIfcSurfaceStyleWithTextures) { //TODO implement this function } else if (surfaceStyle is IIfcExternallyDefinedSurfaceStyle) { //TODO implement this function } else if (surfaceStyle is IIfcSurfaceStyleRefraction) { //TODO implement this function } } } }
static RgbaColour() { Empty = new RgbaColour(); }