public TArray <Triangle2f> CreateTriangulates() { TArray <Triangle2f> triangles = new TArray <Triangle2f>(); if (points.Size() <= 3) { return(triangles); } int index = 1; for (; points.Size() > 3;) { if (IsEar(points.Get(GetIndex(index, -1)), points.Get(index), points.Get(GetIndex(index, 1)))) { triangles.Add(new Triangle2f(points.Get(GetIndex(index, -1)), points.Get(index), points.Get(GetIndex(index, 1)))); points.Remove(points.Get(index)); index = GetIndex(index, -1); } else { index = GetIndex(index, 1); } } triangles.Add(new Triangle2f(points.Get(0), points.Get(1), points.Get(2))); return(triangles); }
protected override void CreatePoints() { TArray <float> tempPoints = new TArray <float>(); maxX = -Float.MIN_VALUE_JAVA; maxY = -Float.MIN_VALUE_JAVA; minX = Float.MAX_VALUE_JAVA; minY = Float.MAX_VALUE_JAVA; float start = _start; float end = _end; float cx = x + radius1; float cy = y + radius2; int step = 360 / segmentCount; for (float a = start; a <= end + step; a += step) { float ang = a; if (ang > end) { ang = end; } float newX = (cx + (MathUtils.Cos(MathUtils.ToRadians(ang)) * radius1)); float newY = (cy + (MathUtils.Sin(MathUtils.ToRadians(ang)) * radius2)); if (newX > maxX) { maxX = newX; } if (newY > maxY) { maxY = newY; } if (newX < minX) { minX = newX; } if (newY < minY) { minY = newY; } tempPoints.Add(newX); tempPoints.Add(newY); } points = new float[tempPoints.size]; for (int i = 0; i < points.Length; i++) { points[i] = tempPoints.Get(i); } }
public virtual TArray <ScaledResource> GetScaledResources(string path) { TArray <ScaledResource> rsrcs = new TArray <ScaledResource>(); rsrcs.Add(new ScaledResource(this, ComputePath(path, factor))); for (float rscale = MathUtils.Ifloor(factor); rscale > 1; rscale -= 1) { if (rscale != factor) { rsrcs.Add(new ScaledResource(new Scale(rscale), ComputePath(path, rscale))); } } rsrcs.Add(new ScaledResource(ONE, path)); return(rsrcs); }
// --- Load start ---// public virtual void AddLoad(Updateable u) { lock (loads) { loads.Add(u); } }
public virtual void AddUnLoad(Updateable u) { lock (unloads) { unloads.Add(u); } }
public virtual TArray <GameProcess> DeleteIndex(string id) { TArray <GameProcess> list = new TArray <GameProcess>(); if (processes != null && processes.size > 0) { lock (this.processes) { TArray <GameProcess> ps = new TArray <GameProcess>(processes); for (int i = 0; i < ps.size; i++) { GameProcess p = ps.Get(i); if (p != null) { if (string.ReferenceEquals(p.GetId(), id) || p.GetId().IndexOf(id, StringComparison.Ordinal) != -1) { p.Kill(); processes.Remove(p); list.Add(p); } } } } } return(list); }
public virtual TArray <GameProcess> Delete(GameProcess process) { TArray <GameProcess> list = new TArray <GameProcess>(); if (process == null) { return(list); } if (processes != null && processes.size > 0) { lock (this.processes) { TArray <GameProcess> ps = new TArray <GameProcess>(processes); for (int i = 0; i < ps.size; i++) { GameProcess p = ps.Get(i); if (p != null) { if (process == p || string.ReferenceEquals(process.GetId(), p.GetId()) || process.GetId().Equals(p.GetId())) { p.Kill(); processes.Remove(p); list.Add(p); } } } } } return(list); }
public virtual TArray <GameProcess> Delete(GameProcessType pt) { TArray <GameProcess> list = new TArray <GameProcess>(); if ((object)pt == null) { return(list); } if (processes != null && processes.size > 0) { lock (this.processes) { TArray <GameProcess> ps = new TArray <GameProcess>(processes); for (int i = 0; i < ps.size; i++) { GameProcess p = ps.Get(i); if (p != null) { if (p.GetProcessType() == pt) { p.Kill(); processes.Remove(p); list.Add(p); } } } } } return(list); }
public override void InvokeLater(Runnable action) { lock (this) { pending.Add(action); } }
public virtual void AddResume(Updateable u) { lock (resumes) { resumes.Add(u); } }
private void SetScreen(Screen screen, bool put) { if (_loadingScreen != null && _loadingScreen.IsOnLoadComplete()) { return; } try { lock (this) { if (screen == null) { this.isInstance = false; throw new LSysException("Cannot create a [Screen] instance !"); } //screen.SetOnLoadState(false); if (_currentScreen == null) { _currentScreen = screen; } else { KillScreen(screen); } this.isInstance = true; screen.OnCreate(LSystem.viewSize.GetWidth(), LSystem.viewSize.GetHeight()); RealtimeProcess process = new RealtimeProcessImpl(this, screen); process.SetProcessType(GameProcessType.Initialize); process.SetDelay(0); RealtimeProcessManager.Get().AddProcess(process); if (put) { _screens.Add(screen); } _loadingScreen = null; } } catch (System.Exception cause) { LSystem.Error("Update Screen failed: " + screen, cause); } }
public void AddPolyPoint(float x, float y) { PointF p = new PointF(x, y); if (!poly.Contains(p)) { poly.Add(p); } }
public void AddPoint(float x, float y) { if (HasVertex(x, y) && (!allowDups)) { return; } int size = points.Length; TArray <float> tempPoints = new TArray <float>(); for (int i = 0; i < size; i++) { tempPoints.Add(points[i]); } tempPoints.Add(x); tempPoints.Add(y); int length = tempPoints.size; this.points = new float[length]; for (int i = 0; i < length; i++) { points[i] = tempPoints.Get(i); } if (x > maxX) { maxX = x; } if (y > maxY) { maxY = y; } if (x < minX) { minX = x; } if (y < minY) { minY = y; } FindCenter(); CalculateRadius(); pointsDirty = true; }
public TArray <Vector2f> GetVertices() { int size = points.Length; TArray <Vector2f> vertices = new TArray <Vector2f>(); for (int i = 0; i < size; i += 2) { vertices.Add(new Vector2f(points[i], points[i + 1])); } return(vertices); }
public virtual TArray <Interval> FindName(string name) { TArray <Interval> result = new TArray <Interval>(); for (int i = _scheduled.size - 1; i > -1; i--) { Interval u = _scheduled.Get(i); if (u != null && name.Equals(u.GetName())) { result.Add(u); } } return(result.Reverse()); }
public static void CalculateConvexHull(TArray <Vector2f> points, TArray <Vector2f> convexHullPoints) { if (points.size <= 1) { return; } Vector2f p; Vector2f bot = points.Get(0); for (int i = 1; i < points.size; i++) { Vector2f point = points.Get(i); if (point.y < bot.y) { bot = point; } } convexHullPoints.Add(bot); p = bot; do { int i; i = points.Get(0) == p ? 1 : 0; Vector2f cand = points.Get(i); for (i += 1; i < points.size; i++) { Vector2f point = points.Get(i); if (point != p && Area(p, cand, point) > 0) { cand = points.Get(i); } } convexHullPoints.Add(cand); p = cand; } while (p != bot); }
public override Token Extend(Token input) { var args = Extend(); if (args == null || args.ElementAtOrDefault(0) == null) { Compiler.ExceptionListener.Throw($"{this.Name} arguments cannot be null.", ExceptionType.CompilerException, input.Line); } int index = -1; if (args.ElementAtOrDefault(1) != null) { var nofail = int.TryParse(args[1].ToString(), out index); if (!nofail) { Compiler.ExceptionListener.Throw($"{this.Name} arguments must be a whole number.", ExceptionType.CompilerException, input.Line); } } var inputAsTobj = new TArray("arr", input.Value, input.Line);; if (inputAsTobj == null) { Compiler.ExceptionListener.Throw($"Cannot find Token [{input.Name}]", ExceptionType.CompilerException, input.Line); } if (index == -1) { inputAsTobj.Add(args[0]); return(inputAsTobj); } var ele = inputAsTobj.Arguments.ElementAtOrDefault(index); if (ele == null) { Compiler.ExceptionListener.Throw($"The element at [{index}] is null.", ExceptionType.NullReferenceException, input.Line); } inputAsTobj.Arguments[index] = args[0]; return(inputAsTobj); }
public virtual TArray <GameProcess> Find(string id) { TArray <GameProcess> list = new TArray <GameProcess>(); if (processes != null && processes.size > 0) { lock (this.processes) { for (LIterator <GameProcess> it = processes.ListIterator(); it.HasNext();) { GameProcess p = it.Next(); if (p != null && (string.ReferenceEquals(p.GetId(), id) || p.GetId().Equals(id))) { list.Add(p); } } } } return(list); }
public virtual TArray <GameProcess> Find(GameProcessType pt) { TArray <GameProcess> list = new TArray <GameProcess>(); if (processes != null && processes.size > 0) { lock (this.processes) { for (LIterator <GameProcess> it = processes.ListIterator(); it.HasNext();) { GameProcess p = it.Next(); if (p != null && p.GetProcessType() == pt) { list.Add(p); } } } } return(list); }
public virtual TouchedClick AddClickListener(ClickListener c) { if (c == null) { return(this); } if (c == this) { return(this); } if (clicks == null) { clicks = new TArray <ClickListener>(8); } if (!clicks.Contains(c)) { clicks.Add(c); } return(this); }
private void CalcNonConvexPoints() { if (points.Size() <= 3) { return; } Vector2f p; Vector2f v; Vector2f u; float res; for (int i = 0; i < points.Size() - 1; i++) { p = points.Get(i); Vector2f tmp = points.Get(i + 1); v = new Vector2f(); v.x = tmp.x - p.x; v.y = tmp.y - p.y; if (i == points.Size() - 2) { u = points.Get(0); } else { u = points.Get(i + 2); } res = u.x * v.y - u.y * v.x + v.x * p.y - v.y * p.x; if ((res > 0 && isCw) || (res <= 0 && !isCw)) { nonconvexPoints.Add(tmp); } } }
public bool Add(LRelease res) { return(objects.Add(res)); }
public CallbackList <T> Add(Callback <T> callback) { CheckState(); callbacks.Add(callback); return(this); }
public virtual bool Add(Interval sched) { return(_scheduled.Add(sched)); }
private bool Process(TArray <PointF> contour, TArray <PointF> result) { result.Clear(); int n = contour.Size(); if (n < 3) { return(false); } int[] sV = new int[n]; if (0.0f < Area(contour)) { for (int v = 0; v < n; v++) { sV[v] = v; } } else { for (int v = 0; v < n; v++) { sV[v] = (n - 1) - v; } } int nv = n; int count = 2 * nv; for (int v = nv - 1; nv > 2;) { if (0 >= (count--)) { return(false); } int u = v; if (nv <= u) { u = 0; } v = u + 1; if (nv <= v) { v = 0; } int w = v + 1; if (nv <= w) { w = 0; } if (Snip(contour, u, v, w, nv, sV)) { int a, b, c, s, t; a = sV[u]; b = sV[v]; c = sV[w]; result.Add(contour.Get(a)); result.Add(contour.Get(b)); result.Add(contour.Get(c)); for (s = v, t = v + 1; t < nv; s++, t++) { sV[s] = sV[t]; } nv--; count = 2 * nv; } } return(true); }