Ejemplo n.º 1
0
Camera* SDLReader::read_camera(string filename)
{
  Vetor C, N, V;
  float d, hx, hy;
  
  Util::read_file(filename, [&C, &V, &N, &d, &hx, &hy](string line, int i) {
	if(line.size() == 0) 
		return;
    vector<string> parm = Util::split_on_separators(line," ");
    float a = stof(parm[0]);
    float b = stof(parm[1]);
    float c = stof(parm[2]);
    
		switch(i)
    {
    	case 1:
      	C = Vetor(a, b, c);
      	break;
      case 2:
      	N = Vetor(a, b, c);
      	break;
      case 3:
      	V = Vetor(a, b, c);
      	break;
      case 4:
      	d = a;
      	hx = b;
      	hy = c;
      	break;
    }
	});
	
	return new Camera(C, N, V, d, hx, hy);
}
Ejemplo n.º 2
0
Ball::Ball(double x, double y, double r, double a, double b) {
    this->r = r;
    this->velocidade = velocidade;
    this->posicao = Vetor(x, y);
    this->velocidade = Vetor (a, b);
    tipo = 0;
}
void CaixaMensagemSimNao::desenhar(IVideoDriver * driver)
{
	if(!fechou )
	{

		driver->draw2DRectangle(SColor(255,245,245,245),core::rect<s32>(posicao.x,posicao.y,posicao.x+tamanho.x,posicao.y+tamanho.y));



	
		for(int i=0;i<componentes.size();i++)
			componentes[i]->desenhar(driver);
		if(!alinhado)
		{
			alinhado = true;
			Vetor tamanhoBotaoSim = CaixaMensagemSimNao::botaoSim->getTamanho();		
			Vetor posicaoBotaoSim = CaixaMensagemSimNao::botaoSim->getPosisao();

			Vetor tamanhoBotaoNao = CaixaMensagemSimNao::botaoNao->getTamanho();		
			Vetor posicaoBotaoNao = CaixaMensagemSimNao::botaoNao->getPosisao();

			int x1 = posicaoBotaoSim.x+ (areaBotaoSim.v2.x - areaBotaoSim.v1.x - tamanhoBotaoSim.x)/2;
			int y1 = posicaoBotaoSim.y+ (areaBotaoSim.v2.y - areaBotaoSim.v1.y - tamanhoBotaoSim.y)/2;
		
			int x2 = posicaoBotaoNao.x+ (areaBotaoNao.v2.x - areaBotaoNao.v1.x - tamanhoBotaoNao.x)/2;
			int y2 = posicaoBotaoNao.y+ (areaBotaoNao.v2.y - areaBotaoNao.v1.y - tamanhoBotaoNao.y)/2;

			CaixaMensagemSimNao::botaoSim->atualizarPosisao(Vetor( x1,y1 ));
			CaixaMensagemSimNao::botaoNao->atualizarPosisao(Vetor( x2,y2 ));
		}
	}
}
void MovimentadorPernaDireita::mover(irr::scene::IAnimatedMeshSceneNode * node,tipos::Esqueleto esqueleto)
{
	std::string coxa_esquerda_bone			=       "UpLeg_L";
	std::string perna_esquerda_bone			=       "LoLeg_L";
	std::string pe_esquerdo_bone_1             =       "Foot_L";
	std::string pe_esquerdo_bone_2             =       "Toe_L";

	tipos::Vetor v3_ = Vetor(esqueleto.joelho_esquerdo.x,esqueleto.abdomen.y);
	Vetor p1_ = esqueleto.abdomen;
	Vetor p2_ = esqueleto.joelho_esquerdo;
	Vetor p3_ = v3_;
	float a1_ = CalculosUteis::anguloEntrePontos(p1_,p2_,p3_);
	if(!_isnan(a1_))
		setarAnguloBone(node,coxa_esquerda_bone,-90 + a1_);
	//setarAnguloPerna(node,coxa_direita_bone,90-a1_);


	float angulo_joelho = CalculosUteis::anguloEntrePontos(esqueleto.joelho_esquerdo,esqueleto.abdomen,esqueleto.pe_esquerdo);
	if(!_isnan(angulo_joelho))
	{

		setarAnguloPerna(node,perna_esquerda_bone, angulo_joelho);

		IBoneSceneNode * joelho = node->getJointNode(perna_esquerda_bone.c_str());
		core::vector3df rot=  joelho->getRotation();
		//rot.Y = angulo_joelho; 
		rot.Z = 180;
		joelho->setRotation(rot);


	}
	//

	IBoneSceneNode * pe_1 = node->getJointNode(pe_esquerdo_bone_1.c_str());
	IBoneSceneNode * pe_2 = node->getJointNode(pe_esquerdo_bone_2.c_str());
	pos_1 = Vetor(pe_1->getAbsolutePosition().X,pe_1->getAbsolutePosition().Y,pe_1->getAbsolutePosition().Z);
	pos_2 = Vetor(pe_2->getAbsolutePosition().X,pe_2->getAbsolutePosition().Y,pe_2->getAbsolutePosition().Z);
/*
	bool tem = false;
	for(int i=0;i<marcadores.size();i++)
	{
		if( ( (marcadores[i]->pontoDentroMarcador(pos_1)) || (marcadores[i]->pontoDentroMarcador(pos_2)) ) && i!=indiceAnterior)
		{
			if(!cronometro.iniciado())
			{
				cronometro.iniciarContagem();						
			}
			tem = true;
			indiceAtual = i;
		}
	}
	if(!tem)
	{
		cronometro.pararContagem();
	}
	*/
}
Ejemplo n.º 5
0
Vetor Vetor::operator *(double k)
{
    double a, b;
    a = k * this->x;
    b = k * this->y;
    return Vetor(a, b);
}
Ejemplo n.º 6
0
Vetor Vetor::operator -(Vetor v)
{
    double a, b;
    a = this->x - v.x;
    b = this->y - v.y;
    return Vetor(a, b);
}
Ejemplo n.º 7
0
Vetor Vetor::operator +(Vetor v)
{
    double a, b;
    a = this->x + v.x;
    b = this->y + v.y;
    return Vetor(a, b);
}
Ejemplo n.º 8
0
void GLWidget::mouseReleaseEvent(QMouseEvent *event)
{
    QGLWidget::mouseReleaseEvent(event);
    if (!this->passaroEmMovimento)
    {
        return;
    }

    // Define que o pássaro parou de se movimentar por função do jogador
    this->passaroEmMovimento = false;

    // Define o uso do vetorFinal
    Vetor vetorFinal = Vetor(event->x(), event->y());

    // Calcula a magnitude entre os dois vetores
    this->magnitudeLancamento = Vetor::magnitudeEntreVetores(
                this->particulas[this->indicePassaro].getPosicaoInicial(), vetorFinal);

    // Define a direção do lançamento
    this->direcaoLancamento =
            vetorFinal.getY() > this->particulas[this->indicePassaro].getPosicaoInicial().getY() ? 'C' : 'S';

    // Calcula o ângulo
    this->angulo = Vetor::anguloEntreVetores(this->particulas[this->indicePassaro].getPosicaoInicial(), vetorFinal,
            this->magnitudeLancamento);

    // A velocidade do lançamento vai ser 0.0005% da magniute
    this->velocidadeLancamento = this->magnitudeLancamento * 0.00005;
    this->atirado = true;
}
Ejemplo n.º 9
0
Mesh* SDLReader::read_object(string filename, Material *material)
{
	Mesh *mesh = new Mesh(material);
	int v, t;
	
	Util::read_file(filename, [&v, &t, &mesh](string l, int i){
		if(l.size() == 0)
			return;

		vector<string> l_parm = Util::split_on_separators(l," ");
		if(i == 1) 
		{
			v = stoi(l_parm[0]);
			t = stoi(l_parm[1]);
		} 
		else if(i <= v + 1) 
		{
			float f1 = stof(l_parm[0]); 
			float f2 = stof(l_parm[1]); 
			float f3 = stof(l_parm[2]); 
			
			mesh->add_vertex(Vetor(f1, f2, f3));
		} 
		else if(i <= v + t + 1) 
		{
			int i1 = stoi(l_parm[0]) - 1; //por causa do indice do vertice no arquivo comecar a partir de 1
			int i2 = stoi(l_parm[1]) - 1;
			int i3 = stoi(l_parm[2]) - 1;
			mesh->add_triangle(i1, i2, i3); 
		}
	});

	mesh->build_vertex_normals();
	return mesh;
}
Ejemplo n.º 10
0
Vetor Vetor::orthogonalize(const Vetor &vetor_) {
    Vetor res = Vetor();

    res = vetor_ - proj(vetor_);

    return res;
}
Ejemplo n.º 11
0
Vetor Vetor::proj(const Vetor &vetor_) {
    Vetor res = Vetor();

    res = *this * ((*this * vetor_)/(*this * *this));

    return res;
}
void TransformadorAtualizarPosicaoBracoDireito::transformar(irr::scene::IAnimatedMeshSceneNode * node, tipos::Esqueleto esqueleto)
{
	IBoneSceneNode * ombro = node->getJointNode("UpArm_R");
	IBoneSceneNode * cotovelo = node->getJointNode("UpArm_R");
	float menorDistancia = 999;
	float anguloOmbro = 0;
	float anguloCotovelo = 0;
	//int anguloMinimo = -60;
	//int anguloMaximo = 60;
	int anguloMinimoOmbro = ombro->getRotation().Y - 20;
	int anguloMaximoOmbro = ombro->getRotation().Y + 20;
	int anguloMinimoCotovelo = cotovelo->getRotation().Y - 20;
	int anguloMaximoCotovelo = cotovelo->getRotation().Y + 20;
	
	for (int i = anguloMinimoOmbro ;i < anguloMaximoOmbro ;i++)
	{
		core::vector3df rotOmbro = ombro->getRotation();
		rotOmbro.Y = i;
		ombro->setRotation(rotOmbro);
		for(int j =anguloMinimoCotovelo ; j< anguloMaximoCotovelo ;j++)
		{
			core::vector3df rotCot = cotovelo->getRotation();
			rotCot.Y = j;
			cotovelo->setRotation(rotCot);
			IBoneSceneNode * mao = node->getJointNode("Hand_R");
			
			node->updateAbsolutePosition();
			for(int i=0;i<node->getJointCount();i++)
			{
				node->getJointNode(i)->updateAbsolutePosition();
			}
			float distancia = CalculosUteis::distanciaEntrePontos(
				Vetor(mao->getAbsolutePosition().X,mao->getAbsolutePosition().Y,mao->getAbsolutePosition().Z),
				esqueletoRef.mao_direita);
			if(distancia<menorDistancia)
			{
				menorDistancia = distancia;
				anguloOmbro = i;
				anguloCotovelo = j;
			}


			
		}
		
		
	}

	printf("i: %f j: %f distancia : %f\n",anguloOmbro,anguloCotovelo,menorDistancia);
	core::vector3df rotOmbro = ombro->getRotation();
		rotOmbro.Y = anguloOmbro;
		ombro->setRotation(rotOmbro);

		core::vector3df rotCot = cotovelo->getRotation();
		rotCot.Y = anguloCotovelo;
		cotovelo->setRotation(rotCot);
}
TransformadorAtualizarPosicaoBracoDireito::TransformadorAtualizarPosicaoBracoDireito(IAnimatedMeshSceneNode * node)
{
	TransformadorAtualizarPosicaoBracoDireito::primeiro = true;
	TransformadorAtualizarPosicaoBracoDireito::node	=	node;
	
	esqueletoRef.abdomen = Vetor( node->getJointNode("Root")->getAbsolutePosition().X , node->getJointNode("Root")->getAbsolutePosition().Y, node->getJointNode("Root")->getAbsolutePosition().Z);
	esqueletoRef.ombro_direito = Vetor( node->getJointNode("UpArm_R")->getAbsolutePosition().X , node->getJointNode("UpArm_R")->getAbsolutePosition().Y, node->getJointNode("UpArm_R")->getAbsolutePosition().Z);
	esqueletoRef.cotovelo_direito = Vetor( node->getJointNode("LoArm_R")->getAbsolutePosition().X , node->getJointNode("LoArm_R")->getAbsolutePosition().Y, node->getJointNode("LoArm_R")->getAbsolutePosition().Z);
	esqueletoRef.mao_direita  = Vetor( node->getJointNode("Hand_R")->getAbsolutePosition().X , node->getJointNode("Hand_R")->getAbsolutePosition().Y, node->getJointNode("Hand_R")->getAbsolutePosition().Z);

	distanciaCotoveloMao = CalculosUteis::distanciaEntrePontos(esqueletoRef.cotovelo_direito,esqueletoRef.mao_direita);
	distanciaOmbroCotovelo = CalculosUteis::distanciaEntrePontos(esqueletoRef.ombro_direito,esqueletoRef.cotovelo_direito);
	
	IBoneSceneNode * nodeOmbro = node->getJointNode("UpArm_R");	
	core::vector3df rotOmbro = nodeOmbro->getRotation();	
	rotOmbro.Y = 0;
	//nodeOmbro->setRotation(rotOmbro);
}
Ejemplo n.º 14
0
Vetor screenOperations::phongShading(Vetor& normal,Ponto& objCoord) {
    normal.normalize();
    Vetor L = lightSourceView_ - objCoord;
    L.normalize();
    Vetor V = (objCoord - cameraCoordView_) * -1.0;
    V.normalize();

    double dotNL = normal*L;
    double dotVN = V*normal;

    Vetor R = ((normal*(2.0*(dotNL)))- L);
    R.normalize();

    double dotVR = V*R;

    Vetor ambiental = Vetor(0.0, 0.0, 0.0);
    Vetor difusa = Vetor(0.0, 0.0, 0.0);
    Vetor especular = Vetor(0.0, 0.0, 0.0);

    //calculo da componente ambiental
    ambiental = Ia_ * ka_;

    //se primeiro parametro for menor que segundo retorna 1
    //se for igual retorna 0
    //se for maior retorna 1

    if(cmp(dotVN) == -1) normal = normal * -1;

    if(cmp(dotNL) == 0 || cmp(dotNL) == 1) {
        Vetor kronecker = Vetor(0.0,0.0,0.0);
        kronecker.x_ = Od_.x_ * Il_.x_;
        kronecker.y_ = Od_.y_ * Il_.y_;
        kronecker.z_ = Od_.z_ * Il_.z_;

        difusa = kronecker * (kd_ * dotNL);

        if(cmp(dotVR) == 0 || cmp(dotVR) == 1) {
            especular = Il_ * ks_ * pow(dotVR,alpha_);
        }
    }

    Vetor corFinal = ambiental + difusa + especular;
    return corFinal;
}
Ejemplo n.º 15
0
Light* SDLReader::read_light(string filename, Material **material, Scene &scene)
{
  Color Il, Ia;
  Vetor Pl, Od;
  float ka, kd, ks, n;
  Util::read_file(filename, [&Pl, &Ia, &Od, &Il, &ka, &kd, &ks, &n](string line, int i) {
	  if(line.size() == 0) 
		return;
    vector<string> parm = Util::split_on_separators(line," ");
    
		switch(i)
    {
    	case 1:
      	Pl = Vetor(stof(parm[0]), stof(parm[1]), stof(parm[2]));
      	break;
      case 2:
      	ka = stof(parm[0]);
      	break;
      case 3:
      	Ia = Color(stoi(parm[0]), stoi(parm[1]), stoi(parm[2]));
      	break;
      case 4:
      	kd = stof(parm[0]);
      	break;
      case 5:
      	Od = Vetor(stof(parm[0]), stof(parm[1]), stof(parm[2]));
      	break;
      case 6:
      	ks = stof(parm[0]);
      	break;
      case 7:
      	Il = Color(stoi(parm[0]), stoi(parm[1]), stoi(parm[2]));
      	break;
      case 8:
      	n = stof(parm[0]);
      	break;
    }
  });
  
	scene.set_la(Ia);
	*material = new Material(ka,kd,ks,n,Od);
	return new Light(Pl, 0.5f, Il);
}
int main(void){
	int n,;
	int *p;
	
	Cabecalho();
	Vetor(n,p);
	
	printf("\n\n");
	system("pause");
	return 0;
}
Ejemplo n.º 17
0
Vetor GLWidget::atirarPassaro()
{
    // Se a magnitude do lançamento for maior que 100, altera ele para o tamanho máximo
    if(this->magnitudeLancamento > 100.0f)
    {
        this->magnitudeLancamento = 100.0f;
    }

    switch(this->direcaoLancamento)
    {
    case 'S':
        return Vetor(cos(this->angulo * PI / 180) * this->magnitudeLancamento * this->velocidadeLancamento,
                     (sin(this->angulo * PI / 180) * (this->magnitudeLancamento * this->velocidadeLancamento)));

    case 'C':
        return Vetor(cos(this->angulo * PI / 180) * this->magnitudeLancamento * this->velocidadeLancamento,
                     (sin(this->angulo * PI / 180) * (this->magnitudeLancamento * this->velocidadeLancamento)) * -1);

    default:
        return Vetor(0, 0);
    }
}
CaixaMensagemSimNao::CaixaMensagemSimNao(Vetor pos,Vetor tamanho,std::string msg,CliqueListener * listenerSim ,CliqueListener * listenerNao ): CaixaMensagem(pos,tamanho)
{
	CaixaMensagemSimNao::texto	=	msg;
	
	CaixaMensagemSimNao::alinhado	=	false;
	
	const int margem_x = tamanho.x*0.05;

	int x = pos.x+margem_x ;
	int y = pos.y+(tamanho.y*0.2) ;


	CaixaMensagemSimNao::mensagem = new Label(
		Vetor(pos.x+margem_x,pos.y+margem_x),
		Vetor(tamanho.x- margem_x*2 ,tamanho.y*0.5),//tamanho
		texto,"comic",TAMANHO::PEQUENO,true,true);
	
	
	CaixaMensagemSimNao::areaBotoes.v1 = Vetor(pos.x+margem_x,(pos.y + pos.y*0.5)+margem_x);
	CaixaMensagemSimNao::areaBotoes.v2 = Vetor(pos.x-margem_x+tamanho.x  ,pos.y +tamanho.y-margem_x);
	
	CaixaMensagemSimNao::areaBotaoSim.v1 = Vetor(areaBotoes.v1.x,areaBotoes.v1.y);
	CaixaMensagemSimNao::areaBotaoSim.v2 = Vetor(areaBotoes.v1.x +(areaBotoes.v2.x-areaBotoes.v1.x) / 2,areaBotoes.v2.y);
	
	CaixaMensagemSimNao::areaBotaoNao.v1 = Vetor(areaBotoes.v1.x +(areaBotoes.v2.x-areaBotoes.v1.x) / 2,areaBotoes.v1.y);
	CaixaMensagemSimNao::areaBotaoNao.v2 = Vetor(areaBotoes.v2.x,areaBotoes.v2.y);

	CaixaMensagemSimNao::botaoSim=new Botao(
		areaBotaoSim.v1,
		"ui/botoes/em-branco-pequeno.png","SIM","comic",	TAMANHO::GRANDE
	);
	
	CaixaMensagemSimNao::botaoNao=new Botao(
		areaBotaoNao.v1,
		"ui/botoes/em-branco-pequeno.png","NAO","comic",	TAMANHO::GRANDE
	);
	
	if(listenerSim) 
		botaoSim->addListener(listenerSim);
	
	if(listenerNao) 
		botaoNao->addListener(listenerNao);

	componentes.push_back(mensagem);							
	componentes.push_back(botaoSim);
	componentes.push_back(botaoNao);

	CaixaMensagemSimNao::fechou = true;
}
void MovimentadorBracoEsquerdo::mover(irr::scene::IAnimatedMeshSceneNode * node,tipos::Esqueleto esqueleto) 
{
	std::string ombro_esquerdo_bone			=       "UpArm_L";
	std::string braco_esquerdo_bone			=       "LoArm_L";
	std::string mao_esquerda_bone			=		"Index_L";

	float anguloOmbroEsquerdo = getAnguloBraco(esqueleto.ombro_esquerdo,esqueleto.cotovelo_esquerdo);	
	setarAnguloBone(node,ombro_esquerdo_bone,-anguloOmbroEsquerdo);		
	float anguloMaoEsquerda = CalculosUteis::anguloEntrePontos(esqueleto.cotovelo_esquerdo,esqueleto.ombro_esquerdo,esqueleto.mao_esquerda);
	if(esqueleto.cotovelo_esquerdo.y < esqueleto.mao_esquerda.y)
		anguloMaoEsquerda = - anguloMaoEsquerda;
	if(!_isnan(anguloMaoEsquerda))
		setarAnguloBone(node,braco_esquerdo_bone,anguloMaoEsquerda);


	IBoneSceneNode * mao = node->getJointNode(mao_esquerda_bone.c_str());
	pos = Vetor(
		mao->getAbsolutePosition().X,
		mao->getAbsolutePosition().Y,
		mao->getAbsolutePosition().Z);
	//teste
	/*
	bool tem = false;
	for(int i=0;i<marcadores.size();i++)
	{
		if(marcadores[i]->pontoDentroMarcador(pos) && i!=indiceAnterior)
		{
			if(!cronometro.iniciado())
			{
				cronometro.iniciarContagem();						
			}
			tem = true;
			indiceAtual = i;
		}


	}
	if(!tem)
	{
		cronometro.pararContagem();
	}
	*/

}
Ejemplo n.º 20
0
void GLWidget::mouseMoveEvent(QMouseEvent *event)
{
    QGLWidget::mouseMoveEvent(event);

    if (!this->passaroEmMovimento)
    {
        return;
    }

    // Se o pássaro entrou em órbita, cancela a execução do método
    if (this->planetoide.particulaAdentrouAtmosfera(
                this->particulas[this->indicePassaro]))
    {
        return;
    }

    this->particulas[this->indicePassaro].setPosicao(
                Vetor(event->pos().x(), event->pos().y()));
}
Ejemplo n.º 21
0
Vetor Vetor::get_abg(const Vetor& p, const Vetor& p1, const Vetor& p2, const Vetor& p3)
{
	Vetor v0 = p1;
	
	Vetor u = p2 - v0;
	Vetor v = p3 - v0;
	Vetor w = p - v0;
	
	float uv = p_escalar(u, v);
	float uu = p_escalar(u, u);
	float vv = p_escalar(v, v);
	
	float d = uv * uv - uu * vv;
	float beta = uv * p_escalar(w, v) - vv * p_escalar(w, u);
	float gama = uv * p_escalar(w, u) - uu * p_escalar(w, v);
	beta /= d;
	gama /= d;
	float alpha = 1 - beta - gama;
	
	return Vetor(alpha, beta, gama);
}
Ejemplo n.º 22
0
std::vector<Vetor> screenOperations::normaisV(std::vector<Ponto> &pontosView, std::vector<int> &faces, int tam) {
    std::vector<Vetor> normaisV;
    std::vector< std::vector<int> > listaAdj = this->lista(pontosView, faces, tam);
    std::vector<Vetor> normaisFace = this->normaisF(pontosView, faces);
    std::cout << (int)normaisFace.size() << std::endl;
    //std::cout << "oi" << std::endl;
    //std::cout << listaAdj[0][0] << std::endl;
    for (int i=0; i < (int)listaAdj.size(); ++i) {
        //if((int)listaAdj[i].size()==0) std::cout << listaAdj[i].size() << std::endl;
        Vetor normal = Vetor(0.0, 0.0, 0.0);
        int aux = 0;
        for (int j=0; j < (int)listaAdj.at(i).size(); ++j) {
            //std::cout << "jota: " << j << "size: " << (int)listaAdj[i][j] << std::endl;
            normal = normal + normaisFace.at(listaAdj[i][j]);
            ++aux;
        }
        //if(aux==0) std::cout << "AEUEAHUEAHUAEHAE" << std::endl;
        normal = normal * (1.0/aux);
        normal.normalize();
        normaisV.push_back(normal);
    }
    std::cout << "saiu porra" << std::endl;
    return normaisV;
}
Ejemplo n.º 23
0
//interface
//_--_-__-_--_---__---_-___--__-_-_---__-__--__--__--____-_--___--_--__-_-
void observer_look(){
	switch(modo_observacao){
		case FREE_CAMERA:{
			double cosphi = cos(phi_free);
			double abscosphi = cosphi<0?-cosphi:cosphi;
			
			gluLookAt(posicao_observador.x,posicao_observador.y,posicao_observador.z,
					posicao_observador.x+abscosphi*cos(theta_free), posicao_observador.y+sin(phi_free), posicao_observador.z+abscosphi*sin(theta_free),
					cos(phi_free+PI/2)*cos(theta_free),cos(phi_free),cos(phi_free+PI/2)*sin(theta_free) );
		}break;
		case FIRST:
		case THIRD_SIDE:
		case THIRD_UP:{			

			Vetor centro = planeta->get_coordenadas();
			Vetor up;
			
			posicao_observador = last_boid->get_coordenadas();
			posicao_observador.rotacionar_em_y(-planeta->get_rotation());
			posicao_observador.rotacionar_em_x(planeta->INCLINACAO_ROT);
			
			if(modo_observacao == THIRD_SIDE){
				posicao_observador.normalizar();	
				posicao_observador += produto_vetorial(posicao_observador, Vetor(0,cos(planeta->INCLINACAO_ROT),sin(planeta->INCLINACAO_ROT)));
				up = last_boid->get_coordenadas();
				up.rotacionar_em_y(-planeta->get_rotation());
				up.rotacionar_em_x(planeta->INCLINACAO_ROT);
				posicao_observador *= distancia_terceira_pessoa;
				posicao_observador += centro;
				centro += up;
			
			} else if(modo_observacao == THIRD_UP){ 
				posicao_observador.normalizar();
				up = produto_vetorial(posicao_observador, Vetor(0,cos(planeta->INCLINACAO_ROT),sin(planeta->INCLINACAO_ROT)));
				posicao_observador *= distancia_terceira_pessoa;
				posicao_observador += centro;
			
			} else {
				up = posicao_observador;
				Vetor velocidade = last_boid->get_velocidade();
				velocidade.rotacionar_em_y(-planeta->get_rotation());
				velocidade.rotacionar_em_x(planeta->INCLINACAO_ROT);
				centro += posicao_observador + velocidade;
				posicao_observador = centro - velocidade;
			}
			
			gluLookAt(posicao_observador.x,posicao_observador.y,posicao_observador.z,
					centro.x,centro.y,centro.z,
					up.x,up.y,up.z);
			
					
		}break;
		case GEO_ESTACIONARIA:{
			double rotacao = planeta->get_rotation();
			posicao_observador = Vetor(distancia_terceira_pessoa + planeta->RAIO,0,0);
			posicao_observador.rotacionar_em_y(-rotacao + theta_geoestacionaria);
			posicao_observador.rotacionar_em_x(planeta->INCLINACAO_ROT);
			
			Vetor centro = planeta->get_coordenadas();
			posicao_observador += centro;
			
			gluLookAt(posicao_observador.x,posicao_observador.y,posicao_observador.z,
					centro.x,centro.y,centro.z,
					0,cos(planeta->INCLINACAO_ROT),sin(planeta->INCLINACAO_ROT));
		}break;
	}
	
		
	//setando as strings do HUD
	//os numeros são a quantidade de caracteres necessários definidos empiricamente
	static char aux_xyz[3][12], aux_observado[21], aux_lider[17], aux_n_boids[11];
	memset(aux_observado,0,21);
	memset(aux_lider,0,17);
	memset(aux_xyz,0,36);
	memset(aux_n_boids,0,11);
	
	sprintf(aux_n_boids, "%d Boids", planeta->boid_container.get_n_boids());
	sprintf(aux_observado, "boid observado: %d", id_observado);
	sprintf(aux_lider, "Lider: %d", lider_atual);
	sprintf(aux_xyz[2],"X: %i",(int)posicao_observador.x);	
	sprintf(aux_xyz[1],"Y: %i",(int)posicao_observador.y);
	sprintf(aux_xyz[0],"Z: %i",(int)posicao_observador.z);
	
	_hud->set_string(string_n_boids, aux_n_boids);
	_hud->set_string(string_lider, aux_lider);
	_hud->set_string(string_boid_observado, aux_observado);
	_hud->set_string(string_coordenadas, aux_xyz[0]);
	_hud->set_string(string_coordenadas+1, aux_xyz[1]);
	_hud->set_string(string_coordenadas+2, aux_xyz[2]);
}
bool TecladoNumerico::emCimaDoTeclado(Vetor pos)
{
	return  CalculosUteis::pontoDentroDeArea(pos,posicao,Vetor(largura,altura));
}
Ejemplo n.º 25
0
#include "Vetor.h"
#include <cmath>

