//NOTE: It's ok to pass in the base dna type. If the derived is passed in, those settings will be used public CameraHardCoded(EditorOptions options, ItemOptions itemOptions, ShipPartDNA dna, IContainer energyTanks, Map map) : base(options, dna, itemOptions.Camera_Damage.HitpointMin, itemOptions.Camera_Damage.HitpointSlope, itemOptions.Camera_Damage.Damage) { _itemOptions = itemOptions; _energyTanks = energyTanks; _map = map; this.Design = new CameraHardCodedDesign(options, true); this.Design.SetDNA(dna); double radius; CameraColorRGB.GetMass(out _mass, out _volume, out radius, dna, itemOptions); this.Radius = radius; _scaleActual = new Vector3D(radius * 2d, radius * 2d, radius * 2d); //TODO: design should have stored custom stuff if the dna has it. Get/Set var neuronResults = CreateNeurons(dna, itemOptions); _neuronPoints = neuronResults.Item1; _neuronSets = neuronResults.Item2; _neurons = neuronResults.Item2. SelectMany(o => o). ToArray(); _neuronMaxRadius = _neurons.Max(o => o.PositionLength); }
//TODO: This should store results in dna public static void AssignCameras(BrainRGBRecognizer[] recognizers, CameraColorRGB[] cameras) { if (cameras != null) { foreach (CameraColorRGB camera in cameras) { camera.NeuronContainerType = NeuronContainerType.Sensor; } } if (recognizers == null || recognizers.Length == 0) { return; } foreach (BrainRGBRecognizer recognizer in recognizers) { recognizer.SetCamera(null); } if (cameras == null || cameras.Length == 0) { return; } // Call linker LinkItem[] recogItems = recognizers. Select(o => new LinkItem(o.Position, o.Radius)). ToArray(); LinkItem[] cameraItems = cameras. Select(o => new LinkItem(o.Position, o.Radius)). ToArray(); Tuple<int, int>[] links = ItemLinker.Link_1_2(cameraItems, recogItems, new ItemLinker_OverflowArgs()); // Assign cameras foreach (var link in links) { recognizers[link.Item2].SetCamera(cameras[link.Item1]); cameras[link.Item1].NeuronContainerType = NeuronContainerType.None; // this recognizer will now be this camera's output } }
public void SetCamera(CameraColorRGB camera) { lock (_lock) { if (camera == null) { _camera = null; _somList = null; } else { _camera = camera; _somList = new SOMList(new[] { camera.PixelWidthHeight, camera.PixelWidthHeight }, Convolutions.GetEdgeSet_Sobel(), discardDupes: _somDiscardDupes, isColor2D: _somIsColor); // the edge detect really helps. without it, there tended to just be one big somnode after a while } _shortTermMemory.Clear(); _nonLifeEventSnapshots.Clear(); _importantEvents.Clear(); _recognizers = null; _results = null; } }
private void btnRGB_Click(object sender, RoutedEventArgs e) { try { if (_offline1 == null) { MessageBox.Show("Start a scene first", this.Title, MessageBoxButton.OK, MessageBoxImage.Warning); return; } ShipPartDNA energyDNA = new ShipPartDNA() { PartType = EnergyTank.PARTTYPE, Orientation = Quaternion.Identity, Position = new Point3D(), Scale = new Vector3D(10, 10, 10) }; EnergyTank energy = new EnergyTank(_editorOptions, _itemOptions, energyDNA); energy.QuantityCurrent = energy.QuantityMax; ShipPartDNA dna = new ShipPartDNA() { PartType = CameraColorRGB.PARTTYPE, Orientation = Quaternion.Identity, Position = new Point3D(0, 0, 0), Scale = new Vector3D(1, 1, 1) }; CameraColorRGB camera = new CameraColorRGB(_editorOptions, _itemOptions, dna, energy, _cameraPool); camera.RequestWorldLocation += new EventHandler<PartRequestWorldLocationArgs>(TestCamera_RequestWorldLocation); //var location = camera.GetWorldLocation_Camera(); //_offline1.SyncCamera(_camera); //IBitmapCustom bitmap = UtilityWPF.RenderControl(_offline1.Control, camera.PixelWidthHeight, camera.PixelWidthHeight, true, Colors.Black, false); //camera.StoreSnapshot(bitmap); camera.Update_MainThread(1); camera.Update_AnyThread(1); } catch (Exception ex) { MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error); } }