本文整理汇总了C++中AABBox::GetVertices方法的典型用法代码示例。如果您正苦于以下问题:C++ AABBox::GetVertices方法的具体用法?C++ AABBox::GetVertices怎么用?C++ AABBox::GetVertices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AABBox
的用法示例。
在下文中一共展示了AABBox::GetVertices方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Cull
bool ModelComponent::Cull(const tt::GameContext& context)
{
tt::Vector3 vertices[8];
tt::Matrix4x4 wvpMat = m_pTransform->GetWorldMatrix() * context.pGame->GetActiveScene()->GetActiveCamera()->GetView() * context.pGame->GetActiveScene()->GetActiveCamera()->GetProjection();
AABBox aabBox = m_pModel->GetAABB();
aabBox.GetVertices(vertices);
//If one point is inside the view frustum, the bounding volume is visible
for(unsigned int i=0; i<8; ++i){
vertices[i] = vertices[i].TransformPoint(wvpMat);
if( vertices[i].x >= -1 && vertices[i].x <= 1 &&
vertices[i].y >= -1 && vertices[i].y <= 1 &&
vertices[i].z >= 0 && vertices[i].z <= 1 )
return false;
}
//Additional checks to make sure we don't cull edge cases
tt::Matrix4x4 invWvpMat = wvpMat.Inverse();
tt::Vector3 origin[] = {tt::Vector3(-1, -1, 0),
tt::Vector3(-1, 1, 0),
tt::Vector3( 1, -1, 0),
tt::Vector3( 1, 1, 0),
};
tt::Vector3 destination[] = {tt::Vector3(-1, -1, 1),
tt::Vector3(-1, 1, 1),
tt::Vector3( 1, -1, 1),
tt::Vector3( 1, 1, 1),
};
tt::Vector3 direction = tt::Vector3(0,0,1).TransformVector(invWvpMat);
if(aabBox.Intersect(Ray(origin[0].TransformPoint(invWvpMat), destination[0].TransformPoint(invWvpMat)), 0, 1) )
return false;
if(aabBox.Intersect(Ray(origin[1].TransformPoint(invWvpMat), destination[1].TransformPoint(invWvpMat)), 0, 1) )
return false;
if(aabBox.Intersect(Ray(origin[2].TransformPoint(invWvpMat), destination[2].TransformPoint(invWvpMat)), 0, 1) )
return false;
if(aabBox.Intersect(Ray(origin[3].TransformPoint(invWvpMat), destination[3].TransformPoint(invWvpMat)), 0, 1) )
return false;
return true;
}