| | | 1 | | // <copyright file="ObjTriplet.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 | | using Equatable.Attributes; |
| | | 9 | | using System.Globalization; |
| | | 10 | | |
| | | 11 | | namespace JeremyAnsel.Media.WavefrontObj |
| | | 12 | | { |
| | | 13 | | [System.Diagnostics.DebuggerDisplay("Vertex:{vertex} Texture:{texture} Normal:{normal}")] |
| | | 14 | | [Equatable] |
| | | 15 | | public partial struct ObjTriplet |
| | | 16 | | { |
| | | 17 | | private int vertex; |
| | | 18 | | |
| | | 19 | | private int texture; |
| | | 20 | | |
| | | 21 | | private int normal; |
| | | 22 | | |
| | | 23 | | public ObjTriplet(int vertexIndex, int textureIndex, int normalIndex) |
| | | 24 | | { |
| | 488 | 25 | | this.vertex = vertexIndex; |
| | 488 | 26 | | this.texture = textureIndex; |
| | 488 | 27 | | this.normal = normalIndex; |
| | 488 | 28 | | } |
| | | 29 | | |
| | | 30 | | public int Vertex |
| | | 31 | | { |
| | 520 | 32 | | readonly get { return this.vertex; } |
| | 8 | 33 | | set { this.vertex = value; } |
| | | 34 | | } |
| | | 35 | | |
| | | 36 | | public int Texture |
| | | 37 | | { |
| | 296 | 38 | | readonly get { return this.texture; } |
| | 8 | 39 | | set { this.texture = value; } |
| | | 40 | | } |
| | | 41 | | |
| | | 42 | | public int Normal |
| | | 43 | | { |
| | 296 | 44 | | readonly get { return this.normal; } |
| | 8 | 45 | | set { this.normal = value; } |
| | | 46 | | } |
| | | 47 | | |
| | | 48 | | public readonly override string ToString() |
| | | 49 | | { |
| | 172 | 50 | | if (this.Normal == 0) |
| | | 51 | | { |
| | 164 | 52 | | if (this.Texture == 0) |
| | | 53 | | { |
| | 160 | 54 | | return this.Vertex.ToString(CultureInfo.InvariantCulture); |
| | | 55 | | } |
| | | 56 | | else |
| | | 57 | | { |
| | 4 | 58 | | return string.Concat( |
| | 4 | 59 | | this.Vertex.ToString(CultureInfo.InvariantCulture), |
| | 4 | 60 | | "/", |
| | 4 | 61 | | this.Texture.ToString(CultureInfo.InvariantCulture)); |
| | | 62 | | } |
| | | 63 | | } |
| | | 64 | | else |
| | | 65 | | { |
| | 8 | 66 | | if (this.Texture == 0) |
| | | 67 | | { |
| | 4 | 68 | | return string.Concat( |
| | 4 | 69 | | this.Vertex.ToString(CultureInfo.InvariantCulture), |
| | 4 | 70 | | "//", |
| | 4 | 71 | | this.Normal.ToString(CultureInfo.InvariantCulture)); |
| | | 72 | | } |
| | | 73 | | else |
| | | 74 | | { |
| | 4 | 75 | | return string.Concat( |
| | 4 | 76 | | this.Vertex.ToString(CultureInfo.InvariantCulture), |
| | 4 | 77 | | "/", |
| | 4 | 78 | | this.Texture.ToString(CultureInfo.InvariantCulture), |
| | 4 | 79 | | "/", |
| | 4 | 80 | | this.Normal.ToString(CultureInfo.InvariantCulture)); |
| | | 81 | | } |
| | | 82 | | } |
| | | 83 | | } |
| | | 84 | | } |
| | | 85 | | } |
| | | 86 | | |