Hi Carsten, Carsten Neumann schreef: > > there is Camera::getWorldToScreen(Matrixr &result, > const Viewport &port) which should give you the matrix > for that transformation. > I guess that the multiplication of a vector with this transformation matrix results in the clipping coordinates of my object (the 3D pointer) ? After this, I rescale these coordinates according to the viewport size. These two steps are done in the two routines below.
After the WorldToViewportCoordinates() method, I'm calling the calcViewRay() function with the obtained X and Y coordinates. When I use the calculated ray for my picking routine, it doesn't give the expected results: the picking ray is not perpendicular on the pointer into the screen. To clarify my intentions, please look at this screenshot: http://lumumba.uhasselt.be/~meskensj/opensg/opensg_picking.JPG. The red sphere is my pointer, when a ray is shot from the pointer, I expect that the big white box should be selected. Well, this is not the case! Can someone explain this behavior and/or give me some advice to solve this problem? //Convert a point in the world to the clipping coordinates void Renderer::WorldToClippingCoordinates(Vec3f& point, float& x, float& y, float& z) { Matrix wts; m_matrixCamera->getWorldToScreen(wts,*m_viewport); Vec3f dest; wts.multVecMatrix(point,dest); x = dest[0]; y = dest[1]; z = dest[3]; } //Map to viewport coordinates void Renderer::WorldToViewportCoordinates(Vec3f& point, float& x, float& y) { float _x,_y,_z; WorldToClippingCoordinates(point,_x,_y,_z); //Map to a 0..1 interval _x = (_x + 1)/2.0; _y = (_y + 1)/2.0; //Scale x = _x * SCREEN_WIDTH; y = ((_y * SCREEN_HEIGHT) - SCREEN_HEIGHT)*(-1); } Thanks in advance, Jan Meskens ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Opensg-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/opensg-users
