| | 1 | | // <copyright file="ObjVector4.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} {W}")] |
| | 13 | | [Equatable] |
| | 14 | | public partial struct ObjVector4 |
| | 15 | | { |
| | 16 | | private float x; |
| | 17 | |
|
| | 18 | | private float y; |
| | 19 | |
|
| | 20 | | private float z; |
| | 21 | |
|
| | 22 | | private float w; |
| | 23 | |
|
| | 24 | | public ObjVector4(System.Numerics.Vector4 v) |
| | 25 | | { |
| 4 | 26 | | this.x = v.X; |
| 4 | 27 | | this.y = v.Y; |
| 4 | 28 | | this.z = v.Z; |
| 4 | 29 | | this.w = v.W; |
| 4 | 30 | | } |
| | 31 | |
|
| | 32 | | public ObjVector4(System.Numerics.Vector3 v, float w = 1.0f) |
| | 33 | | { |
| 4 | 34 | | this.x = v.X; |
| 4 | 35 | | this.y = v.Y; |
| 4 | 36 | | this.z = v.Z; |
| 4 | 37 | | this.w = w; |
| 4 | 38 | | } |
| | 39 | |
|
| | 40 | | public ObjVector4(float x, float y, float z, float w) |
| | 41 | | { |
| 880 | 42 | | this.x = x; |
| 880 | 43 | | this.y = y; |
| 880 | 44 | | this.z = z; |
| 880 | 45 | | this.w = w; |
| 880 | 46 | | } |
| | 47 | |
|
| | 48 | | public ObjVector4(float x, float y, float z) |
| | 49 | | { |
| 4 | 50 | | this.x = x; |
| 4 | 51 | | this.y = y; |
| 4 | 52 | | this.z = z; |
| 4 | 53 | | this.w = 1.0f; |
| 4 | 54 | | } |
| | 55 | |
|
| | 56 | | public float X |
| | 57 | | { |
| 668 | 58 | | readonly get { return this.x; } |
| 8 | 59 | | set { this.x = value; } |
| | 60 | | } |
| | 61 | |
|
| | 62 | | public float Y |
| | 63 | | { |
| 492 | 64 | | readonly get { return this.y; } |
| 8 | 65 | | set { this.y = value; } |
| | 66 | | } |
| | 67 | |
|
| | 68 | | public float Z |
| | 69 | | { |
| 492 | 70 | | readonly get { return this.z; } |
| 8 | 71 | | set { this.z = value; } |
| | 72 | | } |
| | 73 | |
|
| | 74 | | public float W |
| | 75 | | { |
| 492 | 76 | | readonly get { return this.w; } |
| 8 | 77 | | set { this.w = value; } |
| | 78 | | } |
| | 79 | |
|
| | 80 | | public static implicit operator ObjVector4(System.Numerics.Vector4 v) |
| | 81 | | { |
| 4 | 82 | | return new ObjVector4(v); |
| | 83 | | } |
| | 84 | |
|
| | 85 | | public readonly void Deconstruct(out float @x, out float @y, out float @z, out float @w) |
| | 86 | | { |
| 4 | 87 | | @x = this.x; |
| 4 | 88 | | @y = this.y; |
| 4 | 89 | | @z = this.z; |
| 4 | 90 | | @w = this.w; |
| 4 | 91 | | } |
| | 92 | |
|
| | 93 | | public readonly System.Numerics.Vector4 ToVector4() |
| | 94 | | { |
| 4 | 95 | | return new System.Numerics.Vector4(x, y, z, w); |
| | 96 | | } |
| | 97 | | } |
| | 98 | | } |
| | 99 | |
|