示例#1
0
Assembly *GraspGLObjects::CreateVisualTool( double magnifier ) {

	Assembly *tool = new Assembly();

	// Create a set of 'fingers', each of which is a 'capsule' composed of a tube with rounded caps.
	static int n_fingers = target_balls-1;

	double radius = finger_ball_radius * magnifier;
	double length = finger_length * magnifier;

	double spacing = radius * 2.0;

	for ( int trg = - n_fingers; trg <= n_fingers ; trg++ ){


		// Each finger is a 'capsule' composed of a cylinder that is capped on each end with a sphere.
		Assembly *finger = new Assembly();
		Sphere *sphere = new Sphere( radius );
		sphere->SetPosition( 0.0, 0.0, 0.0 );
		finger->AddComponent( sphere );
		Cylinder *cylinder = new Cylinder( radius, radius, length );
		cylinder->SetPosition( 0.0, 0.0, - length / 2 );
		finger->AddComponent( cylinder );
		sphere = new Sphere( radius );
		sphere->SetPosition( 0.0, 0.0, - length );
		finger->AddComponent( sphere );

		// Space the fingers vertically.
		finger->SetPosition( 0.0, spacing * trg, 0.0 );
		tool->AddComponent( finger );
	}
	SetHandColor( tool, true );

	return tool;
}
示例#2
0
MarkerStructureGLObject *GraspGLObjects::CreateHmdMarkerStructure ( char *model_file ) {

	MarkerStructureGLObject *structure = new MarkerStructureGLObject( model_file );

	Slab *bar;
	Assembly *frame = new Assembly();

	bar = new Slab( STRUCTURE_BAR_RADIUS, 100.0, STRUCTURE_BAR_RADIUS );
	bar->SetPosition(   0.0, 0.0, 0.0 );
	frame->AddComponent( bar );
	bar = new Slab( 210.0, STRUCTURE_BAR_RADIUS, STRUCTURE_BAR_RADIUS );
	bar->SetPosition(   0.0, 0.0, 0.0 );
	frame->AddComponent( bar );
	bar = new Slab( STRUCTURE_BAR_RADIUS, 160.0, STRUCTURE_BAR_RADIUS );
	bar->SetPosition( 110.0, 0.0, 40.0 );
	frame->AddComponent( bar );
	bar = new Slab( STRUCTURE_BAR_RADIUS, 160.0, STRUCTURE_BAR_RADIUS );
	bar->SetPosition( -110.0, 0.0, 40.0 );
	frame->AddComponent( bar );
	bar = new Slab( STRUCTURE_BAR_RADIUS, STRUCTURE_BAR_RADIUS, 40 );
	bar->SetPosition( -110.0, 0.0, 20.0 );
	frame->AddComponent( bar );
	bar = new Slab( STRUCTURE_BAR_RADIUS, STRUCTURE_BAR_RADIUS, 40 );
	bar->SetPosition( 110.0, 0.0, 20.0 );
	frame->AddComponent( bar );


	frame->SetPosition( 0.0, 0.0, -10.0 );

	structure->AddComponent( frame );


	structure->SetColor( Translucid( GRAY ) );
	//	structure->SetOrientation( 0.0, 0.0, 90.0 );
	return( structure );
}