public ThermalRenderingData <C> GetThermalData <T, C>(uint level, int time) where T : ThermalDataT <C>, new() where C : struct { ThermalDataBase levelData = thermalData[level]; if (levelData == null || !(levelData is T) || time < levelData.startTime || time >= levelData.endTime) { LoadThermalData <T, C>(level, time); levelData = (ThermalDataT <C>)thermalData[level]; if (levelData == null || levelData.Cells <C>() == null) { Debug.LogWarning("No thermal data found for level " + level); return(null); } } int sampleIndex = (time % fileTimeInterval) / sampleInterval; ThermalFrame frame = levelData.frames[sampleIndex + 1]; ThermalRenderingData <C> renderData = new ThermalRenderingData <C>(); renderData.cells = levelData.Cells <C>(); renderData.cellType = level < maxLevel ? CellType.GroundQuad : CellType.Billboard; renderData.startIndex = levelData.frames[sampleIndex].offset; renderData.endIndex = frame.offset; renderData.minTemperature = frame.minTemperature; renderData.maxTemperature = frame.minTemperature + frame.temperatureRange; renderData.resolution = (uint)Math.Pow(2, level); return(renderData); }
public override ThermalRenderingData <C> GetThermalData <T, C>() { if (thermalData == null || !(thermalData is T)) { LoadThermalData <T, C>(); if (thermalData == null || thermalData.Cells <C>() == null) { Debug.LogWarning("No vision data was loaded"); return(null); } } ThermalFrame frame = thermalData.frames[1]; ThermalRenderingData <C> data = new ThermalRenderingData <C>(); data.cells = thermalData.Cells <C>(); data.cellType = CellType.Billboard; data.startIndex = thermalData.frames[0].offset; data.endIndex = frame.offset; data.minTemperature = frame.minTemperature; data.maxTemperature = frame.minTemperature + frame.temperatureRange; data.resolution = dataHeader.resolution; return(data); }
private void DisplayHeatDataT <T, C>() where T : ThermalDataT <C>, new() where C : struct { ThermalRenderingData <C> data = dataProvider.GetThermalData <T, C>(); System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); //+ Use fast array copy! int newCount = 0; C[] cells = thermalCells.Cells <C>(); for (uint i = data.startIndex; i < data.endIndex; ++i) { cells[newCount++] = data.cells[i]; } thermalDrawer.SetDataFast(cells, newCount); thermalDrawer.Type = data.cellType; if (updateTemperatureRanges) { thermalCamera.temperatureRange.minValue = data.minTemperature; thermalCamera.temperatureRange.maxValue = data.maxTemperature; thermalDrawer.SetTemperatureMinMax(data.minTemperature, data.maxTemperature); } UpdateDrawerCellSize(data.resolution); sw.Stop(); if (sw.Elapsed.TotalMilliseconds > 20) { Debug.LogWarning("Displaying thermal data took " + sw.Elapsed.TotalMilliseconds + "ms."); } }