public void AxisAngle() { var expected = new[] { new CFrame(0, 0, 0, 1, 0, 0, 0, 0.999550045f, -0.0299954992f, 0, 0.0299954992f, 0.999550045f), // right new CFrame(0, 0, 0, 0.999550045f, 0, 0.0299954992f, 0, 1, 0, -0.0299954992f, 0, 0.999550045f), // top new CFrame(0, 0, 0, 0.999550045f, -0.0299954992f, 0, 0.0299954992f, 0.999550045f, 0, 0, 0, 1), // back new CFrame(0, 0, 0, 1, -0, 0, 0, 0.999550045f, 0.0299954992f, -0, -0.0299954992f, 0.999550045f), // left new CFrame(0, 0, 0, 0.999550045f, -0, -0.0299954992f, 0, 1, -0, 0.0299954992f, 0, 0.999550045f), // bottom new CFrame(0, 0, 0, 0.999550045f, 0.0299954992f, 0, -0.0299954992f, 0.999550045f, -0, -0, 0, 1) // front }; for (int i = 0; i < 6; i++) { var actual = CFrame.FromAxisAngle(Vector3.FromNormalId((NormalId)i), 0.03f); Assert.AreEqual(expected[i], actual, $"AxisAngle ({(NormalId)i}) did not return expected results."); } }
private void UpdateSun() { var sunAngles = CalculateSunPosition(DateTime.Today() + _timeOfDay, _longitude, _latitude); var sunCF = CFrame.FromAxisAngle(Vector3.Up, (float)sunAngles.Azimuth) * CFrame.FromAxisAngle(Vector3.Right, (float)sunAngles.Altitude); var sunVector = sunCF.forward; SunVector = sunVector; LightingConstantBuffer.Data.AmbientColour = _ambientColour; LightingConstantBuffer.Data.OutdoorAmbient = _outdoorAmbient; LightingConstantBuffer.Data.SunLight = new PointLightData { Position = sunVector, Colour = SunColour }; lock (Renderer.Locker) { LightingConstantBuffer.Update(ref Renderer.Context); } Shadows.Direction = new SharpDX.Vector3(-sunVector.x, sunVector.y, -sunVector.z); }