| | 1 | | // <copyright file="ObjVector3.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 | |
|
| | 10 | | namespace JeremyAnsel.Media.WavefrontObj |
| | 11 | | { |
| | 12 | | [System.Diagnostics.DebuggerDisplay("{X} {Y} {Z}")] |
| | 13 | | [Equatable] |
| | 14 | | public partial struct ObjVector3 |
| | 15 | | { |
| | 16 | | private float x; |
| | 17 | |
|
| | 18 | | private float y; |
| | 19 | |
|
| | 20 | | private float z; |
| | 21 | |
|
| | 22 | | public ObjVector3(System.Numerics.Vector3 v) |
| | 23 | | { |
| 4 | 24 | | this.x = v.X; |
| 4 | 25 | | this.y = v.Y; |
| 4 | 26 | | this.z = v.Z; |
| 4 | 27 | | } |
| | 28 | |
|
| | 29 | | public ObjVector3(System.Numerics.Vector2 v, float z = 1.0f) |
| | 30 | | { |
| 4 | 31 | | this.x = v.X; |
| 4 | 32 | | this.y = v.Y; |
| 4 | 33 | | this.z = z; |
| 4 | 34 | | } |
| | 35 | |
|
| | 36 | | public ObjVector3(float x, float y, float z) |
| | 37 | | { |
| 2470 | 38 | | this.x = x; |
| 2470 | 39 | | this.y = y; |
| 2470 | 40 | | this.z = z; |
| 2470 | 41 | | } |
| | 42 | |
|
| | 43 | | public ObjVector3(float x, float y) |
| | 44 | | { |
| 4 | 45 | | this.x = x; |
| 4 | 46 | | this.y = y; |
| 4 | 47 | | this.z = 1.0f; |
| 4 | 48 | | } |
| | 49 | |
|
| | 50 | | public ObjVector3(float x) |
| | 51 | | { |
| 4 | 52 | | this.x = x; |
| 4 | 53 | | this.y = 0.0f; |
| 4 | 54 | | this.z = 1.0f; |
| 4 | 55 | | } |
| | 56 | |
|
| | 57 | | public float X |
| | 58 | | { |
| 1028 | 59 | | readonly get { return this.x; } |
| 1000 | 60 | | set { this.x = value; } |
| | 61 | | } |
| | 62 | |
|
| | 63 | | public float Y |
| | 64 | | { |
| 852 | 65 | | readonly get { return this.y; } |
| 856 | 66 | | set { this.y = value; } |
| | 67 | | } |
| | 68 | |
|
| | 69 | | public float Z |
| | 70 | | { |
| 868 | 71 | | readonly get { return this.z; } |
| 832 | 72 | | set { this.z = value; } |
| | 73 | | } |
| | 74 | |
|
| | 75 | | public static implicit operator ObjVector3(System.Numerics.Vector3 v) |
| | 76 | | { |
| 4 | 77 | | return new ObjVector3(v); |
| | 78 | | } |
| | 79 | |
|
| | 80 | | public readonly void Deconstruct(out float @x, out float @y, out float @z) |
| | 81 | | { |
| 4 | 82 | | @x = this.x; |
| 4 | 83 | | @y = this.y; |
| 4 | 84 | | @z = this.z; |
| 4 | 85 | | } |
| | 86 | |
|
| | 87 | | public readonly System.Numerics.Vector3 ToVector3() |
| | 88 | | { |
| 4 | 89 | | return new System.Numerics.Vector3(x, y, z); |
| | 90 | | } |
| | 91 | | } |
| | 92 | | } |
| | 93 | |
|