Beispiel #1
0
osg::Vec4d ConfigManager::getVec4d(std::string attributeX,
        std::string attributeY, std::string attributeZ, std::string attributeW,
        std::string path, osg::Vec4d def, bool * found)
{
    bool hasEntry = false;
    bool isFound;

    osg::Vec4d result;
    result.x() = getDouble(attributeX,path,def.x(),&isFound);
    if(isFound)
    {
        hasEntry = true;
    }
    result.y() = getDouble(attributeY,path,def.y(),&isFound);
    if(isFound)
    {
        hasEntry = true;
    }
    result.z() = getDouble(attributeZ,path,def.z(),&isFound);
    if(isFound)
    {
        hasEntry = true;
    }
    result.w() = getDouble(attributeW,path,def.w(),&isFound);
    if(isFound)
    {
        hasEntry = true;
    }

    if(found)
    {
        *found = hasEntry;
    }
    return result;
}
void DataOutputStream::writeVec4d(const osg::Vec4d& v){
    writeDouble(v.x());
    writeDouble(v.y());
    writeDouble(v.z());
    writeDouble(v.w());

    if (_verboseOutput) std::cout<<"read/writeVec4d() ["<<v<<"]"<<std::endl;
}
Beispiel #3
0
osg::Vec4 calcIntersect (osg::Vec4d P0, osg::Vec4d u, osg::Vec4d V0, osg::Vec4d n)
{
   u.normalize();
   n.normalize();

   osg::Vec4 w = P0 - V0;

   double s =( (-n) * w) / (n * u);

   if (s < 0) return osg::Vec4d(0,0,0,0);
   else return P0 + (u * s);
}
osg::Vec4d lerp_Vec4d(osg::Vec4d v0, osg::Vec4d v1, double t)
{
	osg::Vec4d vec;
	vec.x() = lerp_lf(v0.x(), v1.x(), t);
	vec.y() = lerp_lf(v0.y(), v1.y(), t);
	vec.z() = lerp_lf(v0.z(), v1.z(), t);
	vec.w() = lerp_lf(v0.w(), v1.w(), t);
	return vec;

}
Beispiel #5
0
double LispSM::calcNoptGeneral(const osg::Matrix lightSpace, const osg::BoundingBox &B_ls) const
{
    const osg::Matrix &eyeView      = getViewMatrix();
    const osg::Matrix invLightSpace = osg::Matrix::inverse(lightSpace);

    const osg::Vec3d z0_ls = getZ0_ls(lightSpace, _E, B_ls.zMax(), getEyeDir());
    const osg::Vec3d z1_ls = osg::Vec3d(z0_ls.x(), z0_ls.y(), B_ls.zMin());

    // to world
    const osg::Vec4d z0_ws = osg::Vec4d(z0_ls, 1) * invLightSpace;
    const osg::Vec4d z1_ws = osg::Vec4d(z1_ls, 1) * invLightSpace;

    // to eye
    const osg::Vec4d z0_cs = z0_ws * eyeView;
    const osg::Vec4d z1_cs = z1_ws * eyeView;

    double z0 = -z0_cs.z() / z0_cs.w();
    double z1 = -z1_cs.z() / z1_cs.w();

    if (z1 / z0 <= 1.0)
    {
        // solve camera pos singularity in light space problem brutally:
        // if extreme points of B projected to Light space extend beyond
        // camera frustum simply use B extents in camera frustum

        // Its not optimal selection but ceratainly better than negative N
        osg::BoundingBox bb = _hull.computeBoundingBox(eyeView);
        z0 = -bb.zMax();
        if (z0 <= 0)
            z0 = 0.1;

        z1 = -bb.zMin();
        if (z1 <= z0)
            z1 = z0 + 0.1;
    }

    const double d = osg::absolute(B_ls.zMax() - B_ls.zMin());

    double N = d / (sqrt(z1 / z0) - 1.0);
#if PRINT_COMPUTED_N_OPT
    std::cout
        << " N=" << std::setw(8) << N
        << " n=" << std::setw(8) << z0
        << " f=" << std::setw(8) << z1
        << "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
        << std::flush;
#endif
    return N;
}
Beispiel #6
0
void Clustering::Sphere::transform( osg::Vec3d position, osg::Vec3d scale, osg::Vec4d color )
{
	osg::StateSet* ss = sphereGeometry->getOrCreateStateSet();

	osg::Material* material = new osg::Material();
	material->setAmbient( osg::Material::FRONT,color );
	material->setDiffuse( osg::Material::FRONT,color );
	material->setSpecular( osg::Material::FRONT,color );
	material->setAlpha( osg::Material::FRONT,static_cast<float>( color.a() ) );

	ss->setAttribute( material,osg::StateAttribute::OVERRIDE );
	ss->setMode( GL_DEPTH_TEST,osg::StateAttribute::ON );
	ss->setMode( GL_LIGHTING,osg::StateAttribute::OFF );
	ss->setMode( GL_BLEND,osg::StateAttribute::ON );
	ss->setRenderingHint( osg::StateSet::TRANSPARENT_BIN );

	osg::ref_ptr<osg::Depth> depth = new osg::Depth;
	depth->setWriteMask( false );
	ss->setAttributeAndModes( depth, osg::StateAttribute::ON );
	ss->setAttributeAndModes( new osg::BlendFunc, osg::StateAttribute::ON );

	at->setPosition( position * 1 );
	at->setScale( scale );
}
Beispiel #7
0
void ArucoThread::printVec( const osg::Vec4d v, const QString name ) const
{
	qDebug() << name << " " << v.x() << " " << v.y() << " " << v.z() << " " << v.w();
}