예제 #1
0
void MetavoxelSystem::render() {
    // update the frustum
    ViewFrustum* viewFrustum = Application::getInstance()->getViewFrustum();
    _frustum.set(viewFrustum->getFarTopLeft(), viewFrustum->getFarTopRight(), viewFrustum->getFarBottomLeft(),
        viewFrustum->getFarBottomRight(), viewFrustum->getNearTopLeft(), viewFrustum->getNearTopRight(),
        viewFrustum->getNearBottomLeft(), viewFrustum->getNearBottomRight());
    
    RenderVisitor renderVisitor(getLOD());
    guideToAugmented(renderVisitor);
}
예제 #2
0
void DrawFrustum::getVertices(const ViewFrustum& frustum, glm::vec3 vertices[8]) {
    vertices[0] = frustum.getNearTopLeft();
    vertices[1] = frustum.getNearTopRight();
    vertices[2] = frustum.getNearBottomRight();
    vertices[3] = frustum.getNearBottomLeft();
    vertices[4] = frustum.getFarTopLeft();
    vertices[5] = frustum.getFarTopRight();
    vertices[6] = frustum.getFarBottomRight();
    vertices[7] = frustum.getFarBottomLeft();
}
예제 #3
0
void ConicalViewFrustum::set(const ViewFrustum& viewFrustum) {
    // The ConicalViewFrustum has two parts: a central sphere (same as ViewFrustum) and a circular cone that bounds the frustum part.
    // Why?  Because approximate intersection tests are much faster to compute for a cone than for a frustum.
    _position = viewFrustum.getPosition();
    _radius = viewFrustum.getCenterRadius();
    _farClip = viewFrustum.getFarClip();

    auto topLeft = viewFrustum.getNearTopLeft() - _position;
    auto topRight = viewFrustum.getNearTopRight() - _position;
    auto bottomLeft = viewFrustum.getNearBottomLeft() - _position;
    auto bottomRight = viewFrustum.getNearBottomRight() - _position;
    auto centerAxis = 0.25f * (topLeft + topRight + bottomLeft + bottomRight); // Take the average

    _direction = glm::normalize(centerAxis);
    _angle = std::max(std::max(angleBetween(_direction, topLeft),
                               angleBetween(_direction, topRight)),
                      std::max(angleBetween(_direction, bottomLeft),
                               angleBetween(_direction, bottomRight)));
}