📄 uevents.c
字号:
/* Encode the event data for the slaves to act upon */ event.opcode = APP_EVENT_SPOTLIGHT_ROTATION; ptr_float = (float *)&event.data[0]; *ptr_float = rot.x; ptr_float += 1; *ptr_float = rot.y; ptr_float += 1; *ptr_float = rot.z; /* Update discrete count */ host_data.event = event; host_data.discrete_count++; } #endif}/******************************************************************************* mspotlight_pitch_decrease --** Change the pitch of the spotlight by changing the orientation* of the subpart on the owntrain object (the spotlight effect* is attached to this subpart)*******************************************************************************/static void mspotlight_pitch_decrease( int reason ){ tspotlight_pitch_decrease( reason ); if( !ownspot ) { GV_obi_inq_by_name( "OWNTRAIN", &owntrain ); GV_obi_inq_by_name_relative( owntrain, ".../spotlight", &ownspot ); } #if 0 if( ownspot ) { G_Rotation rot; Tevent event; GV_obi_inq_rotation( ownspot, &rot ); #if DEBUG fprintf( stdout, "spotlight rotx-roty-rotz: %f %f %f\n", rot.x, rot.y, rot.z ); #endif /* Encode the event data for the slaves to act upon */ event.opcode = APP_EVENT_SPOTLIGHT_ROTATION; ptr_float = (float *)&event.data[0]; *ptr_float = rot.x; ptr_float += 1; *ptr_float = rot.y; ptr_float += 1; *ptr_float = rot.z; /* Update discrete count */ host_data.event = event; host_data.discrete_count++; } #endif}/******************************************************************************* mspotlight_pitch_decrease --** Change the pitch of the spotlight by changing the orientation* of the subpart on the owntrain object (the spotlight effect* is attached to this subpart)*******************************************************************************/static void mspotlight_pitch_increase( int reason ){ tspotlight_pitch_increase( reason ); if( !ownspot ) { GV_obi_inq_by_name( "OWNTRAIN", &owntrain ); GV_obi_inq_by_name_relative( owntrain, ".../spotlight", &ownspot ); } #if 0 if( ownspot ) { G_Rotation rot; Tevent event; GV_obi_inq_rotation( ownspot, &rot ); #if DEBUG fprintf( stdout, "spotlight rotx-roty-rotz: %f %f %f\n", rot.x, rot.y, rot.z ); #endif /* Encode the event data for the slaves to act upon */ event.opcode = APP_EVENT_SPOTLIGHT_ROTATION; ptr_float = (float *)&event.data[0]; *ptr_float = rot.x; ptr_float += 1; *ptr_float = rot.y; ptr_float += 1; *ptr_float = rot.z; /* Update discrete count */ host_data.event = event; host_data.discrete_count++; } #endif}/******************************************************************************* mspotlight_roll_decrease --** Change the roll of the spotlight by changing the orientation* of the subpart on the owntrain object (the spotlight effect* is attached to this subpart)*******************************************************************************/static void mspotlight_roll_decrease( int reason ){ tspotlight_roll_decrease( reason ); if( !ownspot ) { GV_obi_inq_by_name( "OWNTRAIN", &owntrain ); GV_obi_inq_by_name_relative( owntrain, ".../spotlight", &ownspot ); } #if 0 if( ownspot ) { G_Rotation rot; Tevent event; GV_obi_inq_rotation( ownspot, &rot ); #if DEBUG fprintf( stdout, "spotlight rotx-roty-rotz: %f %f %f\n", rot.x, rot.y, rot.z ); #endif /* Encode the event data for the slaves to act upon */ event.opcode = APP_EVENT_SPOTLIGHT_ROTATION; ptr_float = (float *)&event.data[0]; *ptr_float = rot.x; ptr_float += 1; *ptr_float = rot.y; ptr_float += 1; *ptr_float = rot.z; /* Update discrete count */ host_data.event = event; host_data.discrete_count++; } #endif}/******************************************************************************* mspotlight_roll_increase --** Change the roll of the spotlight by changing the orientation* of the subpart on the owntrain object (the spotlight effect* is attached to this subpart)*******************************************************************************/static void mspotlight_roll_increase( int reason ){ tspotlight_roll_increase( reason ); if( !ownspot ) { GV_obi_inq_by_name( "OWNTRAIN", &owntrain ); GV_obi_inq_by_name_relative( owntrain, ".../spotlight", &ownspot ); } #if 0 if( ownspot ) { G_Rotation rot; Tevent event; GV_obi_inq_rotation( ownspot, &rot ); #if DEBUG fprintf( stdout, "spotlight rotx-roty-rotz: %f %f %f\n", rot.x, rot.y, rot.z ); #endif /* Encode the event data for the slaves to act upon */ event.opcode = APP_EVENT_SPOTLIGHT_ROTATION; ptr_float = (float *)&event.data[0]; *ptr_float = rot.x; ptr_float += 1; *ptr_float = rot.y; ptr_float += 1; *ptr_float = rot.z; host_data.event = event; host_data.discrete_count++; } #endif}/******************************************************************************* mspotlight_event_attenuation --** Alter the spotlight attenuation*******************************************************************************/static void mspotlight_event_attenuation( int reason ){ GVU_Plsr spotlight; float atten; Tevent event; tspotlight_event_attenuation( reason ); GVU_plsr_inq_by_name( TSPOTLIGHT_NAME, &spotlight ); GVU_plsr_inq_attenuation( spotlight, GL_QUADRATIC_ATTENUATION, &atten ); /* Encode the event data for the slaves to act upon */ event.opcode = APP_EVENT_SPOTLIGHT_ATTENUATION; ptr_float = (float *)&event.data[0]; *ptr_float = atten; host_data.event = event; host_data.discrete_count++;}/******************************************************************************* mspotlight_event_falloff --** Alter the spotlight falloff *******************************************************************************/static void mspotlight_event_falloff( int reason ){ GVU_Plsr spotlight; float falloff; Tevent event; tspotlight_event_falloff( reason ); GVU_plsr_inq_by_name( TSPOTLIGHT_NAME, &spotlight ); GVU_plsr_inq_spot_exponent( spotlight, &falloff ); /* Encode the event data for the slaves to act upon */ event.opcode = APP_EVENT_SPOTLIGHT_FALLOFF; ptr_float = (float *)&event.data[0]; *ptr_float = falloff; host_data.event = event; host_data.discrete_count++;}/****************************************************************************** events_init -- ** Event related initialization stuff when not running as a slave******************************************************************************/void events_init( void ){ static GV_Rgba textcolor = {1.0, 1.0, 1.0, 1.0}; char letteru; char letterl; char letter1; char letter2; char letter3; int uppercase; int lowercase; char temp[1024]; /* Get pointer to parse data */ tparse_inq_data( &tdata ); if( tdata && tdata->network_duties == NETWORK_DUTIES_MASTER ) { tkui_add_callback( G_ASCII_ESCAPE, event_quit ); tkui_add_description( G_ASCII_ESCAPE, " Esc Network shutdown" ); tkui_add_color( G_ASCII_ESCAPE, &textcolor ); } lowercase = TSPOTLIGHT_LOWERCASE_KEY; uppercase = toupper(lowercase); letterl = (char)lowercase; letteru = (char)uppercase; tkui_add_callback( lowercase, mspotlight_toggle_cone_effect ); tkui_add_callback( uppercase, mspotlight_toggle_cone_effect ); sprintf( temp, " %c,%c Toggle spotlight cone object", letterl, letteru ); tkui_add_description( lowercase, temp ); tkui_add_color( lowercase, &textcolor ); tkui_add_callback( lowercase, mspotlight_event_falloff ); tkui_add_callback( uppercase, mspotlight_event_falloff ); sprintf( temp, " %c,%c Spotlight falloff", letterl, letteru ); tkui_add_description( lowercase, temp ); tkui_add_color( lowercase, &textcolor ); tkui_add_callback( lowercase, mspotlight_event_attenuation ); tkui_add_callback( uppercase, mspotlight_event_attenuation ); sprintf( temp, " %c,%c Spotlight attenuation", letterl, letteru ); tkui_add_description( lowercase, temp ); tkui_add_color( lowercase, &textcolor ); tkui_add_callback( lowercase, mspotlight_event_toggle ); tkui_add_callback( uppercase, mspotlight_event_toggle ); sprintf( temp, " %c,%c Toggle spotlight effect", letterl, letteru ); tkui_add_description( lowercase, temp ); tkui_add_color( lowercase, &textcolor );/****************************************************************************/ lowercase = TSPOTLIGHT_ROT_LOWERCASE_KEY; uppercase = toupper(lowercase); letter1 = (char)uppercase; letter2 = (char)uppercase+1; letter3 = (char)uppercase+2; tkui_add_callback( lowercase, mspotlight_pitch_decrease ); tkui_add_callback( lowercase+1, mspotlight_heading_increase ); tkui_add_callback( lowercase+2, mspotlight_roll_increase ); tkui_add_callback( uppercase, mspotlight_pitch_increase ); tkui_add_callback( uppercase+1, mspotlight_heading_decrease ); tkui_add_callback( uppercase+2, mspotlight_roll_decrease ); tkui_add_color( lowercase, &textcolor ); tkui_add_color( lowercase+1, &textcolor ); tkui_add_color( lowercase+2, &textcolor ); sprintf(temp," %c-%c-%c Spotlight direction", letter1, letter2, letter3); tkui_add_description(TKUI_XYZ_GROUP, temp );/****************************************************************************/ tkui_add_callback( 'o', event_toggle_recording ); tkui_add_callback( 'O', event_toggle_recording ); tkui_add_description( 'o', " o,O Record Start/Stop Ownship" ); tkui_add_color( 'o', &textcolor ); /* Mark this as "DEMO specific" */ tkui_add_callback( '>', event_playback_speed); tkui_add_callback( '<', event_playback_speed); tkui_add_description( '>', " <,> Playback speed" ); tkui_add_color( '>', &textcolor ); /* Mark this as "DEMO specific" */}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -