diff options
Diffstat (limited to 'src/ExtensionMethods.cs')
| -rw-r--r-- | src/ExtensionMethods.cs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/ExtensionMethods.cs b/src/ExtensionMethods.cs new file mode 100644 index 0000000..d240078 --- /dev/null +++ b/src/ExtensionMethods.cs @@ -0,0 +1,19 @@ +using System.Numerics; + +namespace vkChess +{ + public static class ExtensionMethods { + public static Vector3 ParseVec3 (string str) { + if (string.IsNullOrEmpty (str)) + return new Vector3(); + string[] components = str.Substring(1, str.Length - 2).Split (','); + if (components.Length != 3) + throw new System.Exception ("Vector3 Parse Error, expecting 3 components."); + return new Vector3( + float.Parse (components[0]), + float.Parse (components[1]), + float.Parse (components[2]) + ); + } + } +}
\ No newline at end of file |