| | | 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 System.Globalization; |
| | | 9 | | |
| | | 10 | | namespace JeremyAnsel.Media.WavefrontObj; |
| | | 11 | | |
| | | 12 | | [System.Diagnostics.DebuggerDisplay("Vertex:{Vertex} Texture:{Texture} Normal:{Normal}")] |
| | | 13 | | [Equatable] |
| | | 14 | | public partial struct ObjTriplet |
| | | 15 | | { |
| | | 16 | | public ObjTriplet(int vertexIndex, int textureIndex, int normalIndex) |
| | | 17 | | { |
| | 3 | 18 | | Vertex = vertexIndex; |
| | 3 | 19 | | Texture = textureIndex; |
| | 3 | 20 | | Normal = normalIndex; |
| | 3 | 21 | | } |
| | | 22 | | |
| | | 23 | | public int Vertex { get; set; } |
| | | 24 | | |
| | | 25 | | public int Texture { get; set; } |
| | | 26 | | |
| | | 27 | | public int Normal { get; set; } |
| | | 28 | | |
| | | 29 | | public readonly override string ToString() |
| | | 30 | | { |
| | 3 | 31 | | if (Normal == 0) |
| | | 32 | | { |
| | 3 | 33 | | if (Texture == 0) |
| | | 34 | | { |
| | 3 | 35 | | return Vertex.ToString(CultureInfo.InvariantCulture); |
| | | 36 | | } |
| | | 37 | | |
| | 3 | 38 | | return string.Concat( |
| | 3 | 39 | | Vertex.ToString(CultureInfo.InvariantCulture), |
| | 3 | 40 | | "/", |
| | 3 | 41 | | Texture.ToString(CultureInfo.InvariantCulture)); |
| | | 42 | | } |
| | | 43 | | |
| | 3 | 44 | | if (Texture == 0) |
| | | 45 | | { |
| | 3 | 46 | | return string.Concat( |
| | 3 | 47 | | Vertex.ToString(CultureInfo.InvariantCulture), |
| | 3 | 48 | | "//", |
| | 3 | 49 | | Normal.ToString(CultureInfo.InvariantCulture)); |
| | | 50 | | } |
| | | 51 | | |
| | 3 | 52 | | return string.Concat( |
| | 3 | 53 | | Vertex.ToString(CultureInfo.InvariantCulture), |
| | 3 | 54 | | "/", |
| | 3 | 55 | | Texture.ToString(CultureInfo.InvariantCulture), |
| | 3 | 56 | | "/", |
| | 3 | 57 | | Normal.ToString(CultureInfo.InvariantCulture)); |
| | | 58 | | } |
| | | 59 | | } |