00001
00025 #include "debug.scene.h"
00026 #include "scene.h"
00027 #include "grid.h"
00028 #include "lbaengine.h"
00029 #include "redraw.h"
00030 #include "interface.h"
00031
00032 int showingZones=0;
00033 int typeZones=127;
00034
00035 void draw_bounding_box_project_points(ScenePoint* pPoint3d, ScenePoint* pPoint3dProjected)
00036 {
00037 project_position_on_screen(pPoint3d->X,pPoint3d->Y,pPoint3d->Z);
00038
00039 pPoint3dProjected->X = projPosX;
00040 pPoint3dProjected->Y = projPosY;
00041 pPoint3dProjected->Z = projPosZ;
00042
00043 if(renderLeft > projPosX)
00044 renderLeft = projPosX;
00045
00046 if(renderRight < projPosX)
00047 renderRight = projPosX;
00048
00049 if(renderTop > projPosY)
00050 renderTop = projPosY;
00051
00052 if(renderBottom < projPosY)
00053 renderBottom = projPosY;
00054 }
00055
00056 int check_zone_type(int type)
00057 {
00058 switch(type)
00059 {
00060 case 0:
00061 if(typeZones & 0x01)
00062 return 1;
00063 break;
00064 case 1:
00065 if(typeZones & 0x02)
00066 return 1;
00067 break;
00068 case 2:
00069 if(typeZones & 0x04)
00070 return 1;
00071 break;
00072 case 3:
00073 if(typeZones & 0x08)
00074 return 1;
00075 break;
00076 case 4:
00077 if(typeZones & 0x10)
00078 return 1;
00079 break;
00080 case 5:
00081 if(typeZones & 0x20)
00082 return 1;
00083 break;
00084 case 6:
00085 if(typeZones & 0x40)
00086 return 1;
00087 break;
00088 default:
00089 break;
00090 }
00091
00092 return 0;
00093 }
00094
00095 void display_zones(short int pKey)
00096 {
00097 if(showingZones==1)
00098 {
00099 int z;
00100 ZoneBox *zonePtr = sceneZones;
00101 for(z=0; z < sceneNumZones; z++)
00102 {
00103 zonePtr = &sceneZones[z];
00104
00105 if(check_zone_type(zonePtr->type))
00106 {
00107 ScenePoint frontBottomLeftPoint;
00108 ScenePoint frontBottomRightPoint;
00109
00110 ScenePoint frontTopLeftPoint;
00111 ScenePoint frontTopRightPoint;
00112
00113 ScenePoint backBottomLeftPoint;
00114 ScenePoint backBottomRightPoint;
00115
00116 ScenePoint backTopLeftPoint;
00117 ScenePoint backTopRightPoint;
00118
00119 ScenePoint frontBottomLeftPoint2D;
00120 ScenePoint frontBottomRightPoint2D;
00121
00122 ScenePoint frontTopLeftPoint2D;
00123 ScenePoint frontTopRightPoint2D;
00124
00125 ScenePoint backBottomLeftPoint2D;
00126 ScenePoint backBottomRightPoint2D;
00127
00128 ScenePoint backTopLeftPoint2D;
00129 ScenePoint backTopRightPoint2D;
00130
00131 unsigned char color;
00132
00133
00134
00135 frontBottomLeftPoint.X = zonePtr->bottomLeft.X - cameraX;
00136 frontBottomLeftPoint.Y = zonePtr->bottomLeft.Y - cameraY;
00137 frontBottomLeftPoint.Z = zonePtr->topRight.Z - cameraZ;
00138
00139 frontBottomRightPoint.X = zonePtr->topRight.X - cameraX;
00140 frontBottomRightPoint.Y = zonePtr->bottomLeft.Y - cameraY;
00141 frontBottomRightPoint.Z = zonePtr->topRight.Z - cameraZ;
00142
00143 frontTopLeftPoint.X = zonePtr->bottomLeft.X - cameraX;
00144 frontTopLeftPoint.Y = zonePtr->topRight.Y - cameraY;
00145 frontTopLeftPoint.Z = zonePtr->topRight.Z - cameraZ;
00146
00147 frontTopRightPoint.X = zonePtr->topRight.X - cameraX;
00148 frontTopRightPoint.Y = zonePtr->topRight.Y - cameraY;
00149 frontTopRightPoint.Z = zonePtr->topRight.Z - cameraZ;
00150
00151 backBottomLeftPoint.X = zonePtr->bottomLeft.X - cameraX;
00152 backBottomLeftPoint.Y = zonePtr->bottomLeft.Y - cameraY;
00153 backBottomLeftPoint.Z = zonePtr->bottomLeft.Z - cameraZ;
00154
00155 backBottomRightPoint.X = zonePtr->topRight.X - cameraX;
00156 backBottomRightPoint.Y = zonePtr->bottomLeft.Y - cameraY;
00157 backBottomRightPoint.Z = zonePtr->bottomLeft.Z - cameraZ;
00158
00159 backTopLeftPoint.X = zonePtr->bottomLeft.X - cameraX;
00160 backTopLeftPoint.Y = zonePtr->topRight.Y - cameraY;
00161 backTopLeftPoint.Z = zonePtr->bottomLeft.Z - cameraZ;
00162
00163 backTopRightPoint.X = zonePtr->topRight.X - cameraX;
00164 backTopRightPoint.Y = zonePtr->topRight.Y - cameraY;
00165 backTopRightPoint.Z = zonePtr->bottomLeft.Z - cameraZ;
00166
00167
00168
00169 draw_bounding_box_project_points( &frontBottomLeftPoint, &frontBottomLeftPoint2D );
00170 draw_bounding_box_project_points( &frontBottomRightPoint, &frontBottomRightPoint2D );
00171 draw_bounding_box_project_points( &frontTopLeftPoint, &frontTopLeftPoint2D );
00172 draw_bounding_box_project_points( &frontTopRightPoint, &frontTopRightPoint2D );
00173 draw_bounding_box_project_points( &backBottomLeftPoint, &backBottomLeftPoint2D );
00174 draw_bounding_box_project_points( &backBottomRightPoint, &backBottomRightPoint2D );
00175 draw_bounding_box_project_points( &backTopLeftPoint, &backTopLeftPoint2D );
00176 draw_bounding_box_project_points( &backTopRightPoint, &backTopRightPoint2D );
00177
00178
00179
00180 color = 15*3+zonePtr->type*16;
00181
00182
00183 draw_line(frontBottomLeftPoint2D.X,frontBottomLeftPoint2D.Y,frontTopLeftPoint2D.X,frontTopLeftPoint2D.Y,color);
00184 draw_line(frontTopLeftPoint2D.X,frontTopLeftPoint2D.Y,frontTopRightPoint2D.X,frontTopRightPoint2D.Y,color);
00185 draw_line(frontTopRightPoint2D.X,frontTopRightPoint2D.Y,frontBottomRightPoint2D.X,frontBottomRightPoint2D.Y,color);
00186 draw_line(frontBottomRightPoint2D.X,frontBottomRightPoint2D.Y,frontBottomLeftPoint2D.X,frontBottomLeftPoint2D.Y,color);
00187
00188
00189 draw_line(frontTopLeftPoint2D.X,frontTopLeftPoint2D.Y,backTopLeftPoint2D.X,backTopLeftPoint2D.Y,color);
00190 draw_line(backTopLeftPoint2D.X,backTopLeftPoint2D.Y,backTopRightPoint2D.X,backTopRightPoint2D.Y,color);
00191 draw_line(backTopRightPoint2D.X,backTopRightPoint2D.Y,frontTopRightPoint2D.X,frontTopRightPoint2D.Y,color);
00192 draw_line(frontTopRightPoint2D.X,frontTopRightPoint2D.Y,frontTopLeftPoint2D.X,frontTopLeftPoint2D.Y,color);
00193
00194
00195 draw_line(backBottomLeftPoint2D.X,backBottomLeftPoint2D.Y,backTopLeftPoint2D.X,backTopLeftPoint2D.Y,color);
00196 draw_line(backTopLeftPoint2D.X,backTopLeftPoint2D.Y,backTopRightPoint2D.X,backTopRightPoint2D.Y,color);
00197 draw_line(backTopRightPoint2D.X,backTopRightPoint2D.Y,backBottomRightPoint2D.X,backBottomRightPoint2D.Y,color);
00198 draw_line(backBottomRightPoint2D.X,backBottomRightPoint2D.Y,backBottomLeftPoint2D.X,backBottomLeftPoint2D.Y,color);
00199
00200
00201 draw_line(frontBottomLeftPoint2D.X,frontBottomLeftPoint2D.Y,backBottomLeftPoint2D.X,backBottomLeftPoint2D.Y,color);
00202 draw_line(backBottomLeftPoint2D.X,backBottomLeftPoint2D.Y,backBottomRightPoint2D.X,backBottomRightPoint2D.Y,color);
00203 draw_line(backBottomRightPoint2D.X,backBottomRightPoint2D.Y,frontBottomRightPoint2D.X,frontBottomRightPoint2D.Y,color);
00204 draw_line(frontBottomRightPoint2D.X,frontBottomRightPoint2D.Y,frontBottomLeftPoint2D.X,frontBottomLeftPoint2D.Y,color);
00205 }
00206 }
00207 }
00208 }