

package Graphics;

public class ActionThread implements Runnable{
         canvas screen;
  double angle;
  int frameno=0;

  public ActionThread() {
  }



  public ActionThread(canvas s)
  {
    screen=s;
  }

  public void run()
  {

    while(true)
    {
      frameno++;
      if(frameno>screen.scene.totalframes)
        frameno=1;

        System.out.println("Animating frame no : " +frameno);
     

    //      Compute animation matrix for animations

      int i;
      for(i=0;i<screen.scene.get_nr_objects();i++)
          screen.scene.get_object(i).set_anim(frameno,screen.scene.totalframes);

          //System.out.println("number of lights : " + screen.scene.nr_lights);
      for(i=0;i<screen.scene.nr_lights;i++)
          screen.scene.lights[i].set_anim(frameno,screen.scene.totalframes);


    // System.out.println("Position : " + screen.cameraLocation.toString());


      draw();
     }


  }

  void draw()
  {
    screen.compute();
    screen.paintImmediately(screen.getVisibleRect());
  }

} 