Пример #1
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
cvf::Vec3f RivGridBoxGenerator::cornerDirection(FaceType face1, FaceType face2)
{
    cvf::Vec3f dir = sideNormalOutwards(face1) + sideNormalOutwards(face2);
    dir.normalize();

    return dir;
}
Пример #2
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RivGridBoxGenerator::updateFromCamera(const cvf::Camera* camera)
{
    m_gridBoxModel->removeAllParts();

    if (m_gridBoxFaceParts.size() == 0) return;

    std::vector<bool> faceVisibility(6, false);
    for (size_t i = POS_X; i <= NEG_Z; i++)
    {
        bool isFaceVisible = false;
        cvf::Vec3f sideNorm = sideNormalOutwards((FaceType)i);

        if (camera->projection() == cvf::Camera::PERSPECTIVE)
        {

            cvf::Vec3d camToSide = camera->position() - pointOnSide((FaceType)i);
            camToSide.normalize();

            isFaceVisible = sideNorm.dot(cvf::Vec3f(camToSide)) < 0.0;
        }
        else
        {
            cvf::Vec3d camToSide = camera->direction();
            isFaceVisible = sideNorm.dot(cvf::Vec3f(camToSide)) > 0.0;
        }

        if (isFaceVisible)
        {
            m_gridBoxModel->addPart(m_gridBoxFaceParts[i].p());
            faceVisibility[i] = true;
        }
    }

    std::vector<bool> edgeVisibility(12, false);
    computeEdgeVisibility(faceVisibility, edgeVisibility);

    CVF_ASSERT(m_gridBoxLegendParts.size() == (NEG_X_NEG_Y + 1)*2);
    for (size_t i = POS_Z_POS_X; i <= NEG_X_NEG_Y; i++)
    {
        if (edgeVisibility[i])
        {
            // We have two parts for each edge - line and text
            m_gridBoxModel->addPart(m_gridBoxLegendParts[2 * i].p());
            m_gridBoxModel->addPart(m_gridBoxLegendParts[2 * i + 1].p());
        }
    }

    m_gridBoxModel->updateBoundingBoxesRecursive();
}