本文整理汇总了C++中APoint::W方法的典型用法代码示例。如果您正苦于以下问题:C++ APoint::W方法的具体用法?C++ APoint::W怎么用?C++ APoint::W使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类APoint
的用法示例。
在下文中一共展示了APoint::W方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PointWorldToViewPort
//----------------------------------------------------------------------------
Vector2f Renderer::PointWorldToViewPort (const APoint &point, bool *isInBack)
{
HMatrix matProjView = GetProjectionMatrix() * GetViewMatrix();
HPoint hPoint(point.X(), point.Y(), point.Z(), point.W());
HPoint tempPoint = matProjView * hPoint;
if (isInBack)
{
if (tempPoint.Z() <= 0)
*isInBack = true;
else
*isInBack = false;
}
float wInv = 1.0f / tempPoint.W();
//投影坐标范围为[-1,1]要变成[0,1]
Vector2f screenPoint;
screenPoint.X() = (1.0f + tempPoint.X()*wInv)/2.0f;
screenPoint.Y() = (1.0f + tempPoint.Y()*wInv)/2.0f;
//投影坐标范围为[0,1]要变成视口内坐标
int viewX, viewY, viewW, viewH;
GetViewport(viewX, viewY, viewW, viewH);
screenPoint.X() = viewX + screenPoint.X()*viewW;
screenPoint.Y() = viewY + screenPoint.Y()*viewH;
return screenPoint;
}
示例2: PointWorldToViewPort
//----------------------------------------------------------------------------
Vector2f RenderStep::PointWorldToViewPort(const APoint &point,
bool *isInBack)
{
Rectf viewPort = mViewPort;
if (viewPort.IsEmpty())
viewPort = Rectf(0.0f, 0.0f, mSize.Width, mSize.Height);
HMatrix matProjView = mCamera->GetProjectionMatrix() * mCamera->GetViewMatrix();
HPoint hPoint(point.X(), point.Y(), point.Z(), point.W());
HPoint tempPoint = matProjView * hPoint;
if (isInBack)
{
if (tempPoint.Z() <= 0)
*isInBack = true;
else
*isInBack = false;
}
float wInv = 1.0f / tempPoint.W();
//投影坐标范围为[-1,1]要变成[0,1]
Vector2f screenPoint;
screenPoint.X() = (1.0f + tempPoint.X()*wInv) / 2.0f;
screenPoint.Y() = (1.0f + tempPoint.Y()*wInv) / 2.0f;
//投影坐标范围为[0,1]要变成视口内坐标
screenPoint.X() = viewPort.Left + screenPoint.X()*viewPort.Width();
screenPoint.Y() = viewPort.Bottom + screenPoint.Y()*viewPort.Height();
return screenPoint;
}