Пример #1
0
Assembly *GraspGLObjects::CreateRollPrompt( double radius ) {

	Assembly *prompt = new Assembly();

	// Angular extent of the circular arrow, where 1.0 = 360°.
	double guage =  radius / 10.0;
	double arc = 0.85;

	Annulus *donut = new Annulus( radius, guage, arc, curve_facets, curve_facets );
	donut->SetAttitude( 0.0, 90.0, 0.0 );
	prompt->AddComponent( donut );

	TaperedAnnulus *tip = new TaperedAnnulus( radius, radius / 3.0, 1.0, 0.05, curve_facets );
	tip->SetAttitude( 0.0, 90.0, 0.0 );
	tip->SetOrientation( - arc * 360.0, 0.0, 0.0 );
	prompt->AddComponent( tip );

	Ellipsoid *base = new Ellipsoid ( guage, guage / 2.0, guage );
	base->SetPosition( radius, 0.0, 0.0 );
	prompt->AddComponent( base );
	prompt->SetColor( 0.5, 0.5, 0.5, 0.5 );

	return prompt;

}
Пример #2
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;
}
Пример #3
0
Assembly *GraspGLObjects::CreateTorso( void ) {

	Assembly *torso = new Assembly();
	Slab *slab = new Slab( torso_shape[X], torso_shape[Y], torso_shape[Z] );
	slab->SetColor( 0.1f, 0.4f, 0.0f );
	torso->AddComponent( slab );
	Disk *disk = new Disk( 50.0 );
	disk->SetPosition( 0.0, 0.0, -40.0 );
	disk->SetColor( 1.0f, 0.7f, 0.0f );
	torso->AddComponent( disk );
	return torso;

}
Пример #4
0
Assembly *GraspGLObjects::CreateSuccessIndicator( void ) {
	Assembly	*assembly = new Assembly();
	Sphere		*sphere = new Sphere( prompt_radius );
	sphere->SetColor( GREEN );
	assembly->AddComponent( sphere );
	return assembly;
}
Пример #5
0
// Create a translucid cloud to show where to place the hand.
Assembly *GraspGLObjects::CreateZone( void ) {
	Assembly *assembly = new Assembly();
	Disk *disk = new Disk( 50.0, 0.0, 128 );
	assembly->AddComponent( disk );
	// Set the color to a blinking translucid green.
	assembly->SetColor( 0.0, 1.0, 0.0, - 0.05 );
	return assembly;
}
Пример #6
0
Assembly *GraspGLObjects::CreateStarrySky( void ) {
	Assembly *sky = new Assembly();
	Patch *patch = new Patch( room_radius * 4.4, room_radius * 4.4 );
	patch->SetTexture( sky_texture );
	sky->AddComponent( patch );
	sky->SetColor(WHITE);
	return( sky );
}
Пример #7
0
Assembly *GraspGLObjects::CreateCodaBar( double r, double g, double b ) {

	Assembly *coda = new Assembly();
	Slab *slab = new Slab( coda_shape[X], coda_shape[Y], coda_shape[Z] );
	slab->SetColor( r, g, b, 1.0 );
	coda->AddComponent( slab );
	for ( int lens = 0; lens < 3; lens ++ ) {
		slab = new Slab( coda_shape[X] / 10.0, coda_shape[Y] * 0.8, coda_shape[Z] );
		slab->SetPosition( ( 1 - lens ) * 0.4 * coda_shape[X], 0.0, - 10.0 );
		slab->SetColor( BLACK );
		coda->AddComponent( slab );
	}
	coda->SetOffset( - 0.4 * coda_shape[X], 0.0, 0.0 );
	coda->SetAttitude( 0.0, -90.0, 0.0 );
	return coda;

}
Пример #8
0
Assembly *GraspGLObjects::CreateDarkSky( void ) {
	Assembly *darkSky = new Assembly();
	Patch *patch = new Patch( room_radius * 2.2, room_radius * 2.2 );
	patch->SetTexture( sky_texture );// there is something strange if I dont put the texture the ligthing of the whole tunnel changes
	darkSky->AddComponent( patch );
	darkSky->SetColor( BLACK );
	darkSky->enabled = false;
	return( darkSky );
}
Пример #9
0
Assembly *GraspGLObjects::CreateLaserPointer( void ) {
	Assembly *laserPointer = new Assembly();
	Sphere *sphere = new Sphere( finger_ball_radius*2.0 );
	sphere->SetPosition( 0.0, 0.0, - laser_distance );
	laserPointer->AddComponent( sphere );
	// Laser is off by default.
	laserPointer->Disable();
	return laserPointer;
}
Пример #10
0
Assembly *GraspGLObjects::CreateKinestheticTool( void ) {

	static const double hand_radius = finger_ball_radius * 2.5;
	Assembly *finger = new Assembly();
	Sphere *sphere = new Sphere( hand_radius );
	sphere->SetPosition( 0.0, 0.0, 0.0 );
	finger->AddComponent( sphere );
	Cylinder *cylinder = new Cylinder( hand_radius, hand_radius, finger_length );
	cylinder->SetPosition( 0.0, 0.0, - finger_length / 2 );
	finger->AddComponent( cylinder );
	sphere = new Sphere( hand_radius );
	sphere->SetPosition( 0.0, 0.0, - finger_length );
	finger->AddComponent( sphere );
	// Set a default color. I like blue.
	// In K-K color will be varied according to the orientation error.
	finger->SetColor( 0.0, 0.0, 1.0, 1.0 );
	return finger;

}
Пример #11
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;
}
Пример #12
0
Assembly *GraspGLObjects::CreateIndicator( Texture *texture, double hole_radius ) {

	Assembly	*assembly = new Assembly();
	Disk		*surface;

	surface = new Disk( 120.0, hole_radius, 128 );
	surface->SetTexture( texture );
	assembly->AddComponent( surface );
	assembly->SetColor( 0.9, 0.9, 1.0, hmdTransparency );
	assembly->Disable();

	return assembly;
}
Пример #13
0
Assembly *GraspGLObjects::CreateResponse( void ) {
	static int fingers = target_balls - 1;
	static double finger_spacing = target_ball_radius;
	Assembly *projectiles = new Assembly();
	for ( int trg = - fingers; trg <= fingers ; trg++ ){
		Sphere *sphere = new Sphere( target_ball_radius * 0.75 );
		sphere->SetColor( 200.0f/255.0f, (75.0f + float(trg) * 75.0f/2.0f)/255.0f , 0.0f, 1.0f  );
		// Space the balls vertically.
		sphere->SetPosition( 0.0, 0.0 + target_ball_spacing * trg, 0.0 );
		projectiles->AddComponent( sphere );
	}
	return projectiles;
}
Пример #14
0
// The following objects are not used during the Grasp protocol and are not seen by the subject.
// Rather, these objects are used in the GraspGUI and elswhere to visualize the subject's pose.
// Perhaps they would be better placed in another class so that they are not included when not needed.
Assembly *GraspGLObjects::CreateHead( void ) {

	Assembly *head = new Assembly();
	// Skull
	Ellipsoid *skull = new Ellipsoid( head_shape );
	skull->SetColor( .4f, 0.0f, .4f );
	// Eyes
	head->AddComponent( skull );
	Sphere *sphere = new Sphere( 20.0 );
	sphere->SetColor( 0.0f, 0.0f, 1.0f );
	sphere->SetPosition( -50.0, 20.0, -100.0 );
	head->AddComponent( sphere );
	sphere = new Sphere( 20.0 );
	sphere->SetColor( 0.0f, 0.0f, 1.0f );
	sphere->SetPosition( 50.0, 20.0, -100.0 );
	head->AddComponent( sphere );
	// Nose
	Cylinder *cylinder = new Cylinder( 20.0, 5.0, 30.0 );	
	cylinder->SetPosition( 0.0, -20.0, - head_shape[Z] );
	cylinder->SetOrientation( 0.0, 90.0, 0.0 );
	cylinder->SetColor( YELLOW );
	head->AddComponent( cylinder );
	return head;
}
Пример #15
0
Assembly *GraspGLObjects::CreateOrientationTarget( void ) {

	Assembly *target = new Assembly();

	if ( useBars ) {
		for (int trg = - target_bars ; trg <= target_bars ; trg++ ){
			Cylinder *cylinder = new Cylinder( target_bar_radius, target_bar_radius,2.0 * room_radius );
			cylinder->SetPosition( 0.0 + target_bar_spacing * trg, 0.0, 0.0 );
			cylinder->SetOrientation(0.0, 90.0, 0.0);
			cylinder->SetColor( Translucid( BLUE ) );
			target->AddComponent( cylinder );
		}
	}
	else {
		for (int trg = - target_balls ; trg <= target_balls ; trg++ ){
			Sphere *sphere = new Sphere( target_ball_radius );
			sphere->SetPosition( 0.0, 0.0 + target_ball_spacing * trg, 0.0 );
			sphere->SetColor(( 255.0 - abs(trg) * 50.0 ) / 255.0, 0.0, 0.0);
			target->AddComponent( sphere );
		}
	}

	return target;
}
Пример #16
0
Assembly *GraspGLObjects::CreatePositionOnlyTarget( void ) {
	Assembly *target = new Assembly();
	Sphere *sphere = new Sphere( room_radius - 100.0 );
	target->AddComponent( sphere );
	target->SetColor( Translucid( CYAN ) );

	// I put back the sphere so that we don't get a flattened disk in an oblique view.
	// I changed the color to CYAN to provide a better background to the yellow-red hand.

	//Disk *disk = new Disk( room_radius - 80.0, 0.0 );//Tagliabue (disk instead of sphere otherwise it hides 
	//disk->SetPosition(0.0 , 0.0 , 5.0);//Tagliabue (moved slightly in front of the sky otherwhise interferences)
	//target->AddComponent( disk );//Tagliabue
	//target->SetColor( Translucid( ORANGE ) );//Tagliabue (translucid is to avoid to see too clearly the pixels)
	return target;
}
Пример #17
0
Assembly *GraspGLObjects::CreateProjectiles( int fingers ) {

	Assembly *assembly = new Assembly();
	double finger_spacing = finger_ball_radius * 2;

	for ( int trg = - fingers; trg <= fingers ; trg++ ){
		Sphere *sphere = new Sphere( finger_ball_radius*1.0 );
		// Create a color that varies as a function of the ball's position.
		if ( fingers == 0 ) sphere->SetColor( 200.0f/255.0f, 0.0f, 0.0f, 1.0f );
		else sphere->SetColor( 200.0f/255.0f, (75.0f + float(trg) * 75.0f / 2.0f ) / 255.0f , 0.0f, 1.0f );
		// Space the balls vertically.
		sphere->SetPosition( 0.0, finger_spacing * trg, 0.0 );
		assembly->AddComponent( sphere );
	}

	return assembly;

}
Пример #18
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 );
}