Example #1
0
bool RCViewableTransform::unitViewportCoordinates(xuint32 x, xuint32 y, float &xUnit, float &yUnit) const
  {
  xint32 adjX = x - viewportX();
  xint32 adjY = y - viewportY();
  if(adjX < 0 || adjY < 0 || adjX > (xint32)viewportWidth() || adjY > (xint32)viewportHeight())
    {
    xUnit = 0.0f;
    yUnit = 0.0f;
    return false;
    }

  xUnit = (float)adjX/viewportWidth();
  yUnit = (float)adjY/viewportHeight();

  xUnit *= 2.0f;
  yUnit *= 2.0f;

  xUnit -= 1.0f;
  yUnit -= 1.0f;

  // viewport units are in positive down, flip to posisitve up
  yUnit *= -1.0f;

  return true;
  }
Example #2
0
void fillViewportLocationFromViewport(SEXP vp, LViewportLocation *vpl) 
{
    vpl->x = viewportX(vp);
    vpl->y = viewportY(vp);
    vpl->width = viewportWidth(vp);
    vpl->height = viewportHeight(vp);
    vpl->hjust = viewportHJust(vp);
    vpl->vjust = viewportVJust(vp);
}
Example #3
0
void RCViewableTransform::approximatePixelSizeAtDistance(float distanceFromCamera, float &xScale, float &yScale) const
  {
  xuint32 x = viewportX() + ((float)viewportWidth()/2.0f);
  xuint32 y = viewportY() + ((float)viewportHeight()/2.0f);

  Eks::Vector3D a = worldSpaceAtDepthFromScreenSpace(x, y, distanceFromCamera);
  Eks::Vector3D b = worldSpaceAtDepthFromScreenSpace(x+1, y, distanceFromCamera);
  Eks::Vector3D c = worldSpaceAtDepthFromScreenSpace(x, y+1, distanceFromCamera);

  xScale = (a - b).norm();
  yScale = (a - c).norm();
  }
Example #4
0
bool RCViewableTransform::screenViewportCoordinates(float xUnit, float yUnit, float &x, float &y) const
  {
  xUnit += 1.0f;
  yUnit += 1.0f;

  xUnit /= 2.0f;
  yUnit /= -2.0f;

  xUnit *= viewportWidth();
  yUnit *= viewportHeight();

  x = viewportX() + xUnit;
  y = viewportY() + yUnit;

  return true;
  }