当前位置: 首页>>代码示例>>C++>>正文


C++ BoundingBox::GetCorners方法代码示例

本文整理汇总了C++中BoundingBox::GetCorners方法的典型用法代码示例。如果您正苦于以下问题:C++ BoundingBox::GetCorners方法的具体用法?C++ BoundingBox::GetCorners怎么用?C++ BoundingBox::GetCorners使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BoundingBox的用法示例。


在下文中一共展示了BoundingBox::GetCorners方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: yAxis

BoundingCone::BoundingCone(const BoundingBox& box, const D3DXMATRIX& projection, const D3DXVECTOR3& apex)
{
	const D3DXVECTOR3 yAxis(0.f, 1.f, 0.f);
    const D3DXVECTOR3 zAxis(0.f, 0.f, 1.f);
    const D3DXVECTOR3 negZAxis(0.f, 0.f, -1.f);

    //  compute a tight bounding sphere for the vertices of the bounding boxes.
    //  the vector from the apex to the center of the sphere is the optimized view direction
    //  start by xforming all points to post-projective space
    D3DXVECTOR3 ppPts[ box.CornerCount ];
	box.GetCorners( ppPts );

	for( int index=0; index<box.CornerCount; index++)
    {
        D3DXVec3TransformCoord( &ppPts[index], &ppPts[index], &projection );
    }

    //  get minimum bounding sphere
	BoundingSphere bSphere = BoundingSphere::CreateFromPoints( ppPts,box.CornerCount );

    float min_cosTheta = 1.f;
    
    m_direction = bSphere.GetCenter() - apex;
    D3DXVec3Normalize(&m_direction, &m_direction);

    D3DXVECTOR3 axis = yAxis;

    if( fabsf(D3DXVec3Dot(&yAxis, &m_direction)) > 0.99f )
	{
        axis = zAxis;
	}

    D3DXMatrixLookAtLH(&m_lookAt, &apex, &(apex+m_direction), &axis);

    m_near = 1e32f;
    m_far = 0.f;

    float maxx=0.f, maxy=0.f;
    for( int index=0; index<box.CornerCount; index++ )
    {
        D3DXVECTOR3 tmp;
        D3DXVec3TransformCoord(&tmp, &ppPts[index], &m_lookAt);
        maxx = max(maxx, fabsf(tmp.x / tmp.z));
        maxy = max(maxy, fabsf(tmp.y / tmp.z));
        m_near = min(m_near, tmp.z);
        m_far  = max(m_far, tmp.z);
    }

    m_fovx = atanf(maxx);
	m_fovy = atanf(maxy);
}
开发者ID:ZeusAFK,项目名称:MikuMikuGameEngine,代码行数:51,代码来源:BoundingCone.cpp


注:本文中的BoundingBox::GetCorners方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。