示例#1
0
//the simulation loop...
void simulation_loop(int *argc, char *argv[])
{
#ifdef OGL_GRAPHICS
  grInit(argc, argv);
#else
  for (;;)
    {
      static int step=0;
      step++;

      if (step == 3000)
	exit(0);

      std::cout<<"Step no: "<<step<<"\n";
      for (polyObject *curr=list; curr != NULL; curr = curr->next)
	{
	  double ogl_trans[16];
	  curr->UpdateOneStep(ogl_trans);

	  double trans[4][4];

	  for (int i=0; i<4; i++)
	    for (int j=0; j<4; j++)
	      trans[i][j] = ogl_trans[4*j+i];

	  UpdatePolytope(curr->id, trans);
	}
      CollisionTestReportAndRespond();

    }
#endif
}
示例#2
0
void DisplayFunc(void)
{
  static int step=0;
  step++;

  std::cout<<"Step no: "<<step<<"\n";
  
  glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );


  glMaterialfv(GL_FRONT, GL_SPECULAR, cube_specular);
  glMaterialfv(GL_FRONT, GL_DIFFUSE, cube_diffuse);
  glMaterialfv(GL_FRONT, GL_SHININESS, cube_shininess);
  DrawCube();

  glMaterialfv(GL_FRONT, GL_SPECULAR, bunny_specular);
  glMaterialfv(GL_FRONT, GL_DIFFUSE, bunny_diffuse);
  glMaterialfv(GL_FRONT, GL_SHININESS, bunny_shininess);
  
  polyObject *curr;
  for (curr=list; curr != NULL; curr = curr->next)
    {
      double ogl_trans[16];
      curr->UpdateOneStep(ogl_trans);

      double trans[4][4];
      
      int i,j;
      for (i=0; i<4; i++)
	for (j=0; j<4; j++)
	  trans[i][j] = ogl_trans[4*j+i];
      
      UpdatePolytope(curr->id, trans);
      curr->p->Display(ogl_trans);
    }
  
  glutSwapBuffers();
  CollisionTestReportAndRespond();
  
}
示例#3
0
void DisplayFunc(void)
{
  static int done=0;
  static int step=1;
  
  if (!done)
    {
      glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
      
      
      char t;
      double time;
      
      fscanf(fp, "%c", &t);
      fscanf(fp, "t %lf", &time);
      
      double ogl_trans[16];
      
      if (time <5.57)
	{
	  std::cout<<"step = "<<step<<"\n";
      step++;
	  
	  int i;
	  for (i=0; i<num_of_polytopes; i++)
	    {
	      UpdatePolytope(i, ogl_trans);
	      polytope[i]->Display(ogl_trans);
	    }
	  
	  glutSwapBuffers();
	  CollisionTestAndReport();
	}
      else
	{
	  done=1;
	}
      
    }
}
示例#4
0
//the simulation_loop...
void simulation_loop(int *argc, char *argv[])
{
#ifdef OGL_GRAPHICS
  grInit(argc, argv);
#else
  for(;;)
    {
      static int step=1;
      
      cout<<"step = "<<step<<"\n";
      step++;
      
      char t;
      double time;
      
      fscanf(fp, "%c", &t);
      fscanf(fp, "t %lf", &time);
      
      double ogl_trans[16];
      
      if (time <5.57)
	{
	  int i;
	  for (i=0; i<num_of_polytopes; i++)
	    {
	      UpdatePolytope(i, ogl_trans);
	    }
	  CollisionTestAndReport();
	}
      else
	{
	  break;
	}
      
    }
#endif
}