MCPcopy Create free account
hub / github.com/bumptop/BumpTop / WorldToClient

Function WorldToClient

trunk/win/Source/BT_Util.cpp:6995–7025  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6993}
6994
6995Vec3 WorldToClient(Vec3 p, bool reverseY, bool zeroZ)
6996{
6997 // we hit this function a lot, so to save on the calls, we will locally use the singleton
6998 Camera * camera = cam;
6999 // TODO world2window should be replaced by this
7000#ifdef DXRENDER
7001 D3DXVECTOR3 window;
7002 D3DXVec3TransformCoord(&window, (const D3DXVECTOR3 *)&p, &dxr->viewProj);
7003 window.x = (window.x + 1) / 2 * dxr->viewport.Width + dxr->viewport.X;
7004 if (reverseY)
7005 window.y = -window.y;
7006 window.y = (window.y + 1) / 2 * dxr->viewport.Height + dxr->viewport.Y;
7007 if (zeroZ)
7008 window.z = 0;
7009 return Vec3(window.x, window.y, window.z);
7010#else
7011 GLdouble wx = 0.0, wy = 0.0, wz = 0.0; // returned world x, y, z coords
7012 float realy;
7013
7014 GLint * viewport = camera->glViewport();
7015 GLdouble * projmatrix = camera->glProjectionMatrix();
7016 GLdouble * mvmatrix = camera->glModelViewMatrix();
7017 // note viewport[3] is height of window in pixels
7018 gluProject (p.x, p.y, p.z, mvmatrix, projmatrix, viewport, &wx, &wy, &wz);
7019
7020 realy = float(reverseY ? viewport[3] - int(wy) - 1 : int(wy));
7021
7022 if(zeroZ) wz=0;
7023 return Vec3(float(wx),realy,float(wz));
7024#endif
7025}
7026
7027//Returns what the mouse cursor translates too in world coordinates. Default is on the floor. Set yValue to a different world Space number to get a different point on the ray
7028Vec3 CurrentWorldMousePos()

Callers 12

RenderCallbackFunction · 0.85
isPointInPolygonFunction · 0.85
Key_RemoveFromPileFunction · 0.85
checkForCrossMethod · 0.85
reshapeTextLabelsMethod · 0.85
onDragEndMethod · 0.85
onRenderMethod · 0.85
getScreenBoundingBoxMethod · 0.85

Calls 3

glViewportMethod · 0.80
glProjectionMatrixMethod · 0.80
glModelViewMatrixMethod · 0.80

Tested by

no test coverage detected