From: Timothy R. <tr...@si...> - 2009-12-14 17:42:53
|
On Dec 14, 2009, at 4:22 AM, Fabien Chéreau wrote: > Hi, it is StelProjector::project(). You Vec3d has to be in the same > reference frame as the StelProjector you use. > Not that the result is given in a Vec3d, but only the 2 first > components contain the x,y screen coordinates. > Fabien > > > On Mon, Dec 14, 2009 at 03:14, Timothy Reaves > <tr...@si...> wrote: >> If I have a vec3d, how do I convert that to screen coordinates? I thought it was unproject, but that doesn't seem to do it. Then I'm doing it wrong, I guess. I'm using the following code to determine where a line from the center of the screen to the south pole intersects the viewport. // Center of screen Vec3d cS(prj->getViewportPosX()+prj->getViewportWidth()/2, prj->getViewportPosY()+prj->getViewportHeight()/2+1, 0); Vec3d cV; prj->unProject(cS, cV); Vec3d southPole = Vec3d(0.0, 0.0, -1.0); Vec3d intersect; if (prj->project(southPole, win) && prj->checkInViewport(win)) { southVector = southPole; } else { Vec3d southScreen; prj->project(southPole, southScreen); southScreen = prj->viewPortIntersect(centerScreen, southScreen); prj->unProject(southScreen, southVector); } When I print out southScreen, the numbers do not represent the pixel coordinates on the screen. What am I doing wrong? Thanks. |