00001
00002 #include "revolt.h"
00003 #include "edportal.h"
00004 #include "main.h"
00005 #include "camera.h"
00006 #include "geom.h"
00007 #include "level.h"
00008 #include "input.h"
00009 #include "text.h"
00010
00011
00012
00013 EDIT_PORTAL *CurrentPortal;
00014
00015 static long EditPortalNum, BigBrother = TRUE;
00016 static EDIT_PORTAL *EditPortal;
00017 static long EditPortalAxis, EditPortalAxisType;
00018 static long EditPortalSide, LastEditPortalID;
00019
00020
00021
00022 static char *EditPortalAxisNames[] = {
00023 "X Y",
00024 "X Z",
00025 "Z Y",
00026 "X",
00027 "Y",
00028 "Z",
00029 };
00030
00031 static char *EditPortalAxisTypeNames[] = {
00032 "Camera",
00033 "World",
00034 };
00035
00036
00037
00038 static unsigned short DrawPortalIndex[] = {
00039 1, 3, 7, 5,
00040 2, 0, 4, 6,
00041 4, 5, 7, 6,
00042 0, 2, 3, 1,
00043 3, 2, 6, 7,
00044 0, 1, 5, 4,
00045 };
00046
00047 static long DrawPortalCol[] = {
00048 0x80ff0000,
00049 0x8000ff00,
00050 0x800000ff,
00051 0x80ffff00,
00052 0x80ff00ff,
00053 0x8000ffff,
00054 };
00055
00057
00059
00060 void KillEditPortals(void)
00061 {
00062 free(EditPortal);
00063 }
00064
00066
00068
00069 void LoadEditPortals(char *file)
00070 {
00071 long i;
00072 FILE *fp;
00073 EDIT_PORTAL por;
00074
00075
00076
00077 EditPortal = (EDIT_PORTAL*)malloc(sizeof(EDIT_PORTAL) * MAX_EDIT_PORTALS);
00078 if (!EditPortal)
00079 {
00080 Box(NULL, "Can't alloc memory for editing portals!", MB_OK);
00081 QuitGame = TRUE;
00082 return;
00083 }
00084
00085
00086
00087 fp = fopen(file, "rb");
00088
00089
00090
00091 if (!fp)
00092 {
00093 fp = fopen(file, "wb");
00094 if (!fp) return;
00095 i = 0;
00096 fwrite(&i, sizeof(i), 1, fp);
00097 fclose(fp);
00098 fp = fopen(file, "rb");
00099 if (!fp) return;
00100 }
00101
00102
00103
00104 fread(&EditPortalNum, sizeof(EditPortalNum), 1, fp);
00105
00106 for (i = 0 ; i < EditPortalNum ; i++)
00107 {
00108
00109
00110
00111 fread(&por, sizeof(por), 1, fp);
00112
00113 VecMulScalar(&por.Pos, EditScale);
00114 VecMulScalar((VEC*)&por.Size, EditScale);
00115
00116
00117
00118 EditPortal[i] = por;
00119 }
00120
00121
00122
00123 fclose(fp);
00124 }
00125
00127
00129
00130 void SaveEditPortals(char *file)
00131 {
00132 long i;
00133 FILE *fp;
00134 EDIT_PORTAL por;
00135 char bak[256];
00136
00137
00138
00139 memcpy(bak, file, strlen(file) - 3);
00140 wsprintf(bak + strlen(file) - 3, "po-");
00141 remove(bak);
00142 rename(file, bak);
00143
00144
00145
00146 fp = fopen(file, "wb");
00147 if (!fp) return;
00148
00149
00150
00151 fwrite(&EditPortalNum, sizeof(EditPortalNum), 1, fp);
00152
00153
00154
00155 for (i = 0 ; i < EditPortalNum ; i++)
00156 {
00157
00158
00159
00160 por = EditPortal[i];
00161
00162
00163
00164 fwrite(&por, sizeof(por), 1, fp);
00165 }
00166
00167
00168
00169 Box("Saved Portal File:", file, MB_OK);
00170 fclose(fp);
00171 }
00172
00174
00176
00177 EDIT_PORTAL *AllocEditPortal(void)
00178 {
00179
00180
00181
00182 if (EditPortalNum >= MAX_EDIT_PORTALS)
00183 return NULL;
00184
00185
00186
00187 return &EditPortal[EditPortalNum++];
00188 }
00189
00191
00193
00194 void FreeEditPortal(EDIT_PORTAL *portal)
00195 {
00196 long idx, i;
00197
00198
00199
00200 idx = (long)(portal - EditPortal);
00201
00202
00203
00204 for (i = idx ; i < EditPortalNum - 1; i++)
00205 {
00206 EditPortal[i] = EditPortal[i + 1];
00207 }
00208
00209
00210
00211 EditPortalNum--;
00212 }
00213
00215
00217
00218 void EditPortals(void)
00219 {
00220 long i, j;
00221 VEC vec, vec2, r, u, l, r2, u2, l2;
00222 float z, sx, sy, rad, add;
00223 MAT mat, mat2;
00224 EDIT_PORTAL *nportal, *portal;
00225
00226
00227
00228 if (Keys[DIK_NUMPADENTER] && !LastKeys[DIK_NUMPADENTER])
00229 BigBrother = !BigBrother;
00230
00231
00232
00233 if (CAM_MainCamera->Type != CAM_EDIT)
00234 {
00235 CurrentPortal = NULL;
00236 return;
00237 }
00238
00239
00240
00241 if (MouseRight)
00242 {
00243 RotMatrixZYX(&mat, (float)-Mouse.lY / 3072, -(float)Mouse.lX / 3072, 0);
00244 MulMatrix(&CAM_MainCamera->WMatrix, &mat, &mat2);
00245 CopyMatrix(&mat2, &CAM_MainCamera->WMatrix);
00246
00247 CAM_MainCamera->WMatrix.m[RY] = 0;
00248 NormalizeVector(&CAM_MainCamera->WMatrix.mv[X]);
00249 CrossProduct(&CAM_MainCamera->WMatrix.mv[Z], &CAM_MainCamera->WMatrix.mv[X], &CAM_MainCamera->WMatrix.mv[Y]);
00250 NormalizeVector(&CAM_MainCamera->WMatrix.mv[Y]);
00251 CrossProduct(&CAM_MainCamera->WMatrix.mv[X], &CAM_MainCamera->WMatrix.mv[Y], &CAM_MainCamera->WMatrix.mv[Z]);
00252 }
00253
00254
00255
00256 if (Keys[DIK_LCONTROL] && Keys[DIK_F4] && !LastKeys[DIK_F4])
00257 {
00258 SaveEditPortals(GetLevelFilename("por", FILENAME_MAKE_BODY | FILENAME_GAME_SETTINGS));
00259 }
00260
00261
00262
00263 if (!CurrentPortal && Keys[DIK_RETURN] && !LastKeys[DIK_RETURN])
00264 {
00265 nportal = NULL;
00266 z = RenderSettings.FarClip;
00267
00268 portal = EditPortal;
00269 for (i = 0 ; i < EditPortalNum ; i++, portal++)
00270 {
00271 for (j = 0 ; j < 2 ; j++)
00272 {
00273 RotTransVector(&ViewMatrix, &ViewTrans, &portal->Pos, &vec);
00274
00275 if (vec.v[Z] < RenderSettings.NearClip || vec.v[Z] >= RenderSettings.FarClip) continue;
00276
00277 sx = vec.v[X] * RenderSettings.GeomPers / vec.v[Z] + REAL_SCREEN_XHALF;
00278 sy = vec.v[Y] * RenderSettings.GeomPers / vec.v[Z] + REAL_SCREEN_YHALF;
00279
00280 rad = 128 * RenderSettings.GeomPers / vec.v[Z];
00281
00282 if (MouseXpos > sx - rad && MouseXpos < sx + rad && MouseYpos > sy - rad && MouseYpos < sy + rad)
00283 {
00284 if (vec.v[Z] < z)
00285 {
00286 nportal = portal;
00287 z = vec.v[Z];
00288 }
00289 }
00290 }
00291 }
00292 if (nportal)
00293 {
00294 CurrentPortal = nportal;
00295 return;
00296 }
00297 }
00298
00299
00300
00301 if (Keys[DIK_INSERT] && !LastKeys[DIK_INSERT])
00302 {
00303 if ((portal = AllocEditPortal()))
00304 {
00305 vec.v[X] = 0;
00306 vec.v[Y] = 0;
00307 vec.v[Z] = 512;
00308 RotVector(&CAM_MainCamera->WMatrix, &vec, &vec2);
00309 AddVector(&CAM_MainCamera->WPos, &vec2, &portal->Pos);
00310
00311 CopyMatrix(&IdentityMatrix, &portal->Matrix);
00312
00313 portal->Size[X] = portal->Size[Y] = portal->Size[Z] = 128;
00314
00315 portal->Region = TRUE;
00316 portal->ID1 = LastEditPortalID;
00317 portal->ID2 = LastEditPortalID;
00318
00319 CurrentPortal = portal;
00320 }
00321 }
00322
00323
00324
00325 if (!CurrentPortal) return;
00326
00327
00328
00329 LastEditPortalID = CurrentPortal->ID1;
00330
00331
00332
00333 if (Keys[DIK_RETURN] && !LastKeys[DIK_RETURN])
00334 {
00335 CurrentPortal = NULL;
00336 return;
00337 }
00338
00339
00340
00341 if (Keys[DIK_DELETE] && !LastKeys[DIK_DELETE])
00342 {
00343 FreeEditPortal(CurrentPortal);
00344 CurrentPortal = NULL;
00345 return;
00346 }
00347
00348
00349
00350 if (Keys[DIK_TAB] && !LastKeys[DIK_TAB])
00351 {
00352 if (Keys[DIK_LSHIFT]) EditPortalAxis--;
00353 else EditPortalAxis++;
00354 if (EditPortalAxis == -1) EditPortalAxis = 5;
00355 if (EditPortalAxis == 6) EditPortalAxis = 0;
00356 }
00357
00358
00359
00360 if (Keys[DIK_LALT] && !LastKeys[DIK_LALT])
00361 EditPortalAxisType ^= 1;
00362
00363
00364
00365 if (Keys[DIK_NUMPADPERIOD] && !LastKeys[DIK_NUMPADPERIOD])
00366 CurrentPortal->Region = !CurrentPortal->Region;
00367
00368
00369
00370 if (Keys[DIK_LSHIFT])
00371 {
00372 if (Keys[DIK_NUMPADMINUS] && !LastKeys[DIK_NUMPADMINUS])
00373 CurrentPortal->ID2--;
00374 if (Keys[DIK_NUMPADPLUS] && !LastKeys[DIK_NUMPADPLUS])
00375 CurrentPortal->ID2++;
00376
00377 if (CurrentPortal->ID2 < 0)
00378 CurrentPortal->ID2 = MAX_EDIT_PORTALS - 1;
00379 else if (CurrentPortal->ID2 >= MAX_EDIT_PORTALS)
00380 CurrentPortal->ID2 = 0;
00381 }
00382 else
00383 {
00384 if (Keys[DIK_NUMPADMINUS] && !LastKeys[DIK_NUMPADMINUS])
00385 CurrentPortal->ID1--;
00386 if (Keys[DIK_NUMPADPLUS] && !LastKeys[DIK_NUMPADPLUS])
00387 CurrentPortal->ID1++;
00388
00389 if (CurrentPortal->ID1 < 0)
00390 CurrentPortal->ID1 = MAX_EDIT_PORTALS - 1;
00391 else if (CurrentPortal->ID1 >= MAX_EDIT_PORTALS)
00392 CurrentPortal->ID1 = 0;
00393 }
00394
00395
00396
00397 if (Keys[DIK_SPACE] && !LastKeys[DIK_SPACE])
00398 EditPortalSide = (EditPortalSide + 1) % 6;
00399
00400 if (!CurrentPortal->Region)
00401 EditPortalSide %= 4;
00402
00403
00404
00405 add = 0;
00406 if (Keys[DIK_NUMPADSTAR])
00407 add = 4 * TimeFactor;
00408 if (Keys[DIK_NUMPADSLASH])
00409 add = -4 * TimeFactor;
00410
00411 if (Keys[DIK_LCONTROL]) add *= 4;
00412
00413 if (add)
00414 {
00415 if (Keys[DIK_LSHIFT])
00416 {
00417 CurrentPortal->Size[X] += add;
00418 if (CurrentPortal->Size[X] < 16) CurrentPortal->Size[X] = 16;
00419 CurrentPortal->Size[Y] += add;
00420 if (CurrentPortal->Size[Y] < 16) CurrentPortal->Size[Y] = 16;
00421 CurrentPortal->Size[Z] += add;
00422 if (CurrentPortal->Size[Z] < 16) CurrentPortal->Size[Z] = 16;
00423 }
00424 else
00425 {
00426 switch (EditPortalSide)
00427 {
00428 case 0:
00429 CurrentPortal->Size[X] += add;
00430 if (CurrentPortal->Size[X] < 16) CurrentPortal->Size[X] = 16;
00431 CurrentPortal->Pos.v[X] += CurrentPortal->Matrix.m[RX] * add;
00432 CurrentPortal->Pos.v[Y] += CurrentPortal->Matrix.m[RY] * add;
00433 CurrentPortal->Pos.v[Z] += CurrentPortal->Matrix.m[RZ] * add;
00434 break;
00435 case 1:
00436 CurrentPortal->Size[X] += add;
00437 if (CurrentPortal->Size[X] < 16) CurrentPortal->Size[X] = 16;
00438 CurrentPortal->Pos.v[X] -= CurrentPortal->Matrix.m[RX] * add;
00439 CurrentPortal->Pos.v[Y] -= CurrentPortal->Matrix.m[RY] * add;
00440 CurrentPortal->Pos.v[Z] -= CurrentPortal->Matrix.m[RZ] * add;
00441 break;
00442 case 2:
00443 CurrentPortal->Size[Y] += add;
00444 if (CurrentPortal->Size[Y] < 16) CurrentPortal->Size[Y] = 16;
00445 CurrentPortal->Pos.v[X] += CurrentPortal->Matrix.m[UX] * add;
00446 CurrentPortal->Pos.v[Y] += CurrentPortal->Matrix.m[UY] * add;
00447 CurrentPortal->Pos.v[Z] += CurrentPortal->Matrix.m[UZ] * add;
00448 break;
00449 case 3:
00450 CurrentPortal->Size[Y] += add;
00451 if (CurrentPortal->Size[Y] < 16) CurrentPortal->Size[Y] = 16;
00452 CurrentPortal->Pos.v[X] -= CurrentPortal->Matrix.m[UX] * add;
00453 CurrentPortal->Pos.v[Y] -= CurrentPortal->Matrix.m[UY] * add;
00454 CurrentPortal->Pos.v[Z] -= CurrentPortal->Matrix.m[UZ] * add;
00455 break;
00456 case 4:
00457 CurrentPortal->Size[Z] += add;
00458 if (CurrentPortal->Size[Z] < 16) CurrentPortal->Size[Z] = 16;
00459 CurrentPortal->Pos.v[X] += CurrentPortal->Matrix.m[LX] * add;
00460 CurrentPortal->Pos.v[Y] += CurrentPortal->Matrix.m[LY] * add;
00461 CurrentPortal->Pos.v[Z] += CurrentPortal->Matrix.m[LZ] * add;
00462 break;
00463 case 5:
00464 CurrentPortal->Size[Z] += add;
00465 if (CurrentPortal->Size[Z] < 16) CurrentPortal->Size[Z] = 16;
00466 CurrentPortal->Pos.v[X] -= CurrentPortal->Matrix.m[LX] * add;
00467 CurrentPortal->Pos.v[Y] -= CurrentPortal->Matrix.m[LY] * add;
00468 CurrentPortal->Pos.v[Z] -= CurrentPortal->Matrix.m[LZ] * add;
00469 break;
00470 }
00471 }
00472 }
00473
00474
00475
00476 if (MouseLeft)
00477 {
00478 RotTransVector(&ViewMatrix, &ViewTrans, &CurrentPortal->Pos, &vec);
00479
00480 switch (EditPortalAxis)
00481 {
00482 case PORTAL_AXIS_XY:
00483 vec.v[X] = MouseXrel * vec.v[Z] / RenderSettings.GeomPers + CameraEditXrel;
00484 vec.v[Y] = MouseYrel * vec.v[Z] / RenderSettings.GeomPers + CameraEditYrel;
00485 vec.v[Z] = CameraEditZrel;
00486 break;
00487 case PORTAL_AXIS_XZ:
00488 vec.v[X] = MouseXrel * vec.v[Z] / RenderSettings.GeomPers + CameraEditXrel;
00489 vec.v[Y] = CameraEditYrel;
00490 vec.v[Z] = -MouseYrel * vec.v[Z] / RenderSettings.GeomPers + CameraEditZrel;
00491 break;
00492 case PORTAL_AXIS_ZY:
00493 vec.v[X] = CameraEditXrel;
00494 vec.v[Y] = MouseYrel * vec.v[Z] / RenderSettings.GeomPers + CameraEditYrel;
00495 vec.v[Z] = MouseXrel * vec.v[Z] / RenderSettings.GeomPers + CameraEditZrel;
00496 break;
00497 case PORTAL_AXIS_X:
00498 vec.v[X] = MouseXrel * vec.v[Z] / RenderSettings.GeomPers + CameraEditXrel;
00499 vec.v[Y] = CameraEditYrel;
00500 vec.v[Z] = CameraEditZrel;
00501 break;
00502 case PORTAL_AXIS_Y:
00503 vec.v[X] = CameraEditXrel;
00504 vec.v[Y] = MouseYrel * vec.v[Z] / RenderSettings.GeomPers + CameraEditYrel;
00505 vec.v[Z] = CameraEditZrel;
00506 break;
00507 case PORTAL_AXIS_Z:
00508 vec.v[X] = CameraEditXrel;
00509 vec.v[Y] = CameraEditYrel;
00510 vec.v[Z] = -MouseYrel * vec.v[Z] / RenderSettings.GeomPers + CameraEditZrel;
00511 break;
00512 }
00513
00514 if (EditPortalAxisType == 1)
00515 {
00516 SetVector(&vec2, vec.v[X], vec.v[Y], vec.v[Z]);
00517 }
00518 else
00519 {
00520 RotVector(&CAM_MainCamera->WMatrix, &vec, &vec2);
00521 }
00522
00523 CurrentPortal->Pos.v[X] += vec2.v[X];
00524 CurrentPortal->Pos.v[Y] += vec2.v[Y];
00525 CurrentPortal->Pos.v[Z] += vec2.v[Z];
00526 }
00527
00528
00529
00530 vec.v[X] = vec.v[Y] = vec.v[Z] = 0;
00531
00532 if (Keys[DIK_NUMPAD7]) vec.v[X] -= 0.001f;
00533 if (Keys[DIK_NUMPAD4]) vec.v[X] += 0.001f;
00534 if (Keys[DIK_NUMPAD8]) vec.v[Y] -= 0.001f;
00535 if (Keys[DIK_NUMPAD5]) vec.v[Y] += 0.001f;
00536 if (Keys[DIK_NUMPAD9]) vec.v[Z] -= 0.001f;
00537 if (Keys[DIK_NUMPAD6]) vec.v[Z] += 0.001f;
00538
00539 if (Keys[DIK_NUMPAD1] && !LastKeys[DIK_NUMPAD1]) vec.v[X] += 0.25f;
00540 if (Keys[DIK_NUMPAD2] && !LastKeys[DIK_NUMPAD2]) vec.v[Y] += 0.25f;
00541 if (Keys[DIK_NUMPAD3] && !LastKeys[DIK_NUMPAD3]) vec.v[Z] += 0.25f;
00542
00543 if (Keys[DIK_NUMPAD0]) CopyMatrix(&IdentityMatrix, &CurrentPortal->Matrix);
00544
00545 RotMatrixZYX(&mat, vec.v[X], vec.v[Y], vec.v[Z]);
00546
00547 if (EditPortalAxisType)
00548 {
00549 MulMatrix(&mat, &CurrentPortal->Matrix, &mat2);
00550 CopyMatrix(&mat2, &CurrentPortal->Matrix);
00551 NormalizeMatrix(&CurrentPortal->Matrix);
00552 }
00553 else if (vec.v[X] || vec.v[Y] || vec.v[Z])
00554 {
00555 RotVector(&ViewMatrix, &CurrentPortal->Matrix.mv[X], &r);
00556 RotVector(&ViewMatrix, &CurrentPortal->Matrix.mv[Y], &u);
00557 RotVector(&ViewMatrix, &CurrentPortal->Matrix.mv[Z], &l);
00558
00559 RotVector(&mat, &r, &r2);
00560 RotVector(&mat, &u, &u2);
00561 RotVector(&mat, &l, &l2);
00562
00563 RotVector(&CAM_MainCamera->WMatrix, &r2, &CurrentPortal->Matrix.mv[X]);
00564 RotVector(&CAM_MainCamera->WMatrix, &u2, &CurrentPortal->Matrix.mv[Y]);
00565 RotVector(&CAM_MainCamera->WMatrix, &l2, &CurrentPortal->Matrix.mv[Z]);
00566
00567 NormalizeMatrix(&CurrentPortal->Matrix);
00568 }
00569 }
00570
00572
00574
00575 void DrawPortals(void)
00576 {
00577 long i, j, k, col[4], rgb;
00578 EDIT_PORTAL *portal;
00579 VEC v[8], vpos[8], pos[4];
00580 MAT mat;
00581 VEC vec;
00582 char buf[128];
00583
00584
00585
00586 ALPHA_SRC(D3DBLEND_SRCALPHA);
00587 ALPHA_DEST(D3DBLEND_INVSRCALPHA);
00588 WIREFRAME_OFF();
00589
00590
00591
00592 portal = EditPortal;
00593 for (i = 0 ; i < EditPortalNum ; i++, portal++)
00594 {
00595
00596
00597
00598 if (portal->Region)
00599 {
00600 if (CurrentPortal && CurrentPortal->Region && ((CurrentPortal->ID1 == portal->ID1 && BigBrother) || CurrentPortal == portal))
00601 {
00602
00603
00604
00605 SetVector(&v[0], -portal->Size[X], -portal->Size[Y], -portal->Size[Z]);
00606 SetVector(&v[1], portal->Size[X], -portal->Size[Y], -portal->Size[Z]);
00607 SetVector(&v[2], -portal->Size[X], -portal->Size[Y], portal->Size[Z]);
00608 SetVector(&v[3], portal->Size[X], -portal->Size[Y], portal->Size[Z]);
00609
00610 SetVector(&v[4], -portal->Size[X], portal->Size[Y], -portal->Size[Z]);
00611 SetVector(&v[5], portal->Size[X], portal->Size[Y], -portal->Size[Z]);
00612 SetVector(&v[6], -portal->Size[X], portal->Size[Y], portal->Size[Z]);
00613 SetVector(&v[7], portal->Size[X], portal->Size[Y], portal->Size[Z]);
00614
00615 for (j = 0 ; j < 8 ; j++)
00616 {
00617 RotTransVector(&portal->Matrix, &portal->Pos, &v[j], &vpos[j]);
00618 }
00619
00620
00621
00622 SET_TPAGE(-1);
00623 ALPHA_ON();
00624 ZBUFFER_ON();
00625
00626 for (j = 0 ; j < 6 ; j++)
00627 {
00628 for (k = 0 ; k < 4 ; k++)
00629 {
00630 pos[k] = vpos[DrawPortalIndex[j * 4 + k]];
00631
00632 if (CurrentPortal == portal && j == EditPortalSide)
00633 col[k] = 0x80ffffff * (FrameCount & 1);
00634 else
00635 col[k] = DrawPortalCol[portal->ID1 % 6];
00636 }
00637
00638 DrawNearClipPolyTEX0(pos, col, 4);
00639 }
00640 }
00641
00642
00643
00644 wsprintf(buf, "%d", portal->ID1);
00645 RotTransVector(&ViewMatrix, &ViewTrans, &portal->Pos, &vec);
00646 vec.v[X] -= 64 * ((portal->ID1 >= 10) + 1);
00647 vec.v[Y] -= 128;
00648 if (vec.v[Z] > RenderSettings.NearClip)
00649 {
00650 ALPHA_OFF();
00651 ZBUFFER_OFF();
00652 DumpText3D(&vec, 128, 256, 0x00ffff, buf);
00653 }
00654 }
00655
00656
00657
00658 else
00659 {
00660
00661
00662
00663 SubVector(&portal->Pos, &ViewCameraPos, &vec);
00664 if (DotProduct(&vec, &portal->Matrix.mv[L]) < 0.0f)
00665 rgb = 0x80ff0000;
00666 else
00667 rgb = 0x8000ff00;
00668
00669
00670
00671 SetVector(&v[0], -portal->Size[X], -portal->Size[Y], 0);
00672 SetVector(&v[1], portal->Size[X], -portal->Size[Y], 0);
00673 SetVector(&v[2], portal->Size[X], portal->Size[Y], 0);
00674 SetVector(&v[3], -portal->Size[X], portal->Size[Y], 0);
00675
00676 for (j = 0 ; j < 4 ; j++)
00677 {
00678 RotTransVector(&portal->Matrix, &portal->Pos, &v[j], &pos[j]);
00679 col[j] = rgb;
00680 }
00681
00682
00683
00684 SET_TPAGE(-1);
00685 ALPHA_ON();
00686 ZBUFFER_ON();
00687
00688 DrawNearClipPolyTEX0(pos, col, 4);
00689 }
00690
00691
00692
00693 if (CurrentPortal == portal)
00694 {
00695 ALPHA_OFF();
00696 ZBUFFER_OFF();
00697
00698 if (EditPortalAxisType)
00699 CopyMatrix(&IdentityMatrix, &mat);
00700 else
00701 CopyMatrix(&CAM_MainCamera->WMatrix, &mat);
00702
00703 MatMulScalar(&mat, 2.0f);
00704 DrawAxis(&mat, &portal->Pos);
00705 }
00706 }
00707
00708
00709
00710 WIREFRAME_ON();
00711 ALPHA_OFF();
00712 ZBUFFER_ON();
00713 }
00714
00716
00718
00719 void DisplayPortalInfo(EDIT_PORTAL *portal)
00720 {
00721 char buf[128];
00722
00723
00724
00725 DumpText(450, 0, 8, 16, 0x00ffff, portal->Region ? "Region" : "Portal");
00726
00727
00728
00729 if (portal->Region)
00730 {
00731 wsprintf(buf, "ID %d", portal->ID1);
00732 DumpText(450, 24, 8, 16, 0xffff00, buf);
00733 }
00734 else
00735 {
00736 wsprintf(buf, "ID1 %d", portal->ID1);
00737 DumpText(450, 24, 8, 16, 0xff0000, buf);
00738 wsprintf(buf, "ID2 %d", portal->ID2);
00739 DumpText(530, 24, 8, 16, 0x00ff00, buf);
00740 }
00741
00742
00743
00744 wsprintf(buf, "Axis %s - %s", EditPortalAxisNames[EditPortalAxis], EditPortalAxisTypeNames[EditPortalAxisType]);
00745 DumpText(450, 48, 8, 16, 0xff00ff, buf);
00746
00747
00748
00749 wsprintf(buf, "Big Bellends: %s", BigBrother ? "Yep" : "Nope");
00750 DumpText(450, 72, 8, 16, 0x0000ff, buf);
00751 }