Huge rework of editor and other changes.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
#include "src/Core/Physics/Rigibody.h"
|
||||
|
||||
namespace Nuake {
|
||||
class BSPBrushComponent
|
||||
class BSPBrushComponent
|
||||
{
|
||||
public:
|
||||
std::vector<Ref<Mesh>> Meshes;
|
||||
@@ -22,10 +22,28 @@ namespace Nuake {
|
||||
bool IsTransparent = false;
|
||||
bool IsFunc = false;
|
||||
|
||||
BSPBrushComponent() {
|
||||
BSPBrushComponent()
|
||||
{
|
||||
Meshes = std::vector<Ref<Mesh>>();
|
||||
Materials = std::vector<Ref<Material>>();
|
||||
Rigidbody = std::vector<Ref<Physics::RigidBody>>();
|
||||
}
|
||||
|
||||
json Serialize()
|
||||
{
|
||||
BEGIN_SERIALIZE();
|
||||
|
||||
for (unsigned int i = 0; i < Meshes.size(); i++)
|
||||
{
|
||||
j["Meshes"][i] = Meshes[i]->Serialize();
|
||||
}
|
||||
|
||||
END_SERIALIZE();
|
||||
}
|
||||
|
||||
bool Deserialize()
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
22
Nuake/src/Scene/Components/BoxCollider.cpp
Normal file
22
Nuake/src/Scene/Components/BoxCollider.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include "BoxCollider.h"
|
||||
#include "src/Resource/Serializable.h"
|
||||
|
||||
namespace Nuake
|
||||
{
|
||||
json BoxColliderComponent::Serialize()
|
||||
{
|
||||
BEGIN_SERIALIZE();
|
||||
|
||||
j["IsTrigger"] = IsTrigger;
|
||||
SERIALIZE_VEC3(Size);
|
||||
END_SERIALIZE();
|
||||
}
|
||||
|
||||
bool BoxColliderComponent::Deserialize(const std::string& str)
|
||||
{
|
||||
BEGIN_DESERIALIZE();
|
||||
this->IsTrigger = j["IsTrigger"];
|
||||
this->Size = Vector3(j["Size"]["x"], j["Size"]["y"], j["Size"]["z"]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,16 @@
|
||||
#pragma once
|
||||
#include "src/Core/Physics/PhysicsShapes.h"
|
||||
#include "src/Core/Core.h"
|
||||
|
||||
namespace Nuake {
|
||||
class BoxColliderComponent
|
||||
{
|
||||
public:
|
||||
Ref<Physics::PhysicShape> Box;
|
||||
glm::vec3 Size = glm::vec3(0.5f, 0.5f, 0.5f);
|
||||
bool IsTrigger;
|
||||
bool IsTrigger = false;
|
||||
|
||||
json Serialize();
|
||||
bool Deserialize(const std::string& str);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Nuake {
|
||||
//start = glm::rotate(start, glm::radians(Direction.z), glm::vec3(0, 0, 1));
|
||||
|
||||
//return glm::vec3(start * glm::vec4(defaultDirection, 1.0f));
|
||||
return Direction;
|
||||
return glm::normalize(Direction);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -108,7 +108,8 @@ namespace Nuake {
|
||||
return nullptr;
|
||||
|
||||
aiMaterial* material = scene->mMaterials[mesh->mMaterialIndex];
|
||||
Ref<Material> newMaterial = MaterialManager::Get()->GetMaterial(directory + std::to_string(mesh->mMaterialIndex) + material->GetName().C_Str());
|
||||
std::string materialPath = directory + std::to_string(mesh->mMaterialIndex) + material->GetName().C_Str();
|
||||
Ref<Material> newMaterial = MaterialManager::Get()->GetMaterial(materialPath);
|
||||
|
||||
aiString str;
|
||||
|
||||
@@ -126,7 +127,13 @@ namespace Nuake {
|
||||
}
|
||||
else
|
||||
{
|
||||
newMaterial->SetAlbedo(TextureManager::Get()->GetTexture(FileSystem::Root + directory + str.C_Str()));
|
||||
std::string texturePath = FileSystem::Root + directory + str.C_Str();
|
||||
if (!FileSystem::FileExists(texturePath))
|
||||
{
|
||||
Logger::Log("Texture file couldn't be found: " + texturePath, Nuake::LOG_TYPE::CRITICAL);
|
||||
texturePath = "resources/Textures/default/Default.png";
|
||||
}
|
||||
newMaterial->SetAlbedo(TextureManager::Get()->GetTexture(texturePath));
|
||||
}
|
||||
|
||||
material->GetTexture(aiTextureType_NORMALS, 0, &str);
|
||||
|
||||
@@ -26,6 +26,12 @@ namespace Nuake {
|
||||
BEGIN_SERIALIZE();
|
||||
SERIALIZE_VAL(HasCollisions);
|
||||
SERIALIZE_VAL(Path);
|
||||
|
||||
for (unsigned int i = 0; i < m_Meshes.size(); i++)
|
||||
{
|
||||
j["Meshes"][i] = m_Meshes[i]->Serialize();
|
||||
}
|
||||
|
||||
END_SERIALIZE();
|
||||
}
|
||||
|
||||
@@ -34,7 +40,6 @@ namespace Nuake {
|
||||
BEGIN_DESERIALIZE();
|
||||
this->Path = j["Path"];
|
||||
this->HasCollisions = j["HasCollisions"];
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -8,8 +8,13 @@
|
||||
#include "../Components/QuakeMap.h"
|
||||
#include "../Components/WrenScriptComponent.h"
|
||||
#include "../Components/CharacterControllerComponent.h"
|
||||
|
||||
#include <src/Scene/Components/BoxCollider.h>
|
||||
#include <src/Scene/Components/MeshComponent.h>
|
||||
|
||||
//#include <src/Scene/Components/BoxCollider.h>
|
||||
#include "src/Scene/Components/BSPBrushComponent.h"
|
||||
|
||||
namespace Nuake
|
||||
{
|
||||
void Entity::AddChild(Entity ent)
|
||||
@@ -39,8 +44,13 @@ namespace Nuake
|
||||
SERIALIZE_OBJECT_REF_LBL("WrenScriptComponent", GetComponent<WrenScriptComponent>());
|
||||
if (HasComponent<CharacterControllerComponent>())
|
||||
SERIALIZE_OBJECT_REF_LBL("CharacterControllerComponent", GetComponent<CharacterControllerComponent>());
|
||||
|
||||
if (HasComponent<BoxColliderComponent>())
|
||||
SERIALIZE_OBJECT_REF_LBL("BoxColliderComponent", GetComponent<BoxColliderComponent>());
|
||||
if (HasComponent<MeshComponent>())
|
||||
SERIALIZE_OBJECT_REF_LBL("MeshComponent", GetComponent<MeshComponent>());
|
||||
if (HasComponent<BSPBrushComponent>())
|
||||
SERIALIZE_OBJECT_REF_LBL("BSPBrushComponent", GetComponent<BSPBrushComponent>());
|
||||
END_SERIALIZE();
|
||||
}
|
||||
|
||||
@@ -56,6 +66,8 @@ namespace Nuake
|
||||
DESERIALIZE_COMPONENT(MeshComponent);
|
||||
DESERIALIZE_COMPONENT(WrenScriptComponent);
|
||||
DESERIALIZE_COMPONENT(CharacterControllerComponent);
|
||||
//DESERIALIZE_COMPONENT(BSPBrushComponent);
|
||||
DESERIALIZE_COMPONENT(BoxColliderComponent);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,11 +13,15 @@ namespace Nuake
|
||||
{
|
||||
public:
|
||||
Environment();
|
||||
bool VolumetricEnabled = false;
|
||||
float VolumetricFog = 0.90f;
|
||||
float VolumetricStepCount = 50.f;
|
||||
|
||||
Scope<Bloom> mBloom;
|
||||
float Exposure = 3.5f;
|
||||
float Gamma = 1.1f;
|
||||
|
||||
bool BloomEnabled = false;
|
||||
Scope<Bloom> mBloom;
|
||||
Vector3 ClearColor;
|
||||
|
||||
glm::vec4 AmbientColor;
|
||||
|
||||
@@ -50,7 +50,8 @@ namespace Nuake {
|
||||
mSceneRenderer->Init();
|
||||
}
|
||||
|
||||
Scene::~Scene() {
|
||||
Scene::~Scene()
|
||||
{
|
||||
}
|
||||
|
||||
std::string Scene::GetName()
|
||||
@@ -251,6 +252,15 @@ namespace Nuake {
|
||||
return true;
|
||||
}
|
||||
|
||||
Scene* Scene::Copy()
|
||||
{
|
||||
Scene* sceneCopy = new Scene();
|
||||
sceneCopy->Path = this->Path;
|
||||
sceneCopy->Name = this->Name;
|
||||
|
||||
return sceneCopy;
|
||||
}
|
||||
|
||||
json Scene::Serialize()
|
||||
{
|
||||
BEGIN_SERIALIZE();
|
||||
@@ -285,28 +295,26 @@ namespace Nuake {
|
||||
}
|
||||
|
||||
// Parse entities
|
||||
if (!j.contains("Entities"))
|
||||
return 0;
|
||||
|
||||
for (json e : j["Entities"])
|
||||
{
|
||||
if (j.contains("Entities"))
|
||||
{
|
||||
for (json e : j["Entities"])
|
||||
{
|
||||
std::string name = e["NameComponent"]["Name"];
|
||||
Entity ent = { m_Registry.create(), this };
|
||||
ent.Deserialize(e.dump());
|
||||
}
|
||||
std::string name = e["NameComponent"]["Name"];
|
||||
Entity ent = { m_Registry.create(), this };
|
||||
ent.Deserialize(e.dump());
|
||||
}
|
||||
|
||||
auto view = m_Registry.view<ParentComponent>();
|
||||
for (auto e : view)
|
||||
{
|
||||
auto parentC = view.get<ParentComponent>(e);
|
||||
if (!parentC.HasParent)
|
||||
continue;
|
||||
auto view = m_Registry.view<ParentComponent>();
|
||||
for (auto e : view)
|
||||
{
|
||||
auto& parentComponent = view.get<ParentComponent>(e);
|
||||
if (!parentComponent.HasParent)
|
||||
continue;
|
||||
|
||||
auto& p = Entity{ e, this };
|
||||
auto parent = GetEntityByID(parentC.ParentID);
|
||||
parent.AddChild(p);
|
||||
}
|
||||
}
|
||||
auto& entity = Entity{ e, this };
|
||||
auto parentEntity = GetEntityByID(parentComponent.ParentID);
|
||||
parentEntity.AddChild(entity);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -69,6 +69,8 @@ namespace Nuake {
|
||||
void AddInterface(Ref<UI::UserInterface> interface);
|
||||
|
||||
json Serialize() override;
|
||||
|
||||
Scene* Copy();
|
||||
bool Deserialize(const std::string& str) override;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Nuake
|
||||
|
||||
rigidbody.m_Rigidbody = btRigidbody;
|
||||
|
||||
btRigidbody->SetKinematic(rigidbody.IsKinematic);
|
||||
//btRigidbody->SetKinematic(rigidbody.IsKinematic);
|
||||
|
||||
PhysicsManager::Get()->RegisterBody(btRigidbody);
|
||||
}
|
||||
@@ -61,16 +61,16 @@ namespace Nuake
|
||||
{
|
||||
auto [transform, brush] = bspView.get<TransformComponent, BSPBrushComponent>(e);
|
||||
|
||||
if (brush.IsSolid)
|
||||
if (!brush.IsSolid)
|
||||
continue;
|
||||
|
||||
for (auto m : brush.Meshes)
|
||||
{
|
||||
for (auto m : brush.Meshes)
|
||||
{
|
||||
Ref<Physics::MeshShape> meshShape = CreateRef<Physics::MeshShape>(m);
|
||||
Ref<Physics::RigidBody> btRigidbody = CreateRef<Physics::RigidBody>(0.0f, transform.GlobalTranslation, meshShape);
|
||||
btRigidbody->SetEntityID(Entity{ e, m_Scene });
|
||||
brush.Rigidbody.push_back(btRigidbody);
|
||||
PhysicsManager::Get()->RegisterBody(btRigidbody);
|
||||
}
|
||||
Ref<Physics::MeshShape> meshShape = CreateRef<Physics::MeshShape>(m);
|
||||
Ref<Physics::RigidBody> btRigidbody = CreateRef<Physics::RigidBody>(0.0f, transform.GlobalTranslation, meshShape);
|
||||
btRigidbody->SetEntityID(Entity{ e, m_Scene });
|
||||
brush.Rigidbody.push_back(btRigidbody);
|
||||
PhysicsManager::Get()->RegisterBody(btRigidbody);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,8 +93,6 @@ namespace Nuake
|
||||
if (!Engine::IsPlayMode)
|
||||
return;
|
||||
|
||||
PhysicsManager::Get()->Step(ts);
|
||||
|
||||
auto brushes = m_Scene->m_Registry.view<TransformComponent, BSPBrushComponent>();
|
||||
for (auto e : brushes)
|
||||
{
|
||||
@@ -122,7 +120,6 @@ namespace Nuake
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
auto bspTriggerView = m_Scene->m_Registry.view<TransformComponent, BSPBrushComponent, TriggerZone>();
|
||||
for (auto e : bspTriggerView)
|
||||
{
|
||||
@@ -156,7 +153,10 @@ namespace Nuake
|
||||
|
||||
void PhysicsSystem::FixedUpdate(Timestep ts)
|
||||
{
|
||||
|
||||
if (!Engine::IsPlayMode)
|
||||
return;
|
||||
|
||||
PhysicsManager::Get()->Step(ts);
|
||||
}
|
||||
|
||||
void PhysicsSystem::Exit()
|
||||
|
||||
Reference in New Issue
Block a user