* render workzone in 3d camera

This commit is contained in:
Garux 2018-08-20 23:33:33 +03:00
parent 601ca95fbf
commit 82ff22882d
3 changed files with 86 additions and 9 deletions

View File

@ -85,6 +85,7 @@ struct camwindow_globals_private_t
bool m_bFaceWire;
bool m_bFaceFill;
int m_MSAA;
bool m_bShowWorkzone;
camwindow_globals_private_t() :
m_nMoveSpeed( 500 ),
@ -98,7 +99,8 @@ struct camwindow_globals_private_t
m_strafeMode( 3 ),
m_bFaceWire( true ),
m_bFaceFill( true ),
m_MSAA( 8 ){
m_MSAA( 8 ),
m_bShowWorkzone( true ){
}
};
@ -1681,6 +1683,16 @@ void ShowStatsToggle(){
UpdateAllWindows();
}
BoolExportCaller g_show_workzone3d_caller( g_camwindow_globals_private.m_bShowWorkzone );
ToggleItem g_show_workzone3d( g_show_workzone3d_caller );
void ShowWorkzone3dToggle(){
g_camwindow_globals_private.m_bShowWorkzone ^= 1;
g_show_workzone3d.update();
if ( g_camwnd != 0 ) {
CamWnd_Update( *g_camwnd );
}
}
#include "stream/stringstream.h"
void CamWnd::Cam_Draw(){
@ -1793,6 +1805,68 @@ void CamWnd::Cam_Draw(){
renderer.render( m_Camera.modelview, m_Camera.projection );
}
/* workzone */
if( g_camwindow_globals_private.m_bShowWorkzone && GlobalSelectionSystem().countSelected() != 0 ){
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glShadeModel( GL_SMOOTH );
glEnable( GL_DEPTH_TEST );
glDepthFunc( GL_LESS );
glDepthMask( GL_TRUE );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glDisableClientState( GL_NORMAL_ARRAY );
glDisableClientState( GL_COLOR_ARRAY );
glDisable( GL_TEXTURE_2D );
glDisable( GL_LIGHTING );
glDisable( GL_COLOR_MATERIAL );
glDisable( GL_LINE_STIPPLE );
glLineWidth( 1 );
#if 0
const Vector4 color0( g_camwindow_globals.color_selbrushes3d, 0 );
const Vector4 color1( g_camwindow_globals.color_selbrushes3d, 1 );
#else
const Vector4 color0( 1, 1, 1, 0 );
const Vector4 color1( 1, 1, 1, 1 );
#endif
const AABB bounds = GlobalSelectionSystem().getBoundsSelected();
glBegin( GL_LINES );
for( std::size_t i = 0; i < 3; ++i ){
const std::size_t i2 = ( i + 1 ) % 3;
const std::size_t i3 = ( i + 2 ) % 3;
const Vector3 normal = g_vector3_axes[i];
const float size = 1024;
std::vector<Vector3> points;
points.reserve( 4 );
points.push_back( bounds.origin + g_vector3_axes[i2] * bounds.extents + g_vector3_axes[i3] * bounds.extents );
if( bounds.extents[i2] != 0 ){
points.push_back( bounds.origin - g_vector3_axes[i2] * bounds.extents + g_vector3_axes[i3] * bounds.extents );
}
if( bounds.extents[i3] != 0 ){
points.push_back( bounds.origin + g_vector3_axes[i2] * bounds.extents - g_vector3_axes[i3] * bounds.extents );
if( bounds.extents[i2] != 0 ){
points.push_back( bounds.origin - g_vector3_axes[i2] * bounds.extents - g_vector3_axes[i3] * bounds.extents );
}
}
for( std::vector<Vector3>::const_iterator j = points.begin(); j != points.end(); ++j ){
glColor4fv( vector4_to_array( color0 ) );
glVertex3fv( vector3_to_array( *j + normal * ( bounds.extents[i] + size ) ) );
glColor4fv( vector4_to_array( color1 ) );
glVertex3fv( vector3_to_array( *j + normal * ( bounds.extents[i] ) ) );
glVertex3fv( vector3_to_array( *j + normal * ( bounds.extents[i] ) ) );
glVertex3fv( vector3_to_array( *j - normal * ( bounds.extents[i] ) ) );
glVertex3fv( vector3_to_array( *j - normal * ( bounds.extents[i] ) ) );
glColor4fv( vector4_to_array( color0 ) );
glVertex3fv( vector3_to_array( *j - normal * ( bounds.extents[i] + size ) ) );
}
}
glEnd();
}
// prepare for 2d stuff
glColor4f( 1, 1, 1, 1 );
glDisable( GL_BLEND );
@ -2324,8 +2398,10 @@ void CamWnd_Construct(){
GlobalShortcuts_insert( "CameraFreeFocus", Accelerator( GDK_Tab ) );
GlobalToggles_insert( "ShowStats", FreeCaller<ShowStatsToggle>(), ToggleItem::AddCallbackCaller( g_show_stats ) );
GlobalToggles_insert( "ShowWorkzone3d", FreeCaller<ShowWorkzone3dToggle>(), ToggleItem::AddCallbackCaller( g_show_workzone3d ) );
GlobalPreferenceSystem().registerPreference( "ShowStats", BoolImportStringCaller( g_camwindow_globals.m_showStats ), BoolExportStringCaller( g_camwindow_globals.m_showStats ) );
GlobalPreferenceSystem().registerPreference( "ShowWorkzone3d", BoolImportStringCaller( g_camwindow_globals_private.m_bShowWorkzone ), BoolExportStringCaller( g_camwindow_globals_private.m_bShowWorkzone ) );
GlobalPreferenceSystem().registerPreference( "CamMoveSpeed", IntImportStringCaller( g_camwindow_globals_private.m_nMoveSpeed ), IntExportStringCaller( g_camwindow_globals_private.m_nMoveSpeed ) );
GlobalPreferenceSystem().registerPreference( "CamMoveTimeToMaxSpeed", IntImportStringCaller( g_camwindow_globals_private.m_time_toMaxSpeed ), IntExportStringCaller( g_camwindow_globals_private.m_time_toMaxSpeed ) );
GlobalPreferenceSystem().registerPreference( "ScrollMoveSpeed", IntImportStringCaller( g_camwindow_globals_private.m_nScrollMoveSpeed ), IntExportStringCaller( g_camwindow_globals_private.m_nScrollMoveSpeed ) );

View File

@ -2096,7 +2096,8 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){
create_check_menu_item_with_mnemonic( menu_in_menu, "Show C_oordinates", "ShowCoordinates" );
create_check_menu_item_with_mnemonic( menu_in_menu, "Show Window Outline", "ShowWindowOutline" );
create_check_menu_item_with_mnemonic( menu_in_menu, "Show Axes", "ShowAxes" );
create_check_menu_item_with_mnemonic( menu_in_menu, "Show Workzone", "ShowWorkzone" );
create_check_menu_item_with_mnemonic( menu_in_menu, "Show 2D Workzone", "ShowWorkzone2d" );
create_check_menu_item_with_mnemonic( menu_in_menu, "Show 3D Workzone", "ShowWorkzone3d" );
create_check_menu_item_with_mnemonic( menu_in_menu, "Show Renderer Stats", "ShowStats" );
}

View File

@ -90,7 +90,7 @@ struct xywindow_globals_private_t
bool show_outline;
bool show_axis;
bool d_show_work;
bool show_workzone;
bool show_blocks;
int blockSize;
@ -109,7 +109,7 @@ struct xywindow_globals_private_t
show_outline( true ),
show_axis( true ),
d_show_work( false ),
show_workzone( false ),
show_blocks( false ),
@ -1752,7 +1752,7 @@ void XYWnd::XY_DrawGrid( void ) {
// show current work zone?
// the work zone is used to place dropped points and brushes
if ( g_xywindow_globals_private.d_show_work ) {
if ( g_xywindow_globals_private.show_workzone ) {
glColor4f( 1.0f, 0.0f, 0.0f, 1.0f );
glBegin( GL_LINES );
glVertex2f( xb, Select_getWorkZone().d_work_min[nDim2] );
@ -2777,10 +2777,10 @@ void ShowAxesToggle(){
}
BoolExportCaller g_show_workzone_caller( g_xywindow_globals_private.d_show_work );
BoolExportCaller g_show_workzone_caller( g_xywindow_globals_private.show_workzone );
ToggleItem g_show_workzone( g_show_workzone_caller );
void ShowWorkzoneToggle(){
g_xywindow_globals_private.d_show_work ^= 1;
g_xywindow_globals_private.show_workzone ^= 1;
g_show_workzone.update();
XY_UpdateAllWindows();
}
@ -2877,7 +2877,7 @@ void XYShow_registerCommands(){
GlobalToggles_insert( "ShowCoordinates", FreeCaller<ShowCoordinatesToggle>(), ToggleItem::AddCallbackCaller( g_show_coordinates ) );
GlobalToggles_insert( "ShowWindowOutline", FreeCaller<ShowOutlineToggle>(), ToggleItem::AddCallbackCaller( g_show_outline ) );
GlobalToggles_insert( "ShowAxes", FreeCaller<ShowAxesToggle>(), ToggleItem::AddCallbackCaller( g_show_axes ) );
GlobalToggles_insert( "ShowWorkzone", FreeCaller<ShowWorkzoneToggle>(), ToggleItem::AddCallbackCaller( g_show_workzone ) );
GlobalToggles_insert( "ShowWorkzone2d", FreeCaller<ShowWorkzoneToggle>(), ToggleItem::AddCallbackCaller( g_show_workzone ) );
}
void XYWnd_registerShortcuts(){
@ -2940,7 +2940,7 @@ void XYWindow_Construct(){
GlobalPreferenceSystem().registerPreference( "SI_ShowCoords", BoolImportStringCaller( g_xywindow_globals_private.show_coordinates ), BoolExportStringCaller( g_xywindow_globals_private.show_coordinates ) );
GlobalPreferenceSystem().registerPreference( "SI_ShowOutlines", BoolImportStringCaller( g_xywindow_globals_private.show_outline ), BoolExportStringCaller( g_xywindow_globals_private.show_outline ) );
GlobalPreferenceSystem().registerPreference( "SI_ShowAxis", BoolImportStringCaller( g_xywindow_globals_private.show_axis ), BoolExportStringCaller( g_xywindow_globals_private.show_axis ) );
GlobalPreferenceSystem().registerPreference( "ShowWorkzone", BoolImportStringCaller( g_xywindow_globals_private.d_show_work ), BoolExportStringCaller( g_xywindow_globals_private.d_show_work ) );
GlobalPreferenceSystem().registerPreference( "ShowWorkzone2d", BoolImportStringCaller( g_xywindow_globals_private.show_workzone ), BoolExportStringCaller( g_xywindow_globals_private.show_workzone ) );
GlobalPreferenceSystem().registerPreference( "SI_AxisColors0", Vector3ImportStringCaller( g_xywindow_globals.AxisColorX ), Vector3ExportStringCaller( g_xywindow_globals.AxisColorX ) );
GlobalPreferenceSystem().registerPreference( "SI_AxisColors1", Vector3ImportStringCaller( g_xywindow_globals.AxisColorY ), Vector3ExportStringCaller( g_xywindow_globals.AxisColorY ) );