Hello, I have a couple of questions - I think these are simple ones. 1. How can I Get screen coordinates for a specified world location. I have objects locations in world coordinates and I have to paint it on the map (from world coordinates to screen coordinates), but I fail to do that . I managed to do the opposite: public Point2D WorldPntToScreen(Point3D worldPnt)     {      Matrix4D modelViewTransform = GetModelViewTransform();      Matrix4D projectionTransform = GetProjectionTransform();      Matrix4D mat = projectionTransform * modelViewTransform;      Point3D retPnt = mat.Transform(worldPnt);      double clientWidth = (double)ClientSize.Width;      double clientHeight = (double)ClientSize.Height;      Point3D ScreenPoint = new Point3D((double)-retPnt.X * clientWidth /2d + 1d,         (double)retPnt.Y *clientHeight / 2d - 1d, 0);      return new Point2D(ScreenPoint.X, ScreenPoint.Y);     }
and I tried to do the same in the opposite direction (with mat.Inverse) but I think I fail in the normalization process of the received screen point. public Point2D ScreenPntToWorld(Point2D pnt)     {      Matrix4D modelViewTransform = GetModelViewTransform();      Matrix4D projectionTransform = GetProjectionTransform();      double clientWidth = (double)ClientSize.Width;      double clientHeight = (double)ClientSize.Height;      Point3D startPoint = new Point3D((double)pnt.X / clientWidth * 2d - 1d,         -(double)pnt.Y / clientHeight * 2d + 1d, 0);      Matrix4D mat = projectionTransform * modelViewTransform;      Point3D retPnt = mat.GetInverse().Transform(startPoint);      return new Point2D(retPnt.X, retPnt.Y);     } 2. Another thing is when I try to draw an image.ico with a transparent part in the paint event, the transparent part appears white. I'm doing it like this (same way I did it with the GDI): private void ViewControl_Paint(object sender, PaintEventArgs e) { glGraphics.Paint(ClientSize.Width, ClientSize.Height); Graphics g = e.Graphics; Point2D screenPnt = WorldPntToScreen(new Point3D(788033.658798808, 2960313.2685174546, 14.129180746096438));//FAILS Image img = Image.FromFile('Operational.ICO'); g.DrawImage(img, new Rectangle((int)screenPnt.X - 12, (int)screenPnt.Y - 12, 24, 24), new Rectangle(0, 0, img.Width, img.Height), GraphicsUnit.Pixel); }
Your quick help would be truly appreciated. Thanks in advance
Shlomit
|