00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "Stage.h"
00025 #include "DisplayDevice.h"
00026 #include "Scene.h"
00027 #include "DispCmds.h"
00028 #include "Inform.h"
00029 #include "utilities.h"
00030
00031
00032
00033 static char *stageloc[Stage::STAGEPOS_TOTAL] = {
00034 (char *) "Off", (char *) "Origin", (char *) "Bottom",
00035 (char *) "Top", (char *) "Left", (char *) "Right", (char *) "Behind" };
00036
00037
00038
00039 #define STAGEEVENCOL REGGREY
00040 #define STAGEODDCOL REGSILVER
00041
00042
00043 Stage::Stage(Displayable *disp) : Displayable(disp) {
00044
00045
00046 rot_off();
00047 scale_off();
00048 glob_trans_off();
00049 cent_trans_off();
00050
00051
00052 Panels = 0;
00053 panels(STAGE_PANELS);
00054 stagePos = STAGEPOS_TOTAL;
00055 location(NO_STAGE);
00056
00057 colorCat = scene->add_color_category("Stage");
00058 scene->add_color_item(colorCat, "Even", STAGEEVENCOL);
00059 scene->add_color_item(colorCat, "Odd", STAGEODDCOL);
00060
00061 do_color_changed(colorCat);
00062 }
00063
00064
00066
00067 void Stage::do_color_changed(int clr) {
00068 if (clr == colorCat) {
00069 usecolors[0] = scene->category_item_value(colorCat,
00070 scene->category_item_index(colorCat, "Even"));
00071 usecolors[1] = scene->category_item_value(colorCat,
00072 scene->category_item_index(colorCat, "Odd"));
00073
00074 need_update = TRUE;
00075 }
00076 }
00077
00079
00080
00081 void Stage::create_cmdlist(void) {
00082 int i, j, k, odd;
00083 float c[4][3], mycorner1[3];
00084
00085 mycorner1[0] = mycorner1[2] = -1.0; mycorner1[1] = 0.0;
00086 c[0][1] = c[1][1] = c[2][1] = c[3][1] = 0.0;
00087
00088
00089 reset_disp_list();
00090
00091
00092 append(DMATERIALOFF);
00093
00094
00095 for(k=0; k < 2; k++) {
00096 odd = (k == 1);
00097
00098
00099 if (odd)
00100 cmdColor.putdata(usecolors[0],cmdList);
00101 else
00102 cmdColor.putdata(usecolors[1],cmdList);
00103
00104
00105 c[0][0] = c[3][0] = mycorner1[0];
00106 c[1][0] = c[2][0] = mycorner1[0] + inc;
00107
00108 for(i=0; i < Panels; i++) {
00109 c[0][2] = c[1][2] = mycorner1[2];
00110 c[2][2] = c[3][2] = mycorner1[2] + inc;
00111 for(j=0; j < Panels; j++) {
00112 if(!odd)
00113 cmdSquare.putdata(c[2], c[1], c[0], cmdList);
00114 odd = !odd;
00115 c[0][2] += inc; c[1][2] += inc; c[2][2] += inc; c[3][2] += inc;
00116 }
00117 c[0][0] += inc; c[1][0] += inc; c[2][0] += inc; c[3][0] += inc;
00118 if(Panels % 2 == 0)
00119 odd = !odd;
00120 }
00121 }
00122 }
00123
00124
00125
00126 int Stage::location(int ap) {
00127 if (ap != stagePos) {
00128 stagePos = ap;
00129 if (ap == NO_STAGE) {
00130 off();
00131 } else {
00132 on();
00133 need_update = TRUE;
00134 }
00135 }
00136
00137 return TRUE;
00138 }
00139
00140
00141
00142 char *Stage::loc_description(int ap) {
00143 return stageloc[ap];
00144 }
00145
00146
00147
00148 void Stage::prepare() {
00149 float rot_amount = 0.0, strans[3];
00150 char rot_axes = 'z';
00151
00152 strans[0] = strans[1] = strans[2] = 0.0;
00153
00154
00155 if (need_update && stagePos != NO_STAGE) {
00156 if (stagePos == STAGE_ORIGIN) {
00157 ;
00158 } else if(stagePos == STAGE_LOWER) {
00159 strans[1] = -1.0;
00160 } else if(stagePos == STAGE_UPPER) {
00161 strans[1] = 1.0;
00162 } else if(stagePos == STAGE_LEFT) {
00163 strans[0] = -1.0;
00164 rot_amount = -90.0;
00165 } else if(stagePos == STAGE_RIGHT) {
00166 strans[0] = 1.0;
00167 rot_amount = 90.0;
00168 } else if(stagePos == STAGE_BEHIND) {
00169 strans[2] = -1.0;
00170 rot_axes = 'x';
00171 rot_amount = 90.0;
00172 } else {
00173 msgErr << "Stage: Illegal stage location " << stagePos << " specified."
00174 << sendmsg;
00175 stagePos = STAGE_ORIGIN;
00176 return;
00177 }
00178
00179
00180 need_update = FALSE;
00181
00182
00183 create_cmdlist();
00184
00185
00186 glob_trans_on();
00187 rot_on();
00188 reset_transformation();
00189 set_glob_trans(strans[0], strans[1], strans[2]);
00190 add_rot(rot_amount, rot_axes);
00191 rot_off();
00192 glob_trans_off();
00193 }
00194 }
00195