protected T_BOUNDS getBounds(CTSPPointList citys) { T_BOUNDS ret = new T_BOUNDS(); if (citys.length() > 0) { ret.left = double.MaxValue; ret.bottom = double.MaxValue; for (int cityIndex = 0; cityIndex < citys.length(); cityIndex++) { CTSPPoint city = citys.getPoint(cityIndex); if (city.x < ret.left) { ret.left = city.x; } if (city.y < ret.bottom) { ret.bottom = city.y; } if (city.x > ret.right) { ret.right = city.x; } if (city.y > ret.top) { ret.top = city.y; } } } else { ret.left = 0; ret.bottom = 0; ret.right = this.Width; ret.top = this.Height; } return(ret); }
public void initViewPort() { InitializeContexts(); Gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); Gl.glMatrixMode(Gl.GL_PROJECTION); Gl.glLoadIdentity(); mBounds = getBounds(mCityList); mBounds.left -= 5; mBounds.right += 5; mBounds.bottom -= 5; mBounds.top += 5; // hier müssen wir bestimmen wie groß die Renderfläche sein soll // wenn z.b. die äußerste Stadt bei 345, 239 liegt, sollte der // Viewport ein wenig größer sein Gl.glOrtho(mBounds.left, mBounds.right, mBounds.bottom, mBounds.top, -100.0f, 100.0f); }
protected T_BOUNDS getBounds(List <CVector2f> citys) { T_BOUNDS ret = new T_BOUNDS(); ret.left = 0; ret.bottom = 0; foreach (CVector2f city in citys) { if (city.x > ret.right) { ret.right = city.x; } if (city.y > ret.top) { ret.top = city.y; } } return(ret); }