如果使一个照相机包围一个被观察物体

来源:互联网 发布:查询域名ip 编辑:程序博客网 时间:2024/05/01 22:50

    // set the field of view of the camera to enclose the bounding sphere of
    // the caster object.
    float fRadius = m_spCaster->GetWorldBound().GetRadius();      //获得被观察物体的包围球

 

    float fFOV =  fRadius / (kTarget - kTranslate).Length() * 0.95f;   //此处由于照相机放置的比较远(沿观察方向5000个单位)

 

    NiFrustum kFrust = m_spCamera->GetViewFrustum();
    kFrust.m_fLeft = -fFOV;
    kFrust.m_fRight = fFOV;
    kFrust.m_fTop = fFOV;
    kFrust.m_fBottom = -fFOV;


    m_spCamera->SetViewFrustum(kFrust);

原创粉丝点击