}
}
+
typedef std::vector<scene::Instance*> InstanceVector;
class PatchStoreInstance
}
}
+void Patch_deform( Patch& patch, scene::Instance& instance, const int deform ){
+ patch.undoSave();
+
+ for (PatchControlIter i = patch.begin(); i != patch.end(); ++i)
+ {
+ PatchControl& control = *i;
+ int randomNumber = int( deform * (float(std::rand()) / float(RAND_MAX)));
+ control.m_vertex[2] += randomNumber;
+ }
+
+ patch.controlPointsChanged();
+}
+
+void Scene_PatchDeform( scene::Graph& graph, const int deform )
+{
+ InstanceVector instances;
+ Scene_forEachVisibleSelectedPatchInstance( PatchStoreInstance( instances ) );
+ for ( InstanceVector::const_iterator i = instances.begin(); i != instances.end(); ++i )
+ {
+ Patch_deform( *Node_getPatch( ( *i )->path().top() ), *( *i ), deform );
+ }
+
+}
+
+void Patch_thicken( Patch& patch, scene::Instance& instance, const float thickness, bool seams, const int axis ){
+
+ // Create a new patch node
+ NodeSmartReference node( g_patchCreator->createPatch() );
+ // Insert the node into worldspawn
+ Node_getTraversable( Map_FindOrInsertWorldspawn( g_map ) )->insert( node );
+
+ // Retrieve the contained patch from the node
+ Patch* targetPatch = Node_getPatch( node );
+
+ // Create the opposite patch with the given thickness = distance
+ bool no12 = true;
+ bool no34 = true;
+ targetPatch->createThickenedOpposite( patch, thickness, axis, no12, no34 );
+
+ // Now select the newly created patches
+ {
+ scene::Path patchpath( makeReference( GlobalSceneGraph().root() ) );
+ patchpath.push( makeReference( *Map_GetWorldspawn( g_map ) ) );
+ patchpath.push( makeReference( node.get() ) );
+ Instance_getSelectable( *GlobalSceneGraph().find( patchpath ) )->setSelected( true );
+ }
+
+ if( seams && thickness != 0.0f){
+ int i = 0;
+ if ( no12 ){
+ i = 2;
+ }
+ int iend = 4;
+ if ( no34 ){
+ iend = 2;
+ }
+ // Now create the four walls
+ for ( ; i < iend; i++ ){
+ // Allocate new patch
+ NodeSmartReference node = NodeSmartReference( g_patchCreator->createPatch() );
+ // Insert each node into worldspawn
+ Node_getTraversable( Map_FindOrInsertWorldspawn( g_map ) )->insert( node );
+
+ // Retrieve the contained patch from the node
+ Patch* wallPatch = Node_getPatch( node );
+
+ // Create the wall patch by passing i as wallIndex
+ wallPatch->createThickenedWall( patch, *targetPatch, i );
+
+ if( ( wallPatch->localAABB().extents[0] <= 0.00005 && wallPatch->localAABB().extents[1] <= 0.00005 ) ||
+ ( wallPatch->localAABB().extents[1] <= 0.00005 && wallPatch->localAABB().extents[2] <= 0.00005 ) ||
+ ( wallPatch->localAABB().extents[0] <= 0.00005 && wallPatch->localAABB().extents[2] <= 0.00005 ) ){
+ //globalOutputStream() << "Thicken: Discarding degenerate patch.\n";
+ Node_getTraversable( Map_FindOrInsertWorldspawn( g_map ) )->erase( node );
+ }
+ else
+ // Now select the newly created patches
+ {
+ scene::Path patchpath( makeReference( GlobalSceneGraph().root() ) );
+ patchpath.push( makeReference( *Map_GetWorldspawn(g_map) ) );
+ patchpath.push( makeReference( node.get() ) );
+ Instance_getSelectable( *GlobalSceneGraph().find( patchpath ) )->setSelected( true );
+ }
+ }
+ }
+
+ // Invert the target patch so that it faces the opposite direction
+ targetPatch->InvertMatrix();
+}
+
+void Scene_PatchThicken( scene::Graph& graph, const int thickness, bool seams, const int axis )
+{
+ InstanceVector instances;
+ Scene_forEachVisibleSelectedPatchInstance( PatchStoreInstance( instances ) );
+ for ( InstanceVector::const_iterator i = instances.begin(); i != instances.end(); ++i )
+ {
+ Patch_thicken( *Node_getPatch( ( *i )->path().top() ), *( *i ), thickness, seams, axis );
+ }
+
+}
+
Patch* Scene_GetUltimateSelectedVisiblePatch(){
if ( GlobalSelectionSystem().countSelected() != 0 ) {
scene::Node& node = GlobalSelectionSystem().ultimateSelected().path().top();
}
};
+namespace{
+bool DoingSearch( const char *repl ){
+ return ( repl == NULL || ( strcmp( "textures/", repl ) == 0 ) );
+}
+}
void Scene_PatchFindReplaceShader( scene::Graph& graph, const char* find, const char* replace ){
- Scene_forEachVisiblePatch( PatchFindReplaceShader( find, replace ) );
+ if( DoingSearch( replace ) ){
+ Scene_forEachVisiblePatchInstance( PatchSelectByShader( find ) );
+ }
+ else{
+ Scene_forEachVisiblePatch( PatchFindReplaceShader( find, replace ) );
+ }
}
void Scene_PatchFindReplaceShader_Selected( scene::Graph& graph, const char* find, const char* replace ){
- Scene_forEachVisibleSelectedPatch( PatchFindReplaceShader( find, replace ) );
+ if( DoingSearch( replace ) ){
+ //do nothing, because alternative is replacing to notex
+ //perhaps deselect ones with not matching shaders here?
+ }
+ else{
+ Scene_forEachVisibleSelectedPatch( PatchFindReplaceShader( find, replace ) );
+ }
}
Scene_PatchNaturalTexture_Selected( GlobalSceneGraph() );
}
+void Patch_CapTexture(){
+ UndoableCommand command( "patchCapTexture" );
+ Scene_PatchCapTexture_Selected( GlobalSceneGraph() );
+}
+
+void Patch_ResetTexture(){
+ float fx, fy;
+ if ( DoTextureLayout( &fx, &fy ) == eIDOK ) {
+ UndoableCommand command( "patchTileTexture" );
+ Scene_PatchTileTexture_Selected( GlobalSceneGraph(), fx, fy );
+ }
+}
+
+void Patch_FitTexture(){
+ UndoableCommand command( "patchFitTexture" );
+ Scene_PatchTileTexture_Selected( GlobalSceneGraph(), 1, 1 );
+}
+
+void DoPatchDeformDlg();
+
+void Patch_Deform(){
+ UndoableCommand undo( "patchDeform" );
+
+ DoPatchDeformDlg();
+}
+
+void DoPatchThickenDlg();
+
+void Patch_Thicken(){
+ UndoableCommand undo( "patchThicken" );
+
+ DoPatchThickenDlg();
+}
filter_patch_all g_filter_patch_all;
-filter_patch_shader g_filter_patch_clip( "textures/common/clip" );
+filter_patch_flags g_filter_patch_clip( QER_CLIP );
+filter_patch_shader g_filter_patch_commonclip( "textures/common/clip" );
filter_patch_shader g_filter_patch_weapclip( "textures/common/weapclip" );
-filter_patch_flags g_filter_patch_translucent( QER_TRANS );
+filter_patch_flags g_filter_patch_translucent( QER_TRANS | QER_ALPHATEST );
void PatchFilters_construct(){
add_patch_filter( g_filter_patch_all, EXCLUDE_CURVES );
add_patch_filter( g_filter_patch_clip, EXCLUDE_CLIP );
+ add_patch_filter( g_filter_patch_commonclip, EXCLUDE_CLIP );
add_patch_filter( g_filter_patch_weapclip, EXCLUDE_CLIP );
add_patch_filter( g_filter_patch_translucent, EXCLUDE_TRANSLUCENT );
}
void Patch_registerCommands(){
GlobalCommands_insert( "InvertCurveTextureX", FreeCaller<Patch_FlipTextureX>(), Accelerator( 'I', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
GlobalCommands_insert( "InvertCurveTextureY", FreeCaller<Patch_FlipTextureY>(), Accelerator( 'I', (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "IncPatchColumn", FreeCaller<Patch_InsertInsertColumn>(), Accelerator( GDK_KP_Add, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
- GlobalCommands_insert( "IncPatchRow", FreeCaller<Patch_InsertInsertRow>(), Accelerator( GDK_KP_Add, (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "DecPatchColumn", FreeCaller<Patch_DeleteLastColumn>(), Accelerator( GDK_KP_Subtract, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
- GlobalCommands_insert( "DecPatchRow", FreeCaller<Patch_DeleteLastRow>(), Accelerator( GDK_KP_Subtract, (GdkModifierType)GDK_CONTROL_MASK ) );
GlobalCommands_insert( "NaturalizePatch", FreeCaller<Patch_NaturalTexture>(), Accelerator( 'N', (GdkModifierType)GDK_CONTROL_MASK ) );
GlobalCommands_insert( "PatchCylinder", FreeCaller<Patch_Cylinder>() );
GlobalCommands_insert( "PatchDenseCylinder", FreeCaller<Patch_DenseCylinder>() );
GlobalCommands_insert( "PatchCone", FreeCaller<Patch_Cone>() );
GlobalCommands_insert( "PatchSphere", FreeCaller<Patch_Sphere>() );
GlobalCommands_insert( "SimplePatchMesh", FreeCaller<Patch_Plane>(), Accelerator( 'P', (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "PatchInsertInsertColumn", FreeCaller<Patch_InsertInsertColumn>() );
+ GlobalCommands_insert( "PatchInsertInsertColumn", FreeCaller<Patch_InsertInsertColumn>(), Accelerator( GDK_KP_Add, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
GlobalCommands_insert( "PatchInsertAddColumn", FreeCaller<Patch_InsertAddColumn>() );
- GlobalCommands_insert( "PatchInsertInsertRow", FreeCaller<Patch_InsertInsertRow>() );
+ GlobalCommands_insert( "PatchInsertInsertRow", FreeCaller<Patch_InsertInsertRow>(), Accelerator( GDK_KP_Add, (GdkModifierType)GDK_CONTROL_MASK ) );
GlobalCommands_insert( "PatchInsertAddRow", FreeCaller<Patch_InsertAddRow>() );
GlobalCommands_insert( "PatchDeleteFirstColumn", FreeCaller<Patch_DeleteFirstColumn>() );
- GlobalCommands_insert( "PatchDeleteLastColumn", FreeCaller<Patch_DeleteLastColumn>() );
+ GlobalCommands_insert( "PatchDeleteLastColumn", FreeCaller<Patch_DeleteLastColumn>(), Accelerator( GDK_KP_Subtract, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
GlobalCommands_insert( "PatchDeleteFirstRow", FreeCaller<Patch_DeleteFirstRow>() );
- GlobalCommands_insert( "PatchDeleteLastRow", FreeCaller<Patch_DeleteLastRow>() );
+ GlobalCommands_insert( "PatchDeleteLastRow", FreeCaller<Patch_DeleteLastRow>(), Accelerator( GDK_KP_Subtract, (GdkModifierType)GDK_CONTROL_MASK ) );
GlobalCommands_insert( "InvertCurve", FreeCaller<Patch_Invert>(), Accelerator( 'I', (GdkModifierType)GDK_CONTROL_MASK ) );
GlobalCommands_insert( "RedisperseRows", FreeCaller<Patch_RedisperseRows>(), Accelerator( 'E', (GdkModifierType)GDK_CONTROL_MASK ) );
GlobalCommands_insert( "RedisperseCols", FreeCaller<Patch_RedisperseCols>(), Accelerator( 'E', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
GlobalCommands_insert( "SmoothCols", FreeCaller<Patch_SmoothCols>(), Accelerator( 'W', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
GlobalCommands_insert( "MatrixTranspose", FreeCaller<Patch_Transpose>(), Accelerator( 'M', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
GlobalCommands_insert( "CapCurrentCurve", FreeCaller<Patch_Cap>(), Accelerator( 'C', (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "CycleCapTexturePatch", FreeCaller<Patch_CycleProjection>(), Accelerator( 'N', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
+ GlobalCommands_insert( "CycleCapTexturePatch", FreeCaller<Patch_CycleProjection>(), Accelerator( 'N', (GdkModifierType)GDK_SHIFT_MASK ) );
GlobalCommands_insert( "MakeOverlayPatch", FreeCaller<Patch_OverlayOn>(), Accelerator( 'Y' ) );
GlobalCommands_insert( "ClearPatchOverlays", FreeCaller<Patch_OverlayOff>(), Accelerator( 'L', (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "PatchDeform", FreeCaller<Patch_Deform>() );
+ GlobalCommands_insert( "PatchThicken", FreeCaller<Patch_Thicken>() );
}
void Patch_constructToolbar( GtkToolbar* toolbar ){
- toolbar_append_button( toolbar, "Put caps on the current patch (SHIFT + C)", "curve_cap.bmp", "CapCurrentCurve" );
+ toolbar_append_button( toolbar, "Put caps on the current patch (SHIFT + C)", "curve_cap.png", "CapCurrentCurve" );
}
void Patch_constructMenu( GtkMenu* menu ){
create_menu_item_with_mnemonic( menu, "End cap", "PatchEndCap" );
create_menu_item_with_mnemonic( menu, "Bevel", "PatchBevel" );
{
- GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "More End caps, Bevels" );
- if ( g_Layout_enableDetachableMenus.m_value ) {
- menu_tearoff( menu_in_menu );
- }
- create_menu_item_with_mnemonic( menu_in_menu, "Square Endcap", "PatchSquareBevel" );
- create_menu_item_with_mnemonic( menu_in_menu, "Square Bevel", "PatchSquareEndcap" );
+// GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "More End caps, Bevels" );
+// if ( g_Layout_enableDetachableMenus.m_value ) {
+// menu_tearoff( menu_in_menu );
+// }
+ create_menu_item_with_mnemonic( menu, "Square Endcap", "PatchSquareBevel" );
+ create_menu_item_with_mnemonic( menu, "Square Bevel", "PatchSquareEndcap" );
}
menu_separator( menu );
create_menu_item_with_mnemonic( menu, "Cone", "PatchCone" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
- create_menu_item_with_mnemonic( menu_in_menu, "Insert (2) Columns", "PatchInsertInsertColumn" );
create_menu_item_with_mnemonic( menu_in_menu, "Add (2) Columns", "PatchInsertAddColumn" );
+ create_menu_item_with_mnemonic( menu_in_menu, "Insert (2) Columns", "PatchInsertInsertColumn" );
menu_separator( menu_in_menu );
- create_menu_item_with_mnemonic( menu_in_menu, "Insert (2) Rows", "PatchInsertInsertRow" );
create_menu_item_with_mnemonic( menu_in_menu, "Add (2) Rows", "PatchInsertAddRow" );
+ create_menu_item_with_mnemonic( menu_in_menu, "Insert (2) Rows", "PatchInsertInsertRow" );
}
{
GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Delete" );
menu_tearoff( menu_in_menu );
}
create_menu_item_with_mnemonic( menu_in_menu, "Invert", "InvertCurve" );
- GtkMenu* menu_3 = create_sub_menu_with_mnemonic( menu_in_menu, "Re-disperse" );
- if ( g_Layout_enableDetachableMenus.m_value ) {
- menu_tearoff( menu_3 );
- }
- create_menu_item_with_mnemonic( menu_3, "Rows", "RedisperseRows" );
- create_menu_item_with_mnemonic( menu_3, "Columns", "RedisperseCols" );
- GtkMenu* menu_4 = create_sub_menu_with_mnemonic( menu_in_menu, "Smooth" );
- if ( g_Layout_enableDetachableMenus.m_value ) {
- menu_tearoff( menu_4 );
- }
- create_menu_item_with_mnemonic( menu_4, "Rows", "SmoothRows" );
- create_menu_item_with_mnemonic( menu_4, "Columns", "SmoothCols" );
create_menu_item_with_mnemonic( menu_in_menu, "Transpose", "MatrixTranspose" );
+// GtkMenu* menu_3 = create_sub_menu_with_mnemonic( menu_in_menu, "Re-disperse" );
+// if ( g_Layout_enableDetachableMenus.m_value ) {
+// menu_tearoff( menu_3 );
+// }
+ menu_separator( menu_in_menu );
+ create_menu_item_with_mnemonic( menu_in_menu, "Re-disperse Rows", "RedisperseRows" );
+ create_menu_item_with_mnemonic( menu_in_menu, "Re-disperse Columns", "RedisperseCols" );
+// GtkMenu* menu_4 = create_sub_menu_with_mnemonic( menu_in_menu, "Smooth" );
+// if ( g_Layout_enableDetachableMenus.m_value ) {
+// menu_tearoff( menu_4 );
+// }
+ menu_separator( menu_in_menu );
+ create_menu_item_with_mnemonic( menu_in_menu, "Smooth Rows", "SmoothRows" );
+ create_menu_item_with_mnemonic( menu_in_menu, "Smooth Columns", "SmoothCols" );
}
menu_separator( menu );
create_menu_item_with_mnemonic( menu, "Cap Selection", "CapCurrentCurve" );
- create_menu_item_with_mnemonic( menu, "Cycle Cap Texture", "CycleCapTexturePatch" );
+ menu_separator( menu );
+ {
+ GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Texture" );
+ if ( g_Layout_enableDetachableMenus.m_value ) {
+ menu_tearoff( menu_in_menu );
+ }
+ create_menu_item_with_mnemonic( menu_in_menu, "Cycle Projection", "CycleCapTexturePatch" );
+ create_menu_item_with_mnemonic( menu_in_menu, "Naturalize", "NaturalizePatch" );
+ create_menu_item_with_mnemonic( menu_in_menu, "Invert X", "InvertCurveTextureX" );
+ create_menu_item_with_mnemonic( menu_in_menu, "Invert Y", "InvertCurveTextureY" );
+
+ }
menu_separator( menu );
{
GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Overlay" );
create_menu_item_with_mnemonic( menu_in_menu, "Set", "MakeOverlayPatch" );
create_menu_item_with_mnemonic( menu_in_menu, "Clear", "ClearPatchOverlays" );
}
+ menu_separator( menu );
+ create_menu_item_with_mnemonic( menu, "Deform...", "PatchDeform" );
+ create_menu_item_with_mnemonic( menu, "Thicken...", "PatchThicken" );
}
}
+void DoPatchDeformDlg(){
+ ModalDialog dialog;
+ GtkWidget* deformW;
+
+ GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Patch deform", G_CALLBACK( dialog_delete_callback ), &dialog );
+
+ GtkAccelGroup* accel = gtk_accel_group_new();
+ gtk_window_add_accel_group( window, accel );
+
+ {
+ GtkHBox* hbox = create_dialog_hbox( 4, 4 );
+ gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) );
+ {
+ GtkTable* table = create_dialog_table( 2, 2, 4, 4 );
+ gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
+ {
+ GtkLabel* label = GTK_LABEL( gtk_label_new( "Max deform:" ) );
+ gtk_widget_show( GTK_WIDGET( label ) );
+ gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1,
+ (GtkAttachOptions) ( GTK_FILL ),
+ (GtkAttachOptions) ( 0 ), 0, 0 );
+ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
+ }
+ {
+ GtkWidget* entry = gtk_entry_new();
+ gtk_entry_set_text( GTK_ENTRY( entry ), "16" );
+ gtk_widget_show( entry );
+ gtk_table_attach( table, entry, 1, 2, 0, 1,
+ (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
+ (GtkAttachOptions) ( 0 ), 0, 0 );
+
+ deformW = entry;
+ }
+ }
+ {
+ GtkVBox* vbox = create_dialog_vbox( 4 );
+ gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 );
+ {
+ GtkButton* button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog );
+ gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ widget_make_default( GTK_WIDGET( button ) );
+ gtk_widget_grab_focus( GTK_WIDGET( button ) );
+ gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
+ }
+ {
+ GtkButton* button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &dialog );
+ gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
+ }
+ }
+ }
+
+ if ( modal_dialog_show( window, dialog ) == eIDOK ) {
+ int deform = static_cast<int>( atoi( gtk_entry_get_text( GTK_ENTRY( deformW ) ) ) );
+ Scene_PatchDeform( GlobalSceneGraph(), deform );
+ }
+
+ gtk_widget_destroy( GTK_WIDGET( window ) );
+}
+
EMessageBoxReturn DoCapDlg( ECapDialog* type ){
gtk_table_set_col_spacings( table, 5 );
{
- GtkImage* image = new_local_image( "cap_bevel.bmp" );
+ GtkImage* image = new_local_image( "cap_bevel.png" );
gtk_widget_show( GTK_WIDGET( image ) );
gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 0, 1,
(GtkAttachOptions) ( GTK_FILL ),
(GtkAttachOptions) ( 0 ), 0, 0 );
}
{
- GtkImage* image = new_local_image( "cap_endcap.bmp" );
+ GtkImage* image = new_local_image( "cap_endcap.png" );
gtk_widget_show( GTK_WIDGET( image ) );
gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 1, 2,
(GtkAttachOptions) ( GTK_FILL ),
(GtkAttachOptions) ( 0 ), 0, 0 );
}
{
- GtkImage* image = new_local_image( "cap_ibevel.bmp" );
+ GtkImage* image = new_local_image( "cap_ibevel.png" );
gtk_widget_show( GTK_WIDGET( image ) );
gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 2, 3,
(GtkAttachOptions) ( GTK_FILL ),
(GtkAttachOptions) ( 0 ), 0, 0 );
}
{
- GtkImage* image = new_local_image( "cap_iendcap.bmp" );
+ GtkImage* image = new_local_image( "cap_iendcap.png" );
gtk_widget_show( GTK_WIDGET( image ) );
gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 3, 4,
(GtkAttachOptions) ( GTK_FILL ),
(GtkAttachOptions) ( 0 ), 0, 0 );
}
{
- GtkImage* image = new_local_image( "cap_cylinder.bmp" );
+ GtkImage* image = new_local_image( "cap_cylinder.png" );
gtk_widget_show( GTK_WIDGET( image ) );
gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 4, 5,
(GtkAttachOptions) ( GTK_FILL ),
return ret;
}
+
+
+void DoPatchThickenDlg(){
+ ModalDialog dialog;
+ GtkWidget* thicknessW;
+ GtkWidget* seamsW;
+ GtkWidget* radX;
+ GtkWidget* radY;
+ GtkWidget* radZ;
+ GtkWidget* radNormals;
+
+ GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Patch thicken", G_CALLBACK( dialog_delete_callback ), &dialog );
+
+ GtkAccelGroup* accel = gtk_accel_group_new();
+ gtk_window_add_accel_group( window, accel );
+
+ {
+ GtkHBox* hbox = create_dialog_hbox( 4, 4 );
+ gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) );
+ {
+ GtkTable* table = create_dialog_table( 2, 4, 4, 4 );
+ gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
+ {
+ GtkLabel* label = GTK_LABEL( gtk_label_new( "Thickness:" ) );
+ gtk_widget_show( GTK_WIDGET( label ) );
+ gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1,
+ (GtkAttachOptions) ( GTK_FILL ),
+ (GtkAttachOptions) ( 0 ), 0, 0 );
+ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
+ }
+ {
+ GtkWidget* entry = gtk_entry_new();
+ gtk_entry_set_text( GTK_ENTRY( entry ), "16" );
+ gtk_widget_set_size_request( entry, 40, -1 );
+ gtk_widget_show( entry );
+ gtk_table_attach( table, entry, 1, 2, 0, 1,
+ (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
+ (GtkAttachOptions) ( 0 ), 0, 0 );
+
+ thicknessW = entry;
+ }
+ {
+ // Create the "create seams" label
+ GtkWidget* _seamsCheckBox = gtk_check_button_new_with_label( "Side walls" );
+ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( _seamsCheckBox ), TRUE );
+ gtk_widget_show( _seamsCheckBox );
+ gtk_table_attach( table, _seamsCheckBox, 3, 4, 0, 1,
+ (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
+ (GtkAttachOptions) ( 0 ), 0, 0 );
+ seamsW = _seamsCheckBox;
+
+ }
+ {
+ // Create the radio button group for choosing the extrude axis
+ GtkWidget* _radNormals = gtk_radio_button_new_with_label( NULL, "Normal" );
+ GtkWidget* _radX = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(_radNormals), "X" );
+ GtkWidget* _radY = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(_radNormals), "Y" );
+ GtkWidget* _radZ = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(_radNormals), "Z" );
+ gtk_widget_show( _radNormals );
+ gtk_widget_show( _radX );
+ gtk_widget_show( _radY );
+ gtk_widget_show( _radZ );
+
+
+ // Pack the buttons into the table
+ gtk_table_attach( table, _radNormals, 0, 1, 1, 2,
+ (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
+ (GtkAttachOptions) ( 0 ), 0, 0 );
+ gtk_table_attach( table, _radX, 1, 2, 1, 2,
+ (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
+ (GtkAttachOptions) ( 0 ), 0, 0 );
+ gtk_table_attach( table, _radY, 2, 3, 1, 2,
+ (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
+ (GtkAttachOptions) ( 0 ), 0, 0 );
+ gtk_table_attach( table, _radZ, 3, 4, 1, 2,
+ (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
+ (GtkAttachOptions) ( 0 ), 0, 0 );
+ radX = _radX;
+ radY = _radY;
+ radZ = _radZ;
+ radNormals = _radNormals;
+ }
+ }
+ {
+ GtkVBox* vbox = create_dialog_vbox( 4 );
+ gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 );
+ {
+ GtkButton* button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog );
+ gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ widget_make_default( GTK_WIDGET( button ) );
+ gtk_widget_grab_focus( GTK_WIDGET( button ) );
+ gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
+ }
+ {
+ GtkButton* button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &dialog );
+ gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
+ }
+ }
+ }
+
+ if ( modal_dialog_show( window, dialog ) == eIDOK ) {
+ int axis;
+ bool seams;
+ float thickness = static_cast<float>( atoi( gtk_entry_get_text( GTK_ENTRY( thicknessW ) ) ) );
+ seams = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( seamsW )) ? true : false;
+
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radX))) {
+ axis = 0;
+ }
+ else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radY))) {
+ axis = 1;
+ }
+ else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radZ))) {
+ axis = 2;
+ }
+ else {
+ // Extrude along normals
+ axis = 3;
+ }
+ Scene_PatchThicken( GlobalSceneGraph(), thickness, seams, axis );
+ }
+
+ gtk_widget_destroy( GTK_WIDGET( window ) );
+}