1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091
|
/************************************************************************************
AstroMenace (Hardcore 3D space shooter with spaceship upgrade possibilities)
Copyright © 2006-2013 Michael Kurinnoy, Viewizard
AstroMenace is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
AstroMenace is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with AstroMenace. If not, see <http://www.gnu.org/licenses/>.
Web Site: http://www.viewizard.com/
Project: http://sourceforge.net/projects/openastromenace/
E-mail: viewizard@viewizard.com
*************************************************************************************/
/// подключаем нужные файлы
#include "BulletExplosion.h"
#include "../../../Game.h"
void DestroyRadiusCollisionAllObject3D(CObject3D *DontTouchObject, VECTOR3D Point, float Radius, float Damage, int ObjectStatus);
void PlayBulletExplosion(VECTOR3D Location, bool NeedExplosionSFX, int ExplType)
{
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// звуковые спец эффекты
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
float fVol = 1.0f;
if (NeedExplosionSFX)
switch (ExplType)
{
// самоликвидация рокет-торпед... и вообще всех снарядов...
// идет со знаком "-" к номеру снаряда при создании
// ракеты землян
case -16:
case -17:
case -18:
case -19:
// ракеты пиратов
case -205:
case -206:
case -209:
case -210:
// мины пиратов
case -214:
case -215:
case -216:
case -217:
// просто малый взрыв
Audio_PlaySound3D(6, fVol, Location, false);
break;
// взрыв и разлет при попадании снарядов в объект
// используем аналогичный номер, как при создании
// Kinetic
case 1:
case 2:
case 3:
case 4:
// пираты (турели + стрельба как Kinetic1)
case 201:
case 202:
case 204:
case 211:
case 212:
// разваливание снарядов
Audio_PlaySound3D(28, fVol, Location, false);
break;
// Ion
case 5:
case 6:
case 7:
// пришельцы (как Kinetic1)
case 101:
// пираты (как Ion2)
case 207:
// разваливание снарядов
Audio_PlaySound3D(29, fVol, Location, false);
break;
// Plasma
case 8:
case 9:
case 10:
// пришельцы (как Kinetic2 и Kinetic3)
case 102:
case 103:
case 104:
case 105:
// пришельцы (как Plasma3 и Plasma2)
case 108:
case 109:
// пираты (как Plasma2)
case 213:
// разваливание снарядов
Audio_PlaySound3D(30, fVol, Location, false);
break;
// Maser - у него луч, тут не учитываем
/* case 11:
break;
case 12:
break;*/
// Antimatter
case 13:
// пришельцы (мина 1 тип)
case 106:
// пришельцы (мина 2 тип)
case 107:
// пираты (как Antimatter)
case 208:
// разваливание снарядов
Audio_PlaySound3D(31, fVol, Location, false);
break;
// Laser - у него луч, тут не учитываем
/* case 14:
break;*/
// Gauss
case 15:
// разваливание снарядов
Audio_PlaySound3D(32, fVol, Location, false);
break;
// ракета
case 16:
// ракеты пиратов
case 205:
// мины пиратов
case 214:
case 215:
case 216:
case 217:
// малый взрыв
Audio_PlaySound3D(6, fVol, Location, false);
break;
// рой
case 17:
// ракеты пиратов
case 206:
// малый взрыв
Audio_PlaySound3D(6, fVol, Location, false);
break;
// торпеда
case 18:
// торпеда пиратов
case 209:
// средний взрыв
Audio_PlaySound3D(7, fVol, Location, false, 2);
break;
// бомба
case 19:
// бомба пиратов
case 210:
// большой взрыв
Audio_PlaySound3D(8, fVol, Location, false, 2);
break;
default:
// если тут, значит взрыв делать не нужно... все и так само уничтожется
break;
}
}
//-----------------------------------------------------------------------------
// Создание взрыва из частей объекта
//-----------------------------------------------------------------------------
void CBulletExplosion::Create(CObject3D *Object, CProjectile *Projectile, int ExplType, VECTOR3D ExplLocation, float Speed, bool NeedExplosionSFX)
{
TimeLastUpdate = Projectile->TimeLastUpdate;
ExplosionTypeByClass = 2;
// 1-взрыв на части, 2-разлет геометрии
int InternalExplosionType = 0;
// AABB нужен, т.к. по нему рисуем, если во фруструме
// копируем AABB, т.к. они сейчас подходят...
AABB[0] = Projectile->AABB[0];
AABB[1] = Projectile->AABB[1];
AABB[2] = Projectile->AABB[2];
AABB[3] = Projectile->AABB[3];
AABB[4] = Projectile->AABB[4];
AABB[5] = Projectile->AABB[5];
AABB[6] = Projectile->AABB[6];
AABB[7] = Projectile->AABB[7];
// сохраняем данные объекта, чтобы не было скачков и не учитывать смещение в меше
SetLocation(Projectile->Location);
Orientation = Projectile->Orientation;
// сохраняем статус объекта, чтобы правильно создавать части-снаряды и обломки
ObjectStatus = Projectile->ObjectStatus;
ExplosionType = ExplType;
// поправка в зависимости от скорости объекта до взрыва
VelocityOrientation = Projectile->Orientation^(-1);
OldSpeed = Speed;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// визуальные эффекты
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
switch (ExplType)
{
// самоликвидация рокет-торпед... и вообще всех снарядов...
// идет со знаком "-" к номеру снаряда при создании
// !!! на минусах не учитываем Object, указатель = 0
// ракеты землян
case -16:
case -17:
case -18:
case -19:
// ракеты пиратов
case -205:
case -206:
case -209:
case -210:
// мины пиратов
case -214:
case -215:
case -216:
case -217:
{
// поправка в зависимости от скорости объекта до взрыва
VelocityOrientation = Projectile->Orientation;
OldSpeed = Projectile->Speed - 0.5f*Projectile->Radius;
Lifetime = 2.0f; // должно соотв. максимальной жизни частицы
// эффект
GraphicFXQuantity = 1;
GraphicFX = new eParticleSystem*[GraphicFXQuantity];
for (int i=0; i<GraphicFXQuantity; i++)
{
GraphicFX[i] = 0;
}
// установка эффекта
GraphicFX[0] = new eParticleSystem;
SetExplosionGFX(GraphicFX[0], 1);
GraphicFX[0]->Speed = 0.5f*Projectile->Radius;
GraphicFX[0]->SpeedVar = vw_Randf0;
GraphicFX[0]->SetStartLocation(Projectile->Location);
if (Projectile->Speed!=0) GraphicFX[0]->Theta = 360.00f;
GraphicFX[0]->ParticlesPerSec = (int)(30*Projectile->Radius);
GraphicFX[0]->CreationType = 1;
GraphicFX[0]->CreationSize = VECTOR3D(AABB[0].x, AABB[0].y, AABB[0].z);
// разварачиваем взрыв по объекту
GraphicFX[0]->RotateSystemAndParticlesByAngle(Projectile->Rotation);
// создаем немного разлетающихся кусков-снарядов
int ttt = (int)(3*Projectile->Radius) + (int)(vw_Randf0*3*Projectile->Radius);
for (int i=0; i<ttt; i++)
{
CProjectile *ProjectileTMP = 0;
ProjectileTMP = new CProjectile;
ProjectileTMP->Create(1);
ProjectileTMP->SetLocation(Location);
ProjectileTMP->SetRotation(VECTOR3D(360.0f*vw_Randf0, 360.0f*vw_Randf0, 360.0f*vw_Randf0));
VECTOR3D TM1 = Projectile->Orientation^Projectile->Speed;
ProjectileTMP->Orientation = TM1 + (ProjectileTMP->Orientation^(Projectile->Radius*6.0f));
ProjectileTMP->Orientation.Normalize();
for (int j=0; j<ProjectileTMP->GraphicFXQuantity; j++)
{
ProjectileTMP->GraphicFX[j]->Direction = ProjectileTMP->Orientation^-1;
ProjectileTMP->GraphicFX[j]->Speed = 1.5f;
ProjectileTMP->GraphicFX[j]->SetStartLocation(Location);
}
ProjectileTMP->ObjectStatus = ObjectStatus;
// учитываем пенальти
ProjectileTMP->Speed = Projectile->Speed + Projectile->Radius*1.5f + 2.0f*vw_Randf0;
ProjectileTMP->SpeedEnd = 0.0f;
ProjectileTMP->SpeedStart = ProjectileTMP->Speed;
ProjectileTMP->Lifetime = Projectile->Age = 2.0f+vw_Randf0;
}
// собираем геометрию и рисуем ее разлет
InternalExplosionType = 2;
}
break;
// взрыв и разлет при попадании снарядов в объект
// используем аналогичный номер, как при создании
// пришельцев
case 101:
case 102:
case 103:
case 104:
case 105:
// фларес
case 203:
// пираты как Kinetic1
case 204:
// пираты как Kinetic2
case 211:
// пираты как Kinetic3
case 212:
// Kinetic
case 1:
case 2:
case 3:
case 4:
// Antimatter
case 13:
// пришельцы (мина 1 тип)
case 106:
// пришельцы (мина 2 тип)
case 107:
// пираты (как Antimatter)
case 208:
// Gauss
case 15:
// поправка в зависимости от скорости объекта до взрыва
if (Object != 0) VelocityOrientation = Object->Orientation;
OldSpeed = Speed;
Lifetime = 0.5f; // должно соотв. максимальной жизни частицы
// просто делаем вспышку нужного цвета
GraphicFXQuantity = 1;
GraphicFX = new eParticleSystem*[GraphicFXQuantity];
for (int i=0; i<GraphicFXQuantity; i++)
{
GraphicFX[i] = 0;
}
// установка эффекта вспышки в месте попадания
if (Projectile->GraphicFX != 0)
if (Projectile->GraphicFX[0]!=0)
{
GraphicFX[0] = new eParticleSystem;
SetExplosionGFX(GraphicFX[0], 0);
float Rexpl = (Projectile->GraphicFX[0]->ColorStart.r + Projectile->GraphicFX[0]->ColorEnd.r)/2.0f;
float Gexpl = (Projectile->GraphicFX[0]->ColorStart.g + Projectile->GraphicFX[0]->ColorEnd.g)/2.0f;
float Bexpl = (Projectile->GraphicFX[0]->ColorStart.b + Projectile->GraphicFX[0]->ColorEnd.b)/2.0f;
GraphicFX[0]->Light = vw_CreatPointLight(VECTOR3D(0.0f,0.0f,0.0f), Rexpl, Gexpl, Bexpl, 0.0f, 0.005f);
GraphicFX[0]->ColorStart.r = Projectile->GraphicFX[0]->ColorStart.r;
GraphicFX[0]->ColorStart.g = Projectile->GraphicFX[0]->ColorStart.g;
GraphicFX[0]->ColorStart.b = Projectile->GraphicFX[0]->ColorStart.b;
GraphicFX[0]->ColorEnd.r = Projectile->GraphicFX[0]->ColorEnd.r;
GraphicFX[0]->ColorEnd.g = Projectile->GraphicFX[0]->ColorEnd.g;
GraphicFX[0]->ColorEnd.b = Projectile->GraphicFX[0]->ColorEnd.b;
GraphicFX[0]->Speed = 150.0f;
GraphicFX[0]->ParticlesPerSec = Projectile->GraphicFX[0]->ParticlesPerSec;
GraphicFX[0]->SizeStart = Projectile->GraphicFX[0]->SizeStart;
GraphicFX[0]->SizeEnd = Projectile->GraphicFX[0]->SizeEnd;
GraphicFX[0]->SizeVar = Projectile->GraphicFX[0]->SizeVar;
GraphicFX[0]->Life = Lifetime;
GraphicFX[0]->NeedStop = false;
GraphicFX[0]->SetStartLocation(ExplLocation);
}
Projectile->NeedStopPartic = true;
NeedStop = false;
break;
// Ion
case 5:
case 6:
case 7:
// пираты (как Ion2)
case 207:
// Plasma
case 8:
case 9:
case 10:
// пришельцы (как Plasma3 и Plasma2)
case 108:
case 109:
// пираты (как Plasma2)
case 213:
// поправка в зависимости от скорости объекта до взрыва
if (Object != 0) VelocityOrientation = Object->Orientation;
OldSpeed = Speed;
Lifetime = 0.5f; // должно соотв. максимальной жизни частицы
// просто делаем вспышку нужного цвета
GraphicFXQuantity = 1;
GraphicFX = new eParticleSystem*[GraphicFXQuantity];
for (int i=0; i<GraphicFXQuantity; i++)
{
GraphicFX[i] = 0;
}
// установка эффекта вспышки в месте попадания
if (Projectile->GraphicFX != 0)
if (Projectile->GraphicFX[0]!=0)
{
GraphicFX[0] = new eParticleSystem;
SetExplosionGFX(GraphicFX[0], 0);
float Rexpl = (Projectile->GraphicFX[0]->ColorStart.r + Projectile->GraphicFX[0]->ColorEnd.r)/2.0f;
float Gexpl = (Projectile->GraphicFX[0]->ColorStart.g + Projectile->GraphicFX[0]->ColorEnd.g)/2.0f;
float Bexpl = (Projectile->GraphicFX[0]->ColorStart.b + Projectile->GraphicFX[0]->ColorEnd.b)/2.0f;
GraphicFX[0]->Light = vw_CreatPointLight(VECTOR3D(0.0f,0.0f,0.0f), Rexpl, Gexpl, Bexpl, 0.0f, 0.005f);
GraphicFX[0]->ColorStart.r = Projectile->GraphicFX[0]->ColorStart.r;
GraphicFX[0]->ColorStart.g = Projectile->GraphicFX[0]->ColorStart.g;
GraphicFX[0]->ColorStart.b = Projectile->GraphicFX[0]->ColorStart.b;
GraphicFX[0]->ColorEnd.r = Projectile->GraphicFX[0]->ColorEnd.r;
GraphicFX[0]->ColorEnd.g = Projectile->GraphicFX[0]->ColorEnd.g;
GraphicFX[0]->ColorEnd.b = Projectile->GraphicFX[0]->ColorEnd.b;
GraphicFX[0]->Speed = 150.0f;
GraphicFX[0]->ParticlesPerSec = Projectile->GraphicFX[0]->ParticlesPerSec;
GraphicFX[0]->SizeStart = Projectile->GraphicFX[0]->SizeStart;
GraphicFX[0]->SizeEnd = Projectile->GraphicFX[0]->SizeEnd;
GraphicFX[0]->SizeVar = Projectile->GraphicFX[0]->SizeVar;
GraphicFX[0]->Life = Lifetime;
GraphicFX[0]->NeedStop = false;
GraphicFX[0]->SetStartLocation(ExplLocation);
}
Projectile->NeedStopPartic = true;
NeedStop = false;
break;
// Maser
/* case 11:
break;
case 12:
break;*/
// Laser
/* case 14:
break;*/
// ракета
case 16:
// мины пиратов
case 214:
case 215:
case 216:
case 217:
{
// поправка в зависимости от скорости объекта до взрыва
VelocityOrientation = Projectile->Orientation^(-1);
OldSpeed = Speed = 0.0f;
Lifetime = 2.0f; // должно соотв. максимальной жизни частицы
// эффект
GraphicFXQuantity = 1;
GraphicFX = new eParticleSystem*[GraphicFXQuantity];
for (int i=0; i<GraphicFXQuantity; i++)
{
GraphicFX[i] = 0;
}
// установка эффекта
GraphicFX[0] = new eParticleSystem;
SetExplosionGFX(GraphicFX[0], 10);
GraphicFX[0]->SetStartLocation(Projectile->Location);
// создаем немного разлетающихся кусков-снарядов
int ttt = (int)(3*Projectile->Radius) + (int)(vw_Randf1*1*Projectile->Radius);
for (int i=0; i<ttt; i++)
{
CProjectile *ProjectileTMP = 0;
ProjectileTMP = new CProjectile;
ProjectileTMP->Create(1);
ProjectileTMP->SetLocation(Location);
ProjectileTMP->SetRotation(VECTOR3D(20.0f*vw_Randf0, 360.0f*vw_Randf0, 0.0f));
VECTOR3D TM1 = Projectile->Orientation;
ProjectileTMP->Orientation = TM1 + (ProjectileTMP->Orientation^(Projectile->Radius*2.0f));
ProjectileTMP->Orientation.Normalize();
for (int j=0; j<ProjectileTMP->GraphicFXQuantity; j++)
{
ProjectileTMP->GraphicFX[j]->Direction = ProjectileTMP->Orientation^-1;
ProjectileTMP->GraphicFX[j]->Speed = ProjectileTMP->GraphicFX[j]->Speed/2.0f;
ProjectileTMP->GraphicFX[j]->SetStartLocation(Location);
}
ProjectileTMP->ObjectStatus = ObjectStatus;
ProjectileTMP->SpeedEnd = ProjectileTMP->Speed/7.0f;
ProjectileTMP->SpeedStart = ProjectileTMP->Speed/4.0f;
ProjectileTMP->Lifetime = ProjectileTMP->Age = 2.0f+vw_Randf0;
}
// собираем геометрию и рисуем ее разлет
InternalExplosionType = 2;
}
break;
// рой
case 17:
{
// поправка в зависимости от скорости объекта до взрыва
VelocityOrientation = Projectile->Orientation^(-1);
OldSpeed = Speed = 0.0f;
Lifetime = 2.0f; // должно соотв. максимальной жизни частицы
// эффект
GraphicFXQuantity = 1;
GraphicFX = new eParticleSystem*[GraphicFXQuantity];
for (int i=0; i<GraphicFXQuantity; i++)
{
GraphicFX[i] = 0;
}
// установка эффекта
GraphicFX[0] = new eParticleSystem;
SetExplosionGFX(GraphicFX[0], 10);
GraphicFX[0]->ParticlesPerSec = 30;
GraphicFX[0]->CreationSize = VECTOR3D(2.0f,0.3f,2.0f);
GraphicFX[0]->SetStartLocation(Projectile->Location);
// создаем немного разлетающихся кусков-снарядов
int ttt = (int)(1*Projectile->Radius) + (int)(vw_Randf1*1*Projectile->Radius);
//vw_LogMessage(LOG_MESS_INF, "%i", ttt);
for (int i=0; i<ttt; i++)
{
CProjectile *ProjectileTMP = 0;
ProjectileTMP = new CProjectile;
ProjectileTMP->Create(1);
ProjectileTMP->SetLocation(Location);
ProjectileTMP->SetRotation(VECTOR3D(20.0f*vw_Randf0, 360.0f*vw_Randf0, 0.0f));
VECTOR3D TM1 = Projectile->Orientation;//^Speed;
ProjectileTMP->Orientation = TM1 + (ProjectileTMP->Orientation^(Projectile->Radius*2.0f));
ProjectileTMP->Orientation.Normalize();
for (int j=0; j<ProjectileTMP->GraphicFXQuantity; j++)
{
ProjectileTMP->GraphicFX[j]->Direction = ProjectileTMP->Orientation^-1;
ProjectileTMP->GraphicFX[j]->Speed = ProjectileTMP->GraphicFX[j]->Speed/2.0f;
ProjectileTMP->GraphicFX[j]->SetStartLocation(Location);
}
ProjectileTMP->ObjectStatus = ObjectStatus;
ProjectileTMP->SpeedEnd = ProjectileTMP->Speed/7.0f;
ProjectileTMP->SpeedStart = ProjectileTMP->Speed/4.0f;
ProjectileTMP->Lifetime = ProjectileTMP->Age = 2.0f+vw_Randf0;
}
// собираем геометрию и рисуем ее разлет
InternalExplosionType = 2;
}
break;
// торпеда
case 18:
// торпеда пиратов
case 209:
{
// убиваем всех, кто рядом
DestroyRadiusCollisionAllObject3D(Object, Projectile->Location, 75.0f, Projectile->DamageHull, Projectile->ObjectStatus);
VelocityOrientation = Projectile->Orientation^(-1);
OldSpeed = Speed = 0.0f;
Lifetime = 2.0f; // должно соотв. максимальной жизни частицы
// эффект
GraphicFXQuantity = 1;
GraphicFX = new eParticleSystem*[GraphicFXQuantity];
for (int i=0; i<GraphicFXQuantity; i++)
{
GraphicFX[i] = 0;
}
// установка эффекта
GraphicFX[0] = new eParticleSystem;
SetExplosionGFX(GraphicFX[0], 8);
GraphicFX[0]->SetStartLocation(Projectile->Location);
// создаем немного разлетающихся кусков-снарядов
int ttt = (int)(2*Projectile->Radius) + (int)(vw_Randf1*1*Projectile->Radius);
for (int i=0; i<ttt; i++)
{
CProjectile *ProjectileTMP = 0;
ProjectileTMP = new CProjectile;
ProjectileTMP->Create(2);
ProjectileTMP->Num = 1;
ProjectileTMP->SetLocation(Location);
ProjectileTMP->SetRotation(VECTOR3D(20.0f*vw_Randf0, 360.0f*vw_Randf0, 0.0f));
VECTOR3D TM1 = Projectile->Orientation;//^Speed;
ProjectileTMP->Orientation = TM1 + (ProjectileTMP->Orientation^(Projectile->Radius*2.0f));
ProjectileTMP->Orientation.Normalize();
for (int j=0; j<ProjectileTMP->GraphicFXQuantity; j++)
{
ProjectileTMP->GraphicFX[j]->Direction = ProjectileTMP->Orientation^-1;
ProjectileTMP->GraphicFX[j]->Speed = ProjectileTMP->GraphicFX[j]->Speed/2.0f;
ProjectileTMP->GraphicFX[j]->SetStartLocation(Location);
}
ProjectileTMP->ObjectStatus = ObjectStatus;
ProjectileTMP->SpeedEnd = ProjectileTMP->Speed/7.0f;
ProjectileTMP->SpeedStart = ProjectileTMP->Speed/4.0f;
ProjectileTMP->Lifetime = ProjectileTMP->Age = 2.0f+vw_Randf0;
}
// собираем геометрию и рисуем ее разлет
InternalExplosionType = 2;
}
break;
// бомба
case 19:
// бомба пиратов
case 210:
{
// убиваем всех, кто рядом
DestroyRadiusCollisionAllObject3D(Object, Projectile->Location, 150.0f, Projectile->DamageHull, Projectile->ObjectStatus);
VelocityOrientation = Projectile->Orientation^(-1);
OldSpeed = Speed = 0.0f;
Lifetime = 2.0f; // должно соотв. максимальной жизни частицы
// эффект
GraphicFXQuantity = 2;
GraphicFX = new eParticleSystem*[GraphicFXQuantity];
for (int i=0; i<GraphicFXQuantity; i++)
{
GraphicFX[i] = 0;
}
// установка эффекта
GraphicFX[0] = new eParticleSystem;
SetExplosionGFX(GraphicFX[0], 7);
GraphicFX[0]->SetStartLocation(Projectile->Location);
GraphicFX[1] = new eParticleSystem;
SetExplosionGFX(GraphicFX[1], 9);
GraphicFX[1]->SetStartLocation(Projectile->Location);
// создаем немного разлетающихся кусков-снарядов
for (int i=0; i<4; i++)
{
CProjectile *ProjectileTMP = 0;
ProjectileTMP = new CProjectile;
ProjectileTMP->Create(3);
ProjectileTMP->Num = 1;
ProjectileTMP->SetLocation(Location);
ProjectileTMP->SetRotation(VECTOR3D(5.0f*vw_Randf0, 360.0f*vw_Randf0, 0.0f));
VECTOR3D TM1 = Projectile->Orientation;
ProjectileTMP->Orientation = TM1 + (ProjectileTMP->Orientation^(Projectile->Radius*4.0f));
ProjectileTMP->Orientation.Normalize();
for (int j=0; j<ProjectileTMP->GraphicFXQuantity; j++)
{
ProjectileTMP->GraphicFX[j]->Direction = ProjectileTMP->Orientation^-1;
ProjectileTMP->GraphicFX[j]->Speed = ProjectileTMP->GraphicFX[j]->Speed/2.0f;
ProjectileTMP->GraphicFX[j]->SetStartLocation(Location);
}
ProjectileTMP->ObjectStatus = ObjectStatus;
ProjectileTMP->SpeedEnd = ProjectileTMP->Speed/6.0f;
ProjectileTMP->SpeedStart = ProjectileTMP->Speed/2.0f;
ProjectileTMP->Lifetime = ProjectileTMP->Age = 3.0f+vw_Randf0;
}
// создаем немного разлетающихся кусков-снарядов
int ttt = (int)(3*Projectile->Radius) + (int)(vw_Randf1*1*Projectile->Radius);
for (int i=0; i<ttt; i++)
{
CProjectile *ProjectileTMP = 0;
ProjectileTMP = new CProjectile;
ProjectileTMP->Create(2);
ProjectileTMP->Num = 1;
ProjectileTMP->SetLocation(Location);
ProjectileTMP->SetRotation(VECTOR3D(5.0f*vw_Randf0, 360.0f*vw_Randf0, 0.0f));
for (int j=0; j<ProjectileTMP->GraphicFXQuantity; j++)
{
ProjectileTMP->GraphicFX[j]->Direction = ProjectileTMP->Orientation^-1;
ProjectileTMP->GraphicFX[j]->Speed = ProjectileTMP->GraphicFX[j]->Speed/2.0f;
ProjectileTMP->GraphicFX[j]->SetStartLocation(Location);
}
ProjectileTMP->ObjectStatus = ObjectStatus;
ProjectileTMP->SpeedEnd = ProjectileTMP->Speed/6.0f;
ProjectileTMP->SpeedStart = ProjectileTMP->Speed/2.0f;
ProjectileTMP->Lifetime = ProjectileTMP->Age = 3.0f+vw_Randf0;
}
// создаем немного разлетающихся кусков-снарядов
ttt = (int)(3*Projectile->Radius) + (int)(vw_Randf1*1*Projectile->Radius);
for (int i=0; i<ttt; i++)
{
CProjectile *ProjectileTMP = 0;
ProjectileTMP = new CProjectile;
ProjectileTMP->Create(3);
ProjectileTMP->Num = 1;
ProjectileTMP->SetLocation(Location);
ProjectileTMP->SetRotation(VECTOR3D(5.0f*vw_Randf0, 360.0f*vw_Randf0, 0.0f));
for (int j=0; j<ProjectileTMP->GraphicFXQuantity; j++)
{
ProjectileTMP->GraphicFX[j]->Direction = ProjectileTMP->Orientation^-1;
ProjectileTMP->GraphicFX[j]->Speed = ProjectileTMP->GraphicFX[j]->Speed/2.0f;
ProjectileTMP->GraphicFX[j]->SetStartLocation(Location);
}
ProjectileTMP->ObjectStatus = ObjectStatus;
ProjectileTMP->SpeedEnd = ProjectileTMP->Speed/6.0f;
ProjectileTMP->SpeedStart = ProjectileTMP->Speed/2.0f;
ProjectileTMP->Lifetime = ProjectileTMP->Age = 3.0f+vw_Randf0;
}
ttt = (int)(3*Projectile->Radius) + (int)(vw_Randf1*5*Projectile->Radius);
for (int i=0; i<ttt; i++)
{
CProjectile *ProjectileTMP = 0;
ProjectileTMP = new CProjectile;
ProjectileTMP->Create(1);
ProjectileTMP->SetLocation(Location);
ProjectileTMP->SetRotation(VECTOR3D(5.0f*vw_Randf0, 360.0f*vw_Randf0, 0.0f));
for (int j=0; j<ProjectileTMP->GraphicFXQuantity; j++)
{
ProjectileTMP->GraphicFX[j]->Direction = ProjectileTMP->Orientation^-1;
ProjectileTMP->GraphicFX[j]->Speed = ProjectileTMP->GraphicFX[j]->Speed/2.0f;
ProjectileTMP->GraphicFX[j]->SetStartLocation(Location);
}
ProjectileTMP->ObjectStatus = ObjectStatus;
ProjectileTMP->SpeedEnd = ProjectileTMP->Speed/6.0f;
ProjectileTMP->SpeedStart = ProjectileTMP->Speed/2.0f;
ProjectileTMP->Lifetime = ProjectileTMP->Age = 3.0f+vw_Randf0;
}
// создаем немного разлетающихся кусков-снарядов
ttt = (int)(5*Projectile->Radius) + (int)(vw_Randf1*3*Projectile->Radius);
for (int i=0; i<ttt; i++)
{
CProjectile *ProjectileTMP = 0;
ProjectileTMP = new CProjectile;
ProjectileTMP->Create(5);
ProjectileTMP->Num = 1;
ProjectileTMP->SetLocation(Location);
ProjectileTMP->SetRotation(VECTOR3D(20.0f*vw_Randf0, 360.0f*vw_Randf0, 0.0f));
for (int j=0; j<ProjectileTMP->GraphicFXQuantity; j++)
{
ProjectileTMP->GraphicFX[j]->Direction = ProjectileTMP->Orientation^-1;
ProjectileTMP->GraphicFX[j]->Speed = ProjectileTMP->GraphicFX[j]->Speed/2.0f;
ProjectileTMP->GraphicFX[j]->SetStartLocation(Location);
}
ProjectileTMP->ObjectStatus = ObjectStatus;
ProjectileTMP->SpeedEnd = ProjectileTMP->Speed/6.0f;
ProjectileTMP->SpeedStart = ProjectileTMP->Speed/2.0f;
ProjectileTMP->Lifetime = ProjectileTMP->Age = 3.0f+vw_Randf0;
}
// собираем геометрию и рисуем ее разлет
InternalExplosionType = 2;
}
break;
// ракета пиратов
case 205:
case 206:
{
// поправка в зависимости от скорости объекта до взрыва
VelocityOrientation = Projectile->Orientation^(-1);
OldSpeed = Speed = 0.0f;
Lifetime = 2.0f; // должно соотв. максимальной жизни частицы
// эффект
GraphicFXQuantity = 1;
GraphicFX = new eParticleSystem*[GraphicFXQuantity];
for (int i=0; i<GraphicFXQuantity; i++)
{
GraphicFX[i] = 0;
}
// установка эффекта
GraphicFX[0] = new eParticleSystem;
SetExplosionGFX(GraphicFX[0], 10);
GraphicFX[0]->SetStartLocation(Projectile->Location);
// собираем геометрию и рисуем ее разлет
InternalExplosionType = 2;
}
break;
default:
// если тут, значит взрыв делать не нужно... все и так само уничтожется
break;
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// взрыв с разлетом геометрии
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if (InternalExplosionType == 2)
{
// создаем новые данные, переносим туда
// объекты малы, по этому не применяем сдесь настройки качества взрыва, делаем со всей геометрией
DrawObjectQuantity = Projectile->DrawObjectQuantity;
Texture = new eTexture*[DrawObjectQuantity];
DrawObjectList = new eObjectBlock[DrawObjectQuantity];
for (int i=0; i<DrawObjectQuantity; i++)
{
Texture[i] = Projectile->Texture[i];
// копируем данные
memcpy(&(DrawObjectList[i]), &(Projectile->DrawObjectList[i]), sizeof(eObjectBlock));
// делаем изменения
DrawObjectList[i].VBO = 0;
DrawObjectList[i].VertexBuffer = 0;
DrawObjectList[i].IBO = 0;
DrawObjectList[i].IndexBuffer = 0;
DrawObjectList[i].VAO = 0;
DrawObjectList[i].NeedDestroyDataInObjectBlock = true; // удалять в объекте
DrawObjectList[i].RangeStart = 0;
// если у нас включены и работают шейдеры, надо приготовить место для данных + изменить формат и шаг
if (Setup.UseGLSL)
{
DrawObjectList[i].VertexStride = 3+3+6;
DrawObjectList[i].VertexFormat = RI_3f_XYZ | RI_3f_NORMAL | RI_3_TEX | RI_2f_TEX;
}
// выделяем память для данных
DrawObjectList[i].VertexBuffer = new float[DrawObjectList[i].VertexStride*DrawObjectList[i].VertexCount];
// делаем поворот геометрии объекта чтобы правильно сделать разлет частиц
VECTOR3D TMP;
for (int j=0; j<DrawObjectList[i].VertexCount; j++)
{
int j1 = j*DrawObjectList[i].VertexStride;
int j2;
if (Projectile->DrawObjectList[i].IndexBuffer != 0)
j2 = Projectile->DrawObjectList[i].IndexBuffer[Projectile->DrawObjectList[i].RangeStart+j]*Projectile->DrawObjectList[i].VertexStride;
else
j2 = (Projectile->DrawObjectList[i].RangeStart+j)*Projectile->DrawObjectList[i].VertexStride;
TMP.x = Projectile->DrawObjectList[i].VertexBuffer[j2] + DrawObjectList[i].Location.x;
TMP.y = Projectile->DrawObjectList[i].VertexBuffer[j2+1] + DrawObjectList[i].Location.y;
TMP.z = Projectile->DrawObjectList[i].VertexBuffer[j2+2] + DrawObjectList[i].Location.z;
Matrix33CalcPoint(&TMP, Projectile->CurrentRotationMat);
// координаты
DrawObjectList[i].VertexBuffer[j1] = TMP.x;
DrawObjectList[i].VertexBuffer[j1+1] = TMP.y;
DrawObjectList[i].VertexBuffer[j1+2] = TMP.z;
// нормали
TMP.x = Projectile->DrawObjectList[i].VertexBuffer[j2+3];
TMP.y = Projectile->DrawObjectList[i].VertexBuffer[j2+4];
TMP.z = Projectile->DrawObjectList[i].VertexBuffer[j2+5];
Matrix33CalcPoint(&TMP, Projectile->CurrentRotationMat);
DrawObjectList[i].VertexBuffer[j1+3] = TMP.x;
DrawObjectList[i].VertexBuffer[j1+4] = TMP.y;
DrawObjectList[i].VertexBuffer[j1+5] = TMP.z;
// текстура
DrawObjectList[i].VertexBuffer[j1+6] = Projectile->DrawObjectList[i].VertexBuffer[j2+6];
DrawObjectList[i].VertexBuffer[j1+7] = Projectile->DrawObjectList[i].VertexBuffer[j2+7];
}
DrawObjectList[i].Location = VECTOR3D(0.0f,0.0f,0.0f);
// копируем индексный буфер блока
DrawObjectList[i].IndexBuffer = new unsigned int[DrawObjectList[i].VertexCount];
memcpy(DrawObjectList[i].IndexBuffer, Projectile->DrawObjectList[i].IndexBuffer,
DrawObjectList[i].VertexCount*sizeof(unsigned int));
}
float tRadius2 = Projectile->Radius/1.5f;
// для каждого треугольника - свои данные (фактически, у нас 1 объект, с ним и работаем)
int Count = 0;
ExplosionPieceData = new CExplosionPiece[DrawObjectList[0].VertexCount/3];
for (int i=0; i<DrawObjectList[0].VertexCount; i+=3)
{
ExplosionPieceData[Count].Velocity.x = DrawObjectList[0].VertexBuffer[i*DrawObjectList[0].VertexStride];
ExplosionPieceData[Count].Velocity.y = DrawObjectList[0].VertexBuffer[i*DrawObjectList[0].VertexStride+1];
ExplosionPieceData[Count].Velocity.z = DrawObjectList[0].VertexBuffer[i*DrawObjectList[0].VertexStride+2];
float VelocityTMP = vw_Randf0*tRadius2;
// записываем центр треугольника, оно же базовое ускорение + цент UV, нужно для шейдера
if (Setup.UseGLSL)
{
// Velocity/центр треугольника
DrawObjectList[0].VertexBuffer[DrawObjectList[0].VertexStride*i+8] = ExplosionPieceData[Count].Velocity.x;
DrawObjectList[0].VertexBuffer[DrawObjectList[0].VertexStride*i+9] = ExplosionPieceData[Count].Velocity.y;
DrawObjectList[0].VertexBuffer[DrawObjectList[0].VertexStride*i+10] = ExplosionPieceData[Count].Velocity.z;
DrawObjectList[0].VertexBuffer[DrawObjectList[0].VertexStride*(i+1)+8] = ExplosionPieceData[Count].Velocity.x;
DrawObjectList[0].VertexBuffer[DrawObjectList[0].VertexStride*(i+1)+9] = ExplosionPieceData[Count].Velocity.y;
DrawObjectList[0].VertexBuffer[DrawObjectList[0].VertexStride*(i+1)+10] = ExplosionPieceData[Count].Velocity.z;
DrawObjectList[0].VertexBuffer[DrawObjectList[0].VertexStride*(i+2)+8] = ExplosionPieceData[Count].Velocity.x;
DrawObjectList[0].VertexBuffer[DrawObjectList[0].VertexStride*(i+2)+9] = ExplosionPieceData[Count].Velocity.y;
DrawObjectList[0].VertexBuffer[DrawObjectList[0].VertexStride*(i+2)+10] = ExplosionPieceData[Count].Velocity.z;
// acc
DrawObjectList[0].VertexBuffer[DrawObjectList[0].VertexStride*i+11] = VelocityTMP;
DrawObjectList[0].VertexBuffer[DrawObjectList[0].VertexStride*(i+1)+11] = DrawObjectList[0].VertexBuffer[DrawObjectList[0].VertexStride*i+11];
DrawObjectList[0].VertexBuffer[DrawObjectList[0].VertexStride*(i+2)+11] = DrawObjectList[0].VertexBuffer[DrawObjectList[0].VertexStride*i+11];
}
// в данном случае, это и есть направление, потому что геометрия в точке 0,0,0
ExplosionPieceData[Count].Velocity = ExplosionPieceData[Count].Velocity^VelocityTMP;
ExplosionPieceData[Count].Life = 1.0f+vw_Randf1/2.0f;
// делаем анализ для ААBB, смотрим отлет частицы
float tmpSpeed = ExplosionPieceData[Count].Velocity.x*ExplosionPieceData[Count].Velocity.x +
ExplosionPieceData[Count].Velocity.y*ExplosionPieceData[Count].Velocity.y +
ExplosionPieceData[Count].Velocity.z*ExplosionPieceData[Count].Velocity.z;
if (tmpSpeed > AABBSpeed) AABBSpeed = tmpSpeed;
Count++;
}
// тк был квадрат, теперь вытягиваем нормальное значение
AABBSpeed = sqrtf(AABBSpeed);
// установка шейдера
if (Setup.UseGLSL)
{
DrawObjectList[0].ShaderType = 2;
// дельта скорости
DrawObjectList[0].ShaderData[0] = 1.0f;
// общий коэф расстояния
DrawObjectList[0].ShaderData[1] = 0.0f;
}
// удаляем старые буферы, если они есть, создаем новые
// ! индексный буфер не трогаем, его не надо пересоздавать вообще
if (DrawObjectList[0].VBO != 0)
{
vw_DeleteVBO(*DrawObjectList[0].VBO); delete DrawObjectList[0].VBO; DrawObjectList[0].VBO = 0;
}
if (DrawObjectList[0].VAO != 0)
{
vw_DeleteVAO(*DrawObjectList[0].VAO); delete DrawObjectList[0].VAO; DrawObjectList[0].VAO = 0;
}
// делаем VBO
DrawObjectList[0].VBO = new unsigned int;
if (!vw_BuildVBO(DrawObjectList[0].VertexCount, DrawObjectList[0].VertexBuffer, DrawObjectList[0].VertexStride, DrawObjectList[0].VBO))
{
delete DrawObjectList[0].VBO; DrawObjectList[0].VBO=0;
}
// делаем IBO, создаем его один раз, если его нет
if (DrawObjectList[0].IBO == 0)
{
DrawObjectList[0].IBO = new unsigned int;
if (!vw_BuildIBO(DrawObjectList[0].VertexCount, DrawObjectList[0].IndexBuffer, DrawObjectList[0].IBO))
{
delete DrawObjectList[0].IBO; DrawObjectList[0].IBO=0;
}
}
// делаем VAO
DrawObjectList[0].VAO = new unsigned int;
if (!vw_BuildVAO(DrawObjectList[0].VAO, DrawObjectList[0].VertexCount, DrawObjectList[0].VertexFormat, DrawObjectList[0].VertexBuffer,
DrawObjectList[0].VertexStride*sizeof(float), DrawObjectList[0].VBO,
DrawObjectList[0].RangeStart, DrawObjectList[0].IndexBuffer, DrawObjectList[0].IBO))
{
delete DrawObjectList[0].VAO; DrawObjectList[0].VAO=0;
}
}
// дальше, если не видем точку взрыва не делать... проверяем...
if (!vw_BoxInFrustum(Location + AABB[6], Location + AABB[0]))
{
return;
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// звуковые спец эффекты
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
PlayBulletExplosion(Location, NeedExplosionSFX, ExplType);
// делаем сотрясание камеры, если нужно
switch (ExplType)
{
// торпеда
case 18:
// торпеда пиратов
case 209:
GameCameraSetExplosion(ExplLocation, 0.5f);
break;
// бомба
case 19:
// бомба пиратов
case 210:
GameCameraSetExplosion(ExplLocation, 1.5f);
break;
}
}
|