Ejemplo n.º 1
0
void SimpleGMap2::cb_initGL()
{
	Utils::GLSLShader::setCurrentOGLVersion(1) ;

	Geom::BoundingBox<VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
	VEC3 gPosObj = bb.center() ;
	float tailleX = bb.size(0) ;
	float tailleY = bb.size(1) ;
	float tailleZ = bb.size(2) ;
	float gWidthObj = std::max<float>(std::max<float>(tailleX, tailleY), tailleZ) ;
	setParamObject(gWidthObj, gPosObj.data());
}
Ejemplo n.º 2
0
void Viewer::importMesh(std::string& filename)
{
	myMap.clear(true) ;

	size_t pos = filename.rfind(".");    // position of "." in filename
	std::string extension = filename.substr(pos);

	if (extension == std::string(".map"))
	{
		myMap.loadMapBin(filename);
		position = myMap.getAttribute<VEC3, VERTEX, MAP>("position") ;
	}
	else
	{
		std::vector<std::string> attrNames ;
		if(!Algo::Surface::Import::importMesh<PFP>(myMap, filename.c_str(), attrNames))
		{
			CGoGNerr << "could not import " << filename << CGoGNendl ;
			return;
		}
		position = myMap.getAttribute<PFP::VEC3, VERTEX, MAP>(attrNames[0]) ;
	}

	//	myMap.enableQuickTraversal<VERTEX>() ;

	m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::POINTS) ;
	m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::LINES) ;
	m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::TRIANGLES) ;

	m_topoRender->updateData(myMap, position, 0.85f, 0.85f, m_drawBoundaryTopo) ;

	bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
	normalBaseSize = bb.diagSize() / 100.0f ;
	//	vertexBaseSize = normalBaseSize / 5.0f ;

	normal = myMap.getAttribute<VEC3, VERTEX, MAP>("normal") ;
	if(!normal.isValid())
		normal = myMap.addAttribute<VEC3, VERTEX, MAP>("normal") ;

	Utils::Chrono c;
	c.start();
	Algo::Surface::Geometry::computeNormalVertices<PFP>(myMap, position, normal) ;
	std::cout << "compute normals -> " << c.elapsed() << std::endl;

	m_positionVBO->updateData(position) ;
	m_normalVBO->updateData(normal) ;

	setParamObject(bb.maxSize(), bb.center().data()) ;
	updateGLMatrices() ;

	std::cout << "#vertices -> " << Algo::Topo::getNbOrbits<VERTEX>(myMap) << std::endl;
}
Ejemplo n.º 3
0
void MCMesh::updateRender()
{
	SelectorDartNoBoundary<PFP::MAP> nb(myMap);
	m_render->initPrimitives<PFP>(myMap, nb, Algo::Render::GL2::LINES);
	m_render->initPrimitives<PFP>(myMap, nb, Algo::Render::GL2::TRIANGLES);

	m_positionVBO->updateData(position);

	bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position);

	setParamObject(bb.maxSize(), bb.center().data());
	updateGLMatrices();
}
Ejemplo n.º 4
0
void SimpleGMap3::cb_initGL()
{
    Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
    VEC3 gPosObj = bb.center() ;
    float tailleX = bb.size(0) ;
    float tailleY = bb.size(1) ;
    float tailleZ = bb.size(2) ;
    float gWidthObj = std::max<float>(std::max<float>(tailleX, tailleY), tailleZ) ;
    setParamObject(gWidthObj, gPosObj.data());

	m_render_topo = new Algo::Render::GL2::Topo3RenderGMap<PFP>();
    m_render_topo->setDartWidth(2.0f);
    m_render_topo->setInitialDartsColor(1.0f,1.0f,1.0f);
	m_render_topo->updateData(myMap, position, 0.9f,0.9f,0.8f);
}