private void retrieveLightmap() //gathers lightmap data from the offset in the file { lightmapLDR = new ColorRGBExp32[LightmapTextureWidth, LightmapTextureLength]; lightmapHDR = new ColorRGBExp32[LightmapTextureWidth, LightmapTextureLength]; if (bsp.LDR) { bsp.file.Seek(bsp.offsets[8].Key + lightOfs, SeekOrigin.Begin); for (int y = 0; y < LightmapTextureLength; y++) { for (int x = 0; x < LightmapTextureWidth; x++) { lightmapLDR[x, y] = new ColorRGBExp32(bsp.reader); } } } if (bsp.HDR) { bsp.file.Seek(bsp.offsets[53].Key + lightOfs, SeekOrigin.Begin); for (int y = 0; y < LightmapTextureLength; y++) { for (int x = 0; x < LightmapTextureWidth; x++) { lightmapHDR[x, y] = new ColorRGBExp32(bsp.reader); } } } }
private void updateLightmapViewer() { luxelsCanvas.Refresh(); if (surface != null && selectedX >= 0 && selectedX < surface.LightmapTextureWidth && selectedY >= 0 && selectedY < surface.LightmapTextureLength) { ColorRGBExp32 luxel = getLuxel(selectedX, selectedY); spinnerR.Value = luxel.r; spinnerG.Value = luxel.g; spinnerB.Value = luxel.b; spinnerE.Value = luxel.e; double exp = Math.Pow(2, luxel.e); int rgbR = (int)(luxel.r * exp); int rgbG = (int)(luxel.g * exp); int rgbB = (int)(luxel.b * exp); labelRGB.Text = "RGB: " + rgbR + " " + rgbG + " " + rgbB; } }