Ejemplo n.º 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 ) );
}
Ejemplo n.º 2
0
  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();
  }
Ejemplo n.º 3
0
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 );
}