Example #1
0
void VRRenderManager::initCalib(VRMaterialPtr mat) {
    string shdrDir = VRSceneManager::get()->getOriginalWorkdir() + "/shader/DeferredShading/";
    mat->setLit(false);
    mat->readVertexShader(shdrDir + "Calib.vp.glsl");
    mat->readFragmentShader(shdrDir + "Calib.fp.glsl");
    mat->setShaderParameter<int>("grid", 64);
}
Example #2
0
VRMaterialPtr getCamGeoMat() {
    VRMaterialPtr mat = VRMaterial::get("cam_geo_mat");
    mat->setDiffuse(Color3f(0.9, 0.9, 0.9));
    mat->setTransparency(0.3);
    mat->setLit(false);
    return mat;
}
Example #3
0
VRMenu::VRMenu(string path) : VRGeometry("menu") {
    type = "Menu";
    group = getName();
    if (path == "") return;

    setLeafType(mtype, scale);

    VRMaterialPtr mat = VRMaterial::get(path);
    mat->setLit(false);
    mat->setTexture(path);
    setMaterial(mat);

    close();
}
Example #4
0
void VRMolecule::updateCoords() {
    coords_geo->hide();
    if (!doCoords) return;

    coords_geo->show();

    GeoPnt3fPropertyRecPtr      Pos = GeoPnt3fProperty::create();
    GeoVec3fPropertyRecPtr      Norms = GeoVec3fProperty::create();
    GeoUInt32PropertyRecPtr     Indices = GeoUInt32Property::create();
    GeoVec3fPropertyRecPtr      cols = GeoVec3fProperty::create();

    int i=0;
    for (auto a : atoms) {
        float s = 0.4;
        Vec4d p0 = a.second->getTransformation()[3];
        Pos->addValue( p0 );
        Pos->addValue( p0 + a.second->getTransformation()[0]*s );
        Pos->addValue( p0 + a.second->getTransformation()[1]*s );
        Pos->addValue( p0 + a.second->getTransformation()[2]*s );
        cols->addValue(Vec3d(0,0,0));
        cols->addValue(Vec3d(1,0,0));
        cols->addValue(Vec3d(0,1,0));
        cols->addValue(Vec3d(0,0,1));
        Norms->addValue( Vec3d(0, 1, 0) );
        Norms->addValue( Vec3d(0, 1, 0) );
        Norms->addValue( Vec3d(0, 1, 0) );
        Norms->addValue( Vec3d(0, 1, 0) );
        Indices->addValue(i+0);
        Indices->addValue(i+1);
        Indices->addValue(i+0);
        Indices->addValue(i+2);
        Indices->addValue(i+0);
        Indices->addValue(i+3);
        i+=4;
    }

    // atoms geometry
    VRMaterialPtr mat = VRMaterial::get("coords");
    mat->setLineWidth(2);
    mat->setLit(false);

    coords_geo->setType(GL_LINES);
    coords_geo->setPositions(Pos);
    coords_geo->setNormals(Norms);
    coords_geo->setColors(cols);
    coords_geo->setIndices(Indices);
    coords_geo->setMaterial(mat);
}
Example #5
0
void VRSprite::webOpen(string path, int res, float ratio){
    VRMaterialPtr mat = VRMaterial::get(getName()+"web");
    setMaterial(mat);
    mat->setLit(false);
    web = CEF::create();

    VRDevice* mouse = VRSetupManager::getCurrent()->getDevice("mouse");
    VRDevice* keyboard = VRSetupManager::getCurrent()->getDevice("keyboard");

    web->setMaterial(mat);
    web->open(path);
    web->addMouse(mouse, ptr(), 0, 2, 3, 4);
    web->addKeyboard(keyboard);
    web->setResolution(res);
    web->setAspectRatio(ratio);
}
Example #6
0
void VRGeometry::showGeometricData(string type, bool b) {
    if (dataLayer.count(type)) dataLayer[type]->destroy();

    VRGeometryPtr geo = VRGeometry::create("DATALAYER_"+getName()+"_"+type, true);
    dataLayer[type] = geo;
    addChild(geo);

    GeoColor3fPropertyRecPtr cols = GeoColor3fProperty::create();
    GeoPnt3fPropertyRecPtr pos = GeoPnt3fProperty::create();
    GeoUInt32PropertyRecPtr inds = GeoUInt32Property::create();

    Pnt3f p;
    Vec3f n;

    if (type == "Normals") {
        GeoVectorPropertyRecPtr g_norms = mesh->getNormals();
        GeoVectorPropertyRecPtr g_pos = mesh->getPositions();
        for (uint i=0; i<g_norms->size(); i++) {
            p = g_pos->getValue<Pnt3f>(i);
            n = g_norms->getValue<Vec3f>(i);
            pos->addValue(p);
            pos->addValue(p+n*0.1);
            cols->addValue(Vec3f(1,1,1));
            cols->addValue(Vec3f(abs(n[0]),abs(n[1]),abs(n[2])));
            inds->addValue(2*i);
            inds->addValue(2*i+1);
        }

        geo->setPositions(pos);
        geo->setType(GL_LINE);
        geo->setColors(cols);
        geo->setIndices(inds);
    }

    VRMaterialPtr m = VRMaterial::create("some-mat");
    geo->setMaterial(m);
    m->setLit(false);
}
Example #7
0
void VRMolecule::updateGeo() {
    GeoPnt3fPropertyRecPtr      Pos = GeoPnt3fProperty::create();
    GeoVec3fPropertyRecPtr      Norms = GeoVec3fProperty::create();
    GeoUInt32PropertyRecPtr     Indices = GeoUInt32Property::create();
    GeoVec3fPropertyRecPtr      cols = GeoVec3fProperty::create();

    GeoPnt3fPropertyRecPtr      Pos2 = GeoPnt3fProperty::create();
    GeoVec3fPropertyRecPtr      Norms2 = GeoVec3fProperty::create();
    GeoUInt32PropertyRecPtr     Indices2 = GeoUInt32Property::create();

    float r_scale = 0.6;

    int i=0;
    int j=0;
    for (auto a : atoms) {
        PeriodicTableEntry aP = a.second->getParams();
        cols->addValue(aP.color);
        Pos->addValue(a.second->getTransformation()[3]);
        Norms->addValue( Vec3d(0, r_scale*aP.radius, 0) );
        Indices->addValue(i++);

        // bonds
        for (auto b : a.second->getBonds()) {
            if (b.second.atom2 == 0) { // duplet
                Pos2->addValue(b.second.p1);
                Pos2->addValue(b.second.p2);
                Norms2->addValue( Vec3d(0, 1, 0) );
                Norms2->addValue( Vec3d(0.1*b.second.type, 1,1) );
                Indices2->addValue(j++);
                Indices2->addValue(j++);
                continue;
            }

            if (b.second.atom2->getID() < a.first) {
                PeriodicTableEntry bP = b.second.atom2->getParams();
                Pos2->addValue(a.second->getTransformation()[3]);
                Pos2->addValue(b.second.atom2->getTransformation()[3]);
                Norms2->addValue( Vec3d(0, 1, 0) );
                Norms2->addValue( Vec3d(0.1*b.second.type, r_scale*aP.radius, r_scale*bP.radius) );
                Indices2->addValue(j++);
                Indices2->addValue(j++);
            }
        }
    }

    // atoms geometry
    VRMaterialPtr mat = VRMaterial::get("atoms");
    mat->setPointSize(40);
    mat->setLit(false);
    mat->setVertexShader(a_vp, "moleculesVS");
    mat->setFragmentShader(a_fp, "moleculesFS");
    mat->setGeometryShader(a_gp, "moleculesGS");

    setType(GL_POINTS);
    setPositions(Pos);
    setNormals(Norms);
    setColors(cols);
    setIndices(Indices);
    setMaterial(mat);

    // bonds geometry
    VRMaterialPtr mat2 = VRMaterial::get("molecule_bonds");
    mat2->setLineWidth(5);
    mat2->setLit(false);
    mat2->setVertexShader(b_vp, "moleculeBondsVS");
    mat2->setFragmentShader(b_fp, "moleculeBondsFS");
    mat2->setGeometryShader(b_gp, "moleculeBondsGS");

    bonds_geo->setType(GL_LINES);
    bonds_geo->setPositions(Pos2);
    bonds_geo->setNormals(Norms2);
    bonds_geo->setColors(cols);
    bonds_geo->setIndices(Indices2);
    bonds_geo->setMaterial(mat2);

    updateLabels();
    updateCoords();
}