本文整理汇总了C++中CScene::TestRayForClosest方法的典型用法代码示例。如果您正苦于以下问题:C++ CScene::TestRayForClosest方法的具体用法?C++ CScene::TestRayForClosest怎么用?C++ CScene::TestRayForClosest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CScene
的用法示例。
在下文中一共展示了CScene::TestRayForClosest方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Sample
// protected functions:
CColor CRenderingCore::Sample(float x, float y, int curDepth)
{
CColor colArray[5];
CColor finalCol;
int colCount = 1;
double dXFraction;
double dYFraction;
/*******************************************************************
STRATEGY:
1. First compute the color for the central pixel.
2. Check if we have to dive further into the oversampling recursion.
3. Average the colors.
4. Return the color.
*******************************************************************/
// 1.
/***********************************************************
SUB_STEPS:
1.1. Calculate the x and y fractions.
1.2. Get the corresponding ray from the camera.
1.3. Test the scene to see which object intersects the ray.
1.4. Query the object for teh color of the point.
***********************************************************/
// 1.1.
dYFraction = (double)y / (double)m_iPixelY;
dXFraction = (double)x / (double)m_iPixelX;
// 1.2.
CRay ray = m_pcamCurrent->GetRay(dXFraction, dYFraction);
// 1.3.
CIntersectionInfo hitInfo = g_objScene.TestRayForClosest(ray);
// 1.4.
colArray[0] = hitInfo.GetShape()->ShadePoint(hitInfo);
// 2.
if (curDepth < m_iSupersampleDepth)
{
colCount = 5;
float inc = 1.0f / (float) pow(2.0f, (float)curDepth);
colArray[1] = Sample (x + inc, y, curDepth + 1);
colArray[2] = Sample (x - inc, y, curDepth + 1);
colArray[3] = Sample (x, y + inc, curDepth + 1);
colArray[4] = Sample (x, y - inc, curDepth + 1);
}
// 3.
finalCol = CColor::Average(colArray, colCount);
// 4.
return finalCol;
}