Huge rework of editor and other changes.

This commit is contained in:
antopilo
2022-01-09 16:44:20 -05:00
parent 55ae840678
commit a71bfcbe75
55 changed files with 734 additions and 398 deletions

View File

@@ -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()
{
}
};
}

View 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;
}
}

View File

@@ -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);
};
}

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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;
}
};