Esempio n. 1
0
void CargarEntrada(Grafo& grafo, Vertice& u, Vertice& v, double& K) 
{
	unsigned int cantVertices;
	unsigned int cantAristas;
	unsigned int numVerticeInicial;
	unsigned int numVerticeFinal;

	cin >> cantVertices >> cantAristas >> numVerticeInicial >> numVerticeFinal >> K;
	assert(cantVertices > 0 && "cantidad de vertices incorrecta");
	assert(cantAristas >= 0 && "cantidad de aristas incorrecta");
	assert(numVerticeInicial > 0 && numVerticeFinal > 0 && numVerticeFinal <= cantVertices && numVerticeInicial <= cantVertices && "vertices u,v incorrectos");
	assert(K > 0 && "K incorrecto");
	
	grafo = Grafo(cantVertices);
	u = Vertice(numVerticeInicial);
	v = Vertice(numVerticeFinal);
	
	for (unsigned int i = 1; i <= cantAristas; i++) {

		unsigned int v1;
		unsigned int v2;
		double peso1;
		double peso2;
		
		cin >> v1 >> v2 >> peso1 >> peso2;
		assert(0 < v1 && v1 <= cantVertices && 0 < v2 && v2 <= cantVertices && "aristas incorrectas");
		assert(peso1 >= 0 && peso2 >= 0 && "pesos incorrectos");
		
		Arista e = Arista(Vertice(v1), Vertice(v2), peso1, peso2);
		grafo.AgregarArista(e);

	}

	cin.ignore(1); //Ignora el newline a continuación, dejando como siguiente caracter el primer dato de la próxima instancia.
}	
Esempio n. 2
0
void Light::defineVBO()
{
	std::vector<GLfloat> vertices;

	for (int latNumber = 0; latNumber <= m_nLats; latNumber++)
	{
		GLfloat theta = latNumber * glm::pi<float>() / m_nLats;
		GLfloat sinTheta = sin(theta);
		GLfloat cosTheta = cos(theta);

		for (int longNumber = 0; longNumber <= m_nLongs; longNumber++)
		{
			GLfloat phi = longNumber * 2 * glm::pi<float>() / m_nLongs;
			GLfloat sinPhi = sin(phi);
			GLfloat cosPhi = cos(phi);

			GLfloat x = cosPhi * sinTheta;
			GLfloat y = cosTheta;
			GLfloat z = sinPhi * sinTheta;
			GLfloat u = 1 - (longNumber / m_nLongs);
			GLfloat v = 1 - (latNumber / m_nLats);

			// Set the vertex's position
			vertices.push_back(m_radius * x);
			vertices.push_back(m_radius * y);
			vertices.push_back(m_radius * z);

			// Set the vertex's normal
			vertices.push_back(x);
			vertices.push_back(y);
			vertices.push_back(z);
		}
	}

	for (int i = 0; i < vertices.size(); i += 3)
	{
		m_vertices.push_back(Vertice(vertices[i], vertices[i + 1], vertices[i + 2]));
	}

	glGenBuffers(1, &m_VBO);
	glBindBuffer(GL_ARRAY_BUFFER, m_VBO);
	glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(GLfloat), &vertices[0], GL_STATIC_DRAW);
}
Esempio n. 3
0
Etiqueta::Etiqueta(void){
	this->valorAcomulado = 0;
	this->verticeProcedente = Vertice();
}
void TerrainGenerator::SetVertice(int x, int y, int z)		// Sets The Color Value For A Particular Index, Depending On The Height Index
{
	iVector3d Vertice(x,y,z);

	_vboVer.push_back(Vertice);
}
Esempio n. 5
0
int _tmain(int argc, _TCHAR* argv[])
{
	Camera* camera = &Camera();
	camera->position.x = 0;
	camera->position.y = 0;
	camera->position.z = 0;
	camera->viewPort.x = 240;
	camera->viewPort.y = 240;
	camera->focalDistance=100;
	camera->fogDistance=150;

	Scene* mainScene = new Scene(*camera);

	for(int i=0;i<=3;i++)
	{
		//for(int j=0;j<4;j++)
		{
			Color8 green; green.setColor(0, 255, 0, 255);
			Color8 red; red.setColor(255, 0, 0, 255);
			Color8 blue; blue.setColor(0, 0, 255, 255);
			Color8 white; white.setColor(255, 255, 255, 255);
			Vertice*v1=new Vertice(0, 0, 0, green);
			Vertice*v2=new Vertice(0, 50, 0, red);
			Vertice*v3=new Vertice(50, 0, 0, blue);

			Triangle* t = new Triangle(*v1, *v2, *v3);
			std::list<Triangle> tris;
			tris.push_back(*t);
			Object3D* triangle = new Object3D(MESH, tris, Vector3(i*50-50*2, 40, 20));
			//triangle->rotate(-PI/8*(i), 0, 0);
			//mainScene->addObject(triangle);
			
			/*Color8* yellow = &Color8(i*55, 255, 255, 255);
			Sphere* cube2 = &Sphere(20, &Vertice(i*30, 66, 0, *yellow));
			//cube2->scale(&Vector3(1, 2, 1));
	
			mainScene->addObject((Object3D*)cube2);*/
		}
	}

	Color8 white; white.setColor(255, 255, 255, 255);
	Object3D* plane = new Object3D(MESH, getPlane(30, white), Vector3(0, 0, 0));
	plane ->rotate(PI/2, 0, 0);
	//mainScene->addObject(plane);

	Color8 color2; color2.setColor(0, 0, 255, 255);
	Sphere* sphere = new Sphere(40,&Vertice(30, 30, 30, white));
	mainScene->addObject((Object3D*)sphere);

	Sphere* sphere2 = new Sphere(40,&Vertice(-30, 30, 60, white));
	mainScene->addObject((Object3D*)sphere2);

	Sphere* sphere6 = new Sphere(60,&Vertice(0, 0, 60, Color8(255, 0, 0, 255)));
	mainScene->addObject((Object3D*)sphere6);

	Cylinder* sphere3 = new Cylinder(&Vector3(0, 20, 50), &Vector3(0, 20, 0), 20, &Color8(255, 0, 0, 255));
	//mainScene->addObject((Object3D*)sphere3);
	
	Cylinder* sphere5 = new Cylinder(&Vector3(0, 0, 0), &Vector3(10, 30, 20), 10, &color2);
	//mainScene->addObject((Object3D*)sphere5);
	
	Cylinder* sphere4 = new Cylinder(&Vector3(-50, 0, 20), &Vector3(0, 0, 30), 20, &color2);
	//mainScene->addObject((Object3D*)sphere4);

	Light* light = new Light(DIRECTIONAL, Vector3(), Color8(255, 255, 255, 255), Vector3(1, 0, 0));
	//mainScene->addLight(light);

	Light* light2 = new Light(DIRECTIONAL, Vector3(), Color8(255, 255, 255, 255), Vector3(1, 1, 0));
	mainScene->addLight(light2);

	Renderer* renderer = new Renderer(*mainScene);
	ppm_image testImage = renderer->render(PERSPECTIVE);

	BmpExporter* exporter = new BmpExporter("test.bmp");
	
	exporter->export2(&testImage);

	return 0;
}