const Vetor Vetor::null = Vetor(FLT_MAX, FLT_MAX, FLT_MAX);

Vetor::Vetor()
{
	this->x = this->y = this->z = 0;
}

Vetor::Vetor(float x, float y, float z)
{
	this->x = x;
	this->y = y;
	this->z = z;
}

float Vetor::norma() const
{
	return sqrt(this->x * this->x + this->y * this->y + this->z * this->z);
}

void Vetor::m_escalar(float escalar)
{
	this->x *= escalar;
	this->y *= escalar;
	this->z *= escalar;
}

void Vetor::normalizar()
{
Ejemplo n.º 26
0
Ponto viewOperations::worldToView(const Ponto &p, const Ponto &c) {
    Vetor res = Vetor();
    res = (this->camCoords_) * (p-c);
    Ponto p_ = Ponto(res.x_,res.y_,res.z_);
    return p_;
}
Ejemplo n.º 27
0
void Objeto::setVelocidade(int x, int y)
{
    velocidade = Vetor(x,y);

}
Ejemplo n.º 28
0
screenOperations::screenOperations() : cameraCoord_(Ponto()), cameraCoordView_(Ponto()),lightSource_(Ponto()), lightSourceView_(Ponto()), ka_(0.0),
    Ia_(Vetor()), kd_(0.0), Od_(Vetor()), ks_(0.0), Il_(Vetor()), alpha_(0.0) {}
Ejemplo n.º 29
0
void Objeto::setPosicao(int x, int y)
{
    posicao = Vetor(x,y);
}