private void TestToStringResults(Vec3F o, string s, string listSeparator, string decimalSeparator) { string[] results = s.Split(new[] { listSeparator }, StringSplitOptions.RemoveEmptyEntries); Assert.AreEqual(results.Length, 3); foreach (string oneFloatString in results) { Assert.True(oneFloatString.Contains(decimalSeparator)); } Assert.AreEqual(float.Parse(results[0]), o.X); Assert.AreEqual(float.Parse(results[1]), o.Y); Assert.AreEqual(float.Parse(results[2]), o.Z); Vec3F roundTrip = Vec3F.Parse(s); Assert.AreEqual(roundTrip.X, o.X); Assert.AreEqual(roundTrip.Y, o.Y); Assert.AreEqual(roundTrip.Z, o.Z); }
/// <summary> /// Sets this cammera's state completely. Complements GetState().</summary> /// <param name="root">The XML element containing the state of a camera</param> /// <param name="xmlDoc">The XML document that owns 'root'</param> public void SetState(XmlElement root, XmlDocument xmlDoc) { ViewTypes viewType; Vec3F eye; Vec3F lookAtPoint; Vec3F upVector; float yFov; float nearZ; float farZ; float focusRadius; string value; value = root.GetAttribute("viewType"); viewType = (ViewTypes)int.Parse(value, NumberStyles.AllowHexSpecifier); value = root.GetAttribute("eye"); eye = Vec3F.Parse(value); value = root.GetAttribute("lookAtPoint"); lookAtPoint = Vec3F.Parse(value); value = root.GetAttribute("upVector"); upVector = Vec3F.Parse(value); value = root.GetAttribute("yFov"); yFov = float.Parse(value); value = root.GetAttribute("nearZ"); nearZ = float.Parse(value); value = root.GetAttribute("farZ"); farZ = float.Parse(value); value = root.GetAttribute("focusRadius"); focusRadius = float.Parse(value); SetState(viewType, eye, lookAtPoint, upVector, yFov, nearZ, farZ, focusRadius); }