static Cam2d() { restrictions_low = new crds4(0f, 0f, 0f, 30f); restrictions_high = new crds4(200f, 200f, 0f, 300f); current = _target = new crds4(100f, 100f, 0f, 100f); set_angle(60); }
public static void encompass(crds2 hi_extr, crds2 lo_extr, float zoom_factor = 1f) { var c = (hi_extr + lo_extr) * 0.5f; var dhor = XMath.abs((hi_extr - lo_extr).x); var dver = XMath.abs((hi_extr - lo_extr).y); if (dhor < 1f) dhor = 1f; if (dver < 1f) dver = 1f; var aspect = dhor / dver; var screen_aspect = (float)Graphics.screen_w / Graphics.screen_h; var desired_zoom = 1f; if (aspect > screen_aspect) // width rules desired_zoom = (float)Graphics.screen_w / dhor; else // height rules desired_zoom = (float)Graphics.screen_h / dver; _target = new crds4(c.x, c.y, 0f, desired_zoom * zoom_factor); current = _target; delta = default(crds4); raise_restrictions(); }
public shader_param_float4(string name, crds4 value) { this.name = name; this.value = value; }
public static void force(crds3 c, float desired_zoom) { _target.x = c.x; _target.y = c.y; _target.z = c.z; _target.w = desired_zoom; current = _target; }
public static void raise_restrictions() { restrictions_low = new crds4(float.MinValue, float.MinValue, float.MinValue, float.MinValue); restrictions_high = new crds4(float.MaxValue, float.MaxValue, float.MaxValue, float.MaxValue); }
public static void on_tick() { current += delta; _target.x = _target.x.choke(restrictions_low.x, restrictions_high.x); _target.y = _target.y.choke(restrictions_low.y, restrictions_high.y); _target.z = _target.z.choke(restrictions_low.z, restrictions_high.z); _target.w = _target.w.choke(restrictions_low.w, restrictions_high.w); delta = _target - current; if (delta.lenght > update_speed) delta *= update_speed; }