/// <summary> /// This method handles all the sequencing required to generate data from the mapData file /// </summary> /// <param name="mapfile">The mapfile to process</param> static void doProcessing(mapData mapfile, DemoParser parser) { Debug.Success("Starting processing"); //First step: Make a grey dark version of the radar. Bitmap backgroundRadar = bitmapfilters.brightness(bitmapfilters.greyScaleAverage(mapfile.image_radar), 0.3f); //Second step: Load the demo into a demodatainstance, so that it parses into different lists. demodatainstance demo = new demodatainstance(parser); //Third step: Start making heatmaps densitymap density_shotsfired = new densitymap(); //Legacy, Make the camera object camera cam = new camera(); cam.offset = new vector2(mapfile.radar.pos_x, mapfile.radar.pos_y); cam.scale = mapfile.radar.scale; foreach (p_Player plyr in demo.players.Values.ToList()) { foreach (p_Round rnd in plyr.rounds) { foreach (vector3 shot in rnd.shotsFired) { vector2 screenPos = transforms.worldToScreenSpace(shot, cam); density_shotsfired.createHeatMapSplodge((int)screenPos.x, (int)screenPos.y, 20); } } } density_shotsfired.averageBlur3x3(); density_shotsfired.normalise(0.4f); Bitmap output = density_shotsfired.toBitMap(); output = gradients.fire.applyToImage(output); output = bitmapfilters.alphaOver(backgroundRadar, output); output.Save("test_shotsfired.png"); }
public static vector2 worldToScreenSpace(this vector3 position, camera cam) { return(new vector2(Convert.ToInt32((position.x - cam.offset.x) / cam.scale).Clamp(0, (int)cam.resolution.x), (Convert.ToInt32((position.y - cam.offset.y) / cam.scale) + 1024))); }