| | 1 | | // <copyright file="ObjMaterialColor.cs" company="Jérémy Ansel"> |
| | 2 | | // Copyright (c) 2017, 2019 Jérémy Ansel |
| | 3 | | // </copyright> |
| | 4 | | // <license> |
| | 5 | | // Licensed under the MIT license. See LICENSE.txt |
| | 6 | | // </license> |
| | 7 | |
|
| | 8 | | namespace JeremyAnsel.Media.WavefrontObj |
| | 9 | | { |
| | 10 | | [System.Diagnostics.DebuggerDisplay("{ToDebuggerDisplayString(),nq}")] |
| | 11 | | public class ObjMaterialColor |
| | 12 | | { |
| 252 | 13 | | public ObjMaterialColor() |
| | 14 | | { |
| 252 | 15 | | this.SpectralFactor = 1.0f; |
| 252 | 16 | | } |
| | 17 | |
|
| | 18 | | public ObjMaterialColor(float x, float y, float z) |
| 30 | 19 | | : this() |
| | 20 | | { |
| 30 | 21 | | this.Color = new ObjVector3(x, y, z); |
| 30 | 22 | | } |
| | 23 | |
|
| | 24 | | public ObjMaterialColor(string? spectralFileName) |
| 15 | 25 | | : this() |
| | 26 | | { |
| 15 | 27 | | this.SpectralFileName = spectralFileName; |
| 15 | 28 | | } |
| | 29 | |
|
| | 30 | | public ObjMaterialColor(string? spectralFileName, float factor) |
| 15 | 31 | | : this() |
| | 32 | | { |
| 15 | 33 | | this.SpectralFileName = spectralFileName; |
| 15 | 34 | | this.SpectralFactor = factor; |
| 15 | 35 | | } |
| | 36 | |
|
| 375 | 37 | | public ObjVector3 Color { get; set; } |
| | 38 | |
|
| 183 | 39 | | public bool UseXYZColorSpace { get; set; } |
| | 40 | |
|
| 345 | 41 | | public string? SpectralFileName { get; set; } |
| | 42 | |
|
| 366 | 43 | | public float SpectralFactor { get; set; } |
| | 44 | |
|
| | 45 | | public bool IsSpectral |
| | 46 | | { |
| | 47 | | get |
| | 48 | | { |
| 222 | 49 | | return !string.IsNullOrWhiteSpace(this.SpectralFileName); |
| | 50 | | } |
| | 51 | | } |
| | 52 | |
|
| | 53 | | public bool IsRGB |
| | 54 | | { |
| 54 | 55 | | get { return !this.IsSpectral && !this.UseXYZColorSpace; } |
| | 56 | | } |
| | 57 | |
|
| | 58 | | public bool IsXYZ |
| | 59 | | { |
| 54 | 60 | | get { return !this.IsSpectral && this.UseXYZColorSpace; } |
| | 61 | | } |
| | 62 | |
|
| | 63 | | private string ToDebuggerDisplayString() |
| | 64 | | { |
| 0 | 65 | | if (IsSpectral) return $"Spectral:{SpectralFileName} Factor:{SpectralFactor}"; |
| 0 | 66 | | if (UseXYZColorSpace) return $"X:{Color.X} Y:{Color.X} Z:{Color.X}"; |
| 0 | 67 | | return $"R:{Color.X} G:{Color.X} B:{Color.X}"; |
| | 68 | | } |
| | 69 | | } |
| | 70 | | } |
| | 71 | |
|