Example #1
0
MeterStick::MeterStick( void ) {

  double stick_radius = 25.0;

  Cylinder *cylinder;
  Disk *disk;

  cylinder = new Cylinder( stick_radius, stick_radius, 200.0 );
  cylinder->SetColor( RED );
  AddComponent( cylinder );
  cylinder = new Cylinder( stick_radius, stick_radius, 200.0 );
  cylinder->SetOffset( 0.0, 0.0, 200.0 );
  cylinder->SetColor( WHITE );
  AddComponent( cylinder );
  cylinder = new Cylinder( stick_radius, stick_radius, 200.0 );
  cylinder->SetOffset( 0.0, 0.0, 400.0 );
  cylinder->SetColor( RED );
  AddComponent( cylinder );
  cylinder = new Cylinder( stick_radius, stick_radius, 200.0 );
  cylinder->SetOffset( 0.0, 0.0, 600.0 );
  cylinder->SetColor( WHITE );
  AddComponent( cylinder );
  cylinder = new Cylinder( stick_radius, stick_radius, 200.0 );
  cylinder->SetOffset( 0.0, 0.0, 800.0 );
  cylinder->SetColor( RED );
  AddComponent( cylinder );

  cylinder = new Cylinder( stick_radius / 2.0, stick_radius / 2.0, 100.0 );
  cylinder->SetAttitude( 90.0, j_vector );
  cylinder->SetColor( BLACK );
  AddComponent( cylinder );

  cylinder = new Cylinder( stick_radius / 2.0, stick_radius / 2.0, 100.0 );
  cylinder->SetAttitude( 90.0, j_vector );
  cylinder->SetPosition( 0.0, 0.0, 1000.0 - stick_radius );
  cylinder->SetColor( BLACK );
  AddComponent( cylinder );

  disk = new Disk( stick_radius );
  disk->SetPosition( 0.0, 0.0, 990.0 );
  disk->SetColor( RED );
  AddComponent( disk );

}
Example #2
0
Assembly *GraspGLObjects::CreateRoom( void ) {

	Assembly *structure = new Assembly();
	structure->SetColor( BLACK );

	// Tunnel
	tunnel = new Assembly();
	Cylinder *cylinder = new Cylinder( room_radius, room_radius, room_length, room_facets );
	cylinder->SetColor( WHITE );
	cylinder->SetTexture( wall_texture );
	cylinder->SetOrientation( 90.0, 0.0, 0.0 );
	tunnel->AddComponent( cylinder );
	// Reference Bars 
	double bar_length = room_length - 5.0 * reference_bar_radius;
	for (int i=0; i < reference_bars; i++ ){ 
		Cylinder *referenceBar = new Cylinder( reference_bar_radius, reference_bar_radius, bar_length, reference_bar_facets );
		referenceBar->SetOffset( room_radius, 0.0, 0.0 );
		referenceBar->SetOrientation( 90.0 + 180 * (float) i / (float) reference_bars, referenceBar->kVector );
		referenceBar->SetColor(  1.0 - (double) i / reference_bars, 1.0f - (double) i / reference_bars, 1.0f - (double) i / reference_bars, 1.0 );
		// The texturing on the bars may be commented out for the moment because it lengthens the rendering time too much.
		referenceBar->SetTexture( references_texture );
		tunnel->AddComponent( referenceBar );
		referenceBar = new Cylinder( reference_bar_radius, reference_bar_radius, bar_length, reference_bar_facets );
		referenceBar->SetOffset( room_radius, 0.0, 0.0 );
		referenceBar->SetOrientation( - 90.0 + 180 * (float) i / (float) reference_bars, referenceBar->kVector );
		referenceBar->SetColor(  (double) i / reference_bars, (double) i / reference_bars, (double) i / reference_bars, 1.0 );
		// See above.
		referenceBar->SetTexture( references_texture );
		tunnel->AddComponent( referenceBar );
	}
	structure->AddComponent( tunnel );

	Sphere *sphere = new Sphere( target_ball_radius );
	sphere->SetPosition( 0.0, 0.0, room_length / 2.0 );
	sphere->SetColor( RED );
	structure->AddComponent( sphere );

	return structure;
}