コード例 #1
0
void SquarePlane::computeBounds(){

    glm::vec4 vertices[]{
        glm::vec4( .5f, .5f, 0.f, 1.f ),
        glm::vec4( .5f, -.5f, 0.f, 1.f ),
        glm::vec4( -.5f, .5f, 0.f, 1.f ),
        glm::vec4( -.5f, -.5, 0.f, 1.f ),
    };

    glm::vec3 vertices_in_world[]{
        glm::vec3( transform.T() * vertices[ 0 ] ),
        glm::vec3( transform.T() * vertices[ 1 ] ),
        glm::vec3( transform.T() * vertices[ 2 ] ),
        glm::vec3( transform.T() * vertices[ 3 ] ),
    };

    glm::vec3 max_bound( -1e6f );
    glm::vec3 min_bound( 1e6f );

    for( int i = 0; i < 4; ++i ){
        max_bound = glm::max( max_bound, vertices_in_world[ i ] );
        min_bound = glm::min( min_bound, vertices_in_world[ i ] );
    }

    pBBox = new BoundingBox( max_bound + glm::vec3( .1f ), min_bound - glm::vec3( -.1f ) );
}
コード例 #2
0
ファイル: seqdbatlas.cpp プロジェクト: svn2github/ncbi_tk
/// Set all parameters.
void CSeqDBMapStrategy::x_SetBounds(Uint8 bound)
{
    Uint8 max_bound(0);
    Uint8 max_slice(0);

    if (sizeof(int*) == 8) {
        max_bound = e_MaxMemory64;
        max_slice = e_MaxSlice64;
    } else {
        max_bound = e_MaxMemory32;
        max_slice = e_MaxSlice32;
    }

    int overhang_ratio = 32;
    int slice_ratio = 10;

    // If a mapping request has never failed, use large slice for
    // efficiency.  Otherwise, if the client follows a mostly linear
    // access pattern, use middle sized slices, and if not, use small
    // slices.

    const int no_limits   = 4;
    const int linear_oids = 10;
    const int random_oids = 80;

    if (! m_MapFailed) {
        slice_ratio = no_limits;
    } else if (m_InOrder) {
        slice_ratio = linear_oids;
    } else {
        slice_ratio = random_oids;
    }

    m_MaxBound = x_Pick(e_MinMemory,
                        min(max_bound, bound),
                        bound);

    m_SliceSize = x_Pick(e_MinSlice,
                         max_slice,
                         m_MaxBound / slice_ratio);

    m_RetBound = x_Pick(e_MinMemory,
                        m_MaxBound-((m_SliceSize*3)/2),
                        (m_MaxBound*8)/10);

    m_Overhang = x_Pick(e_MinOverhang,
                        e_MaxOverhang,
                        m_SliceSize / overhang_ratio);

    m_AdjustedBound = false;
}
コード例 #3
0
ファイル: light_point.cpp プロジェクト: jonathantompson/jtil
  LightPoint::LightPoint() : Light()  {
    pos_world_.set(0, 0, 0);

    if (outside_model_rad_scale_ == 0) {
      float out_rad = GeometryManager::calcSphereOutsideRadius(
        LIGHT_POINT_MODEL_STACKS, LIGHT_POINT_MODEL_SLICES,
        LIGHT_POINT_MODEL_INSIDE_RADIUS);
      outside_model_rad_scale_ = out_rad / LIGHT_POINT_MODEL_INSIDE_RADIUS;
    }

    float out_rad = outside_model_rad_scale_ * LIGHT_POINT_MODEL_INSIDE_RADIUS;
    Float3 min_bound(-out_rad, -out_rad, -out_rad);
    Float3 max_bound(out_rad, out_rad, out_rad);
    aabbox_ = new objects::AABBox();
    aabbox_->init(min_bound, max_bound);

    update();
  }
コード例 #4
0
ファイル: cube.cpp プロジェクト: itoupeter/Computer_Graphics
void Cube::computeBounds(){

    glm::vec4 vertices[]{
        { .5f, .5f, .5f, 1.f }, { .5f, .5f, -.5f, 1.f },
        { .5f, -.5f, .5f, 1.f }, { .5f, .5f, -.5f, 1.f },
        { -.5f, .5f, .5f, 1.f }, { -.5f, .5f, -.5f, 1.f },
        { -.5f, -.5f, .5f, 1.f }, { -.5f, .5f, -.5f, 1.f },
    };

    glm::vec3 vertices_in_world[ 8 ];
    glm::vec3 max_bound( -1e6f );
    glm::vec3 min_bound( 1e6f );

    for( int i = 0; i < 8; ++i ){
        vertices_in_world[ i ] = glm::vec3( transform.T() * vertices[ i ] );
        max_bound = glm::max( max_bound, vertices_in_world[ i ] );
        min_bound = glm::min( min_bound, vertices_in_world[ i ] );
    }

    pBBox = new BoundingBox( max_bound, min_bound );
}