public Cell(Vector2f position, int startUnits, CellSizeEnum sizeEnum, int id) { _cellSettings = CellSettingsDic[sizeEnum]; _unitsText = new Text(string.Empty, ResourceManager.Instance["fonts/verdana"] as Font, TextFontSize); _spriteCellBubble = new Sprite(ResourceManager.Instance["game/cell_bubble"] as Texture) { Scale = _cellSettings .Scale }; _spriteCellBubble.Origin = new Vector2f( _spriteCellBubble.TextureRect.Width / 2, _spriteCellBubble.TextureRect.Height / 2); _spriteCellInside = new Sprite(ResourceManager.Instance["game/cell_inside_neutral"] as Texture) { Scale = _cellSettings .Scale }; _spriteCellInside.Origin = new Vector2f( _spriteCellInside.TextureRect.Width / 2, _spriteCellInside.TextureRect.Height / 2); Type = sizeEnum; Id = id; Radius = (float)_spriteCellBubble.TextureRect.Height / 2 * _cellSettings.Scale.X; Units = startUnits; Position = position; }
/// <summary> /// Constructor. /// </summary> /// <param name="indexInCell">The position of the cube in terms of cell arrays</param> /// <param name="cellPoints">Local points/positions of the densities</param> /// <param name="cellDensities">The calculated densities for each point in the cell</param> public MarchingCube(CellSettings settings, Vector3Int indexInCell, Vector3[,,] cellPoints, float[,,] cellDensities) { this.indexInCell = indexInCell; this.settings = settings; points = CalculateCubePoints(cellPoints); densities = CalculateCubeDensities(cellDensities); }
/// <summary> /// Constructor for the cell. /// </summary> /// <param name="position">The world position of the cell (left, bottom, back).</param> /// <param name="settings">Settings for the cell that should be applied to all cells.</param> public Cell(Vector3 position, CellSettings settings, NoiseFilter noise) { this.position = position; this.settings = settings; this.noise = noise; worldPoints = new Vector3[settings.resolution + 1, settings.resolution + 1, settings.resolution + 1]; localPoints = new Vector3[settings.resolution + 1, settings.resolution + 1, settings.resolution + 1]; densities = new float[settings.resolution + 1, settings.resolution + 1, settings.resolution + 1]; }
/// <summary> /// Grabs necessary attached components to this game object. /// </summary> private void GetComponents() { cellSettings = this.gameObject.GetComponent <CellSettings>(); noiseSettings = this.gameObject.GetComponent <NoiseSettings>(); if (cellSettings == null || noiseSettings == null) { Debug.LogError("Some components not attached.", this); } }
public async Task Generate(ChunkCellData data, CaveChunkManager chunkManager) { Settings = chunkManager.GeneratorSettings; ChunkManager = chunkManager; CellData = data; ChunkCoordinate = data.ChunkCoordinate; ChunkSeed = Settings.GenerateSeed(Settings.Seed, ChunkCoordinate); await data.Generate(); }
public BBDMercury16Input(USBDeviceInfo selectedDevice = null) : base(4000, 8) { string expectedDeviceID = $"USB\\VID_{DEVICE_VID}&PID_{DEVICE_PID}"; // libusbK implementation //int deviceCount = 0; //KLST_DEVINFO_HANDLE deviceInfo; //LstK lst = new LstK(KLST_FLAG.NONE); //lst.Count(ref deviceCount); //while (lst.MoveNext(out deviceInfo)) //{ // Console.WriteLine("libusbk: " + deviceInfo.DeviceInterfaceGUID.ToLower()); //} //lst.Free(); // DotNetLibUsb //var deviceList = LibUsbDotNet.LibUsb.LibUsbDevice.AllDevices.ToArray(); //foreach (var deviceInfoLUDN in deviceList) //{ // Console.WriteLine("libusb: " + deviceInfoLUDN.DeviceInterfaceGuids[0].ToString().ToLower() + " - " + deviceInfoLUDN.Device.Info.ProductString); //} //if (this.deviceInfo == null) //{ // throw new System.IO.IOException("There is no BBD Mercury-16 connected on any of the USB ports."); //} //if (deviceInfo.Device.Open()) //{ // reader = deviceInfo.Device.OpenEndpointReader(LibUsbDotNet.Main.ReadEndpointID.Ep01); // writer = deviceInfo.Device.OpenEndpointWriter(LibUsbDotNet.Main.WriteEndpointID.Ep01); //} // WinUSB.NET if (selectedDevice == null) { // GUID is an example, specify your own unique GUID in the .inf file USBDeviceInfo[] connectedDevices = USBDevice.GetDevices(DEVICE_INTERFACE_GUID); if (connectedDevices.Length == 0) { throw new System.IO.IOException("There is no BBD Mercury-16 connected on any of the USB ports."); } selectedDevice = connectedDevices[0]; //USBNotifier notifier = new USBNotifier(null, DEVICE_INTERFACE_GUID); } // Find your device in the array usbDevice = new USBDevice(selectedDevice); usbInterface = usbDevice.Interfaces.Find(USBBaseClass.PersonalHealthcare); var phdPacket = ReadIEEE11073Pakcet(usbInterface.InPipe); // stop streaming data usbInterface.OutPipe.Write(new byte[] { 0xF0, 0x01, 0x00, 0x00 }); CellSettings cellSettings = new CellSettings(); while (cellSettings.SystemClock == 0) { // get the cell settings usbInterface.OutPipe.Write(new byte[] { 0xF0, 0x03, 0x00, 0x00 }); cellSettings = ReadPacket <CellSettings>(usbInterface.InPipe, 0xF004, 10); } // set the modified cell settings //cellSettings.SampleRate /= 4; //WritePacket<CellSettings>(usbInterface.OutPipe, 0xF009, cellSettings); // start streaming data usbInterface.OutPipe.Write(new byte[] { 0xF0, 0x02, 0x00, 0x00 }); if ((cellSettings.ChannelCount != 8) && (cellSettings.ChannelCount != 16) && (cellSettings.ChannelCount != 24)) { throw new Exception($"The number of channels reported by Mercury-16 ({cellSettings.ChannelCount}) is invalid!"); } //this.SamplesPerSecond = cellSettings.SampleRate; for (int i = 0; i < cellSettings.ChannelCount; i++) { this.SetChannel(i, new SinglePrecisionDataChannel(this.SamplesPerSecond, this.SamplesPerSecond * 5)); } this.BufferSize = Math.Max(this.BufferSize, this.SamplesPerSecond * this.ChannelCount * 2 / targetFPS); this.GoertzelOutputs = new List <float> [this.ChannelCount]; this.GoertzelFrequency01 = cellSettings.GoertzelFrequency01; this.GoertzelFrequency02 = cellSettings.GoertzelFrequency02; this.GoertzelFrequency03 = cellSettings.GoertzelFrequency03; Task usbPollTask = Task.Run(() => { while (PollUSBData(this)) { } }); }
/// <summary> /// Constructor. /// </summary> /// <param name="settings">The settings used for the Cell</param> /// <param name="densities">The calculated densities from the cell</param> /// <param name="points">The local points/positions of the densities</param> public CellMesh(CellSettings settings, float[,,] densities, Vector3[,,] points) { this.settings = settings; this.densities = densities; this.points = points; }