Ejemplo n.º 1
0
bool GeneticEventManager::handleShortInsert( ge_id_t eID, int len, pos_t & pos, allele_t & all ) {
    pos_t ePos;

    decodePosition( eID, ePos );

    if( ePos <= pos && pos < ePos + len ) {
        all = eID.bytes[4 + (pos - ePos)];
        return true;
    }

    return false;
}
Ejemplo n.º 2
0
//WARNING: do not use this method with Ogre
component::collision::BodyPicked PickHandler::findCollisionUsingColourCoding(const defaulttype::Vector3& origin,
        const defaulttype::Vector3& direction)
{
    assert(_fboAllocated);
    BodyPicked result;
#ifndef SOFA_NO_OPENGL
    result.dist =  0;
    sofa::defaulttype::Vec4f color;
    int x = mousePosition.x;
    int y = mousePosition.screenHeight - mousePosition.y;
    TriangleModel* tmodel;
    SphereModel* smodel;
#ifdef SOFA_HAVE_GLEW
    _fbo.start();
    if(renderCallback)
    {
        renderCallback->render(ColourPickingVisitor::ENCODE_COLLISIONELEMENT );
        glReadPixels(x,y,1,1,_fboParams.colorFormat,_fboParams.colorType,color.elems);
        decodeCollisionElement(color,result);
        renderCallback->render(ColourPickingVisitor::ENCODE_RELATIVEPOSITION );
        glReadPixels(x,y,1,1,_fboParams.colorFormat,_fboParams.colorType,color.elems);
        if( ( tmodel = dynamic_cast<TriangleModel*>(result.body) ) != NULL )
        {
            decodePosition(result,color,tmodel,result.indexCollisionElement);
        }
        if( ( smodel = dynamic_cast<SphereModel*>(result.body)) != NULL)
        {
            decodePosition(result, color,smodel,result.indexCollisionElement);
        }
        result.rayLength = (result.point-origin)*direction;
    }
    _fbo.stop();
#endif // SOFA_HAVE_GLEW
#endif // SOFA_NO_OPENGL
    return result;
}