Group/Scene graph code

This is code for a group object in in processing that allows you to group together objects and create scene graphs.

 
import processing.opengl.*;
import javax.media.opengl.*; 
 
 
class Group extends Shape
{
  Vector shapes;
 
  Group()
  {
    shapes = new Vector();
  }
 
  void addShape(Shape shape)
  {
    shapes.add(shape);
  }
 
  void update()
  {
    for (Enumeration e = shapes.elements(); e.hasMoreElements();)
    {
	Shape shp = (Shape) e.nextElement();
	shp.update();
    }
  }
 
  void drawShape(GL gl)
  {
    for (Enumeration e = shapes.elements(); e.hasMoreElements();)
    {
	Shape shape = (Shape) e.nextElement();
	shape.draw(gl);
    }
  }
}
PDF    Send article as PDF to