Example #1
0
int main(int argc, char **argv)
{


	// interface:
	QApplication app(argc, argv);
	MyQT sqt;

	if (argc>1)
		sqt.NBP = atoi(argv[1]);


	sqt.setHelpMsg("Param :size of grid (number of objects)\nMpuse (with shift):\n"
			" -click on object: selection\n -left click on frame: constraint 3d Rotation/Translation/Scale\n"
			" -right click on frame :free 2D Rotation/Translation\nKeys:\n  x/y/z lock/unlock translation\n  a/b/c lock/unlock rotation\n   s/t/u lock/unlock scaling");

    //  bounding box
    Geom::Vec3f lPosObj = Geom::Vec3f(0.0f,0.0f,0.0f);
    float lWidthObj = sqt.NBP*4.0f;

    // envoit info BB a l'interface
	sqt.setParamObject(lWidthObj,lPosObj.data());

	// show final pour premier redraw
	sqt.show();

	// et on attend la fin.
	return app.exec();

	return 0;
}
Example #2
0
int main(int argc, char **argv)
{
	//	// interface
	QApplication app(argc, argv);
	MyQT sqt;

	// example code itself
	sqt.createMap();

	// set help message in menu
	sqt.setHelpMsg("First Tuto: \nCreate two faces\nsew them\nand affect positions");
	// final show for redraw
	sqt.show();
	// and wait for the end

//	QGLViewer* ptr = sqt.getQGLWidget();
	return app.exec();
}
Example #3
0
int main(int argc, char **argv)
{
	//	// interface
	QApplication app(argc, argv);
	MyQT sqt;
	// copy output tout Qt console of application (shift enter)
	CGoGNout.toConsole(&sqt);

	// example code itself
	sqt.createMap();

	sqt.traverseMap();

	// set help message in menu
	sqt.setHelpMsg("Tuto 3: \nUsage of DartMarker and CellMarker\nPick of dart with mouse");
	// final show for redraw
	sqt.show();


	CGoGNout << "You can pick darts dans see it's id with left mouse button"<< CGoGNendl;

	// and wait for the end
	return app.exec();
}
Example #4
0
int main(int argc, char **argv)
{
	position = myMap.addAttribute<VEC3, VERTEX>("position");

	Dart d0 = myMap.newFace(12);
	position[d0] = PFP::VEC3(0, 20, 0);
	d0 = myMap.phi1(d0);
	position[d0] = PFP::VEC3(10, 20, 0);
	d0 = myMap.phi1(d0);
	position[d0] = PFP::VEC3(10, 30, 0);
	Dart dx = myMap.phi1(d0);
	d0 = myMap.phi<11>(dx);
	position[d0] = PFP::VEC3(8, 27, 0);
	d0 = myMap.phi1(d0);
	position[d0] = PFP::VEC3(8, 22, 0);
	d0 = myMap.phi1(d0);
	position[d0] = PFP::VEC3(2, 22, 0);
	d0 = myMap.phi1(d0);
	position[d0] = PFP::VEC3(2, 27, 0);
	d0 = myMap.phi1(d0);
	myMap.sewFaces(d0,dx);
	position[d0] = PFP::VEC3(5, 27, 0);
	d0 = myMap.phi1(d0);
	position[d0] = PFP::VEC3(5, 30, 0);
	d0 = myMap.phi1(d0);
	position[d0] = PFP::VEC3(0, 30, 0);

	d0 = myMap.newFace(4);
	position[d0] = PFP::VEC3(-5, 14, -5);
	d0 = myMap.phi1(d0);
	position[d0] = PFP::VEC3(0, 18, -5);
	d0 = myMap.phi1(d0);
	position[d0] = PFP::VEC3(5, 14, -5);
	d0 = myMap.phi1(d0);
	position[d0] = PFP::VEC3(0, 20, -5);
	d0 = myMap.phi1(d0);

	Dart d1 = myMap.newFace(10);

	position[d1] = PFP::VEC3(0, 0, 0);
	d1 = myMap.phi1(d1);

	position[d1] = PFP::VEC3(2, 4, 0);
	d1 = myMap.phi1(d1);
	position[d1] = PFP::VEC3(4, 0, 0);
	d1 = myMap.phi1(d1);

	position[d1] = PFP::VEC3(10, 0, 0);
	d1 = myMap.phi1(d1);

	position[d1] = PFP::VEC3(4, 2, 0);
	d1 = myMap.phi1(d1);
	position[d1] = PFP::VEC3(14, 6, 0);
	d1 = myMap.phi1(d1);
	position[d1] = PFP::VEC3(6, 16, 0);
	d1 = myMap.phi1(d1);

	position[d1] = PFP::VEC3(8, 8, 0);
	d1 = myMap.phi1(d1);
	position[d1] = PFP::VEC3(4, 4, 0);
	d1 = myMap.phi1(d1);
	position[d1] = PFP::VEC3(0, 8, 0);

	Dart d2 = myMap.newFace(12);

	position[d2] = PFP::VEC3(0, -20, 0);
	d2 = myMap.phi1(d2);
	position[d2] = PFP::VEC3(4, -20, 0);
	d2 = myMap.phi1(d2);
	position[d2] = PFP::VEC3(8, -20, 0);
	d2 = myMap.phi1(d2);
	position[d2] = PFP::VEC3(12, -20, 0);
	d2 = myMap.phi1(d2);
	position[d2] = PFP::VEC3(12, -16, 0);
	d2 = myMap.phi1(d2);
	position[d2] = PFP::VEC3(12, -12, 0);
	d2 = myMap.phi1(d2);
	position[d2] = PFP::VEC3(12, -8, 0);
	d2 = myMap.phi1(d2);
	position[d2] = PFP::VEC3(8, -8, 0);
	d2 = myMap.phi1(d2);
	position[d2] = PFP::VEC3(4, -8, 0);
	d2 = myMap.phi1(d2);
	position[d2] = PFP::VEC3(0, -8, 0);
	d2 = myMap.phi1(d2);
	position[d2] = PFP::VEC3(0, -12, 0);
	d2 = myMap.phi1(d2);
	position[d2] = PFP::VEC3(0, -16, 0);
	d2 = myMap.phi1(d2);

#define NB 32

	//SPIRAL

	Dart d3 = myMap.newFace(NB*2);

	for (int i = 0; i<NB; ++i)
	{
		float z = 3.0f*float(rand()-RAND_MAX/2)/float(RAND_MAX);
		float alpha = (4.0f*6.283f / NB)*i;
		float radius = 1.2f*(NB-i);
		position[d3] = PFP::VEC3(radius*cos(alpha) -  2*NB+8, radius*sin(alpha), z);
		d3 = myMap.phi1(d3);
	}

	for (int i = NB-1; i>=0; --i)
	{
		float z = 3.0f*float(rand()-RAND_MAX/2)/float(RAND_MAX);
		float alpha = (4.0f*6.283f / NB)*i;
		float radius = (NB-i);
		position[d3] = PFP::VEC3(radius*cos(alpha) -  2*NB+8, radius*sin(alpha), z);
		d3 = myMap.phi1(d3);
	}

	//CIRCLE

	Dart d6 = myMap.newFace(NB);
	for (int i = 0; i<NB; ++i)
	{
		float z = 3.0f*float(rand()-RAND_MAX/2)/float(RAND_MAX);
		float alpha = (6.283f / NB)*i;
		float radius = NB;
		position[d6] = PFP::VEC3(radius*cos(alpha) + 2*NB+8, radius*sin(alpha), z);
		d6 = myMap.phi1(d6);
	}

// pour comparer les 2 versions (oreille et basique)
//#define NBB 100
//	for (int j = 0; j<10000; ++j)
//	{
//		Dart d6 = myMap.newFace(NBB);
//		for (int i = 0; i<NBB; ++i)
//		{
//			float alpha = (6.283f / NB)*i;
//			float radius = NB;
//			position[d6] = PFP::VEC3(radius*cos(alpha) + 2*NB+8, radius*sin(alpha), 0.1f*j);
//			d6 = myMap.phi1(d6);
//		}
//	}

	Geom::Vec3f V1(3,3,3);
	V1.normalize();
	Geom::Vec3f V2 = V1 ^ Geom::Vec3f(0,0,-1);
	Geom::Vec3f V3 = V1 ^ V2;

	V1 *= 50.0f;
	V2 *= 50.0f;

	Dart d5 = myMap.newFace(74);
	for (int i=0; i<74;++i)
	{
		float a = float(rand()-RAND_MAX/2)/float(RAND_MAX) * 0.25f;
		position[d5] = PFP::VEC3(0.0,60.0,0.0f) + Ifont[2*i] * V1 + Ifont[2*i+1]*V2 + a*V3;
		d5 = myMap.phi1(d5);
	}
	Dart d9 = myMap.newFace(174);
	for (int i=0; i<174;++i)
	{
		float a = float(rand()-RAND_MAX/2)/float(RAND_MAX) * 0.25f;
		position[d9] = PFP::VEC3(60.0,60.0,0.0f) + Gfont[2*i] * V1 + Gfont[2*i+1]*V2 + a*V3;
		d9 = myMap.phi1(d9);
	}

	// interface:
	QApplication app(argc, argv);
	MyQT sqt;


	// message d'aide
	sqt.setHelpMsg("Concave face rendering (ears method):\n"
			"a show all trianglesfaces\n"
			"a show none trianglesfaces\n"
			"+ / - show trinagles order rendering (ears creation)");

    //  bounding box
    Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position);
    float lWidthObj = std::max<PFP::REAL>(std::max<PFP::REAL>(bb.size(0), bb.size(1)), bb.size(2));
    Geom::Vec3f lPosObj = (bb.min() +  bb.max()) / PFP::REAL(2);

    // envoit info BB a l'interface
	sqt.setParamObject(lWidthObj, lPosObj.data());

	// show 1 pour GL context
	sqt.show();

	// update du VBO position (context GL necessaire)
	sqt.m_positionVBO->updateData(position);

	// update des primitives du renderer
	sqt.m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES, &position);
	sqt.m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::LINES, &position);
	sqt.m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::POINTS, &position);

//	 show final pour premier redraw
	sqt.show();

	// et on attend la fin.
	return app.exec();
}