public void DrawSquares(DrawContext dc) { FlatBatch2D flatBatch2D = dc.PrimitivesRenderer2D.FlatBatch(1, DepthStencilState.None, null, BlendState.AlphaBlend); int count = flatBatch2D.LineVertices.Count; int count2 = flatBatch2D.TriangleVertices.Count; float num = (float)MathUtils.Remainder(Time.FrameStartTime + (double)m_timeOffset, 10000.0); float num2 = base.ActualSize.X / 12f; float num3 = (float)(int)base.GlobalColorTransform.A / 255f; for (float num4 = 0f; num4 < base.ActualSize.X; num4 += num2) { for (float num5 = 0f; num5 < base.ActualSize.Y; num5 += num2) { float num6 = 0.35f * MathUtils.Pow(MathUtils.Saturate(SimplexNoise.OctavedNoise(num4 + 1000f, num5, 0.7f * num, 0.5f, 1, 2f, 1f) - 0.1f), 1f) * num3; float num7 = 0.7f * MathUtils.Pow(SimplexNoise.OctavedNoise(num4, num5, 0.5f * num, 0.5f, 1, 2f, 1f), 3f) * num3; Vector2 corner = new Vector2(num4, num5); Vector2 corner2 = new Vector2(num4 + num2, num5 + num2); if (num6 > 0.01f) { flatBatch2D.QueueRectangle(corner, corner2, 0f, new Color(0f, 0f, 0f, num6)); } if (num7 > 0.01f) { flatBatch2D.QueueQuad(corner, corner2, 0f, new Color(0f, 0f, 0f, num7)); } } } flatBatch2D.TransformLines(base.GlobalTransform, count); flatBatch2D.TransformTriangles(base.GlobalTransform, count2); }
public override void Update(float dt) { dt = MathUtils.Min(dt, 0.1f); Vector3 zero = Vector3.Zero; if (Keyboard.IsKeyDown(Key.A)) { zero.X = -1f; } if (Keyboard.IsKeyDown(Key.D)) { zero.X = 1f; } if (Keyboard.IsKeyDown(Key.W)) { zero.Z = 1f; } if (Keyboard.IsKeyDown(Key.S)) { zero.Z = -1f; } Vector2 vector = 0.03f * new Vector2(Mouse.MouseMovement.X, -Mouse.MouseMovement.Y); bool num = Keyboard.IsKeyDown(Key.Shift); bool flag = Keyboard.IsKeyDown(Key.Control); Vector3 direction = m_direction; Vector3 unitY = Vector3.UnitY; Vector3 vector2 = Vector3.Normalize(Vector3.Cross(direction, unitY)); float num2 = 8f; if (num) { num2 *= 10f; } if (flag) { num2 /= 10f; } Vector3 zero2 = Vector3.Zero; zero2 += num2 * zero.X * vector2; zero2 += num2 * zero.Y * unitY; zero2 += num2 * zero.Z * direction; m_position += zero2 * dt; m_direction = Vector3.Transform(m_direction, Matrix.CreateFromAxisAngle(unitY, -4f * vector.X * dt)); m_direction = Vector3.Transform(m_direction, Matrix.CreateFromAxisAngle(vector2, 4f * vector.Y * dt)); SetupPerspectiveCamera(m_position, m_direction, Vector3.UnitY); Vector2 v = ViewportSize / 2f; FlatBatch2D flatBatch2D = PrimitivesRenderer2D.FlatBatch(0, DepthStencilState.None); int count = flatBatch2D.LineVertices.Count; flatBatch2D.QueueLine(v - new Vector2(5f, 0f), v + new Vector2(5f, 0f), 0f, Color.White); flatBatch2D.QueueLine(v - new Vector2(0f, 5f), v + new Vector2(0f, 5f), 0f, Color.White); flatBatch2D.TransformLines(ViewportMatrix, count); PrimitivesRenderer2D.Flush(); }