public void UpdateHeatMap(float[] heat) { GL.BindTexture(TextureTarget.Texture1D, heatMap); var buffer = new byte[heatPixelSize * heatPixelCount]; for (int i = 0; i < heatPixelCount; i++) { float pHeat = 0; for (int j = 0; j < heat.Length; j++) { pHeat += Math.Max(0, heat [j] * (1 - 8 * Math.Abs(Type.Points [j] - (i / (heatPixelCount - 1f))))); } buffer [i * heatPixelSize] = (byte)(KnownMetal.GetRedEmmission(Metal, pHeat) * 25); buffer [i * heatPixelSize + 1] = (byte)(KnownMetal.GetGreenEmmission(Metal, pHeat) * 25); } GL.TexImage1D <byte> (TextureTarget.Texture1D, 0, PixelInternalFormat.Rg8, heatPixelCount, 0, PixelFormat.Rg, PixelType.UnsignedByte, buffer); }
public void UpdateView(Scene s) { transition.UpdateTransition(Time.Delta() * 2); if (Input.CloseKeyPressed) { OnAnvilNotUsed(); game.SetView(parentView); return; } if (Input.InteractKeyPressed | Input.MousePressed & Input.OrthoMouseX > 50 & Input.OrthoMouseX < 300 & Input.OrthoMouseY > 50 & Input.OrthoMouseY < 300) { game.SetView(table); table.OnTableUsed(heat, blade); OnAnvilNotUsed(); return; } for (int i = 0; i < heat.Length; i++) { if (heat[i] > 25) { heat [i] -= Time.Delta() * (i == diamond? 100 : 200); } } if (!hammerDown && Input.MousePressed & hammerMove <0.3f& Input.OrthoMouseX> OrthoRenderEngine.GetCanvasWidth() / 2 - 100 & Input.OrthoMouseX <OrthoRenderEngine.GetCanvasWidth() / 2 + 100 & Input.OrthoMouseY> OrthoRenderEngine.GetCanvasHeight() / 2 - 70 & Input.OrthoMouseY < OrthoRenderEngine.GetCanvasHeight() / 2 + 70) { hammerDown = true; hammerX = Util.NextFloat() - 0.5f; hammerY = Util.NextFloat() - 0.5f; } if (hammerDown) { if (hammerMove < 1) { hammerMove += Time.Delta() * 10; if (hammerMove >= 1) { hammerDown = false; hammerMove = 1; if (diamond >= 0) { blade.Sharpness [diamond] = Math.Min(1, blade.Sharpness [diamond] + KnownMetal.GetRedEmmission(blade.Metal, heat[diamond]) * 0.01f * (1 - blade.Sharpness [diamond])); blade.UpdateSharpnessMap(); } } } } else if (hammerMove > 0) { hammerMove = Math.Max(0, hammerMove - Time.Delta() * 4); } if (Input.LeftKey) { panAngle -= (panAngle + 0.6f) * Time.Delta() * 3; } else if (Input.RightKey) { panAngle -= (panAngle - 0.6f) * Time.Delta() * 3; } else { panAngle -= panAngle * Time.Delta() * 3; } if (Input.DownKey) { panAngleY -= (panAngleY + 0.3f) * Time.Delta() * 3; } else if (Input.UpKey) { panAngleY -= (panAngleY - 0.28f) * Time.Delta() * 3; } else { panAngleY -= panAngleY * Time.Delta() * 3; } }