diff --git a/Editor/AnimationWindow.cpp b/Editor/AnimationWindow.cpp index 896a5bc8a..a0995e2b3 100644 --- a/Editor/AnimationWindow.cpp +++ b/Editor/AnimationWindow.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include "AnimationWindow.h" +using namespace wiSceneComponents; AnimationWindow::AnimationWindow(wiGUI* gui) :GUI(gui) { diff --git a/Editor/AnimationWindow.h b/Editor/AnimationWindow.h index 9fd482111..13865b124 100644 --- a/Editor/AnimationWindow.h +++ b/Editor/AnimationWindow.h @@ -1,6 +1,10 @@ #pragma once -struct Armature; +namespace wiSceneComponents +{ + struct Armature; +} + class wiGUI; class wiWindow; class wiLabel; @@ -15,8 +19,8 @@ public: ~AnimationWindow(); wiGUI* GUI; - Armature* armature; - void SetArmature(Armature* armature); + wiSceneComponents::Armature* armature; + void SetArmature(wiSceneComponents::Armature* armature); wiWindow* animWindow; wiComboBox* actionsComboBox; diff --git a/Editor/CameraWindow.cpp b/Editor/CameraWindow.cpp index 13ee54557..b7a5a769c 100644 --- a/Editor/CameraWindow.cpp +++ b/Editor/CameraWindow.cpp @@ -1,6 +1,8 @@ #include "stdafx.h" #include "CameraWindow.h" +using namespace wiSceneComponents; + void CameraWindow::ResetCam() { wiRenderer::getCamera()->Clear(); diff --git a/Editor/CameraWindow.h b/Editor/CameraWindow.h index 7a206fe97..2e9a4bad9 100644 --- a/Editor/CameraWindow.h +++ b/Editor/CameraWindow.h @@ -1,6 +1,11 @@ #pragma once -struct Material; +namespace wiSceneComponents +{ + struct Camera; + struct Transform; +} + class wiGUI; class wiWindow; class wiLabel; @@ -16,10 +21,10 @@ public: void ResetCam(); - Camera* proxy = nullptr; - void SetProxy(Camera* camera); + wiSceneComponents::Camera* proxy = nullptr; + void SetProxy(wiSceneComponents::Camera* camera); - Transform* orbitalCamTarget; + wiSceneComponents::Transform* orbitalCamTarget; wiGUI* GUI; diff --git a/Editor/DecalWindow.cpp b/Editor/DecalWindow.cpp index bc12ac3c2..f2d789d9e 100644 --- a/Editor/DecalWindow.cpp +++ b/Editor/DecalWindow.cpp @@ -1,6 +1,8 @@ #include "stdafx.h" #include "DecalWindow.h" +using namespace wiSceneComponents; + DecalWindow::DecalWindow(wiGUI* gui) : GUI(gui) { diff --git a/Editor/DecalWindow.h b/Editor/DecalWindow.h index 9bfe59112..f60592ce2 100644 --- a/Editor/DecalWindow.h +++ b/Editor/DecalWindow.h @@ -1,14 +1,16 @@ #pragma once -struct Material; +namespace wiSceneComponents +{ + struct Decal; +} + class wiGUI; class wiWindow; class wiLabel; class wiCheckBox; class wiSlider; -struct Decal; - class DecalWindow { public: @@ -17,9 +19,9 @@ public: wiGUI* GUI; - void SetDecal(Decal* decal); + void SetDecal(wiSceneComponents::Decal* decal); - Decal* decal; + wiSceneComponents::Decal* decal; wiWindow* decalWindow; wiSlider* opacitySlider; diff --git a/Editor/Editor.cpp b/Editor/Editor.cpp index cd3cbb073..ad59fccbe 100644 --- a/Editor/Editor.cpp +++ b/Editor/Editor.cpp @@ -24,6 +24,7 @@ using namespace std; using namespace wiGraphicsTypes; using namespace wiRectPacker; +using namespace wiSceneComponents; Editor::Editor() { diff --git a/Editor/EmitterWindow.cpp b/Editor/EmitterWindow.cpp index 49b10fc74..6c30dc0f6 100644 --- a/Editor/EmitterWindow.cpp +++ b/Editor/EmitterWindow.cpp @@ -5,6 +5,7 @@ #include using namespace std; +using namespace wiSceneComponents; EmitterWindow::EmitterWindow(wiGUI* gui) : GUI(gui) { diff --git a/Editor/EmitterWindow.h b/Editor/EmitterWindow.h index dc72633be..6d8ca9707 100644 --- a/Editor/EmitterWindow.h +++ b/Editor/EmitterWindow.h @@ -1,6 +1,10 @@ #pragma once -struct Object; +namespace wiSceneComponents +{ + struct Object; +} + class wiEmittedParticle; class wiGUI; @@ -19,11 +23,11 @@ public: EmitterWindow(wiGUI* gui); ~EmitterWindow(); - void SetObject(Object* obj); + void SetObject(wiSceneComponents::Object* obj); void SetMaterialWnd(MaterialWindow* wnd); void UpdateData(); - Object* object; + wiSceneComponents::Object* object; wiEmittedParticle* GetEmitter(); wiGUI* GUI; diff --git a/Editor/EnvProbeWindow.cpp b/Editor/EnvProbeWindow.cpp index db2bce33a..7ac018ef7 100644 --- a/Editor/EnvProbeWindow.cpp +++ b/Editor/EnvProbeWindow.cpp @@ -1,6 +1,8 @@ #include "stdafx.h" #include "EnvProbeWindow.h" +using namespace wiSceneComponents; + EnvProbeWindow::EnvProbeWindow(wiGUI* gui) : GUI(gui) { probe = nullptr; diff --git a/Editor/EnvProbeWindow.h b/Editor/EnvProbeWindow.h index f8ba6ff93..9f0096bcb 100644 --- a/Editor/EnvProbeWindow.h +++ b/Editor/EnvProbeWindow.h @@ -1,6 +1,10 @@ #pragma once -struct Material; +namespace wiSceneComponents +{ + struct EnvironmentProbe; +} + class wiGUI; class wiWindow; class wiLabel; @@ -15,8 +19,8 @@ public: wiGUI* GUI; - EnvironmentProbe* probe; - void SetProbe(EnvironmentProbe* value); + wiSceneComponents::EnvironmentProbe* probe; + void SetProbe(wiSceneComponents::EnvironmentProbe* value); wiWindow* envProbeWindow; diff --git a/Editor/ForceFieldWindow.cpp b/Editor/ForceFieldWindow.cpp index e4274f6b1..e9c96a009 100644 --- a/Editor/ForceFieldWindow.cpp +++ b/Editor/ForceFieldWindow.cpp @@ -1,6 +1,8 @@ #include "stdafx.h" #include "ForceFieldWindow.h" +using namespace wiSceneComponents; + ForceFieldWindow::ForceFieldWindow(wiGUI* gui) : GUI(gui) { diff --git a/Editor/ForceFieldWindow.h b/Editor/ForceFieldWindow.h index 297bc2744..38a3a02ed 100644 --- a/Editor/ForceFieldWindow.h +++ b/Editor/ForceFieldWindow.h @@ -1,6 +1,9 @@ #pragma once -struct ForceField; +namespace wiSceneComponents +{ + struct ForceField; +} class wiGUI; class wiWindow; @@ -16,9 +19,9 @@ public: ForceFieldWindow(wiGUI* gui); ~ForceFieldWindow(); - void SetForceField(ForceField* force); + void SetForceField(wiSceneComponents::ForceField* force); - ForceField* force; + wiSceneComponents::ForceField* force; wiGUI* GUI; diff --git a/Editor/LightWindow.cpp b/Editor/LightWindow.cpp index 44efdba53..eac495a3a 100644 --- a/Editor/LightWindow.cpp +++ b/Editor/LightWindow.cpp @@ -1,6 +1,8 @@ #include "stdafx.h" #include "LightWindow.h" +using namespace wiSceneComponents; + LightWindow::LightWindow(wiGUI* gui) : GUI(gui), light(nullptr) { diff --git a/Editor/LightWindow.h b/Editor/LightWindow.h index eb4aa0ddb..e4175a8d4 100644 --- a/Editor/LightWindow.h +++ b/Editor/LightWindow.h @@ -1,6 +1,11 @@ #pragma once -struct Material; + +namespace wiSceneComponents +{ + struct Light; +} + class wiGUI; class wiWindow; class wiLabel; @@ -10,8 +15,6 @@ class wiButton; class wiColorPicker; class wiComboBox; -struct Light; - class LightWindow { public: @@ -20,10 +23,10 @@ public: wiGUI* GUI; - void SetLight(Light* light); - void SetLightType(Light::LightType type); + void SetLight(wiSceneComponents::Light* light); + void SetLightType(wiSceneComponents::Light::LightType type); - Light* light; + wiSceneComponents::Light* light; wiWindow* lightWindow; wiSlider* energySlider; diff --git a/Editor/MaterialWindow.cpp b/Editor/MaterialWindow.cpp index 6232e457c..cb418b929 100644 --- a/Editor/MaterialWindow.cpp +++ b/Editor/MaterialWindow.cpp @@ -6,6 +6,7 @@ using namespace std; using namespace wiGraphicsTypes; +using namespace wiSceneComponents; MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui) { diff --git a/Editor/MaterialWindow.h b/Editor/MaterialWindow.h index d4db010ec..7225a06d6 100644 --- a/Editor/MaterialWindow.h +++ b/Editor/MaterialWindow.h @@ -1,6 +1,10 @@ #pragma once -struct Material; +namespace wiSceneComponents +{ + struct Material; +} + class wiGUI; class wiWindow; class wiLabel; @@ -17,11 +21,11 @@ public: MaterialWindow(wiGUI* gui); ~MaterialWindow(); - void SetMaterial(Material* mat); + void SetMaterial(wiSceneComponents::Material* mat); wiGUI* GUI; - Material* material; + wiSceneComponents::Material* material; wiWindow* materialWindow; wiTextInputField* materialNameField; diff --git a/Editor/MeshWindow.cpp b/Editor/MeshWindow.cpp index c70637820..ce20d12d0 100644 --- a/Editor/MeshWindow.cpp +++ b/Editor/MeshWindow.cpp @@ -4,6 +4,7 @@ #include using namespace std; +using namespace wiSceneComponents; MeshWindow::MeshWindow(wiGUI* gui) : GUI(gui) { diff --git a/Editor/MeshWindow.h b/Editor/MeshWindow.h index 7458ef1fb..a34c3cb96 100644 --- a/Editor/MeshWindow.h +++ b/Editor/MeshWindow.h @@ -1,6 +1,10 @@ #pragma once -struct Material; +namespace wiSceneComponents +{ + struct Mesh; +} + class wiGUI; class wiWindow; class wiLabel; @@ -8,8 +12,6 @@ class wiCheckBox; class wiSlider; class wiButton; -struct Mesh; - class MeshWindow { public: @@ -18,9 +20,9 @@ public: wiGUI* GUI; - void SetMesh(Mesh* mesh); + void SetMesh(wiSceneComponents::Mesh* mesh); - Mesh* mesh; + wiSceneComponents::Mesh* mesh; wiWindow* meshWindow; wiLabel* meshInfoLabel; diff --git a/Editor/ModelImporter.h b/Editor/ModelImporter.h index fd159d2b8..3f7e2fd91 100644 --- a/Editor/ModelImporter.h +++ b/Editor/ModelImporter.h @@ -1,9 +1,12 @@ #pragma once #include -struct Model; +namespace wiSceneComponents +{ + struct Model; +} -Model* ImportModel_WIO(const std::string& fileName); -Model* ImportModel_OBJ(const std::string& fileName); -Model* ImportModel_GLTF(const std::string& fileName); +wiSceneComponents::Model* ImportModel_WIO(const std::string& fileName); +wiSceneComponents::Model* ImportModel_OBJ(const std::string& fileName); +wiSceneComponents::Model* ImportModel_GLTF(const std::string& fileName); diff --git a/Editor/ModelImporter_GLTF.cpp b/Editor/ModelImporter_GLTF.cpp index 3914bac2c..e52a35e5a 100644 --- a/Editor/ModelImporter_GLTF.cpp +++ b/Editor/ModelImporter_GLTF.cpp @@ -10,6 +10,8 @@ using namespace std; using namespace wiGraphicsTypes; +using namespace wiSceneComponents; + namespace tinygltf { diff --git a/Editor/ModelImporter_OBJ.cpp b/Editor/ModelImporter_OBJ.cpp index 9f62113e8..205508195 100644 --- a/Editor/ModelImporter_OBJ.cpp +++ b/Editor/ModelImporter_OBJ.cpp @@ -8,6 +8,7 @@ using namespace std; using namespace wiGraphicsTypes; +using namespace wiSceneComponents; Model* ImportModel_OBJ(const std::string& fileName) { diff --git a/Editor/ModelImporter_WIO.cpp b/Editor/ModelImporter_WIO.cpp index 04e7e9bb2..a25ac9393 100644 --- a/Editor/ModelImporter_WIO.cpp +++ b/Editor/ModelImporter_WIO.cpp @@ -6,9 +6,10 @@ using namespace std; using namespace wiGraphicsTypes; +using namespace wiSceneComponents; -Mesh* LoadMeshFromBinaryFile(const std::string& newName, const std::string& fname, const MaterialCollection& materialColl, const unordered_set& armatures) +Mesh* LoadMeshFromBinaryFile(const std::string& newName, const std::string& fname, const std::map& materialColl, const unordered_set& armatures) { Mesh* mesh = new Mesh(newName); @@ -83,7 +84,7 @@ Mesh* LoadMeshFromBinaryFile(const std::string& newName, const std::string& fnam stringstream identified_matname(""); identified_matname << matName; - MaterialCollection::const_iterator iter = materialColl.find(identified_matname.str()); + auto& iter = materialColl.find(identified_matname.str()); if (iter != materialColl.end()) { mesh->subsets.push_back(MeshSubset()); mesh->subsets.back().material = iter->second; @@ -393,7 +394,7 @@ void LoadWiArmatures(const std::string& directory, const std::string& name, unor } } -void LoadWiMaterialLibrary(const std::string& directory, const std::string& name, const std::string& texturesDir, MaterialCollection& materials) +void LoadWiMaterialLibrary(const std::string& directory, const std::string& name, const std::string& texturesDir, std::map& materials) { int materialI = (int)(materials.size() - 1); @@ -543,7 +544,7 @@ void LoadWiMaterialLibrary(const std::string& directory, const std::string& name } void LoadWiObjects(const std::string& directory, const std::string& name, unordered_set& objects , unordered_set& armatures - , MeshCollection& meshes, const MaterialCollection& materials) + , std::map& meshes, const std::map& materials) { stringstream filename(""); @@ -572,7 +573,7 @@ void LoadWiObjects(const std::string& directory, const std::string& name, unorde string meshName = ""; file >> meshName; object->meshName = meshName; - MeshCollection::iterator iter = meshes.find(meshName); + auto& iter = meshes.find(meshName); if (line[1] == 'b') { @@ -678,8 +679,8 @@ void LoadWiObjects(const std::string& directory, const std::string& name, unorde file.close(); } -void LoadWiMeshes(const std::string& directory, const std::string& name, MeshCollection& meshes, - const unordered_set& armatures, const MaterialCollection& materials) +void LoadWiMeshes(const std::string& directory, const std::string& name, std::map& meshes, + const unordered_set& armatures, const std::map& materials) { int meshI = (int)(meshes.size() - 1); Mesh* currentMesh = NULL; @@ -838,7 +839,7 @@ void LoadWiMeshes(const std::string& directory, const std::string& name, MeshCol string mName = ""; file >> mName; currentMesh->materialNames.push_back(mName); - MaterialCollection::const_iterator iter = materials.find(mName); + auto& iter = materials.find(mName); if (iter != materials.end()) { currentMesh->subsets.push_back(MeshSubset()); currentMesh->renderable = true; diff --git a/Editor/ObjectWindow.cpp b/Editor/ObjectWindow.cpp index 7d7f7e8f1..39da363cd 100644 --- a/Editor/ObjectWindow.cpp +++ b/Editor/ObjectWindow.cpp @@ -1,6 +1,8 @@ #include "stdafx.h" #include "ObjectWindow.h" +using namespace wiSceneComponents; + ObjectWindow::ObjectWindow(wiGUI* gui) : GUI(gui) { diff --git a/Editor/ObjectWindow.h b/Editor/ObjectWindow.h index b85420de6..43ba8527a 100644 --- a/Editor/ObjectWindow.h +++ b/Editor/ObjectWindow.h @@ -1,6 +1,9 @@ #pragma once -struct Object; +namespace wiSceneComponents +{ + struct Object; +} class wiGUI; class wiWindow; @@ -16,9 +19,9 @@ public: ObjectWindow(wiGUI* gui); ~ObjectWindow(); - void SetObject(Object* obj); + void SetObject(wiSceneComponents::Object* obj); - Object* object; + wiSceneComponents::Object* object; wiGUI* GUI; diff --git a/Editor/RendererWindow.h b/Editor/RendererWindow.h index b3f314b03..6155055cb 100644 --- a/Editor/RendererWindow.h +++ b/Editor/RendererWindow.h @@ -1,6 +1,5 @@ #pragma once -struct Material; class wiGUI; class wiWindow; class wiLabel; diff --git a/Editor/WorldWindow.cpp b/Editor/WorldWindow.cpp index 547332e13..17bf7e82d 100644 --- a/Editor/WorldWindow.cpp +++ b/Editor/WorldWindow.cpp @@ -7,6 +7,7 @@ using namespace std; using namespace wiGraphicsTypes; +using namespace wiSceneComponents; WorldWindow::WorldWindow(wiGUI* gui) : GUI(gui) { diff --git a/Editor/WorldWindow.h b/Editor/WorldWindow.h index 2251359cf..c360c75c5 100644 --- a/Editor/WorldWindow.h +++ b/Editor/WorldWindow.h @@ -1,6 +1,5 @@ #pragma once -struct Material; class wiGUI; class wiWindow; class wiLabel; diff --git a/WickedEngine/PathTracingRenderableComponent.cpp b/WickedEngine/PathTracingRenderableComponent.cpp index 93d79c0a9..b535d7ac0 100644 --- a/WickedEngine/PathTracingRenderableComponent.cpp +++ b/WickedEngine/PathTracingRenderableComponent.cpp @@ -7,6 +7,7 @@ #include "wiSprite.h" #include "ResourceMapping.h" #include "wiProfiler.h" +#include "wiSceneComponents.h" using namespace wiGraphicsTypes; diff --git a/WickedEngine/Renderable3DComponent.cpp b/WickedEngine/Renderable3DComponent.cpp index b9fee387a..5ab4d353a 100644 --- a/WickedEngine/Renderable3DComponent.cpp +++ b/WickedEngine/Renderable3DComponent.cpp @@ -4,7 +4,7 @@ #include "wiImageEffects.h" #include "wiHelper.h" #include "wiTextureHelper.h" -#include "wiLoader.h" +#include "wiSceneComponents.h" #include "ResourceMapping.h" #include "wiProfiler.h" diff --git a/WickedEngine/WickedEngine.h b/WickedEngine/WickedEngine.h index dd22425ec..16b3c9bc8 100644 --- a/WickedEngine/WickedEngine.h +++ b/WickedEngine/WickedEngine.h @@ -19,7 +19,7 @@ #include "wiFont.h" #include "wiFrameRate.h" #include "wiCpuInfo.h" -#include "wiLoader.h" +#include "wiSceneComponents.h" #include "wiEmittedParticle.h" #include "wiHairParticle.h" #include "wiRenderer.h" @@ -69,9 +69,7 @@ #include "LoadingScreenComponent.h" #include "MainComponent.h" -#include "wiGraphicsDevice_DX11.h" -#include "wiGraphicsDevice_DX12.h" -#include "wiGraphicsDevice_Vulkan.h" +#include "wiGraphicsDevice.h" #ifdef _WIN32 diff --git a/WickedEngine/WickedEngine_SHARED.vcxitems b/WickedEngine/WickedEngine_SHARED.vcxitems index e6c8c9836..ebc83445c 100644 --- a/WickedEngine/WickedEngine_SHARED.vcxitems +++ b/WickedEngine/WickedEngine_SHARED.vcxitems @@ -339,8 +339,8 @@ - - + + @@ -684,8 +684,8 @@ - - + + diff --git a/WickedEngine/WickedEngine_SHARED.vcxitems.filters b/WickedEngine/WickedEngine_SHARED.vcxitems.filters index 9ce0200e3..52aa0fd94 100644 --- a/WickedEngine/WickedEngine_SHARED.vcxitems.filters +++ b/WickedEngine/WickedEngine_SHARED.vcxitems.filters @@ -222,9 +222,6 @@ ENGINE\Scripting\LuaBindings - - ENGINE\Scripting\LuaBindings - ENGINE\Scripting\LuaBindings @@ -897,9 +894,6 @@ ENGINE\Graphics - - ENGINE\Graphics - ENGINE\Graphics @@ -1152,6 +1146,12 @@ UTILITY + + ENGINE\Graphics + + + ENGINE\Scripting\LuaBindings + @@ -1325,9 +1325,6 @@ ENGINE\Scripting\LuaBindings - - ENGINE\Scripting\LuaBindings - ENGINE\Scripting\LuaBindings @@ -1781,9 +1778,6 @@ ENGINE\Graphics - - ENGINE\Graphics - ENGINE\Graphics @@ -1952,6 +1946,12 @@ UTILITY + + ENGINE\Graphics + + + ENGINE\Scripting\LuaBindings + diff --git a/WickedEngine/wiBULLET.cpp b/WickedEngine/wiBULLET.cpp index 5fa658359..354b2c6aa 100644 --- a/WickedEngine/wiBULLET.cpp +++ b/WickedEngine/wiBULLET.cpp @@ -1,5 +1,5 @@ #include "wiBULLET.h" -#include "wiLoader.h" +#include "wiSceneComponents.h" @@ -12,6 +12,7 @@ #include "BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h" using namespace std; +using namespace wiSceneComponents; int PHYSICS::softBodyIterationCount=5; bool PHYSICS::rigidBodyPhysicsEnabled = true, PHYSICS::softBodyPhysicsEnabled = true; diff --git a/WickedEngine/wiBULLET.h b/WickedEngine/wiBULLET.h index 699fda889..836d4689d 100644 --- a/WickedEngine/wiBULLET.h +++ b/WickedEngine/wiBULLET.h @@ -50,19 +50,19 @@ public: void addTriangleMesh(const std::vector& vertices, const std::vector& indices, const XMFLOAT3& sca, const XMFLOAT4& rot, const XMFLOAT3& pos , float newMass, float newFriction, float newRestitution, float newDamping, bool kinematic); - void addSoftBodyTriangleMesh(const Mesh* mesh, const XMFLOAT3& sca, const XMFLOAT4& rot, const XMFLOAT3& pos + void addSoftBodyTriangleMesh(const wiSceneComponents::Mesh* mesh, const XMFLOAT3& sca, const XMFLOAT4& rot, const XMFLOAT3& pos , float newMass, float newFriction, float newRestitution, float newDamping); void addBone(float rad, float hei); - void connectVerticesToSoftBody(Mesh* const mesh, int objectI); - void connectSoftBodyToVertices(const Mesh* const mesh, int objectI); + void connectVerticesToSoftBody(wiSceneComponents::Mesh* const mesh, int objectI); + void connectSoftBodyToVertices(const wiSceneComponents::Mesh* const mesh, int objectI); void transformBody(const XMFLOAT4& rot, const XMFLOAT3& pos, int objectI); PhysicsTransform* getObject(int index); - void registerObject(Object* object); - void removeObject(Object* object); + void registerObject(wiSceneComponents::Object* object); + void removeObject(wiSceneComponents::Object* object); void Update(float dt); void MarkForRead(); diff --git a/WickedEngine/wiEmittedParticle.cpp b/WickedEngine/wiEmittedParticle.cpp index 14e260164..21f8935a6 100644 --- a/WickedEngine/wiEmittedParticle.cpp +++ b/WickedEngine/wiEmittedParticle.cpp @@ -1,6 +1,6 @@ #include "wiEmittedParticle.h" #include "wiMath.h" -#include "wiLoader.h" +#include "wiSceneComponents.h" #include "wiRenderer.h" #include "wiResourceManager.h" #include "wiFrustum.h" @@ -13,6 +13,7 @@ using namespace std; using namespace wiGraphicsTypes; +using namespace wiSceneComponents; VertexShader *wiEmittedParticle::vertexShader = nullptr; PixelShader *wiEmittedParticle::pixelShader[PARTICLESHADERTYPE_COUNT] = {}; diff --git a/WickedEngine/wiEmittedParticle.h b/WickedEngine/wiEmittedParticle.h index ed585f8bb..37033fedc 100644 --- a/WickedEngine/wiEmittedParticle.h +++ b/WickedEngine/wiEmittedParticle.h @@ -5,11 +5,14 @@ #include "ShaderInterop_EmittedParticle.h" #include "wiImageEffects.h" -struct Object; -struct Material; - class wiArchive; +namespace wiSceneComponents +{ + struct Object; + struct Material; +} + class wiEmittedParticle { public: @@ -63,7 +66,7 @@ private: public: wiEmittedParticle(); - wiEmittedParticle(const std::string& newName, const std::string& newMat, Object* newObject, float newSize, float newRandomFac, float newNormalFac + wiEmittedParticle(const std::string& newName, const std::string& newMat, wiSceneComponents::Object* newObject, float newSize, float newRandomFac, float newNormalFac ,float newCount, float newLife, float newRandLife, float newScaleX, float newScaleY, float newRot); wiEmittedParticle(const wiEmittedParticle& other); static void SetUpStatic(); @@ -90,9 +93,9 @@ public: PARTICLESHADERTYPE shaderType = SOFT; std::string name; - Object* object; + wiSceneComponents::Object* object; std::string materialName; - Material* material; + wiSceneComponents::Material* material; float size,random_factor,normal_factor; float count,life,random_life; diff --git a/WickedEngine/wiFont.cpp b/WickedEngine/wiFont.cpp index d36ba22d4..759a2cc79 100644 --- a/WickedEngine/wiFont.cpp +++ b/WickedEngine/wiFont.cpp @@ -2,7 +2,7 @@ #include "wiRenderer.h" #include "wiResourceManager.h" #include "wiHelper.h" -#include "wiLoader.h" +#include "wiSceneComponents.h" #include "ResourceMapping.h" #include diff --git a/WickedEngine/wiHairParticle.cpp b/WickedEngine/wiHairParticle.cpp index 753e98c9b..2102c0e84 100644 --- a/WickedEngine/wiHairParticle.cpp +++ b/WickedEngine/wiHairParticle.cpp @@ -1,7 +1,7 @@ #include "wiHairParticle.h" #include "wiRenderer.h" #include "wiResourceManager.h" -#include "wiLoader.h" +#include "wiSceneComponents.h" #include "wiMath.h" #include "wiFrustum.h" #include "wiRandom.h" @@ -12,6 +12,7 @@ using namespace std; using namespace wiGraphicsTypes; +using namespace wiSceneComponents; VertexShader *wiHairParticle::vs = nullptr; PixelShader *wiHairParticle::ps[]; diff --git a/WickedEngine/wiHairParticle.h b/WickedEngine/wiHairParticle.h index 21d836797..e48c65cac 100644 --- a/WickedEngine/wiHairParticle.h +++ b/WickedEngine/wiHairParticle.h @@ -5,14 +5,17 @@ #include "wiSPTree.h" -struct SkinnedVertex; -struct Mesh; -struct Object; -struct Material; -struct Camera; - class wiArchive; +namespace wiSceneComponents +{ + struct SkinnedVertex; + struct Mesh; + struct Object; + struct Material; + struct Camera; +} + class wiHairParticle { public: @@ -54,14 +57,14 @@ public: public: wiHairParticle(); wiHairParticle(const std::string& newName, float newLen, int newCount - , const std::string& newMat, Object* newObject, const std::string& densityGroup, const std::string& lengthGroup); + , const std::string& newMat, wiSceneComponents::Object* newObject, const std::string& densityGroup, const std::string& lengthGroup); wiHairParticle(const wiHairParticle& other); void CleanUp(); void Generate(); - void ComputeCulling(Camera* camera, GRAPHICSTHREAD threadID); - void Draw(Camera* camera, SHADERTYPE shaderType, bool transparent, GRAPHICSTHREAD threadID); + void ComputeCulling(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID); + void Draw(wiSceneComponents::Camera* camera, SHADERTYPE shaderType, bool transparent, GRAPHICSTHREAD threadID); static void CleanUpStatic(); static void SetUpStatic(); @@ -70,9 +73,9 @@ public: float length; int count; std::string name, densityG, lenG, materialName; - Material* material; + wiSceneComponents::Material* material; XMFLOAT4X4 OriginalMatrix_Inverse; - Object* object; + wiSceneComponents::Object* object; size_t particleCount; void Serialize(wiArchive& archive); diff --git a/WickedEngine/wiImage.cpp b/WickedEngine/wiImage.cpp index 35708755d..a2e3e6e1e 100644 --- a/WickedEngine/wiImage.cpp +++ b/WickedEngine/wiImage.cpp @@ -2,7 +2,7 @@ #include "wiResourceManager.h" #include "wiRenderer.h" #include "wiImageEffects.h" -#include "wiLoader.h" +#include "wiSceneComponents.h" #include "wiHelper.h" #include "SamplerMapping.h" #include "ResourceMapping.h" diff --git a/WickedEngine/wiLoader_BindLua.h b/WickedEngine/wiLoader_BindLua.h deleted file mode 100644 index 5b1799148..000000000 --- a/WickedEngine/wiLoader_BindLua.h +++ /dev/null @@ -1,298 +0,0 @@ -#pragma once -#include "wiLua.h" -#include "wiLuna.h" -#include "wiLoader.h" - -namespace wiLoader_BindLua -{ - void Bind(); -} - -class Node_BindLua -{ -public: - Node* node; - - static const char className[]; - static Luna::FunctionType methods[]; - static Luna::PropertyType properties[]; - - Node_BindLua(Node* node = nullptr); - Node_BindLua(lua_State *L); - ~Node_BindLua(); - - int GetName(lua_State* L); - int SetName(lua_State* L); - int SetLayerMask(lua_State *L); - int GetLayerMask(lua_State *L); - - static void Bind(); -}; - -class Transform_BindLua : public Node_BindLua -{ -public: - Transform* transform; - - static const char className[]; - static Luna::FunctionType methods[]; - static Luna::PropertyType properties[]; - - Transform_BindLua(Transform* transform = nullptr); - Transform_BindLua(lua_State *L); - ~Transform_BindLua(); - - int AttachTo(lua_State* L); - int Detach(lua_State* L); - int DetachChild(lua_State* L); - int ApplyTransform(lua_State* L); - int Scale(lua_State* L); - int Rotate(lua_State* L); - int Translate(lua_State* L); - int Lerp(lua_State* L); - int CatmullRom(lua_State* L); - int MatrixTransform(lua_State* L); - int GetMatrix(lua_State* L); - int ClearTransform(lua_State* L); - int SetTransform(lua_State* L); - int GetPosition(lua_State* L); - int GetRotation(lua_State* L); - int GetScale(lua_State* L); - - static void Bind(); -}; - -class Cullable_BindLua -{ -public: - Cullable* cullable; - - static const char className[]; - static Luna::FunctionType methods[]; - static Luna::PropertyType properties[]; - - Cullable_BindLua(Cullable* cullable = nullptr); - Cullable_BindLua(lua_State *L); - ~Cullable_BindLua(); - - int Intersects(lua_State *L); - int GetAABB(lua_State* L); - int SetAABB(lua_State* L); - - static void Bind(); -}; - -class Object_BindLua : public Cullable_BindLua, public Transform_BindLua -{ -public: - Object* object; - - static const char className[]; - static Luna::FunctionType methods[]; - static Luna::PropertyType properties[]; - - Object_BindLua(Object* object = nullptr); - Object_BindLua(lua_State *L); - ~Object_BindLua(); - - int EmitTrail(lua_State *L); - int SetTrailDistortTex(lua_State *L); - int SetTrailTex(lua_State *L); - int SetTransparency(lua_State *L); - int GetTransparency(lua_State *L); - int SetColor(lua_State *L); - int GetColor(lua_State *L); - int GetEmitter(lua_State *L); - int IsValid(lua_State *L); - - static void Bind(); -}; - -class Armature_BindLua : public Transform_BindLua -{ -public: - Armature* armature; - - static const char className[]; - static Luna::FunctionType methods[]; - static Luna::PropertyType properties[]; - - Armature_BindLua(Armature* armature = nullptr); - Armature_BindLua(lua_State* L); - ~Armature_BindLua(); - - int GetAction(lua_State* L); - int GetActions(lua_State* L); - int GetBones(lua_State* L); - int GetBone(lua_State* L); - int GetFrame(lua_State* L); - int GetFrameCount(lua_State* L); - int IsValid(lua_State *L); - - int ChangeAction(lua_State* L); - int StopAction(lua_State* L); - int PauseAction(lua_State* L); - int PlayAction(lua_State* L); - int ResetAction(lua_State* L); - int AddAnimLayer(lua_State* L); - int DeleteAnimLayer(lua_State* L); - int SetAnimLayerWeight(lua_State* L); - int SetAnimLayerLooped(lua_State* L); - - static void Bind(); -}; - -class Decal_BindLua : public Cullable_BindLua, public Transform_BindLua -{ -public: - Decal* decal; - - static const char className[]; - static Luna::FunctionType methods[]; - static Luna::PropertyType properties[]; - - Decal_BindLua(Decal* decal); - Decal_BindLua(lua_State* L); - ~Decal_BindLua(); - - int SetTexture(lua_State* L); - int SetNormal(lua_State* L); - int SetLife(lua_State* L); - int GetLife(lua_State* L); - int SetFadeStart(lua_State* L); - int GetFadeStart(lua_State* L); - - static void Bind(); -}; - -class Ray_BindLua -{ -public: - RAY ray; - - static const char className[]; - static Luna::FunctionType methods[]; - static Luna::PropertyType properties[]; - - Ray_BindLua(const RAY& ray); - Ray_BindLua(lua_State* L); - ~Ray_BindLua(); - - int GetOrigin(lua_State* L); - int GetDirection(lua_State* L); - - static void Bind(); -}; - -class AABB_BindLua -{ -public: - AABB aabb; - - static const char className[]; - static Luna::FunctionType methods[]; - static Luna::PropertyType properties[]; - - AABB_BindLua(const AABB& ray); - AABB_BindLua(lua_State* L); - ~AABB_BindLua(); - - int Intersects(lua_State* L); - int Transform(lua_State* L); - int GetMin(lua_State* L); - int GetMax(lua_State* L); - - static void Bind(); -}; - -class EmittedParticle_BindLua -{ -public: - wiEmittedParticle* ps; - - static const char className[]; - static Luna::FunctionType methods[]; - static Luna::PropertyType properties[]; - - EmittedParticle_BindLua(wiEmittedParticle* ps); - EmittedParticle_BindLua(lua_State* L); - ~EmittedParticle_BindLua(); - - int GetName(lua_State* L); - int SetName(lua_State* L); - int GetMotionBlur(lua_State* L); - int SetMotionBlur(lua_State* L); - int Burst(lua_State* L); - int IsValid(lua_State* L); - - static void Bind(); -}; - -class Material_BindLua -{ -public: - Material* material; - - static const char className[]; - static Luna::FunctionType methods[]; - static Luna::PropertyType properties[]; - - Material_BindLua(Material* material); - Material_BindLua(lua_State* L); - ~Material_BindLua(); - - int GetName(lua_State* L); - int SetName(lua_State* L); - int GetColor(lua_State* L); - int SetColor(lua_State* L); - int GetAlpha(lua_State* L); - int SetAlpha(lua_State* L); - int GetRefractionIndex(lua_State* L); - int SetRefractionIndex(lua_State* L); - - static void Bind(); -}; - -class Camera_BindLua : public Transform_BindLua -{ -public: - Camera* cam; - - static const char className[]; - static Luna::FunctionType methods[]; - static Luna::PropertyType properties[]; - - Camera_BindLua(Camera* cam); - Camera_BindLua(lua_State* L); - ~Camera_BindLua(); - - int GetFarPlane(lua_State* L); - int SetFarPlane(lua_State* L); - int GetNearPlane(lua_State* L); - int SetNearPlane(lua_State* L); - int GetFOV(lua_State* L); - int SetFOV(lua_State* L); - int Lerp(lua_State* L); - int CatmullRom(lua_State* L); - - static void Bind(); -}; - -class Model_BindLua :public Transform_BindLua -{ -public: - Model* model; - - static const char className[]; - static Luna::FunctionType methods[]; - static Luna::PropertyType properties[]; - - Model_BindLua(Model* model); - Model_BindLua(lua_State* L); - ~Model_BindLua(); - - static void Bind(); -}; - - - diff --git a/WickedEngine/wiLua.cpp b/WickedEngine/wiLua.cpp index 6ee6b6b5d..20215b982 100644 --- a/WickedEngine/wiLua.cpp +++ b/WickedEngine/wiLua.cpp @@ -17,7 +17,7 @@ #include "wiImageEffects_BindLua.h" #include "SpriteAnim_BindLua.h" #include "wiResourceManager_BindLua.h" -#include "wiLoader_BindLua.h" +#include "wiSceneComponents_BindLua.h" #include "Vector_BindLua.h" #include "Matrix_BindLua.h" #include "wiInputManager_BindLua.h" @@ -71,7 +71,7 @@ wiLua* wiLua::GetGlobal() wiImageEffects_BindLua::Bind(); SpriteAnim_BindLua::Bind(); wiResourceManager_BindLua::Bind(); - wiLoader_BindLua::Bind(); + wiSceneComponents_BindLua::Bind(); Vector_BindLua::Bind(); Matrix_BindLua::Bind(); wiInputManager_BindLua::Bind(); diff --git a/WickedEngine/wiOcean.cpp b/WickedEngine/wiOcean.cpp index 2dcc1c48b..028bd9d53 100644 --- a/WickedEngine/wiOcean.cpp +++ b/WickedEngine/wiOcean.cpp @@ -3,8 +3,9 @@ #include "wiResourceManager.h" #include "ShaderInterop_Ocean.h" -using namespace wiGraphicsTypes; using namespace std; +using namespace wiGraphicsTypes; +using namespace wiSceneComponents; ComputeShader* wiOcean::m_pUpdateSpectrumCS = nullptr; ComputeShader* wiOcean::m_pUpdateDisplacementMapCS = nullptr; diff --git a/WickedEngine/wiOcean.h b/WickedEngine/wiOcean.h index 2042b3977..45c3b8e12 100644 --- a/WickedEngine/wiOcean.h +++ b/WickedEngine/wiOcean.h @@ -7,8 +7,10 @@ #include - -struct Camera; +namespace wiSceneComponents +{ + struct Camera; +} struct wiOceanParameter { @@ -63,7 +65,7 @@ public: ~wiOcean(); void UpdateDisplacementMap(float time, GRAPHICSTHREAD threadID); - void Render(const Camera* camera, float time, GRAPHICSTHREAD threadID); + void Render(const wiSceneComponents::Camera* camera, float time, GRAPHICSTHREAD threadID); wiGraphicsTypes::Texture2D* getDisplacementMap(); wiGraphicsTypes::Texture2D* getGradientMap(); diff --git a/WickedEngine/wiPHYSICS.h b/WickedEngine/wiPHYSICS.h index 8750bdc66..4df9cd4bf 100644 --- a/WickedEngine/wiPHYSICS.h +++ b/WickedEngine/wiPHYSICS.h @@ -3,8 +3,11 @@ #include -struct Mesh; -struct Object; +namespace wiSceneComponents +{ + struct Mesh; + struct Object; +} class PHYSICS { @@ -54,17 +57,17 @@ public: , float newMass=1, float newFriction=1, float newRestitution=1, float newDamping=1, bool kinematic=false)=0; - virtual void addSoftBodyTriangleMesh(const Mesh* mesh, const XMFLOAT3& sca, const XMFLOAT4& rot, const XMFLOAT3& pos + virtual void addSoftBodyTriangleMesh(const wiSceneComponents::Mesh* mesh, const XMFLOAT3& sca, const XMFLOAT4& rot, const XMFLOAT3& pos , float newMass=1, float newFriction=1, float newRestitution=1, float newDamping=1)=0; - virtual void connectVerticesToSoftBody(Mesh* const mesh, int objectI)=0; - virtual void connectSoftBodyToVertices(const Mesh* const mesh, int objectI)=0; + virtual void connectVerticesToSoftBody(wiSceneComponents::Mesh* const mesh, int objectI)=0; + virtual void connectSoftBodyToVertices(const wiSceneComponents::Mesh* const mesh, int objectI)=0; virtual void transformBody(const XMFLOAT4& rot, const XMFLOAT3& pos, int objectI)=0; virtual PhysicsTransform* getObject(int index)=0; // add object to the simulation - virtual void registerObject(Object* object) = 0; + virtual void registerObject(wiSceneComponents::Object* object) = 0; // remove object from simulation - virtual void removeObject(Object* object) = 0; + virtual void removeObject(wiSceneComponents::Object* object) = 0; }; diff --git a/WickedEngine/wiProfiler.cpp b/WickedEngine/wiProfiler.cpp index 6eb4a2e9f..f305b4529 100644 --- a/WickedEngine/wiProfiler.cpp +++ b/WickedEngine/wiProfiler.cpp @@ -3,6 +3,8 @@ #include "wiRenderer.h" #include "wiFont.h" +#include + using namespace std; using namespace wiGraphicsTypes; diff --git a/WickedEngine/wiRenderer.cpp b/WickedEngine/wiRenderer.cpp index 796fe18fe..94ba23239 100644 --- a/WickedEngine/wiRenderer.cpp +++ b/WickedEngine/wiRenderer.cpp @@ -4,7 +4,7 @@ #include "wiEmittedParticle.h" #include "wiResourceManager.h" #include "wiSprite.h" -#include "wiLoader.h" +#include "wiSceneComponents.h" #include "wiFrustum.h" #include "wiRenderTarget.h" #include "wiDepthTarget.h" @@ -38,6 +38,7 @@ using namespace std; using namespace wiGraphicsTypes; +using namespace wiSceneComponents; #pragma region STATICS GraphicsDevice* wiRenderer::graphicsDevice = nullptr; @@ -2873,7 +2874,7 @@ Material* wiRenderer::getMaterialByName(const std::string& get) { for (Model* model : GetScene().models) { - MaterialCollection::iterator iter = model->materials.find(get); + auto& iter = model->materials.find(get); if (iter != model->materials.end()) return iter->second; } @@ -2924,60 +2925,6 @@ Light* wiRenderer::getLightByName(const std::string& name) return nullptr; } -Mesh::Vertex_FULL wiRenderer::TransformVertex(const Mesh* mesh, int vertexI, const XMMATRIX& mat) -{ - XMMATRIX sump; - XMVECTOR pos = mesh->vertices_POS[vertexI].LoadPOS(); - XMVECTOR nor = mesh->vertices_POS[vertexI].LoadNOR(); - - if (mesh->hasArmature() && !mesh->armature->boneCollection.empty()) - { - XMFLOAT4 ind = mesh->vertices_BON[vertexI].GetInd_FULL(); - XMFLOAT4 wei = mesh->vertices_BON[vertexI].GetWei_FULL(); - - - float inWei[4] = { - wei.x, - wei.y, - wei.z, - wei.w - }; - float inBon[4] = { - ind.x, - ind.y, - ind.z, - ind.w - }; - if (inWei[0] || inWei[1] || inWei[2] || inWei[3]) - { - sump = XMMATRIX(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - for (unsigned int i = 0; i < 4; i++) - { - sump += XMLoadFloat4x4(&mesh->armature->boneCollection[int(inBon[i])]->boneRelativity) * inWei[i]; - } - } - else - { - sump = XMMatrixIdentity(); - } - sump = XMMatrixMultiply(sump, mat); - } - else - { - sump = mat; - } - - XMFLOAT3 transformedP, transformedN; - XMStoreFloat3(&transformedP, XMVector3Transform(pos, sump)); - - XMStoreFloat3(&transformedN, XMVector3Normalize(XMVector3TransformNormal(nor, sump))); - - Mesh::Vertex_FULL retV(transformedP); - retV.nor = XMFLOAT4(transformedN.x, transformedN.y, transformedN.z, retV.nor.w); - retV.tex = mesh->vertices_FULL[vertexI].tex; - - return retV; -} void wiRenderer::FixedUpdate() { cam->UpdateTransform(); @@ -3461,7 +3408,7 @@ void wiRenderer::UpdateRenderData(GRAPHICSTHREAD threadID) } // Skinning: - for (MeshCollection::iterator iter = model->meshes.begin(); iter != model->meshes.end(); ++iter) + for (auto& iter = model->meshes.begin(); iter != model->meshes.end(); ++iter) { Mesh* mesh = iter->second; @@ -8163,7 +8110,7 @@ void wiRenderer::RayIntersectMeshes(const RAY& ray, const CulledList& culledObje { for (size_t i = 0; i < mesh->vertices_POS.size(); ++i) { - _tmpvert = TransformVertex(mesh, (int)i); + _tmpvert = mesh->TransformVertex((int)i); _vertices[i] = XMLoadFloat4(&_tmpvert.pos); } } @@ -8441,7 +8388,7 @@ void wiRenderer::SynchronizeWithPhysicsEngine(float dt) for (std::map::iterator it = mesh->vertexGroups[gvg].vertices.begin(); it != mesh->vertexGroups[gvg].vertices.end(); ++it) { int vi = (*it).first; - Mesh::Vertex_FULL tvert = TransformVertex(mesh, vi, worldMat); + Mesh::Vertex_FULL tvert = mesh->TransformVertex(vi, worldMat); mesh->goalPositions[j] = XMFLOAT3(tvert.pos.x, tvert.pos.y, tvert.pos.z); mesh->goalNormals[j] = XMFLOAT3(tvert.nor.x, tvert.nor.y, tvert.nor.z); ++j; diff --git a/WickedEngine/wiRenderer.h b/WickedEngine/wiRenderer.h index 17d17448c..eb3e7e32d 100644 --- a/WickedEngine/wiRenderer.h +++ b/WickedEngine/wiRenderer.h @@ -3,30 +3,36 @@ #include "ShaderInterop.h" #include "wiEnums.h" #include "wiGraphicsAPI.h" -#include "wiSPTree.h" #include "wiWindowRegistration.h" +#include "wiSPTree.h" +#include "wiFrustum.h" #include +#include -struct Transform; -struct Vertex; -struct SkinnedVertex; -struct Material; -struct Object; -struct Mesh; -struct Armature; -struct Bone; -struct KeyFrame; -struct SHCAM; -struct Light; -struct Decal; -struct WorldInfo; -struct Wind; -struct Camera; -struct RAY; -struct Camera; -struct Model; -struct Scene; +namespace wiSceneComponents +{ + struct Transform; + struct Vertex; + struct SkinnedVertex; + struct Material; + struct Object; + struct Mesh; + struct Armature; + struct Bone; + struct KeyFrame; + struct SHCAM; + struct Light; + struct Decal; + struct WorldInfo; + struct Wind; + struct Camera; + struct Model; + struct Scene; + struct Cullable; + struct EnvironmentProbe; + struct ForceField; +} class Lines; class Cube; @@ -37,16 +43,13 @@ class wiHairParticle; class wiSprite; class wiSPTree; class TaskThread; -struct Cullable; class PHYSICS; class wiRenderTarget; class wiWaterPlane; class wiOcean; struct wiOceanParameter; -typedef std::map MeshCollection; -typedef std::map MaterialCollection; - +struct RAY; class wiRenderer { @@ -275,7 +278,7 @@ protected: static float GameSpeed, overrideGameSpeed; - static Scene* scene; + static wiSceneComponents::Scene* scene; static wiWaterPlane waterPlane; @@ -326,7 +329,7 @@ public: static void OcclusionCulling_Read(); static void UpdateImages(); static void ManageImages(); - static void PutDecal(Decal* decal); + static void PutDecal(wiSceneComponents::Decal* decal); static void PutWaterRipple(const std::string& image, const XMFLOAT3& pos); static void ManageWaterRipples(); static void DrawWaterRipples(GRAPHICSTHREAD threadID); @@ -403,21 +406,19 @@ public: static wiGraphicsTypes::Texture2D* GetLuminance(wiGraphicsTypes::Texture2D* sourceImage, GRAPHICSTHREAD threadID); static wiWaterPlane GetWaterPlane(); - static Transform* getTransformByName(const std::string& name); - static Transform* getTransformByID(uint64_t id); - static Armature* getArmatureByName(const std::string& get); - static int getActionByName(Armature* armature, const std::string& get); - static int getBoneByName(Armature* armature, const std::string& get); - static Material* getMaterialByName(const std::string& get); - static Object* getObjectByName(const std::string& name); - static Camera* getCameraByName(const std::string& name); - static Light* getLightByName(const std::string& name); + static wiSceneComponents::Transform* getTransformByName(const std::string& name); + static wiSceneComponents::Transform* getTransformByID(uint64_t id); + static wiSceneComponents::Armature* getArmatureByName(const std::string& get); + static int getActionByName(wiSceneComponents::Armature* armature, const std::string& get); + static int getBoneByName(wiSceneComponents::Armature* armature, const std::string& get); + static wiSceneComponents::Material* getMaterialByName(const std::string& get); + static wiSceneComponents::Object* getObjectByName(const std::string& name); + static wiSceneComponents::Camera* getCameraByName(const std::string& name); + static wiSceneComponents::Light* getLightByName(const std::string& name); static void ReloadShaders(const std::string& path = ""); static void BindPersistentState(GRAPHICSTHREAD threadID); - static Mesh::Vertex_FULL TransformVertex(const Mesh* mesh, int vertexI, const XMMATRIX& mat = XMMatrixIdentity()); - struct FrameCulling { Frustum frustum; @@ -426,8 +427,8 @@ public: CulledCollection culledRenderer_transparent; std::vector culledHairParticleSystems; CulledList culledLights; - std::list culledDecals; - std::list culledEnvProbes; + std::list culledDecals; + std::list culledEnvProbes; void Clear() { @@ -440,7 +441,7 @@ public: culledEnvProbes.clear(); } }; - static std::unordered_map frameCullings; + static std::unordered_map frameCullings; inline static XMUINT3 GetEntityCullingTileCount() { @@ -455,7 +456,7 @@ public: static void UpdateWorldCB(GRAPHICSTHREAD threadID); static void UpdateFrameCB(GRAPHICSTHREAD threadID); - static void UpdateCameraCB(Camera* camera, GRAPHICSTHREAD threadID); + static void UpdateCameraCB(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID); static void SetClipPlane(const XMFLOAT4& clipPlane, GRAPHICSTHREAD threadID); static void SetAlphaRef(float alphaRef, GRAPHICSTHREAD threadID); static void ResetAlphaRef(GRAPHICSTHREAD threadID) { SetAlphaRef(0.75f, threadID); } @@ -466,31 +467,31 @@ public: bool tessellation = false, bool occlusionCulling = false, uint32_t layerMask = 0xFFFFFFFF); static void DrawSky(GRAPHICSTHREAD threadID); static void DrawSun(GRAPHICSTHREAD threadID); - static void DrawWorld(Camera* camera, bool tessellation, GRAPHICSTHREAD threadID, SHADERTYPE shaderType, bool grass, bool occlusionCulling, uint32_t layerMask = 0xFFFFFFFF); + static void DrawWorld(wiSceneComponents::Camera* camera, bool tessellation, GRAPHICSTHREAD threadID, SHADERTYPE shaderType, bool grass, bool occlusionCulling, uint32_t layerMask = 0xFFFFFFFF); static void DrawForShadowMap(GRAPHICSTHREAD threadID, uint32_t layerMask = 0xFFFFFFFF); - static void DrawWorldTransparent(Camera* camera, SHADERTYPE shaderType, GRAPHICSTHREAD threadID, bool grass, bool occlusionCulling, uint32_t layerMask = 0xFFFFFFFF); - void DrawDebugSpheres(Camera* camera, GRAPHICSTHREAD threadID); - static void DrawDebugBoneLines(Camera* camera, GRAPHICSTHREAD threadID); - static void DrawDebugLines(Camera* camera, GRAPHICSTHREAD threadID); - static void DrawDebugBoxes(Camera* camera, GRAPHICSTHREAD threadID); - static void DrawTranslators(Camera* camera, GRAPHICSTHREAD threadID); - static void DrawDebugEnvProbes(Camera* camera, GRAPHICSTHREAD threadID); - static void DrawDebugGridHelper(Camera* camera, GRAPHICSTHREAD threadID); - static void DrawDebugVoxels(Camera* camera, GRAPHICSTHREAD threadID); - static void DrawDebugEmitters(Camera* camera, GRAPHICSTHREAD threadID); - static void DrawDebugForceFields(Camera* camera, GRAPHICSTHREAD threadID); - static void DrawDebugCameras(Camera* camera, GRAPHICSTHREAD threadID); - static void DrawSoftParticles(Camera* camera, bool distortion, GRAPHICSTHREAD threadID); + static void DrawWorldTransparent(wiSceneComponents::Camera* camera, SHADERTYPE shaderType, GRAPHICSTHREAD threadID, bool grass, bool occlusionCulling, uint32_t layerMask = 0xFFFFFFFF); + void DrawDebugSpheres(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID); + static void DrawDebugBoneLines(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID); + static void DrawDebugLines(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID); + static void DrawDebugBoxes(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID); + static void DrawTranslators(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID); + static void DrawDebugEnvProbes(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID); + static void DrawDebugGridHelper(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID); + static void DrawDebugVoxels(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID); + static void DrawDebugEmitters(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID); + static void DrawDebugForceFields(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID); + static void DrawDebugCameras(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID); + static void DrawSoftParticles(wiSceneComponents::Camera* camera, bool distortion, GRAPHICSTHREAD threadID); static void DrawTrails(GRAPHICSTHREAD threadID, wiGraphicsTypes::Texture2D* refracRes); static void DrawImagesAdd(GRAPHICSTHREAD threadID, wiGraphicsTypes::Texture2D* refracRes); //alpha-opaque static void DrawImages(GRAPHICSTHREAD threadID, wiGraphicsTypes::Texture2D* refracRes); static void DrawImagesNormals(GRAPHICSTHREAD threadID, wiGraphicsTypes::Texture2D* refracRes); - static void DrawLights(Camera* camera, GRAPHICSTHREAD threadID); - static void DrawLightVisualizers(Camera* camera, GRAPHICSTHREAD threadID); - static void DrawVolumeLights(Camera* camera, GRAPHICSTHREAD threadID); + static void DrawLights(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID); + static void DrawLightVisualizers(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID); + static void DrawVolumeLights(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID); static void DrawLensFlares(GRAPHICSTHREAD threadID); - static void DrawDecals(Camera* camera, GRAPHICSTHREAD threadID); + static void DrawDecals(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID); static void RefreshEnvProbes(GRAPHICSTHREAD threadID); static void VoxelRadiance(GRAPHICSTHREAD threadID); @@ -498,7 +499,7 @@ public: static void ResolveMSAADepthBuffer(wiGraphicsTypes::Texture2D* dst, wiGraphicsTypes::Texture2D* src, GRAPHICSTHREAD threadID); static void BuildSceneBVH(GRAPHICSTHREAD threadID); - static void DrawTracedScene(Camera* camera, wiGraphicsTypes::Texture2D* result, GRAPHICSTHREAD threadID); + static void DrawTracedScene(wiSceneComponents::Camera* camera, wiGraphicsTypes::Texture2D* result, GRAPHICSTHREAD threadID); enum MIPGENFILTER { @@ -541,13 +542,13 @@ public: static wiSPTree* spTree_lights; // The scene holds all models, world information and wind information - static Scene& GetScene(); + static wiSceneComponents::Scene& GetScene(); static std::vector boneLines; static std::vector linesTemp; static std::vector cubes; - static std::unordered_set objectsWithTrails; + static std::unordered_set objectsWithTrails; static std::unordered_set emitterSystems; static std::deque images; @@ -557,21 +558,21 @@ public: static wiRenderTarget normalMapRT, imagesRT, imagesRTAdd; - static Camera* cam, *refCam, *prevFrameCam; - static Camera* getCamera(){ return cam; } - static Camera* getRefCamera(){ return refCam; } + static wiSceneComponents::Camera* cam, *refCam, *prevFrameCam; + static wiSceneComponents::Camera* getCamera(){ return cam; } + static wiSceneComponents::Camera* getRefCamera(){ return refCam; } std::string DIRECTORY; struct Picked { - Transform* transform; - Object* object; - Light* light; - Decal* decal; - EnvironmentProbe* envProbe; - ForceField* forceField; - Camera* camera; + wiSceneComponents::Transform* transform; + wiSceneComponents::Object* object; + wiSceneComponents::Light* light; + wiSceneComponents::Decal* decal; + wiSceneComponents::EnvironmentProbe* envProbe; + wiSceneComponents::ForceField* forceField; + wiSceneComponents::Camera* camera; XMFLOAT3 position,normal; float distance; int subsetIndex; @@ -617,7 +618,7 @@ public: static RAY getPickRay(long cursorX, long cursorY); static void RayIntersectMeshes(const RAY& ray, const CulledList& culledObjects, std::vector& points, int pickType = PICK_OPAQUE, bool dynamicObjects = true, bool onlyVisible = false, uint32_t layerMask = 0xFFFFFFFF); - static void CalculateVertexAO(Object* object); + static void CalculateVertexAO(wiSceneComponents::Object* object); static PHYSICS* physicsEngine; static void SynchronizeWithPhysicsEngine(float dt = 1.0f / 60.0f); @@ -626,13 +627,13 @@ public: static void SetOceanEnabled(bool enabled, const wiOceanParameter& params); static wiOcean* GetOcean() { return ocean; } - static Model* LoadModel(const std::string& fileName, const XMMATRIX& transform = XMMatrixIdentity()); + static wiSceneComponents::Model* LoadModel(const std::string& fileName, const XMMATRIX& transform = XMMatrixIdentity()); static void LoadWorldInfo(const std::string& fileName); static void LoadDefaultLighting(); static void PutEnvProbe(const XMFLOAT3& position); - static void CreateImpostor(Mesh* mesh, GRAPHICSTHREAD threadID); + static void CreateImpostor(wiSceneComponents::Mesh* mesh, GRAPHICSTHREAD threadID); static std::vector renderableTranslators; // Add translator to render in next frame @@ -645,22 +646,22 @@ public: static void AddDeferredMIPGen(wiGraphicsTypes::Texture2D* tex); // Add model to the scene - static void AddModel(Model* value); + static void AddModel(wiSceneComponents::Model* value); // Add Object Instance - static void Add(Object* value); + static void Add(wiSceneComponents::Object* value); // Add Light Instance - static void Add(Light* value); + static void Add(wiSceneComponents::Light* value); // Add Force Field Instance - static void Add(ForceField* value); + static void Add(wiSceneComponents::ForceField* value); // Add Camera Instance - static void Add(Camera* value); + static void Add(wiSceneComponents::Camera* value); // Remove from the scene - static void Remove(Object* value); - static void Remove(Light* value); - static void Remove(Decal* value); - static void Remove(EnvironmentProbe* value); - static void Remove(ForceField* value); - static void Remove(Camera* value); + static void Remove(wiSceneComponents::Object* value); + static void Remove(wiSceneComponents::Light* value); + static void Remove(wiSceneComponents::Decal* value); + static void Remove(wiSceneComponents::EnvironmentProbe* value); + static void Remove(wiSceneComponents::ForceField* value); + static void Remove(wiSceneComponents::Camera* value); }; diff --git a/WickedEngine/wiRenderer_BindLua.cpp b/WickedEngine/wiRenderer_BindLua.cpp index e9584dfb0..954110fa5 100644 --- a/WickedEngine/wiRenderer_BindLua.cpp +++ b/WickedEngine/wiRenderer_BindLua.cpp @@ -1,9 +1,9 @@ #include "wiRenderer_BindLua.h" #include "wiRenderer.h" #include "wiLines.h" -#include "wiLoader.h" +#include "wiSceneComponents.h" #include "wiHelper.h" -#include "wiLoader_BindLua.h" +#include "wiSceneComponents_BindLua.h" #include "Vector_BindLua.h" #include "Matrix_BindLua.h" #include "wiWaterPlane.h" @@ -14,6 +14,7 @@ using namespace std; using namespace wiGraphicsTypes; +using namespace wiSceneComponents_BindLua; namespace wiRenderer_BindLua { diff --git a/WickedEngine/wiResourceManager_BindLua.cpp b/WickedEngine/wiResourceManager_BindLua.cpp index d1b42c7f7..b18496ef1 100644 --- a/WickedEngine/wiResourceManager_BindLua.cpp +++ b/WickedEngine/wiResourceManager_BindLua.cpp @@ -4,6 +4,8 @@ #include "Texture_BindLua.h" #include "wiRenderer.h" +#include + using namespace std; using namespace wiGraphicsTypes; diff --git a/WickedEngine/wiSPTree.cpp b/WickedEngine/wiSPTree.cpp index 84f12da00..19db4dd4d 100644 --- a/WickedEngine/wiSPTree.cpp +++ b/WickedEngine/wiSPTree.cpp @@ -1,8 +1,10 @@ #include "wiSPTree.h" #include "wiMath.h" -#include "wiLoader.h" +#include "wiSceneComponents.h" #include "wiFrustum.h" +using namespace wiSceneComponents; + #define SP_TREE_MAX_DEPTH 12 #define SP_TREE_OBJECT_PER_NODE 6 #define SP_TREE_BOX_CONTAIN diff --git a/WickedEngine/wiSPTree.h b/WickedEngine/wiSPTree.h index 81c419246..c27ae9f9a 100644 --- a/WickedEngine/wiSPTree.h +++ b/WickedEngine/wiSPTree.h @@ -1,16 +1,23 @@ #pragma once #include "CommonInclude.h" -#include "wiLoader.h" +#include "wiIntersectables.h" #include #include +namespace wiSceneComponents +{ + struct Mesh; + struct Object; + struct Cullable; +} + class Frustum; -typedef std::list CulledList; +typedef std::list CulledList; -typedef std::list CulledObjectList; -typedef std::unordered_map CulledCollection; +typedef std::list CulledObjectList; +typedef std::unordered_map CulledCollection; class wiSPTree { @@ -19,7 +26,7 @@ protected: wiSPTree(); public: ~wiSPTree(); - void initialize(const std::vector& objects, const XMFLOAT3& newMin = XMFLOAT3(FLOAT32_MAX, FLOAT32_MAX, FLOAT32_MAX), const XMFLOAT3& newMax = XMFLOAT3(-FLOAT32_MAX, -FLOAT32_MAX, -FLOAT32_MAX)); + void initialize(const std::vector& objects, const XMFLOAT3& newMin = XMFLOAT3(FLT_MAX, FLT_MAX, FLT_MAX), const XMFLOAT3& newMax = XMFLOAT3(-FLT_MAX, -FLT_MAX, -FLT_MAX)); struct Node { @@ -63,7 +70,7 @@ public: // Sort culled list by their distance to the origin point static void Sort(const XMFLOAT3& origin, CulledList& objects, SortType sortType = SP_TREE_SORT_UNIQUE); - void AddObjects(Node* node, const std::vector& newObjects); + void AddObjects(Node* node, const std::vector& newObjects); void getVisible(Frustum& frustum, CulledList& objects, SortType sortType = SP_TREE_SORT_UNIQUE, CullStrictness type = SP_TREE_STRICT_CULL, Node* node = nullptr); void getVisible(AABB& frustum, CulledList& objects, SortType sortType = SP_TREE_SORT_UNIQUE, CullStrictness type = SP_TREE_STRICT_CULL, Node* node = nullptr); void getVisible(SPHERE& frustum, CulledList& objects, SortType sortType = SP_TREE_SORT_UNIQUE, CullStrictness type = SP_TREE_STRICT_CULL, Node* node = nullptr); @@ -71,13 +78,13 @@ public: void getAll(CulledList& objects, Node* node = nullptr); // Updates the tree. Returns null if successful, returns a new tree if the tree is resized. The old tree can be thrown away then. wiSPTree* updateTree(Node* node = nullptr); - void Remove(Cullable* value, Node* node = nullptr); + void Remove(wiSceneComponents::Cullable* value, Node* node = nullptr); }; class Octree : public wiSPTree { public: - Octree(const std::vector& objects, const XMFLOAT3& newMin = XMFLOAT3(FLOAT32_MAX, FLOAT32_MAX, FLOAT32_MAX), const XMFLOAT3& newMax = XMFLOAT3(-FLOAT32_MAX, -FLOAT32_MAX, -FLOAT32_MAX)) + Octree(const std::vector& objects, const XMFLOAT3& newMin = XMFLOAT3(FLT_MAX, FLT_MAX, FLT_MAX), const XMFLOAT3& newMax = XMFLOAT3(-FLT_MAX, -FLT_MAX, -FLT_MAX)) { childCount=8; initialize(objects, newMin, newMax); @@ -86,7 +93,7 @@ public: class QuadTree : public wiSPTree { public: - QuadTree(const std::vector& objects, const XMFLOAT3& newMin = XMFLOAT3(FLOAT32_MAX, FLOAT32_MAX, FLOAT32_MAX), const XMFLOAT3& newMax = XMFLOAT3(-FLOAT32_MAX, -FLOAT32_MAX, -FLOAT32_MAX)) + QuadTree(const std::vector& objects, const XMFLOAT3& newMin = XMFLOAT3(FLT_MAX, FLT_MAX, FLT_MAX), const XMFLOAT3& newMax = XMFLOAT3(-FLT_MAX, -FLT_MAX, -FLT_MAX)) { childCount = 4; initialize(objects, newMin, newMax); diff --git a/WickedEngine/wiLoader.cpp b/WickedEngine/wiSceneComponents.cpp similarity index 98% rename from WickedEngine/wiLoader.cpp rename to WickedEngine/wiSceneComponents.cpp index f65a4af9d..a00ddd690 100644 --- a/WickedEngine/wiLoader.cpp +++ b/WickedEngine/wiSceneComponents.cpp @@ -1,4 +1,4 @@ -#include "wiLoader.h" +#include "wiSceneComponents.h" #include "wiResourceManager.h" #include "wiHelper.h" #include "wiMath.h" @@ -12,10 +12,14 @@ #include "wiArchive.h" #include "wiBackLog.h" +#include using namespace std; using namespace wiGraphicsTypes; +namespace wiSceneComponents +{ + #pragma region SCENE Model* _CreateWorldNode() { @@ -1069,6 +1073,60 @@ void Mesh::FlipNormals() renderDataComplete = false; CreateRenderData(); } +Mesh::Vertex_FULL Mesh::TransformVertex(int vertexI, const XMMATRIX& mat) +{ + XMMATRIX sump; + XMVECTOR pos = vertices_POS[vertexI].LoadPOS(); + XMVECTOR nor = vertices_POS[vertexI].LoadNOR(); + + if (hasArmature() && !armature->boneCollection.empty()) + { + XMFLOAT4 ind = vertices_BON[vertexI].GetInd_FULL(); + XMFLOAT4 wei = vertices_BON[vertexI].GetWei_FULL(); + + + float inWei[4] = { + wei.x, + wei.y, + wei.z, + wei.w + }; + float inBon[4] = { + ind.x, + ind.y, + ind.z, + ind.w + }; + if (inWei[0] || inWei[1] || inWei[2] || inWei[3]) + { + sump = XMMATRIX(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + for (unsigned int i = 0; i < 4; i++) + { + sump += XMLoadFloat4x4(&armature->boneCollection[int(inBon[i])]->boneRelativity) * inWei[i]; + } + } + else + { + sump = XMMatrixIdentity(); + } + sump = XMMatrixMultiply(sump, mat); + } + else + { + sump = mat; + } + + XMFLOAT3 transformedP, transformedN; + XMStoreFloat3(&transformedP, XMVector3Transform(pos, sump)); + + XMStoreFloat3(&transformedN, XMVector3Normalize(XMVector3TransformNormal(nor, sump))); + + Mesh::Vertex_FULL retV(transformedP); + retV.nor = XMFLOAT4(transformedN.x, transformedN.y, transformedN.z, retV.nor.w); + retV.tex = vertices_FULL[vertexI].tex; + + return retV; +} int Mesh::GetRenderTypes() const { @@ -1675,7 +1733,7 @@ void Model::Serialize(wiArchive& archive) if (x->mesh == nullptr) { // find mesh - MeshCollection::iterator found = meshes.find(x->meshName); + auto& found = meshes.find(x->meshName); if (found != meshes.end()) { x->mesh = found->second; @@ -1689,7 +1747,7 @@ void Model::Serialize(wiArchive& archive) { if (y.material == nullptr) { - MaterialCollection::iterator it = materials.find(x->mesh->materialNames[i]); + auto& it = materials.find(x->mesh->materialNames[i]); if (it != materials.end()) { y.material = it->second; @@ -1714,7 +1772,7 @@ void Model::Serialize(wiArchive& archive) for (auto& y : x->eParticleSystems) { y->object = x; - MaterialCollection::iterator it = materials.find(y->materialName); + auto& it = materials.find(y->materialName); if (it != materials.end()) { y->material = it->second; @@ -1723,7 +1781,7 @@ void Model::Serialize(wiArchive& archive) for (auto& y : x->hParticleSystems) { y->object = x; - MaterialCollection::iterator it = materials.find(y->materialName); + auto& it = materials.find(y->materialName); if (it != materials.end()) { y->material = it->second; @@ -2704,8 +2762,8 @@ void Object::EmitTrail(const XMFLOAT3& col, float fadeSpeed) { if (base >= 0 && tip >= 0) { XMFLOAT4 baseP, tipP; XMFLOAT4 newCol = XMFLOAT4(col.x, col.y, col.z, 1); - baseP = wiRenderer::TransformVertex(mesh, base).pos; - tipP = wiRenderer::TransformVertex(mesh, tip).pos; + baseP = mesh->TransformVertex(base).pos; + tipP = mesh->TransformVertex(tip).pos; trail.push_back(RibbonVertex(XMFLOAT3(baseP.x, baseP.y, baseP.z), XMFLOAT2(0,0), XMFLOAT4(0, 0, 0, 1),fadeSpeed)); trail.push_back(RibbonVertex(XMFLOAT3(tipP.x, tipP.y, tipP.z), XMFLOAT2(0,0), newCol,fadeSpeed)); @@ -3264,4 +3322,4 @@ void EnvironmentProbe::Serialize(wiArchive& archive) #pragma endregion - +} diff --git a/WickedEngine/wiLoader.h b/WickedEngine/wiSceneComponents.h similarity index 99% rename from WickedEngine/wiLoader.h rename to WickedEngine/wiSceneComponents.h index 404c4aa93..f738ebb9d 100644 --- a/WickedEngine/wiLoader.h +++ b/WickedEngine/wiSceneComponents.h @@ -17,11 +17,18 @@ #include #include + +class wiArchive; + class wiParticle; class wiEmittedParticle; class wiHairParticle; class wiRenderTarget; + +namespace wiSceneComponents +{ + struct Armature; struct Bone; struct Mesh; @@ -29,11 +36,6 @@ struct Material; struct Object; struct Model; -typedef std::map MeshCollection; -typedef std::map MaterialCollection; - -class wiArchive; - struct ModelChild { Model* parentModel = nullptr; @@ -518,6 +520,7 @@ public: void ComputeNormals(bool smooth = false); void FlipCulling(); void FlipNormals(); + Vertex_FULL TransformVertex(int vertexI, const XMMATRIX& mat = XMMatrixIdentity()); void init(); bool hasArmature() const { return armature != nullptr; } @@ -1183,8 +1186,8 @@ struct ForceField : public Transform, public ModelChild struct Model : public Transform { std::unordered_set objects; - MeshCollection meshes; - MaterialCollection materials; + std::map meshes; + std::map materials; std::unordered_set armatures; std::unordered_set lights; std::unordered_set decals; @@ -1225,6 +1228,5 @@ struct Scene void Update(); }; -// Load world info from file: -void LoadWiWorldInfo(const std::string& fileName, WorldInfo& worldInfo, Wind& wind); +} diff --git a/WickedEngine/wiLoader_BindLua.cpp b/WickedEngine/wiSceneComponents_BindLua.cpp similarity index 99% rename from WickedEngine/wiLoader_BindLua.cpp rename to WickedEngine/wiSceneComponents_BindLua.cpp index fa86ef251..479f9e0e3 100644 --- a/WickedEngine/wiLoader_BindLua.cpp +++ b/WickedEngine/wiSceneComponents_BindLua.cpp @@ -1,4 +1,4 @@ -#include "wiLoader_BindLua.h" +#include "wiSceneComponents_BindLua.h" #include "Vector_BindLua.h" #include "Matrix_BindLua.h" #include "wiEmittedParticle.h" @@ -6,29 +6,25 @@ using namespace std; -namespace wiLoader_BindLua +namespace wiSceneComponents_BindLua { - void Bind() - { - Node_BindLua::Bind(); - Transform_BindLua::Bind(); - Cullable_BindLua::Bind(); - Object_BindLua::Bind(); - Armature_BindLua::Bind(); - Ray_BindLua::Bind(); - AABB_BindLua::Bind(); - EmittedParticle_BindLua::Bind(); - Decal_BindLua::Bind(); - Material_BindLua::Bind(); - Camera_BindLua::Bind(); - Model_BindLua::Bind(); - } +void Bind() +{ + Node_BindLua::Bind(); + Transform_BindLua::Bind(); + Cullable_BindLua::Bind(); + Object_BindLua::Bind(); + Armature_BindLua::Bind(); + Ray_BindLua::Bind(); + AABB_BindLua::Bind(); + EmittedParticle_BindLua::Bind(); + Decal_BindLua::Bind(); + Material_BindLua::Bind(); + Camera_BindLua::Bind(); + Model_BindLua::Bind(); } - - - const char Node_BindLua::className[] = "Node"; Luna::FunctionType Node_BindLua::methods[] = { @@ -2048,4 +2044,6 @@ void Model_BindLua::Bind() initialized = true; Luna::Register(wiLua::GetGlobal()->GetLuaState()); } -} \ No newline at end of file +} + +} diff --git a/WickedEngine/wiSceneComponents_BindLua.h b/WickedEngine/wiSceneComponents_BindLua.h new file mode 100644 index 000000000..8ece9a581 --- /dev/null +++ b/WickedEngine/wiSceneComponents_BindLua.h @@ -0,0 +1,299 @@ +#pragma once +#include "wiLua.h" +#include "wiLuna.h" +#include "wiSceneComponents.h" + +using namespace wiSceneComponents; + +namespace wiSceneComponents_BindLua +{ + void Bind(); + + class Node_BindLua + { + public: + Node * node; + + static const char className[]; + static Luna::FunctionType methods[]; + static Luna::PropertyType properties[]; + + Node_BindLua(Node* node = nullptr); + Node_BindLua(lua_State *L); + ~Node_BindLua(); + + int GetName(lua_State* L); + int SetName(lua_State* L); + int SetLayerMask(lua_State *L); + int GetLayerMask(lua_State *L); + + static void Bind(); + }; + + class Transform_BindLua : public Node_BindLua + { + public: + Transform * transform; + + static const char className[]; + static Luna::FunctionType methods[]; + static Luna::PropertyType properties[]; + + Transform_BindLua(Transform* transform = nullptr); + Transform_BindLua(lua_State *L); + ~Transform_BindLua(); + + int AttachTo(lua_State* L); + int Detach(lua_State* L); + int DetachChild(lua_State* L); + int ApplyTransform(lua_State* L); + int Scale(lua_State* L); + int Rotate(lua_State* L); + int Translate(lua_State* L); + int Lerp(lua_State* L); + int CatmullRom(lua_State* L); + int MatrixTransform(lua_State* L); + int GetMatrix(lua_State* L); + int ClearTransform(lua_State* L); + int SetTransform(lua_State* L); + int GetPosition(lua_State* L); + int GetRotation(lua_State* L); + int GetScale(lua_State* L); + + static void Bind(); + }; + + class Cullable_BindLua + { + public: + Cullable * cullable; + + static const char className[]; + static Luna::FunctionType methods[]; + static Luna::PropertyType properties[]; + + Cullable_BindLua(Cullable* cullable = nullptr); + Cullable_BindLua(lua_State *L); + ~Cullable_BindLua(); + + int Intersects(lua_State *L); + int GetAABB(lua_State* L); + int SetAABB(lua_State* L); + + static void Bind(); + }; + + class Object_BindLua : public Cullable_BindLua, public Transform_BindLua + { + public: + Object * object; + + static const char className[]; + static Luna::FunctionType methods[]; + static Luna::PropertyType properties[]; + + Object_BindLua(Object* object = nullptr); + Object_BindLua(lua_State *L); + ~Object_BindLua(); + + int EmitTrail(lua_State *L); + int SetTrailDistortTex(lua_State *L); + int SetTrailTex(lua_State *L); + int SetTransparency(lua_State *L); + int GetTransparency(lua_State *L); + int SetColor(lua_State *L); + int GetColor(lua_State *L); + int GetEmitter(lua_State *L); + int IsValid(lua_State *L); + + static void Bind(); + }; + + class Armature_BindLua : public Transform_BindLua + { + public: + Armature * armature; + + static const char className[]; + static Luna::FunctionType methods[]; + static Luna::PropertyType properties[]; + + Armature_BindLua(Armature* armature = nullptr); + Armature_BindLua(lua_State* L); + ~Armature_BindLua(); + + int GetAction(lua_State* L); + int GetActions(lua_State* L); + int GetBones(lua_State* L); + int GetBone(lua_State* L); + int GetFrame(lua_State* L); + int GetFrameCount(lua_State* L); + int IsValid(lua_State *L); + + int ChangeAction(lua_State* L); + int StopAction(lua_State* L); + int PauseAction(lua_State* L); + int PlayAction(lua_State* L); + int ResetAction(lua_State* L); + int AddAnimLayer(lua_State* L); + int DeleteAnimLayer(lua_State* L); + int SetAnimLayerWeight(lua_State* L); + int SetAnimLayerLooped(lua_State* L); + + static void Bind(); + }; + + class Decal_BindLua : public Cullable_BindLua, public Transform_BindLua + { + public: + Decal * decal; + + static const char className[]; + static Luna::FunctionType methods[]; + static Luna::PropertyType properties[]; + + Decal_BindLua(Decal* decal); + Decal_BindLua(lua_State* L); + ~Decal_BindLua(); + + int SetTexture(lua_State* L); + int SetNormal(lua_State* L); + int SetLife(lua_State* L); + int GetLife(lua_State* L); + int SetFadeStart(lua_State* L); + int GetFadeStart(lua_State* L); + + static void Bind(); + }; + + class Ray_BindLua + { + public: + RAY ray; + + static const char className[]; + static Luna::FunctionType methods[]; + static Luna::PropertyType properties[]; + + Ray_BindLua(const RAY& ray); + Ray_BindLua(lua_State* L); + ~Ray_BindLua(); + + int GetOrigin(lua_State* L); + int GetDirection(lua_State* L); + + static void Bind(); + }; + + class AABB_BindLua + { + public: + AABB aabb; + + static const char className[]; + static Luna::FunctionType methods[]; + static Luna::PropertyType properties[]; + + AABB_BindLua(const AABB& ray); + AABB_BindLua(lua_State* L); + ~AABB_BindLua(); + + int Intersects(lua_State* L); + int Transform(lua_State* L); + int GetMin(lua_State* L); + int GetMax(lua_State* L); + + static void Bind(); + }; + + class EmittedParticle_BindLua + { + public: + wiEmittedParticle * ps; + + static const char className[]; + static Luna::FunctionType methods[]; + static Luna::PropertyType properties[]; + + EmittedParticle_BindLua(wiEmittedParticle* ps); + EmittedParticle_BindLua(lua_State* L); + ~EmittedParticle_BindLua(); + + int GetName(lua_State* L); + int SetName(lua_State* L); + int GetMotionBlur(lua_State* L); + int SetMotionBlur(lua_State* L); + int Burst(lua_State* L); + int IsValid(lua_State* L); + + static void Bind(); + }; + + class Material_BindLua + { + public: + Material * material; + + static const char className[]; + static Luna::FunctionType methods[]; + static Luna::PropertyType properties[]; + + Material_BindLua(Material* material); + Material_BindLua(lua_State* L); + ~Material_BindLua(); + + int GetName(lua_State* L); + int SetName(lua_State* L); + int GetColor(lua_State* L); + int SetColor(lua_State* L); + int GetAlpha(lua_State* L); + int SetAlpha(lua_State* L); + int GetRefractionIndex(lua_State* L); + int SetRefractionIndex(lua_State* L); + + static void Bind(); + }; + + class Camera_BindLua : public Transform_BindLua + { + public: + Camera * cam; + + static const char className[]; + static Luna::FunctionType methods[]; + static Luna::PropertyType properties[]; + + Camera_BindLua(Camera* cam); + Camera_BindLua(lua_State* L); + ~Camera_BindLua(); + + int GetFarPlane(lua_State* L); + int SetFarPlane(lua_State* L); + int GetNearPlane(lua_State* L); + int SetNearPlane(lua_State* L); + int GetFOV(lua_State* L); + int SetFOV(lua_State* L); + int Lerp(lua_State* L); + int CatmullRom(lua_State* L); + + static void Bind(); + }; + + class Model_BindLua :public Transform_BindLua + { + public: + Model * model; + + static const char className[]; + static Luna::FunctionType methods[]; + static Luna::PropertyType properties[]; + + Model_BindLua(Model* model); + Model_BindLua(lua_State* L); + ~Model_BindLua(); + + static void Bind(); + }; + +} + diff --git a/WickedEngine/wiTransform.cpp b/WickedEngine/wiTransform.cpp index 646c5a18d..f67d0a37e 100644 --- a/WickedEngine/wiTransform.cpp +++ b/WickedEngine/wiTransform.cpp @@ -4,6 +4,9 @@ #include +namespace wiSceneComponents +{ + std::atomic Node::__Unique_ID_Counter = 0; Node::Node() { @@ -416,3 +419,5 @@ void Transform::Serialize(wiArchive& archive) } } + +} diff --git a/WickedEngine/wiTransform.h b/WickedEngine/wiTransform.h index 30481eda4..c3ed82599 100644 --- a/WickedEngine/wiTransform.h +++ b/WickedEngine/wiTransform.h @@ -7,6 +7,9 @@ class wiArchive; +namespace wiSceneComponents +{ + struct Node { private: @@ -85,4 +88,6 @@ struct Transform : public Node void Serialize(wiArchive& archive); }; +} + #endif // _TRANSFORM_H_ diff --git a/WickedEngine/wiTranslator.cpp b/WickedEngine/wiTranslator.cpp index 17e3ab582..5fa98228e 100644 --- a/WickedEngine/wiTranslator.cpp +++ b/WickedEngine/wiTranslator.cpp @@ -4,6 +4,7 @@ #include "wiMath.h" using namespace wiGraphicsTypes; +using namespace wiSceneComponents; GPUBuffer* wiTranslator::vertexBuffer_Axis = nullptr; GPUBuffer* wiTranslator::vertexBuffer_Plane = nullptr; diff --git a/WickedEngine/wiTranslator.h b/WickedEngine/wiTranslator.h index 98d4438e7..45804fc93 100644 --- a/WickedEngine/wiTranslator.h +++ b/WickedEngine/wiTranslator.h @@ -1,8 +1,8 @@ #pragma once #include "CommonInclude.h" -#include "wiLoader.h" +#include "wiSceneComponents.h" -class wiTranslator : public Transform +class wiTranslator : public wiSceneComponents::Transform { private: XMFLOAT4 prevPointer; diff --git a/WickedEngine/wiWidget.cpp b/WickedEngine/wiWidget.cpp index 20817b056..3a26916fb 100644 --- a/WickedEngine/wiWidget.cpp +++ b/WickedEngine/wiWidget.cpp @@ -9,6 +9,8 @@ #include +#include + using namespace std; using namespace wiGraphicsTypes; diff --git a/WickedEngine/wiWidget.h b/WickedEngine/wiWidget.h index ffb153382..2cf675ead 100644 --- a/WickedEngine/wiWidget.h +++ b/WickedEngine/wiWidget.h @@ -25,7 +25,7 @@ struct wiEventArgs std::string sValue; }; -class wiWidget : public Transform +class wiWidget : public wiSceneComponents::Transform { friend class wiGUI; public: