diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/DarkLUA.cpp b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/DarkLUA.cpp index fdca8d8d..9d97a3e1 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/DarkLUA.cpp +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/DarkLUA.cpp @@ -3,6 +3,14 @@ //#define FASTBULLETPHYSICS +#ifdef WINVER +#undef WINVER +#endif +//PE: We need the latest dpi functions. +#define WINVER 0x0605 +#include "Windows.h" +#include "WinUser.h" + #define _USING_V110_SDK71_ #include "stdafx.h" #include "DarkLUA.h" @@ -45,6 +53,13 @@ extern StoryboardStruct Storyboard; #include "optick.h" #endif +#include "..\..\..\..\Guru-WickedMAX\wickedcalls.h" +#include "WickedEngine.h" +using namespace std; +using namespace wiGraphics; +using namespace wiScene; +using namespace wiECS; + // Prototypes extern void DrawSpritesFirst(void); extern void DrawSpritesLast(void); @@ -9736,6 +9751,172 @@ int EffectSetLifespan(lua_State* L) return 0; } +#ifdef WICKEDPARTICLESYSTEM +std::vector vWickedEmitterEffects; +void CleanUpEmitterEffects(void) +{ + Scene& scene = wiScene::GetScene(); + + std::vector vEntityDelete; + for (int i = 0; i < vWickedEmitterEffects.size(); i++) + { + uint32_t root = vWickedEmitterEffects[i]; + for (int a = 0; a < scene.emitters.GetCount(); a++) + { + Entity emitter = scene.emitters.GetEntity(a); + HierarchyComponent* hier = scene.hierarchy.GetComponent(emitter); + if (hier) + { + if (hier->parentID == root) + { + vEntityDelete.push_back(emitter); + } + } + } + vEntityDelete.push_back(root); + } + + for (int i = 0; i < vEntityDelete.size(); i++) + { + scene.Entity_Remove(vEntityDelete[i]); + } + vEntityDelete.clear(); + vWickedEmitterEffects.clear(); +} + +//PE: WParticleEffectPosition("FileName") - Return EffectID +int WParticleEffectLoad(lua_State* L) +{ + lua = L; + int n = lua_gettop(L); + if (n < 1) return 0; + + Scene& scene = wiScene::GetScene(); + + char pFileName[MAX_PATH]; + strcpy(pFileName, lua_tostring(L, 1)); + + uint32_t root = 0; + uint32_t count_before = scene.emitters.GetCount(); + + cstr pOldDir = GetDir(); + + char path[MAX_PATH]; + strcpy(path, pFileName); + GG_GetRealPath(path, 0); + + WickedCall_LoadWiScene(path, false, NULL, NULL); + uint32_t count_after = scene.emitters.GetCount(); + if (count_before != count_after) + { + Entity emitter = scene.emitters.GetEntity(scene.emitters.GetCount() - 1); + if (scene.emitters.GetCount() > 0) + { + Entity emitter = scene.emitters.GetEntity(0); + HierarchyComponent* hier = scene.hierarchy.GetComponent(emitter); + if (hier) + { + root = hier->parentID; + } + } + wiEmittedParticle* ec = scene.emitters.GetComponent(emitter); + if (ec) + { + ec->Restart(); + ec->SetVisible(true); + } + } + if (root != 0) + vWickedEmitterEffects.push_back(root); + lua_pushnumber(L, root); + return 1; + +} +//PE: WParticleEffectPosition(EffectID,x,y,z) +int WParticleEffectPosition(lua_State* L) +{ + lua = L; + int n = lua_gettop(L); + if (n < 4) return 0; + + Entity root = lua_tonumber(L, 1); + float fX = lua_tonumber(L, 2); + float fY = lua_tonumber(L, 3); + float fZ = lua_tonumber(L, 4); + + Scene& scene = wiScene::GetScene(); + TransformComponent* root_tranform = scene.transforms.GetComponent(root); + if (root_tranform) + { + root_tranform->ClearTransform(); + root_tranform->Translate(XMFLOAT3(fX, fY, fZ)); + root_tranform->UpdateTransform(); + } + + //for (int i = 0; i < scene.emitters.GetCount(); i++) + //{ + // Entity emitter = scene.emitters.GetEntity(i); + // HierarchyComponent* hier = scene.hierarchy.GetComponent(emitter); + // if (hier) + // { + // if (hier->parentID == root) + // { + // } + // } + //} + + return 0; +} +int WParticleEffectVisible(lua_State* L) +{ + lua = L; + int n = lua_gettop(L); + if (n < 2) return 0; + + Entity root = lua_tonumber(L, 1); + bool bVisible = lua_tonumber(L, 2); + + Scene& scene = wiScene::GetScene(); + + for (int i = 0; i < scene.emitters.GetCount(); i++) + { + Entity emitter = scene.emitters.GetEntity(i); + HierarchyComponent* hier = scene.hierarchy.GetComponent(emitter); + if (hier) + { + if (hier->parentID == root) + { + wiEmittedParticle* ec = scene.emitters.GetComponent(emitter); + if (ec) + { + ec->SetVisible(bVisible); + } + } + } + } + + return 0; +} + +//WParticleEffectAction(EffectID,Action) - Action = 1 Burst all. 2 = Pause. - 3 = Resume. - 4 = Restart +int WParticleEffectAction(lua_State* L) +{ + lua = L; + int n = lua_gettop(L); + if (n < 2) return 0; + Entity root = lua_tonumber(L, 1); + int iAction = lua_tonumber(L, 2); + WickedCall_PerformEmitterAction(iAction, root); + return 0; +} + +// rotate +// Stop +// copy lua code from app. +// add emitter with all settings. +#endif + + // Misc Commands int GetBulletHit(lua_State* L) @@ -12801,6 +12982,15 @@ void addFunctions() lua_register(lua, "EffectSetColor", EffectSetColor); lua_register(lua, "EffectSetLifespan", EffectSetLifespan); + //PE: Wicked particle system. +#ifdef WICKEDPARTICLESYSTEM + lua_register(lua, "WParticleEffectLoad", WParticleEffectLoad); + lua_register(lua, "WParticleEffectPosition", WParticleEffectPosition); + lua_register(lua, "WParticleEffectVisible", WParticleEffectVisible); + lua_register(lua, "WParticleEffectAction", WParticleEffectAction); + +#endif + lua_register(lua, "GetBulletHit", GetBulletHit); lua_register(lua, "SetFlashLight" , SetFlashLight ); lua_register(lua, "SetAttachmentVisible" , SetAttachmentVisible ); diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/DarkLUA.vcxproj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/DarkLUA.vcxproj index 4cfa7f7d..b8c16a47 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/DarkLUA.vcxproj +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/DarkLUA.vcxproj @@ -79,14 +79,14 @@ MaxSpeed false - WIN32;NDEBUG;_WINDOWS;_USRDLL;DARKLUA_EXPORTS;%(PreprocessorDefinitions) + GGREDUCED;WIN32;NDEBUG;_WINDOWS;_USRDLL;DARKLUA_EXPORTS;%(PreprocessorDefinitions) MultiThreaded true Level1 ProgramDatabase - lua;%(AdditionalIncludeDirectories);$(ProjectDir)..\..\..\Include\;$(ProjectDir)..\..\..\..\Dark Wicked Shared\Include\;$(ProjectDir)..\..\..\..\GameGuru\Include\;$(ProjectDir)..\..\..\..\SDK\RecastContrib;$(ProjectDir)..\..\..\..\SDK\RecastContrib\fastlz;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\DebugUtils/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\Detour/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\DetourCrowd/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\DetourTileCache/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\Recast/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\;$(ProjectDir)..\..\..\..\SDK\RecastContrib\SDL\include + ../../../../../../WICKEDREPO/WickedEngine;lua;%(AdditionalIncludeDirectories);$(ProjectDir)..\..\..\Include\;$(ProjectDir)..\..\..\..\Dark Wicked Shared\Include\;$(ProjectDir)..\..\..\..\GameGuru\Include\;$(ProjectDir)..\..\..\..\SDK\RecastContrib;$(ProjectDir)..\..\..\..\SDK\RecastContrib\fastlz;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\DebugUtils/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\Detour/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\DetourCrowd/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\DetourTileCache/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\Recast/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\;$(ProjectDir)..\..\..\..\SDK\RecastContrib\SDL\include false 4005;4995;4723 Disabled @@ -133,14 +133,14 @@ Disabled false - WIN32;NDEBUG;_WINDOWS;_USRDLL;DARKLUA_EXPORTS;%(PreprocessorDefinitions) + GGREDUCED;WIN32;NDEBUG;_WINDOWS;_USRDLL;DARKLUA_EXPORTS;%(PreprocessorDefinitions) MultiThreadedDebug true Level1 ProgramDatabase - lua;%(AdditionalIncludeDirectories);$(ProjectDir)..\..\..\Include\;$(ProjectDir)..\..\..\..\Dark Wicked Shared\Include\;$(ProjectDir)..\..\..\..\GameGuru\Include\;$(ProjectDir)..\..\..\..\SDK\RecastContrib;$(ProjectDir)..\..\..\..\SDK\RecastContrib\fastlz;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\DebugUtils/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\Detour/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\DetourCrowd/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\DetourTileCache/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\Recast/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\;$(ProjectDir)..\..\..\..\SDK\RecastContrib\SDL\include + ../../../../../../WICKEDREPO/WickedEngine;lua;%(AdditionalIncludeDirectories);$(ProjectDir)..\..\..\Include\;$(ProjectDir)..\..\..\..\Dark Wicked Shared\Include\;$(ProjectDir)..\..\..\..\GameGuru\Include\;$(ProjectDir)..\..\..\..\SDK\RecastContrib;$(ProjectDir)..\..\..\..\SDK\RecastContrib\fastlz;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\DebugUtils/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\Detour/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\DetourCrowd/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\DetourTileCache/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\Recast/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\;$(ProjectDir)..\..\..\..\SDK\RecastContrib\SDL\include false 4005;4995;4723 Default diff --git a/GameGuru Core/GameGuru/Include/preprocessor-moreflags.h b/GameGuru Core/GameGuru/Include/preprocessor-moreflags.h index 11dd1123..c879c0d4 100644 --- a/GameGuru Core/GameGuru/Include/preprocessor-moreflags.h +++ b/GameGuru Core/GameGuru/Include/preprocessor-moreflags.h @@ -139,6 +139,8 @@ #define NEWPROJSYSWORKINPROGRESS #define DETECTANDUSENEWPARTICLEDECALS + #define WICKEDPARTICLESYSTEM + #else // Flags to compile the Classic version of GameGuru #define FPSEXCHANGE diff --git a/GameGuru Core/Guru-WickedMAX/master.cpp b/GameGuru Core/Guru-WickedMAX/master.cpp index 110a6e13..015f362e 100644 --- a/GameGuru Core/Guru-WickedMAX/master.cpp +++ b/GameGuru Core/Guru-WickedMAX/master.cpp @@ -2278,6 +2278,10 @@ void MasterRenderer::Update(float dt) } wiProfiler::EndRange(range3); +#ifdef WICKEDPARTICLESYSTEM + WickedCall_UpdateEmitters(); +#endif + // now just prepared IMGUI, but actual render called from Wicked hook auto range2 = wiProfiler::BeginRangeCPU("Update - Render"); GuruLoopRender(); diff --git a/GameGuru Core/Guru-WickedMAX/wickedcalls.cpp b/GameGuru Core/Guru-WickedMAX/wickedcalls.cpp index fac84c01..2aa34b96 100644 --- a/GameGuru Core/Guru-WickedMAX/wickedcalls.cpp +++ b/GameGuru Core/Guru-WickedMAX/wickedcalls.cpp @@ -6867,4 +6867,387 @@ void WickedCall_CreateDecal(sObject* pObject) //} //} } -*/ \ No newline at end of file +*/ + +#ifdef WICKEDPARTICLESYSTEM +uint32_t WickedCall_LoadWiScene(char* filename, bool attached, char* changename, char* changenameto) +{ + Entity root = 0; + + XMMATRIX& transformMatrix = XMMatrixIdentity(); + Scene scene2; + wiArchive archive(filename, true); + if (archive.IsOpen()) + { + if (archive.IsReadMode()) + { + uint32_t reserved; + archive >> reserved; + } + else + { + uint32_t reserved = 0; + archive << reserved; + } + + //PE: Keeping this alive to keep serialized resources alive until entity serialization ends: + wiResourceManager::ResourceSerializer resource_seri; + if (archive.GetVersion() >= 63) + { + wiResourceManager::Serialize(archive, resource_seri); + } + + EntitySerializer seri; + + scene2.names.Serialize(archive, seri); + scene2.layers.Serialize(archive, seri); + scene2.transforms.Serialize(archive, seri); + scene2.prev_transforms.Serialize(archive, seri); + scene2.hierarchy.Serialize(archive, seri); + scene2.materials.Serialize(archive, seri); + scene2.meshes.Serialize(archive, seri); + scene2.impostors.Serialize(archive, seri); + scene2.objects.Serialize(archive, seri); + scene2.aabb_objects.Serialize(archive, seri); + scene2.rigidbodies.Serialize(archive, seri); + + scene2.softbodies.Serialize(archive, seri); + + scene2.armatures.Serialize(archive, seri); + scene2.lights.Serialize(archive, seri); + scene2.aabb_lights.Serialize(archive, seri); + scene2.cameras.Serialize(archive, seri); + scene2.probes.Serialize(archive, seri); + scene2.aabb_probes.Serialize(archive, seri); + scene2.forces.Serialize(archive, seri); + scene2.decals.Serialize(archive, seri); + scene2.aabb_decals.Serialize(archive, seri); + scene2.animations.Serialize(archive, seri); + scene2.emitters.Serialize(archive, seri); + scene2.hairs.Serialize(archive, seri); + scene2.weathers.Serialize(archive, seri); + if (archive.GetVersion() >= 30) + { + scene2.sounds.Serialize(archive, seri); + } + if (archive.GetVersion() >= 37) + { + scene2.inverse_kinematics.Serialize(archive, seri); + } + if (archive.GetVersion() >= 38) + { + scene2.springs.Serialize(archive, seri); + } + if (archive.GetVersion() >= 46) + { + scene2.animation_datas.Serialize(archive, seri); + } + + //PE: create new root: + root = CreateEntity(); + scene2.transforms.Create(root); + scene2.layers.Create(root).layerMask = ~0; + + //PE: Parent all unparented transforms to new root entity + for (size_t i = 0; i < scene2.transforms.GetCount() - 1; ++i) // GetCount() - 1 because the last added was the "root" + { + Entity entity = scene2.transforms.GetEntity(i); + if (!scene2.hierarchy.Contains(entity)) + { + scene2.Component_Attach(entity, root); + } + } + //PE: The root component is transformed, scene is updated: + scene2.transforms.GetComponent(root)->MatrixTransform(transformMatrix); + scene2.Update(0); + + if (!attached) + { + //PE: In this case, we don't care about the root anymore, so delete it. This will simplify overall hierarchy + scene2.Component_DetachChildren(root); + scene2.Entity_Remove(root); + root = INVALID_ENTITY; + } + } + + //PE: Fix for GG moved enums + if (pestrcasestr(filename, ".wiscene")) + { + for (int i = 0; i < scene2.materials.GetCount(); i++) + { + if (scene2.materials[i].userBlendMode == BLENDMODE_PREMULTIPLIED) + scene2.materials[i].userBlendMode = BLENDMODE_MULTIPLY; + if (scene2.materials[i].userBlendMode == BLENDMODE_ALPHA) + scene2.materials[i].userBlendMode = BLENDMODE_ADDITIVE; + if (scene2.materials[i].userBlendMode == BLENDMODE_FORCEDEPTH) + scene2.materials[i].userBlendMode = BLENDMODE_PREMULTIPLIED; + if (scene2.materials[i].userBlendMode == BLENDMODE_ALPHANOZ) + scene2.materials[i].userBlendMode = BLENDMODE_ALPHA; + scene2.materials[i].SetDirty(); + } + } + + if (changename && changenameto) + { + for (int i = 0; i < scene2.names.GetCount(); i++) + { + if (stricmp(scene2.names[i].name.c_str(), changename) == 0) + { + scene2.names[i].name = changenameto; + } + } + } + GetScene().Merge(scene2); + return root; +} + +//iAction = 1 Burst all. 2 = Pause. - 3 = Resume. - 4 = Restart +void WickedCall_PerformEmitterAction(int iAction, uint32_t emitter_root) +{ + + Scene& scene = wiScene::GetScene(); + + //PE: Scan emitters. + for (int i = 0; i < scene.emitters.GetCount(); i++) + { + Entity emitter = scene.emitters.GetEntity(i); + HierarchyComponent* hier = scene.hierarchy.GetComponent(emitter); + if (hier) + { + if (hier->parentID == emitter_root) + { + wiEmittedParticle* ec = scene.emitters.GetComponent(emitter); + switch (iAction) + { + case 1: + { + ec->Burst(0); + break; + } + case 2: + { + ec->SetPaused(true); + break; + } + case 3: + { + ec->SetPaused(false); + break; + } + case 4: + { + ec->Restart(); + break; + } + } + } + } + } + +} + +//#define WPEDebug +void WickedCall_UpdateEmitters(void) +{ + //PE: Scan emitters. + std::vector< uint32_t> parent_used; + parent_used.clear(); + Scene& scene = wiScene::GetScene(); + for (int i = 0; i < scene.emitters.GetCount(); i++) + { + Entity emitter = scene.emitters.GetEntity(i); + wiEmittedParticle* ec = scene.emitters.GetComponent(emitter); + +#ifdef WPEDebug + if (ec && ec->IsVolumeEnabled()) + { + XMFLOAT4X4 hoverBox; + wiScene::TransformComponent* pTransform = wiScene::GetScene().transforms.GetComponent(emitter); + if (pTransform) + { + if (1) + { + AABB aabb; + XMFLOAT3 pos = pTransform->GetPosition(); + //if (bIsUsingWidget && emitter_root != transform_entity) + //{ + // TransformComponent* root_tranform = scene.transforms.GetComponent(emitter_root); + // //PE: Need to add root here , as its not updated before next frame in wicked. + // if (root_tranform) + // { + // pos.x += root_tranform->GetPosition().x; + // pos.y += root_tranform->GetPosition().y; + // pos.z += root_tranform->GetPosition().z; + // } + //} + + XMFLOAT3 sca = pTransform->GetScale(); + aabb._min = XMFLOAT3(pos.x - sca.x, pos.y, pos.z - sca.z); + aabb._max = XMFLOAT3(pos.x + sca.x, pos.y + sca.y, pos.z + sca.z); + + XMStoreFloat4x4(&hoverBox, aabb.getAsBoxMatrix()); // *pTransform->GetLocalMatrix()); + XMVECTOR S, R, T; + XMMatrixDecompose(&S, &R, &T, XMLoadFloat4x4(&hoverBox)); + + //XMVECTOR R_local = XMLoadFloat4(&root_tranform->rotation_local); + XMVECTOR R_local = XMLoadFloat4(&pTransform->rotation_local); + XMStoreFloat4x4(&hoverBox, + XMMatrixScalingFromVector(S) * + XMMatrixRotationQuaternion(R_local) * + XMMatrixTranslationFromVector(T)); + + wiRenderer::DrawBox(hoverBox, XMFLOAT4(1.0f, 1.0f, 0.0f, 1.0f)); + } + } + } +#endif + + //PE: If bFollowCamera , find InDoor , OutDoor , UnderWater. + //PE: bFindFloor ONLY if ec->bFollowCamera + if (ec && (ec->bFindFloor || ec->bFollowCamera)) + { + HierarchyComponent* hier = scene.hierarchy.GetComponent(emitter); + if (hier) + { + if (hier->parentID != wiECS::INVALID_ENTITY) + { + bool bAlreadySet = false; + for (int a = 0; a > parent_used.size(); a++) + { + if (parent_used[a] == hier->parentID) + { + bAlreadySet = true; + break; + } + } + if (!bAlreadySet) + { + parent_used.push_back(hier->parentID); + TransformComponent* root_tranform = scene.transforms.GetComponent(hier->parentID); + if (root_tranform) + { + + if (ec->bFollowCamera) + { + float fX, fY, fZ; + //float PlayerHeight = 62.0f; + fX = CameraPositionX(); + //PE: PlayerHeight might have to be removed in GGM + fY = CameraPositionY(); // -PlayerHeight; + fZ = CameraPositionZ(); + root_tranform->ClearTransform(); + root_tranform->Translate(XMFLOAT3(fX, fY, fZ)); + root_tranform->UpdateTransform(); + } + if (ec->bFindFloor && ec->bFollowCamera) + { + float fX = root_tranform->GetPosition().x; + float fZ = root_tranform->GetPosition().z; + float height = BT_GetGroundHeight(t.terrain.TerrainID, CameraPositionX(), CameraPositionZ()); + root_tranform->ClearTransform(); + root_tranform->Translate(XMFLOAT3(fX, height, fZ)); + root_tranform->UpdateTransform(); + } + } + } + } + } + } + } +} + +uint32_t WickedCall_CreateEmitter(std::string& name, float posX, float posY, float posZ, uint32_t proot) +{ + XMFLOAT3 position = { posX , posY, posZ }; + + //wiScene::Scene& scene = wiScene::GetScene(); + Scene scene; + XMMATRIX& transformMatrix = XMMatrixIdentity(); + + //PE: Create emitter. + Entity entity = CreateEntity(); + + scene.names.Create(entity) = name; + scene.emitters.Create(entity).count = 10; + + wiEmittedParticle* ec; + ec = scene.emitters.GetComponent(entity); + ec->count = 40; + ec->life = 2.5f; + ec->size = 2; + //ec->random_color = 1.0f; + ec->gravity = XMFLOAT3(0, 9, 0); + + TransformComponent& transform = scene.transforms.Create(entity); + transform.ClearTransform(); + transform.Translate(position); + transform.Scale(XMFLOAT3(3, 1, 3)); + transform.UpdateTransform(); + + scene.materials.Create(entity).userBlendMode = BLENDMODE_ADDITIVE; // BLENDMODE_ALPHA; + + //PE: Create root. + Entity root; + bool bUsePrevRoot = false; + if (proot > 0) + { + root = proot; + bUsePrevRoot = true; + } + else + { + root = CreateEntity(); + scene.transforms.Create(root); + scene.layers.Create(root).layerMask = ~0; + //emitter_root = root; + } + + if (!bUsePrevRoot) + { + //PE: Parent all unparented transforms to new root entity + for (size_t i = 0; i < scene.transforms.GetCount() - 1; ++i) // GetCount() - 1 because the last added was the "root" + { + Entity entity = scene.transforms.GetEntity(i); + if (!scene.hierarchy.Contains(entity)) + { + scene.Component_Attach(entity, root); + } + } + //PE: The root component is transformed, scene is updated: + scene.transforms.GetComponent(root)->MatrixTransform(transformMatrix); + scene.Update(0); + } + GetScene().Merge(scene); + + //PE: Find name; + wiScene::Scene& sceneR = wiScene::GetScene(); + + for (int i = 0; i < sceneR.emitters.GetCount(); i++) + { + + Entity emitter = sceneR.emitters.GetEntity(i); + Entity text = sceneR.names.GetIndex(emitter); + if (text > 0) + { + if (sceneR.names[text].name == name) + { + entity = emitter; + break; + } + } + } + + if (bUsePrevRoot) + { + sceneR.Component_Attach(entity, root); + wiScene::TransformComponent* pTransform = wiScene::GetScene().transforms.GetComponent(entity); + pTransform->ClearTransform(); + pTransform->Translate(position); + pTransform->UpdateTransform(); + } + + return entity; +} + +#endif + diff --git a/GameGuru Core/Guru-WickedMAX/wickedcalls.h b/GameGuru Core/Guru-WickedMAX/wickedcalls.h index 371d2867..84654df0 100644 --- a/GameGuru Core/Guru-WickedMAX/wickedcalls.h +++ b/GameGuru Core/Guru-WickedMAX/wickedcalls.h @@ -214,3 +214,9 @@ void WickedCall_RemoveObjectTextures(sObject* pObject); void WickedCall_SetExposure(float exposure); void WickedCall_CreateDecal(sObject* pObject); + +uint32_t WickedCall_LoadWiScene(char* filename, bool attached, char* changename, char* changenameto); +void WickedCall_PerformEmitterAction(int iAction, uint32_t emitter_root); +void WickedCall_UpdateEmitters(void); +uint32_t WickedCall_CreateEmitter(std::string& name, float posX, float posY, float posZ, uint32_t proot); +