Esempio n. 1
0
/* create various resources like shrapnells */
void client_game_create()
{
	frame_create();
	shrapnells_init();
	shine_load();
	init_angles();

	/* background */
	bkgnd = stk_surface_create( SDL_SWSURFACE, 
			stk_display->w, stk_display->h );
	SDL_SetColorKey( bkgnd, 0, 0 );
	stk_surface_fill( bkgnd, 0,0,-1,-1, 0x0 );

}
void panel_control_hand::slotgo_inverse()
{

 Rhmatrix *A_prov = new Rhmatrix[grasp_number];
 int num_iter;
 fi0=FALSE;
 fi1=FALSE;
 fi2=FALSE;
 fi3=FALSE;

 //NO S'HA SELECCIONAT CAP PUNT DE GRASPING
 if(select_f0->currentItem()==0 && select_f1->currentItem()==0 && select_f2->currentItem()==0 && select_f3->currentItem()==0)
 {
   std::ostringstream pcout;
   pcout << "----------------------------------------------------" << std::endl;
   pcout << "No grasping points have been selected " << std::endl;
   pcout << "----------------------------------------------------" << std::endl;
   kinechain->send_stream(pcout);
 }

 //TOTS ELS DITS TENEN ASSIGNAT UN PUNT DE GRASPING
 if(select_f0->currentItem()!=0 && select_f1->currentItem()!=0 && select_f2->currentItem()!=0 && select_f3->currentItem()!=0)
 {
  A_prov[0] = A_hand[select_f0->currentItem()-1];
  A_prov[1] = A_hand[select_f1->currentItem()-1];
  A_prov[2] = A_hand[select_f2->currentItem()-1];
  A_prov[3] = A_hand[select_f3->currentItem()-1];

  init_angles();
  num_iter = kinechain->kineinverse_hand(A_prov,sol);
 }

 //NOMÉS EL PRIMER DIT TÉ ASSIGNAT UN PUNT DE GRASPING
if(select_f0->currentItem()!=0 && select_f1->currentItem()==0 && select_f2->currentItem()==0 && select_f3->currentItem()==0)
 {
  A_prov[0] = A_hand[select_f0->currentItem()-1];

  init_angles1();
  num_iter = kinechain->kineinverse(A_prov[0],sol1,0);
 }

 //NOMÉS EL SEGON DIT TÉ ASSIGNAT UN PUNT DE GRASPING
 if(select_f0->currentItem()==0 && select_f1->currentItem()!=0 && select_f2->currentItem()==0 && select_f3->currentItem()==0)
 {
  A_prov[0] = A_hand[select_f1->currentItem()-1];

  init_angles1();
  num_iter = kinechain->kineinverse(A_prov[0],sol1,1);
 }

 //NOMÉS EL TERCER DIT TÉ ASSIGNAT UN PUNT DE GRASPING
 if(select_f0->currentItem()==0 && select_f1->currentItem()==0 && select_f2->currentItem()!=0 && select_f3->currentItem()==0)
 {
  A_prov[0] = A_hand[select_f2->currentItem()-1];

  init_angles1();
  num_iter = kinechain->kineinverse(A_prov[0],sol1,2);
 }

 //NOMÉS EL QUART DIT TÉ ASSIGNAT UN PUNT DE GRASPING
 if(select_f0->currentItem()==0 && select_f1->currentItem()==0 && select_f2->currentItem()==0 && select_f3->currentItem()!=0)
 {
  A_prov[0] = A_hand[select_f3->currentItem()-1];

  init_angles1();
  num_iter = kinechain->kineinverse(A_prov[0],sol1,3);
 }

 //EL PRIMER I EL SEGON DIT TENEN ASSIGNATS PUNTS DE GRASPING
 if(select_f0->currentItem()!=0 && select_f1->currentItem()!=0 && select_f2->currentItem()==0 && select_f3->currentItem()==0)
 {
  A_prov[0] = A_hand[select_f0->currentItem()-1];
  A_prov[1] = A_hand[select_f1->currentItem()-1];
  fi0 = TRUE;
  fi1 = TRUE;
  fi2 = FALSE;
  fi3 = FALSE;
  init_angles();
  num_iter = kinechain->kineinverse_two_chains(A_prov,sol,fi0,fi1,fi2,fi3,2);
 }

 //EL PRIMER I EL TERCER DIT TENEN ASSIGNATS PUNTS DE GRASPING
 if(select_f0->currentItem()!=0 && select_f1->currentItem()==0 && select_f2->currentItem()!=0 && select_f3->currentItem()==0)
 {
  A_prov[0] = A_hand[select_f0->currentItem()-1];
  A_prov[2] = A_hand[select_f2->currentItem()-1];
  fi0 = TRUE;
  fi1 = FALSE;
  fi2 = TRUE;
  fi3 = FALSE;
  init_angles();
  num_iter = kinechain->kineinverse_two_chains(A_prov,sol,fi0,fi1,fi2,fi3,2);
 }

 //EL PRIMER I EL QUART DIT TENEN ASSIGNATS PUNTS DE GRASPING
 if(select_f0->currentItem()!=0 && select_f1->currentItem()==0 && select_f2->currentItem()==0 && select_f3->currentItem()!=0)
 {
  A_prov[0] = A_hand[select_f0->currentItem()-1];
  A_prov[3] = A_hand[select_f3->currentItem()-1];
  fi0 = TRUE;
  fi1 = FALSE;
  fi2 = FALSE;
  fi3 = TRUE;
  init_angles();
  num_iter = kinechain->kineinverse_two_chains(A_prov,sol,fi0,fi1,fi2,fi3,2);
 }

 //EL SEGON I EL TERCER DIT TENEN ASSIGNATS PUNTS DE GRASPING
 if(select_f0->currentItem()==0 && select_f1->currentItem()!=0 && select_f2->currentItem()!=0 && select_f3->currentItem()==0)
 {
  A_prov[1] = A_hand[select_f1->currentItem()-1];
  A_prov[2] = A_hand[select_f2->currentItem()-1];
  fi0 = FALSE;
  fi1 = TRUE;
  fi2 = TRUE;
  fi3 = FALSE;
  init_angles();
  num_iter = kinechain->kineinverse_two_chains(A_prov,sol,fi0,fi1,fi2,fi3,2);
 }

 //EL SEGON I EL QUART DIT TENEN ASSIGNATS PUNTS DE GRASPING
 if(select_f0->currentItem()==0 && select_f1->currentItem()!=0 && select_f2->currentItem()==0 && select_f3->currentItem()!=0)
 {
  A_prov[1] = A_hand[select_f1->currentItem()-1];
  A_prov[3] = A_hand[select_f3->currentItem()-1];
  fi0 = FALSE;
  fi1 = TRUE;
  fi2 = FALSE;
  fi3 = TRUE;
  init_angles();
  num_iter = kinechain->kineinverse_two_chains(A_prov,sol,fi0,fi1,fi2,fi3,2);
 }

 //EL TERCER I EL QUART DIT TENEN ASSIGNATS PUNTS DE GRASPING
 if(select_f0->currentItem()==0 && select_f1->currentItem()==0 && select_f2->currentItem()!=0 && select_f3->currentItem()!=0)
 {
  A_prov[2] = A_hand[select_f2->currentItem()-1];
  A_prov[3] = A_hand[select_f3->currentItem()-1];
  fi0 = FALSE;
  fi1 = FALSE;
  fi2 = TRUE;
  fi3 = TRUE;
  init_angles();
  num_iter = kinechain->kineinverse_two_chains(A_prov,sol,fi0,fi1,fi2,fi3,2);
 }

 //EL PRIMER, EL SEGON I EL TERCER DIT TENEN ASSIGNATS PUNTS DE GRASPING
 if(select_f0->currentItem()!=0 && select_f1->currentItem()!=0 && select_f2->currentItem()!=0 && select_f3->currentItem()==0)
 {
  A_prov[0] = A_hand[select_f0->currentItem()-1];
  A_prov[1] = A_hand[select_f1->currentItem()-1];
  A_prov[2] = A_hand[select_f2->currentItem()-1];
  fi0 = TRUE;
  fi1 = TRUE;
  fi2 = TRUE;
  fi3 = FALSE;
  init_angles();
  num_iter = kinechain->kineinverse_two_chains(A_prov,sol,fi0,fi1,fi2,fi3,3);
 }

 //EL PRIMER, EL SEGON I EL QUART DIT TENEN ASSIGNATS PUNTS DE GRASPING
 if(select_f0->currentItem()!=0 && select_f1->currentItem()!=0 && select_f2->currentItem()==0 && select_f3->currentItem()!=0)
 {
  A_prov[0] = A_hand[select_f0->currentItem()-1];
  A_prov[1] = A_hand[select_f1->currentItem()-1];
  A_prov[3] = A_hand[select_f3->currentItem()-1];
  fi0 = TRUE;
  fi1 = TRUE;
  fi2 = FALSE;
  fi3 = TRUE;
  init_angles();
  num_iter = kinechain->kineinverse_two_chains(A_prov,sol,fi0,fi1,fi2,fi3,3);
 }

 //EL PRIMER, EL TERCER I EL QUART DIT TENEN ASSIGNATS PUNTS DE GRASPING
 if(select_f0->currentItem()!=0 && select_f1->currentItem()==0 && select_f2->currentItem()!=0 && select_f3->currentItem()!=0)
 {
  A_prov[0] = A_hand[select_f0->currentItem()-1];
  A_prov[2] = A_hand[select_f2->currentItem()-1];
  A_prov[3] = A_hand[select_f3->currentItem()-1];
  fi0 = TRUE;
  fi1 = FALSE;
  fi2 = TRUE;
  fi3 = TRUE;
  init_angles();
  num_iter = kinechain->kineinverse_two_chains(A_prov,sol,fi0,fi1,fi2,fi3,3);
 }

 //EL SEGON, EL TERCER I EL QUART DIT TENEN ASSIGNATS PUNTS DE GRASPING
 if(select_f0->currentItem()==0 && select_f1->currentItem()!=0 && select_f2->currentItem()!=0 && select_f3->currentItem()!=0)
 {
  A_prov[1] = A_hand[select_f1->currentItem()-1];
  A_prov[2] = A_hand[select_f2->currentItem()-1];
  A_prov[3] = A_hand[select_f3->currentItem()-1];
  fi0 = FALSE;
  fi1 = TRUE;
  fi2 = TRUE;
  fi3 = TRUE;
  init_angles();
  num_iter = kinechain->kineinverse_two_chains(A_prov,sol,fi0,fi1,fi2,fi3,3);
 }

  delete[] A_prov;
}
	virtual void scaleInit (void) {faceDown (); init_angles ();}