|
||
|
|
|
The following example shows how to make use of the undo and redo system. It organizes the construction of the SilverScreen castle drawing into sections, then allows the user to undo and redo its construction. Note that SilverScreen commands, for instance begin polygon, record the necessary undo/redo state information automatically when the undo system is initialized and the commands are nested within an undo_begin/undo_end pair. Note too that you may group multiple commands together into a single logical unit by carefully nesting the undo_begin and undo_end pairs.
|
|
#include "silver.h"
static void refresh_and_message(const char *message);
static void refresh_the_castle();
void main(void)
{
char buffer[512];
char big_string[1023];
ss_command("clear");
ss_command("paint background color black");
undo_initialize(0);
cv_set(CV_REFRESH, 0);
// Make the walls
panel_message("Make the castle walls");
undo_begin();
ss_command("create object temp1");
ss_command("pen color brown");
ss_command("begin polygon");
ss_command("point 0,0,0");
ss_command("point 0,0,-20");
ss_command("point 30,0,-20");
ss_command("point 30,0,0");
ss_command("end");
ss_command("view select isometric front right top");
ss_command("zoom drawing");
ss_command("begin polygon");
ss_command("point 0.5,0,-0.5");
ss_command("point 0.5,0,-19.5");
ss_command("point 29.5,0,-19.5");
ss_command("point 29.5,0,-0.5");
ss_command("end");
ss_command("sweep linear object \\temp1 points 29.5,0,-19.5 29.5,8,-19.5 scale angles name wall");
ss_command("zoom drawing");
ss_command("zoom magnify .9");
ss_command("surface object \\wall fill-color light-gray");
undo_set_description("Make the castle walls");
undo_end();
// Make the turrets
refresh_and_message("Build the turrets");
undo_begin();
ss_command("create object circle");
ss_command("at (0,0,0)");
ss_command("pen color yellow");
ss_command("draw circle radius 2.000,0.000,0.000 normal 0.000,1.000,0.000");
ss_command("display refine circle sweep 12");
ss_command("sweep linear object \\circle points 0,0,0 0,10.25,0 scale angles name top");
ss_command("surface object \\top fill-color gray");
ss_command("copy object \\top single x30");
ss_command("solid trim object \\wall object \\top");
ss_command("solid trim object \\wall1 object \\top1");
ss_command("pen color light-gray");
ss_command("create object form");
ss_command("begin polygon");
ss_command("point 2,10.25,0");
ss_command("point 2.75,12,0");
ss_command("point 2.75,13.5,0");
ss_command("point 2,13.5,0");
ss_command("point 2,12,0");
ss_command("point 1.25,10.25,0");
ss_command("end");
ss_command("sweep solid circular object \\form axis 0,10.5,0 0,13.5,0 angle 360 faces 12 horizontal 11 vertical 9 name tur1");
ss_command("surface object \\tur1 fill-color gray");
ss_command("zoom object \\tur1");
ss_command("create object cutter");
ss_command("pen color white");
ss_command("draw rectangle -0.5,12.75,3.5 0.5,14,3.5");
ss_command("sweep linear object \\cutter points 0.5,14,3.5 0.5,14,-3.5 scale angles name cutb1");
ss_command("surface object \\cutb1 fill-color light-cyan");
ss_command("copy object \\cutb1 radial angle 360 copies 3 axis 0,14.5,0 0,12.25,0");
ss_command("solid difference object \\tur1 object \\cutb1");
ss_command("solid difference object \\tur2 object \\cutb2");
ss_command("solid difference object \\tur3 object \\cutb3");
ss_command("newname object \\tur4 name turret1");
ss_command("hide drawing quick fill edged 0");
ss_command("zoom drawing");
ss_command("copy object \\turret1 single x30");
ss_command("create block at-root walls");
ss_command("relocate object \\turret1 to \\walls");
ss_command("relocate object \\turret2 to \\walls");
ss_command("relocate object \\wall2 to \\walls");
ss_command("relocate object \\wall3 to \\walls");
ss_command("relocate object \\top to \\walls");
ss_command("relocate object \\top1 to \\walls");
ss_command("goto root");
undo_set_description("Build the turrets");
undo_end();
// Put an entrance in the wall
refresh_and_message("Add an entrance to the castle wall");
undo_begin();
ss_command("display refine circle sweep 20");
ss_command("create object tmp22");
ss_command("pen color light-cyan");
ss_command("draw rectangle 13,4,1 17,-6,1");
ss_command("fillet polygon \\tmp22.1 insert line 4 line 5 radius 1/2");
ss_command("fillet polygon \\tmp22.1 insert line 2 line 5 radius 1/2");
ss_command("sweep linear object \\tmp22 points 17,-6,1 17,-6,-4 scale angles name cutter");
ss_command("surface object \\cutter fill-color light-gray");
ss_command("solid difference object \\walls\\wall2 object \\cutter");
ss_command("display refine circle sweep 16");
undo_set_description("Add an entrance to the castle wall");
undo_end();
// Make the right-hand tower
refresh_and_message("Create a watch tower");
undo_begin();
ss_command("goto root");
ss_command("pen color light-cyan");
ss_command("create object base");
ss_command("begin polygon");
ss_command("point 29.5,0,-19.5");
ss_command("point 29.5,0,-13");
ss_command("point 23,0,-13");
ss_command("point 23,0,-19.5");
ss_command("end");
ss_command("sweep linear object \\base points 23,0,-13 23,14.75,-13 scale angles name lower");
ss_command("surface object \\lower fill-color light-gray");
ss_command("create object polyx");
ss_command("begin polygon");
ss_command("point 21.5,18.75,-11.5");
ss_command("point 21.5,18.75,-21");
ss_command("point 31,18.75,-21");
ss_command("point 31,18.75,-11.5");
ss_command("end");
ss_command("sweep join polygon \\polyx.1 polygon \\lower.6 name mid");
ss_command("surface object \\mid fill-color light-gray");
ss_command("zoom object \\mid");
ss_command("zoom magnify 3/4");
ss_command("display refine circle sweep 20");
ss_command("create object kut");
ss_command("pen color light-gray");
ss_command("draw rectangle 24.25,14.25,-10.5 28.25,17.75,-10.5");
ss_command("fillet polygon \\kut.1 insert line 2 line 3 radius 1");
ss_command("fillet polygon \\kut.1 insert line 3 line 4 radius 1");
ss_command("sweep linear object \\kut points 28.25,17.75,-10.5 28.25,17.75,-22 scale angles name kutt1");
ss_command("surface object \\kutt1 fill-color light-cyan");
ss_command("display refine circle sweep 16");
ss_command("copy object \\kutt1 radial angle 90 copies 2 axis 26.25,21.5,-16.25 26.25,19.5,-16.25");
ss_command("surface object \\mid fill-color gray");
ss_command("solid difference object \\mid object \\kutt1");
ss_command("solid difference object \\mid1 object \\kutt2");
ss_command("hide drawing quick fill edged 0");
ss_command("at (26.25,18.75,-16.25)");
ss_command("create object circle7");
ss_command("draw circle radius 2.5,0.000,0.000 normal 0.000,1.000,0.000");
ss_command("sweep linear object \\circle7 points 26.25,18.75,-16.25 26.25,22,-16.25 scale angles name ltower");
ss_command("surface object \\ltower fill-color cyan");
ss_command("zoom object \\ltower");
ss_command("zoom magnify 1/2");
ss_command("create object circle8");
ss_command("at (26.25,22,-16.25)");
ss_command("draw circle radius 3,0,0 normal 0.000,1.000,0.000");
ss_command("sweep linear object \\circle8 points 26.25,22,-16.25 26.25,25,-16.25 scale angles name utower");
ss_command("surface object \\utower fill-color light-gray");
ss_command("create object aline");
ss_command("pen color cyan");
ss_command("draw line 22.25,25,-16.25 26.25,27,-16.25");
ss_command("sweep solid circular object \\aline axis 26.25,27,-16.25 26.25,25.75,-16.25 angle faces 12 horizontal 3 vertical 3 name roofie");
ss_command("surface object \\roofie fill-color gray");
ss_command("hide drawing quick fill edged 0");
undo_set_description("Create a watch tower");
undo_end();
// Build three floors
refresh_and_message("Build 3 floors of the main castle");
undo_begin();
ss_command("zoom block \\walls");
ss_command("goto root");
ss_command("create object temp1");
ss_command("pen color light-gray");
ss_command("begin polygon");
ss_command("point 0.5,0,-19.5");
ss_command("point 16,0,-19.5");
ss_command("point 16,0,-14");
ss_command("point 11,0,-14");
ss_command("point 11,0,-6.25");
ss_command("point 0.5,0,-6.25");
ss_command("end");
ss_command("begin polygon");
ss_command("point 1,0,-6.75");
ss_command("point 1,0,-19");
ss_command("point 15.25,0,-19");
ss_command("point 15.25,0,-14.5");
ss_command("point 10.5,0,-14.5");
ss_command("point 10.5,0,-6.75");
ss_command("end");
ss_command("sweep linear object \\temp1 points 0.5,0,-6.25 0.5,5.5,-6.25 scale angles name first");
ss_command("surface object \\first fill-color cyan");
ss_command("pen color cyan");
ss_command("create object temp1");
ss_command("begin polygon");
ss_command("point 0.5,5.5,-19.5");
ss_command("point 16,5.5,-19.5");
ss_command("point 16,5.5,-14");
ss_command("point 11,5.5,-14");
ss_command("point 11,5.5,-6.25");
ss_command("point 0.5,5.5,-6.25");
ss_command("end");
ss_command("sweep linear polygon \\temp1.1 points 0.5,5.5,-6.25 0.5,6,-6.25 scale angles name ceil1");
ss_command("surface object \\ceil1 fill-color gray");
ss_command("copy object \\first single y6");
ss_command("newname object \\first1 name second");
ss_command("copy object \\ceil1 single y6");
ss_command("pen color light-gray");
ss_command("create object temp1");
ss_command("begin polygon");
ss_command("point 0.5,12,-19.5");
ss_command("point 0.5,12,-6.25");
ss_command("point 11,12,-6.25");
ss_command("point 11,12,-19.5");
ss_command("end");
ss_command("begin polygon");
ss_command("point 10.5,12,-19");
ss_command("point 10.5,12,-6.75");
ss_command("point 1,12,-6.75");
ss_command("point 1,12,-19");
ss_command("end");
ss_command("sweep linear object \\temp1 points 8.75,6,-6.75 8.75,11.5,-6.75 scale angles name third");
ss_command("surface object \\third fill-color cyan");
ss_command("zoom object \\third");
ss_command("zoom magnify 2/3");
undo_set_description("Build 3 floors of the main castle");
undo_end();
// Construct the dormer
refresh_and_message("Build the castle roof");
undo_begin();
ss_command("create object temp1");
ss_command("pen color gray");
ss_command("begin polygon");
ss_command("point 0.5,17.5,-6.25");
ss_command("point 11,17.5,-6.25");
ss_command("point 5.75,27.75,-6.25");
ss_command("end");
ss_command("sweep linear polygon \\temp1.1 points 5.75,27.75,-6.25 5.75,27.75,-19.5 scale angles name roofa");
ss_command("isolate object \\roofa");
ss_command("zoom visible");
ss_command("create object temp1");
ss_command("pen color light-gray");
ss_command("begin polygon");
ss_command("point 10.75,18.25,-8.5");
ss_command("point 10.75,20.25,-8.5");
ss_command("point 10.75,20.25,-8.25");
ss_command("point 10.75,21.75,-9.75");
ss_command("point 10.75,20.25,-11.25");
ss_command("point 10.75,20.25,-11");
ss_command("point 10.75,18.25,-11");
ss_command("end");
ss_command("begin polygon");
ss_command("point 10.75,20,-9");
ss_command("point 10.75,18.5,-9");
ss_command("point 10.75,18.5,-10.5");
ss_command("point 10.75,20,-10.5");
ss_command("end");
ss_command("sweep linear object \\temp1 points 10.75,18.5,-10.5 5,18.5,-10.5 scale angles name gable1");
ss_command("copy object \\gable1 single z-6.25");
ss_command("solid trim object \\gable1 object \\roofa");
ss_command("solid trim object \\gable2 object \\roofa");
ss_command("isolate reset");
ss_command("hide drawing quick fill edged 0");
undo_set_description("Build the castle roof");
undo_end();
// Punch windows and doors in the 3 floors
refresh_and_message("Add windows and doors to the main castle building");
undo_begin();
ss_command("isolate object \\first");
ss_command("zoom object \\first");
ss_command("display refine circle sweep 20");
ss_command("create object xyz");
ss_command("pen color blue");
ss_command("draw rectangle 14.5,4.75,-13 11.75,-1,-13");
ss_command("fillet polygon \\xyz.1 insert line 4 line 5 radius 1");
ss_command("fillet polygon \\xyz.1 insert line 2 line 5 radius 1");
ss_command("sweep linear object \\xyz points 11.75,-1,-13 11.75,-1,-15.75 scale angles name doorcut");
ss_command("solid difference object \\first object \\doorcut");
ss_command("create object tempx");
ss_command("begin polygon");
ss_command("point 16.75,-0.75,-15.25");
ss_command("point 16.75,4.75,-15.25");
ss_command("point 16.75,4.75,-18.25");
ss_command("point 16.75,-0.75,-18.25");
ss_command("end");
ss_command("fillet polygon \\tempx.1 insert line 2 line 3 radius 1");
ss_command("fillet polygon \\tempx.1 insert line 3 line 4 radius 1");
ss_command("sweep linear object \\tempx points 16.75,4.75,-18.25 13.75,4.75,-18.25 scale angles name tempcut");
ss_command("surface object \\tempcut fill-color blue");
ss_command("solid difference object \\first1 object \\tempcut");
ss_command("isolate reset");
ss_command("zoom drawing");
ss_command("zoom area (0.27,0.70 0.65,0.32)");
ss_command("display refine circle sweep 16");
ss_command("pen color white");
ss_command("create object tempy");
ss_command("draw rectangle 2.25,2.5,-5.5 3.25,1,-5.5");
ss_command("sweep linear object \\tempy points 2.25,1,-5.5 2.25,1,-8.5 scale angles name wcut1");
ss_command("surface object \\wcut1 fill-color light-cyan");
ss_command("copy object \\wcut1 matrix rows 3 delta y6 columns 3 delta x3");
ss_command("q-group begin ");
ss_command("q-group object \\wcut3");
ss_command("q-group object \\wcut2");
ss_command("q-group object \\wcut1");
ss_command("q-group end ");
ss_command("solid difference object \\first2 [q-group]");
ss_command("q-group begin ");
ss_command("q-group object \\wcut6");
ss_command("q-group object \\wcut5");
ss_command("q-group object \\wcut4");
ss_command("q-group end ");
ss_command("solid difference object \\second [q-group]");
ss_command("q-group begin ");
ss_command("q-group object \\wcut9");
ss_command("q-group object \\wcut8");
ss_command("q-group object \\wcut7");
ss_command("q-group end ");
ss_command("solid difference object \\third [q-group]");
ss_command("create object wcutb1");
ss_command("begin polygon");
ss_command("point 12.25,2.5,-8.5");
ss_command("point 12.25,1,-8.5");
ss_command("point 12.25,1,-9.5");
ss_command("point 12.25,2.5,-9.5");
ss_command("end");
ss_command("sweep linear object \\wcutb1 points 12.25,1,-9.5 9.25,1,-9.5 scale angles name wc1");
ss_command("surface object \\wc1 fill-color light-cyan");
ss_command("copy object \\wc1 matrix rows 3 delta y6 columns 2 delta z-2.75");
ss_command("q-group begin ");
ss_command("q-group object \\wc1");
ss_command("q-group object \\wc2");
ss_command("q-group end ");
ss_command("solid difference object \\first5 [q-group]");
ss_command("q-group begin ");
ss_command("q-group object \\wc3");
ss_command("q-group object \\wc4");
ss_command("q-group end ");
ss_command("solid difference object \\second3 [q-group]");
ss_command("q-group begin ");
ss_command("q-group object \\wc5");
ss_command("q-group object \\wc6");
ss_command("q-group end ");
ss_command("solid difference object \\third3 [q-group]");
ss_command("create object temp1");
ss_command("draw rectangle 12,8.5,-12.25 14.25,7,-12.25");
ss_command("sweep linear object \\temp1 points 14.25,7,-12.25 14.25,7,-21 scale angles name cut");
ss_command("surface object \\cut fill-color light-cyan");
ss_command("solid difference object \\second5 object \\cut");
undo_set_description("Add windows and doors to the main castle building");
undo_end();
// Work on the attic
refresh_and_message("Make an attic in the castle roof");
undo_begin();
ss_command("isolate object \\roofa");
ss_command("zoom object \\roofa");
ss_command("create object temp1");
ss_command("at (5.75,20.25,-5.5)");
ss_command("draw circle radius 1.500,0.000,0.000");
ss_command("pen color light-green");
ss_command("sweep linear object \\temp1 points 5.75,20.25,-5.5 5.75,20.25,-20.5 scale angles name hole");
ss_command("surface object \\hole fill-color light-cyan");
ss_command("solid difference object \\roofa object \\hole");
ss_command("hide drawing quick fill edged 0");
ss_command("create object temp1");
ss_command("begin polygon");
ss_command("point 1.25,18,-6.75");
ss_command("point 10.25,18,-6.75");
ss_command("point 5.75,26.75,-6.75");
ss_command("end");
ss_command("sweep linear object \\temp1 points 5.75,26.75,-6.75 5.75,26.75,-19 scale angles name inner");
ss_command("surface object \\inner fill-color light-green");
ss_command("solid difference object \\roofa1 object \\inner");
ss_command("hide drawing quick fill edged 0");
ss_command("isolate object \\roofa2");
ss_command("visibility enable object \\gable4");
ss_command("visibility enable object \\gable3");
ss_command("zoom visible");
ss_command("create object box");
ss_command("begin polygon");
ss_command("point 11.75,18.5,-9");
ss_command("point 11.75,20,-9");
ss_command("point 11.75,20,-10.5");
ss_command("point 11.75,18.5,-10.5");
ss_command("end");
ss_command("sweep linear object \\box points 11.75,20,-10.5 7.75,20,-10.5 scale angles name window");
ss_command("surface object \\window fill-color light-cyan");
ss_command("copy object \\window single z-6.25");
ss_command("solid difference object \\roofa2 object \\window");
ss_command("solid difference object \\roofa3 object \\window1");
ss_command("window split four-way drawing");
ss_command("zoom object \\roofa4");
ss_command("goto window 1");
ss_command("hide drawing quick fill edged 0");
ss_command("goto window 2");
ss_command("hide drawing quick fill edged 0");
ss_command("goto window 3");
ss_command("hide drawing quick fill edged 0");
ss_command("goto window 4");
ss_command("hide drawing quick fill edged 0");
ss_command("screen previous");
ss_command("zoom area (0.22,0.40) (0.42,0.17)");
ss_command("pen color yellow");
ss_command("create object tmp");
ss_command("draw rectangle 5.625,22,-6.375 5.875,18.25,-6.375");
ss_command("sweep linear object \\tmp points 5.875,18.25,-6.375 5.875,18.25,-6.625 scale angles name piece");
ss_command("copy object \\piece radial angle 360 copies 3 axis 5.75,20.25,-6.5 5.75,20.25,-7.5");
ss_command("solid trim object \\piece object \\roofa4");
ss_command("solid trim object \\piece1 object \\roofa4");
ss_command("solid trim object \\piece2 object \\roofa4");
ss_command("solid union object \\piece3 object \\piece4");
ss_command("solid union object \\piece5 object \\piece6");
ss_command("surface object \\piece7 fill-color yellow");
ss_command("hide drawing quick fill edged 0");
ss_command("zoom visible");
ss_command("copy object \\piece7 single z-12.75");
ss_command("isolate reset");
ss_command("hide drawing quick fill edged 0");
undo_set_description("Make an attic in the castle roof");
undo_end();
// Work on the extension roof
refresh_and_message("Build a roof for the extension");
undo_begin();
ss_command("zoom object \\third5");
ss_command("zoom magnify 2/3");
ss_command("pen color light-green");
ss_command("create object temp1");
ss_command("begin polygon");
ss_command("point 16,12,-14");
ss_command("point 16,12,-19.5");
ss_command("point 16,17.5,-16.75");
ss_command("end");
ss_command("sweep linear object \\temp1 points 16,17.5,-16.75 11,17.5,-16.75 scale angles name roofb");
ss_command("surface object \\roofb fill-color gray");
ss_command("copy object \\roofb single x-0.75y-0.75");
ss_command("surface object \\roofb1 fill-color light-cyan");
ss_command("solid difference object \\roofb object \\roofb1");
ss_command("pen color white");
ss_command("create object hole");
ss_command("at (16.75,13.25,-16.75)");
ss_command("draw equilateral edge 5 delta 0,-0.75,0 normal 1,0,0");
ss_command("pen color light-gray");
ss_command("sweep linear object \\hole points 16.75,13.25,-16.75 14.25,13.25,-16.75 scale angles name cutt");
ss_command("zoom object \\roofb2");
ss_command("isolate object \\roofb2");
ss_command("visibility enable object \\cutt");
ss_command("surface object \\cutt fill-color light-cyan");
ss_command("solid difference object \\roofb2 object \\cutt");
ss_command("pen color yellow");
ss_command("create object bar");
ss_command("begin polygon");
ss_command("point 15.75,12.25,-16.625");
ss_command("point 15.75,14.5,-16.625");
ss_command("point 15.75,14.5,-16.875");
ss_command("point 15.75,12.25,-16.875");
ss_command("end");
ss_command("sweep linear object \\bar points 15.75,13.25,-16.75 15.5,13.25,-16.75 scale angles name bar1");
ss_command("surface object \\bar1 fill-color yellow");
ss_command("copy object \\bar1 radial angle 90 copies 2 axis 15.75,13.25,-16.75 15.125,13.25,-16.75");
ss_command("solid trim object \\bar1 object \\roofb3");
ss_command("solid trim object \\bar2 object \\roofb3");
ss_command("solid union object \\bar4 object \\bar3");
ss_command("hide drawing quick edged 0");
ss_command("isolate object \\roofb3");
ss_command("visibility enable object \\third5");
ss_command("zoom visible");
ss_command("pen color brown");
ss_command("create object t");
ss_command("begin polygon");
ss_command("point 12.125,11.75,-16.125");
ss_command("point 12.125,14.75,-16.125");
ss_command("point 12.125,14.75,-17.5");
ss_command("point 12.125,11.75,-17.5");
ss_command("end");
ss_command("pen color light-green");
ss_command("sweep linear object \\t points 12.125,14.75,-17.5 9.25,14.75,-17.5 scale angles name ttt");
ss_command("surface object \\ttt fill-color blue");
ss_command("solid difference object \\third5 object \\ttt");
undo_set_description("Build a roof for the extension");
undo_end();
// Work on the watch tower
refresh_and_message("Finish the watch tower and add the ground");
undo_begin();
ss_command("isolate object \\lower");
ss_command("zoom object \\lower");
ss_command("create object tt");
ss_command("begin polygon");
ss_command("point 23.75,-0.5,-13.75");
ss_command("point 23.75,-0.5,-18.75");
ss_command("point 28.75,-0.5,-18.75");
ss_command("point 28.75,-0.5,-13.75");
ss_command("end");
ss_command("pen color light-cyan");
ss_command("sweep linear object \\tt points 28.75,-0.5,-18.75 28.75,14,-18.75 scale angles name inside");
ss_command("surface object \\inside fill-color yellow");
ss_command("solid difference object \\lower object \\inside");
ss_command("create object ttt");
ss_command("draw rectangle 27.75,3.75,-12.25 27,9.25,-12.25");
ss_command("sweep linear object \\ttt points 27,9.25,-12.25 27,9.25,-14.75 scale angles name cut");
ss_command("surface object \\cut fill-color light-cyan");
ss_command("copy object \\cut single x-2.25y2.25");
ss_command("solid difference object \\lower1 object \\cut");
ss_command("solid difference object \\lower2 object \\cut1");
ss_command("display refine circle sweep 20");
ss_command("create object tmp");
ss_command("begin polygon");
ss_command("point 21.75,-0.5,-14.75");
ss_command("point 21.75,4,-14.75");
ss_command("point 21.75,4,-18");
ss_command("point 21.75,-0.5,-18");
ss_command("end");
ss_command("fillet polygon \\tmp.1 insert line 2 line 3 radius 1");
ss_command("fillet polygon \\tmp.1 insert line 3 line 4 radius 1");
ss_command("sweep linear object \\tmp points 21.75,4,-18 25,4,-18 scale angles name door");
ss_command("display refine circle sweep 16");
ss_command("surface object \\door fill-color blue");
ss_command("solid difference object \\lower3 object \\door");
ss_command("hide drawing quick edged 0");
ss_command("create object tt5");
ss_command("pen color brown");
ss_command("draw rectangle -4.5,0,5.75 34.75,-0.5,5.75");
ss_command("sweep linear object \\tt5 points 34.75,-0.5,5.75 34.75,-0.5,-25.75 scale angles name base");
ss_command("surface object \\base fill-color blue");
ss_command("surface object \\base pat-color cyan");
ss_command("surface primitive polygon \\base.26 pattern hex");
ss_command("surface primitive polygon \\roofa4.215 pattern square");
ss_command("surface primitive polygon \\roofa4.215 fill-color blue");
ss_command("surface object \\ceil2 pat-color light-cyan");
ss_command("surface object \\ceil2 scale 1");
ss_command("surface primitive polygon \\ceil2.8 fill-color blue");
ss_command("surface primitive polygon \\ceil2.8 pattern square");
ss_command("surface object \\ceil1 pat-color cyan");
ss_command("surface object \\ceil1 scale 1");
ss_command("surface primitive polygon \\ceil1.8 fill-color red");
ss_command("surface primitive polygon \\ceil1.8 pattern square");
ss_command("surface object \\lower4 scale 1");
ss_command("surface object \\lower4 pat-color gray");
ss_command("surface primitive polygon \\lower4.6 pattern brick");
ss_command("surface primitive polygon \\lower4.11 pattern brick");
ss_command("surface primitive polygon \\lower4.51 pattern brick");
ss_command("surface primitive polygon \\lower4.133 pattern brick");
ss_command("isolate reset");
ss_command("zoom drawing");
ss_command("hide drawing quick edged 0 patterns");
undo_set_description("Finish work on the watch tower and add the ground");
undo_end();
// Display a usage message to the user
refresh_and_message("U: to undo\nR: to redo\nESCAPE: To exit");
for ( ; ; )
{
big_string[0] = 0;
if ( is_undo_available() )
undo_get_description(buffer);
else
strcpy(buffer, "(none)");
sprintf(big_string, "Undo: %s, ", buffer);
if ( is_redo_available() )
redo_get_description(buffer);
else
strcpy(buffer, "(none)");
sprintf(big_string + strlen(big_string), "Redo: %s", buffer);
qmessage(big_string, color_white, color_light_blue);
// Get user input
switch ( inchar() )
{
case 'U':
case 'u':
if ( is_undo_available() )
{
undo_one();
refresh_the_castle();
}
else
error_message("No undo available");
break;
case 'R':
case 'r':
if ( is_redo_available() )
{
redo_one();
refresh_the_castle();
}
else
error_message("No redo available");
break;
case ESCAPE:
undo_stop();
cv_set(CV_REFRESH, 1);
exit(-1);
}
}
}
static void refresh_and_message(const char *message)
{
refresh_the_castle();
panel_message(message);
}
static void refresh_the_castle()
{
ss_command("zoom drawing");
cv_set(CV_REFRESH, 1);
ss_command("hide drawing quick edged 0 patterns");
cv_set(CV_REFRESH, 0);
}