public void StopFaceDetection_NO_EXCEPTION() { TestCamera.StartPreview(); try { TestCamera.StartFaceDetection(); } catch (NotSupportedException) { if (TestCamera.Capabilities.IsFaceDetectionSupported) { Assert.Fail("Face Detection feature is supported. But StartFaceDetection returns NotSupportedException."); } else { Assert.Pass("Face Detection feature is not supported."); } } /* TESTCODE */ try { TestCamera.StopFaceDetection(); } catch { Assert.Fail("Exception should not be occurred."); } }
public async Task GetDeviceState_ENUM_ALL() { // Check NotOpened State for secondary camera. if (IsSupportedSecondaryCamera()) { Assert.That(Camera.GetDeviceState(CameraDevice.Front), Is.EqualTo(CameraDeviceState.NotOpened)); } // Check NotOpened State. Assert.That(Camera.GetDeviceState(CameraDevice.Rear), Is.EqualTo(CameraDeviceState.NotOpened)); /* Opened state cannot be tested. * DeviceState is internally translated from NotOpened state to Working state after calling StartPreview method. */ using (var eventWaiter = EventAwaiter <CameraStateChangedEventArgs> .Create()) { TestCamera.StateChanged += eventWaiter; TestCamera.StartPreview(); await eventWaiter.IsRaisedAsync(); // Check Working State. Assert.That(Camera.GetDeviceState(CameraDevice.Rear), Is.EqualTo(CameraDeviceState.Working)); } }
public async Task HdrCaptureProgress_CHECK_EVENT() { if (TestCamera.Capabilities.IsHdrCaptureSupported == false) { Assert.Pass("HDR feature is not supported."); } using (var completeWaiter = EventAwaiter.Create()) using (var eventWaiter = EventAwaiter <HdrCaptureProgressEventArgs> .Create()) { TestCamera.Settings.HdrMode = CameraHdrMode.Enable; TestCamera.HdrCaptureProgress += eventWaiter; TestCamera.CaptureCompleted += completeWaiter; TestCamera.StartPreview(); TestCamera.StartCapture(); var eventArgs = await eventWaiter.GetResultAsync(); Assert.That(eventArgs.Percent, Is.GreaterThan(0), "HDR progress should be bigger than 0."); await completeWaiter.IsRaisedAsync(); } }
public void Camera_Constructor_returns_object_given_valid_parameters() { Point position = new Point(0.0f, 0.0f, 0.0f); float width = 10.0f; float height = 10.0f; var camera = new TestCamera(position, width, height); Assert.IsNotNull(camera); }
public async Task Preview_CHECK_EVENT() { using (var eventWaiter = EventAwaiter <CameraStateChangedEventArgs> .Create()) { TestCamera.StateChanged += eventWaiter; TestCamera.StartPreview(); Assert.That(await eventWaiter.IsRaisedAsync()); } }
void Start () { rc = FindObjectOfType<RadarController>(); sp = FindObjectOfType<ShipPanel>(); Player = GameObject.FindGameObjectWithTag("Player"); tc = FindObjectOfType<TestCamera>(); HUD = FindObjectOfType<playerHUD>(); tg = FindObjectOfType<Targeting>(); pm = FindObjectOfType<PhysicsMovement>(); mycontrol = GetComponent<dfControl>(); mycontrol.CanFocus = true; mainCamera = Camera.main; }
public async Task StopPreview_CHECK_STATE() { using (var eventWaiter = EventAwaiter <CameraStateChangedEventArgs> .Create()) { TestCamera.StateChanged += eventWaiter; TestCamera.StartPreview(); await eventWaiter.IsRaisedAsync(); } TestCamera.StopPreview(); Assert.That(TestCamera.State, Is.EqualTo(CameraState.Created)); }
public async Task DisplayReuseHint_PROPERTY_READ_WRITE() { using (var eventWaiter = EventAwaiter <CameraStateChangedEventArgs> .Create()) { TestCamera.StateChanged += eventWaiter; TestCamera.StartPreview(); await eventWaiter.IsRaisedAsync(); } TestCamera.DisplayReuseHint = true; Assert.IsNotNull(TestCamera.DisplayReuseHint, "display reuse hint should not be null."); Assert.IsTrue(TestCamera.DisplayReuseHint, "display reuse hint is not same as set value."); }
public async Task StartCapture_INVALID_OP_EXCEPTION() { TestCamera.StartPreview(); using (var tokenSource = new CancellationTokenSource()) { try { TestCamera.StartCapture(3, 100, tokenSource.Token); await Task.Delay(1000); } catch (NotSupportedException) { if (TestCamera.Capabilities.IsContinuousCaptureSupported) { Assert.Fail("Continuous capture is failed."); } else { Assert.Pass("Continuous capture feature is not supported."); } } catch (Exception ex) { Assert.Fail("Continuous capture is failed. Msg : " + ex.ToString()); } /* TESTCODE */ try { tokenSource.Cancel(); } catch (AggregateException ex) { ex.Handle((x) => { if (x is InvalidOperationException) { Assert.Pass("Proper exception is occured."); return(true); } Assert.Fail("Proper exception is not occured."); return(false); }); } } }
public async Task State_GET_ENUM_ALL() { Assert.That(TestCamera.State, Is.EqualTo(CameraState.Created)); TestCamera.StartPreview(); Assert.That(TestCamera.State, Is.EqualTo(CameraState.Preview)); using (var eventWaiter = EventAwaiter <EventArgs> .Create()) { TestCamera.CaptureCompleted += eventWaiter; TestCamera.StartCapture(); Assert.That(await eventWaiter.IsRaisedAsync()); } }
public async Task MediaPacketPreview_CHECK_EVENT() { if (TestCamera.Capabilities.IsMediaPacketPreviewCallbackSupported == false) { Assert.Pass("MediaPacketPreviewCallback feature is not supported."); } using (var eventWaiter = EventAwaiter <MediaPacketPreviewEventArgs> .Create()) { TestCamera.MediaPacketPreview += eventWaiter; TestCamera.StartPreview(); var eventArgs = await eventWaiter.GetResultAsync(); Assert.IsNotNull(eventArgs.Packet); } }
public async Task StartCapture_CHANGE_STATUS() { TestCamera.StartPreview(); using (var completeWaiter = EventAwaiter <CameraCapturingEventArgs> .Create()) using (var tokenSource = new CancellationTokenSource()) { try { TestCamera.Capturing += completeWaiter; TestCamera.StartCapture(10, 100, tokenSource.Token); await completeWaiter.IsRaisedAsync(); } catch (NotSupportedException) { if (TestCamera.Capabilities.IsContinuousCaptureSupported) { Assert.Fail("Continuous capture is failed."); } else { Assert.Pass("Continuous capture feature is not supported."); } } catch (Exception ex) { Assert.Fail("Continuous capture is failed. Msg : " + ex.ToString()); } /* TESTCODE */ using (var eventWaiter = EventAwaiter <CameraStateChangedEventArgs> .Create()) { TestCamera.StateChanged += eventWaiter; tokenSource.Cancel(); await eventWaiter.IsRaisedAsync(); } Assert.That(TestCamera.State, Is.EqualTo(CameraState.Captured)); } }
public void StopFocusing_NO_EXCEPTION() { bool isAfModeSupported = false; IList afModes = TestCamera.Capabilities.SupportedAutoFocusModes.ToList(); foreach (CameraAutoFocusMode afMode in afModes) { if (afMode != CameraAutoFocusMode.None) { TestCamera.Settings.AutoFocusMode = afMode; isAfModeSupported = true; break; } } TestCamera.StartPreview(); try { TestCamera.StartFocusing(true); } catch (NotSupportedException) { if (isAfModeSupported) { Assert.Fail("StartFocusing is failed."); } else { Assert.Pass("Auto focus feature is not supported."); } } /* TESTCODE */ try { TestCamera.StopFocusing(); } catch { Assert.Fail("No exception should be occurred."); } }
public async Task CaptureCompleted_CHECK_EVENT() { using (var completeWaiter = EventAwaiter.Create()) using (var eventWaiter = EventAwaiter <EventArgs> .Create()) { TestCamera.Settings.ImageQuality = 100; TestCamera.Settings.CapturePixelFormat = CameraPixelFormat.Jpeg; TestCamera.CaptureCompleted += eventWaiter; TestCamera.CaptureCompleted += completeWaiter; TestCamera.StartPreview(); TestCamera.StartCapture(); Assert.That(await eventWaiter.IsRaisedAsync()); await completeWaiter.IsRaisedAsync(); } }
protected override async Task LoadContent() { await base.LoadContent(); var knightModel = Content.Load <Model>("knight Model"); knight = new Entity { new ModelComponent { Model = knightModel } }; knight.Transform.Position = new Vector3(0, 0f, 0f); var animationComponent = knight.GetOrCreate <AnimationComponent>(); animationComponent.Animations.Add("Run", Content.Load <AnimationClip>("knight Run")); animationComponent.Animations.Add("Idle", Content.Load <AnimationClip>("knight Idle")); // We will test both non-optimized and optimized clips megalodonClip = CreateModelChangeAnimation(new ProceduralModelDescriptor(new CubeProceduralModel { Size = Vector3.One, MaterialInstance = { Material = knightModel.Materials[0].Material } }).GenerateModel(Services)); knightOptimizedClip = CreateModelChangeAnimation(Content.Load <Model>("knight Model")); knightOptimizedClip.Optimize(); animationComponent.Animations.Add("ChangeModel1", megalodonClip); animationComponent.Animations.Add("ChangeModel2", knightOptimizedClip); Scene.Entities.Add(knight); camera = new TestCamera(Services.GetSafeServiceAs <SceneSystem>().GraphicsCompositor); CameraComponent = camera.Camera; Script.Add(camera); camera.Position = new Vector3(6.0f, 2.5f, 1.5f); camera.SetTarget(knight, true); }
public static void Main() { using (var game = new TestCamera()) game.Run(); }
protected override async Task LoadContent() { await base.LoadContent(); spriteBatch = new SpriteBatch(GraphicsDevice); font = Content.Load <SpriteFont>("Font"); wireframeState = new RasterizerStateDescription(CullMode.Back) { FillMode = FillMode.Wireframe }; materials.Add(Content.Load <Material>("NoTessellation")); materials.Add(Content.Load <Material>("FlatTessellation")); materials.Add(Content.Load <Material>("PNTessellation")); materials.Add(Content.Load <Material>("PNTessellationAE")); materials.Add(Content.Load <Material>("FlatTessellationDispl")); materials.Add(Content.Load <Material>("FlatTessellationDisplAE")); materials.Add(Content.Load <Material>("PNTessellationDisplAE")); RenderContext.GetShared(Services).RendererInitialized += RendererInitialized; var cube = new Entity("Cube") { new ModelComponent(new ProceduralModelDescriptor(new CubeProceduralModel { Size = new Vector3(80), MaterialInstance = { Material = materials[0] } }).GenerateModel(Services)) }; var sphere = new Entity("Sphere") { new ModelComponent(new ProceduralModelDescriptor(new SphereProceduralModel { Radius = 50, Tessellation = 5, MaterialInstance = { Material = materials[0] } }).GenerateModel(Services)) }; var megalodon = new Entity { new ModelComponent { Model = Content.Load <Model>("megalodon Model") } }; megalodon.Transform.Position = new Vector3(0, -30f, -10f); var knight = new Entity { new ModelComponent { Model = Content.Load <Model>("knight Model") } }; knight.Transform.RotationEulerXYZ = new Vector3(-MathUtil.Pi / 2, MathUtil.Pi / 4, 0); knight.Transform.Position = new Vector3(0, -50f, 20f); knight.Transform.Scale = new Vector3(0.6f); entities.Add(sphere); entities.Add(cube); entities.Add(megalodon); entities.Add(knight); camera = new TestCamera(Services.GetSafeServiceAs <SceneSystem>().GraphicsCompositor); CameraComponent = camera.Camera; Script.Add(camera); // TODO GRAPHICS REFACTOR ChangeModel(0); camera.Position = new Vector3(25, 45, 80); camera.SetTarget(currentEntity, true); }
protected override async Task LoadContent() { await base.LoadContent(); var debugSheet = Content.Load <SpriteSheet>("DebugSpriteSheet"); // normal reference one var normal = CreateSpriteEntity(debugSheet, "Normal"); normal.Transform.Position = new Vector3(75, 75, 0); normal.Transform.RotationEulerXYZ = new Vector3(0.8f, 1.2f, 0.3f); normal.Get <SpriteComponent>().CurrentSprite.Center = new Vector2(75); // billboard var billboard = CreateSpriteEntity(debugSheet, "Billboard"); billboard.Transform.Position = new Vector3(150, 150, 0); billboard.Transform.RotationEulerXYZ = new Vector3(0.5f, 1f, 1.5f); billboard.Get <SpriteComponent>().SpriteType = SpriteType.Billboard; // ratio var child = CreateSpriteEntity(debugSheet, "Child", false); child.Transform.Position = new Vector3(100, 0, 0); ratio = CreateSpriteEntity(debugSheet, "OtherRatio"); ratio.Transform.Position = new Vector3(350, 150, 0); ratio.AddChild(child); // depth test var onBack = CreateSpriteEntity(debugSheet, "OnBack"); onBack.Transform.Position = new Vector3(75, 250, 0); onBack.Transform.RotationEulerXYZ = new Vector3(0, 1f, 0); onBack.Get <SpriteComponent>().CurrentSprite.Center = new Vector2(75); var onFront = CreateSpriteEntity(debugSheet, "OnFront"); onFront.Transform.Position = new Vector3(75, 350, 0.1f); onFront.Transform.RotationEulerXYZ = new Vector3(0, 1f, 0); onFront.Get <SpriteComponent>().CurrentSprite.Center = new Vector2(75); var noDepth = CreateSpriteEntity(debugSheet, "NoDepth"); noDepth.Transform.Position = new Vector3(75, 450, 0.2f); noDepth.Get <SpriteComponent>().CurrentSprite.Center = new Vector2(75); noDepth.Get <SpriteComponent>().IgnoreDepth = true; // create the rotating sprites rotatingSprites.Add(CreateSpriteEntity(debugSheet, "Center")); rotatingSprites.Add(CreateSpriteEntity(debugSheet, "TopLeft")); rotatingSprites.Add(CreateSpriteEntity(debugSheet, "OutOfImage")); for (int i = 0; i < rotatingSprites.Count; i++) { // Add some z-offset, so non-deterministic sorting due to threading does not cause issues with blending and depth testing enabled rotatingSprites[i].Transform.Position = new Vector3(ScreenWidth, ScreenHeight, 0) / 2; } // add all the entities to the scene foreach (var entity in entities) { SceneSystem.SceneInstance.RootScene.Entities.Add(entity); } cameraScript = new TestCamera(Services.GetSafeServiceAs <SceneSystem>().GraphicsCompositor); CameraComponent = cameraScript.Camera; Script.Add(cameraScript); cameraScript.Yaw = 0; cameraScript.Pitch = 0; cameraScript.Position = new Vector3(400, 300, 800); }
private void SetupScene() { // Load default graphics compositor SceneSystem.GraphicsCompositor = Content.Load <GraphicsCompositor>("GraphicsCompositor"); Scene = new Scene(); Scene.Entities.Add(Camera); //var ambientLight = new Entity { new LightComponent { Type = new LightAmbient { Color = new ColorRgbProvider(Color.White) }, Intensity = 1 } }; ////var ambientLight = new Entity { new LightComponent { Type = new LightDirectional { Color = new ColorRgbProvider(Color.White) }, Intensity = 1 } }; ////ambientLight.Transform.RotationEulerXYZ = new Vector3(0.0f, (float) Math.PI, 0.0f); //Scene.Entities.Add(ambientLight); var directionalLight = new Entity { new LightComponent { Type = new LightDirectional { Color = new ColorRgbProvider(Color.White), Shadow = { Enabled = true } }, Intensity = 1 }, }; directionalLight.Transform.Rotation = Quaternion.RotationY(MathUtil.PiOverTwo * 0.2f); Scene.Entities.Add(directionalLight); //var pointLight1 = new Entity { new LightComponent() { Type = new LightPoint { Color = new ColorRgbProvider(Color.Red), Radius = 100.0f, Shadow = { Enabled = false } }, Intensity = 1.0f } }; //pointLight1.Transform.Position.X = 5.0f; //Scene.Entities.Add(pointLight1); //var directionalLight2 = new Entity { new LightComponent { Type = new LightSpot { Range = 25, Color = new ColorRgbProvider(Color.White), Shadow = { Enabled = false } }, Intensity = 20 }, }; //directionalLight2.Transform.Position = Vector3.UnitX * 40; //directionalLight2.Transform.Rotation = Quaternion.RotationY(MathUtil.PiOverTwo); //Scene.Entities.Add(directionalLight2); var rand = new Random(); for (int i = 0; i < 512; ++i) { var pointLight1 = new Entity { new LightComponent() { Type = i % 2 == 0 ? (ILight) new LightPoint { Color = new ColorRgbProvider(new Color((float)rand.NextDouble(), (float)rand.NextDouble(), (float)rand.NextDouble(), 1.0f)), Radius = 2.0f, Shadow = { Enabled = false }, } : new LightSpot { Color = new ColorRgbProvider(new Color((float)rand.NextDouble(), (float)rand.NextDouble(), (float)rand.NextDouble(), 1.0f)), Range = 4.0f, Shadow = { Enabled = false }, }, Intensity = 10.0f } }; pointLight1.Transform.Position = new Vector3( (float)rand.NextDouble() * 20.0f - 10.0f, (float)rand.NextDouble() * 20.0f - 10.0f, (float)rand.NextDouble() * 20.0f - 10.0f ); Scene.Entities.Add(pointLight1); } SceneSystem.SceneInstance = new SceneInstance(Services, Scene); // Load default graphics compositor SceneSystem.GraphicsCompositor = Content.Load <GraphicsCompositor>("GraphicsCompositor"); camera = new TestCamera(Services.GetSafeServiceAs <SceneSystem>().GraphicsCompositor); CameraComponent = camera.Camera; Script.Add(camera); }
public void ChangeDevice_THROWS_IF_PARAM_IS_INVALID() { Assert.Throws <ArgumentException>(() => TestCamera.ChangeDevice(_invalidDevideNumber)); }
public void SetCamera(CameraType cameraType) { switch (cameraType) { case CameraType.FreeCamera: Camera = new FreeCamera(this, Settings); break; case CameraType.StaticCamera: Camera = new StaticCamera(this, Settings); break; case CameraType.TestCamera: Camera = new TestCamera(this, Settings); break; default: throw new ArgumentOutOfRangeException(SystemResources.InvalidCameraType); } currentCameraType = cameraType; Camera.Initialize(); }
// Start is called before the first frame update void Start() { testCamera = Camera.main.GetComponent <TestCamera>(); }
public void Dispose_CHECK_STATE() { TestCamera.Dispose(); Assert.Throws <ObjectDisposedException>(() => { IntPtr handle = TestCamera.Handle; }); }