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