|
30 | 30 | // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// |
31 | 31 | #include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine |
32 | 32 |
|
| 33 | +#define DEFINE_SHADOW_NAMES |
| 34 | + |
33 | 35 | #include "GameClient/FXList.h" |
34 | 36 |
|
35 | 37 | #include "Common/DrawModule.h" |
|
50 | 52 | #include "GameClient/Drawable.h" |
51 | 53 | #include "GameClient/ParticleSys.h" |
52 | 54 | #include "GameLogic/PartitionManager.h" |
| 55 | +#include "GameClient/Shadow.h" |
| 56 | +#include "../../../GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DModelDraw.h" |
| 57 | +#include "../../../GameEngineDevice/Include/W3DDevice/GameClient/W3DShadow.h" |
53 | 58 |
|
54 | 59 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
55 | 60 | // PUBLIC DATA //////////////////////////////////////////////////////////////////////////////////// |
@@ -467,6 +472,119 @@ class RayEffectFXNugget : public FXNugget |
467 | 472 | }; |
468 | 473 | EMPTY_DTOR(RayEffectFXNugget) |
469 | 474 |
|
| 475 | + |
| 476 | +//------------------------------------------------------------------------------------------------- |
| 477 | +class DecalFXNugget : public FXNugget |
| 478 | +{ |
| 479 | + MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(DecalFXNugget, "DecalFXNugget") |
| 480 | +public: |
| 481 | + |
| 482 | + DecalFXNugget() |
| 483 | + { |
| 484 | + m_templateName.set("GenericDecal"); // TODO |
| 485 | + //m_templateName = AsciiString::TheEmptyString; |
| 486 | + //m_textureName = AsciiString::TheEmptyString; |
| 487 | + //m_opacity = 1.0; ///< value between 0 and 1 |
| 488 | + //m_color = 0; ///< color in ARGB format. (Alpha is ignored). |
| 489 | + m_lifetime = 0; |
| 490 | + /* m_fadeOutTime = 0; |
| 491 | + m_fadeInTime = 0; |
| 492 | + m_type = 0; /// type of projection |
| 493 | + m_decalSizeX = 0.0; /// 1/(world space extent of texture in x direction) |
| 494 | + m_decalSizeY = 0.0; /// 1/(world space extent of texture in y direction)*/ |
| 495 | + m_offset.x = m_offset.y = m_offset.z = 0; |
| 496 | + m_angle = 0.0; |
| 497 | + m_orientToObject = FALSE; |
| 498 | + m_randomAngle = FALSE; |
| 499 | + m_probability = 1.0f; |
| 500 | + } |
| 501 | + |
| 502 | + virtual void doFXPos(const Coord3D* primary, const Matrix3D* primaryMtx, const Real primarySpeed, const Coord3D* secondary, const Real /*overrideRadius*/, FXSurfaceInfo* /*surfaceInfo*/) const |
| 503 | + { |
| 504 | + if (m_probability <= GameClientRandomValueReal(0, 1)) |
| 505 | + return; |
| 506 | + |
| 507 | + if (primary) |
| 508 | + { |
| 509 | + Coord3D offset = m_offset; |
| 510 | + if (primaryMtx) { |
| 511 | + if (m_orientToObject) |
| 512 | + { |
| 513 | + adjustVector(&offset, primaryMtx); |
| 514 | + } |
| 515 | + } |
| 516 | + |
| 517 | + Drawable* drawable = TheThingFactory->newDrawable(TheThingFactory->findTemplate(m_templateName)); |
| 518 | + if (!drawable) |
| 519 | + return; |
| 520 | + |
| 521 | + // Does it even make sense to set the matrix? |
| 522 | + if (primaryMtx && m_orientToObject) |
| 523 | + drawable->setTransformMatrix(primaryMtx); |
| 524 | + |
| 525 | + Coord3D newPos; |
| 526 | + newPos.x = primary->x + offset.x; |
| 527 | + newPos.y = primary->y + offset.y; |
| 528 | + newPos.z = primary->z + offset.z; |
| 529 | + drawable->setPosition(&newPos); |
| 530 | + |
| 531 | + if (m_randomAngle) |
| 532 | + drawable->setOrientation(GameClientRandomValueReal(0, PI * 2)); |
| 533 | + |
| 534 | + drawable->setExpirationDate(TheGameLogic->getFrame() + m_lifetime); |
| 535 | + } |
| 536 | + else |
| 537 | + { |
| 538 | + DEBUG_CRASH(("You must have a primary source for this effect")); |
| 539 | + } |
| 540 | + } |
| 541 | + |
| 542 | + virtual void doFXObj(const Object* primary, const Object* secondary, FXSurfaceInfo* surfaceInfo) const |
| 543 | + { |
| 544 | + if (primary) |
| 545 | + { |
| 546 | + doFXPos(primary->getPosition(), primary->getTransformMatrix(), 0.0f, nullptr, 0.0f, surfaceInfo); |
| 547 | + } |
| 548 | + else |
| 549 | + { |
| 550 | + DEBUG_CRASH(("You must have a primary source for this effect")); |
| 551 | + } |
| 552 | + } |
| 553 | + |
| 554 | + static void parse(INI* ini, void* instance, void* /*store*/, const void* /*userData*/) |
| 555 | + { |
| 556 | + static const FieldParse myFieldParse[] = |
| 557 | + { |
| 558 | + { "DecalName", INI::parseAsciiString, nullptr, offsetof(DecalFXNugget, m_templateName) }, |
| 559 | + { "Lifetime", INI::parseDurationUnsignedInt, nullptr, offsetof(DecalFXNugget, m_lifetime) }, |
| 560 | + { "Offset", INI::parseCoord3D, nullptr, offsetof(DecalFXNugget, m_offset) }, |
| 561 | + { "Angle", INI::parseReal, nullptr, offsetof(DecalFXNugget, m_angle) }, |
| 562 | + { "RandomAngle", INI::parseBool, nullptr, offsetof(DecalFXNugget, m_randomAngle) }, |
| 563 | + { "OrientToObject", INI::parseBool, nullptr, offsetof(DecalFXNugget, m_orientToObject) }, |
| 564 | + { "Probability", INI::parseReal, nullptr, offsetof(DecalFXNugget, m_probability) }, |
| 565 | + { nullptr, nullptr, nullptr, 0 } |
| 566 | + }; |
| 567 | + |
| 568 | + DecalFXNugget* nugget = newInstance(DecalFXNugget); |
| 569 | + ini->initFromINI(nugget, myFieldParse); |
| 570 | + ((FXList*)instance)->addFXNugget(nugget); |
| 571 | + } |
| 572 | + |
| 573 | +private: |
| 574 | + AsciiString m_templateName; |
| 575 | + UnsignedInt m_lifetime; |
| 576 | + Coord3D m_offset; |
| 577 | + Real m_angle; |
| 578 | + Bool m_orientToObject; |
| 579 | + Bool m_randomAngle; |
| 580 | + |
| 581 | + // spawn parameters |
| 582 | + Real m_probability; |
| 583 | + // TODO: Height/Surface, etc. |
| 584 | +}; |
| 585 | +EMPTY_DTOR(DecalFXNugget) |
| 586 | + |
| 587 | + |
470 | 588 | //------------------------------------------------------------------------------------------------- |
471 | 589 | class LightPulseFXNugget : public FXNugget |
472 | 590 | { |
@@ -1025,6 +1143,7 @@ static const FieldParse TheFXListFieldParse[] = |
1025 | 1143 | { "TerrainScorch", TerrainScorchFXNugget::parse, nullptr, 0}, |
1026 | 1144 | { "ParticleSystem", ParticleSystemFXNugget::parse, nullptr, 0}, |
1027 | 1145 | { "FXListAtBonePos", FXListAtBonePosFXNugget::parse, nullptr, 0}, |
| 1146 | + { "Decal", DecalFXNugget::parse, nullptr, 0}, |
1028 | 1147 | { nullptr, nullptr, nullptr, 0 } |
1029 | 1148 | }; |
1030 | 1149 |
|
|
0 commit comments