Compare commits
128 Commits
eaef554b10
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
565c91b276 | ||
|
|
fec9286dee | ||
|
|
9f83ac816a | ||
|
|
076fe75409 | ||
|
|
913d1437c0 | ||
|
|
edd6b2f19e | ||
|
|
1a5dc70632 | ||
|
|
037aefc711 | ||
|
|
61bc9f032d | ||
|
|
b1b283f4c6 | ||
|
|
2fa9c3780d | ||
|
|
c99c89d26a | ||
|
|
b02fc33da3 | ||
|
|
9005863300 | ||
|
|
60a1683255 | ||
|
|
e85781c29e | ||
|
|
580c05c37b | ||
|
|
2c7bb51658 | ||
|
|
3f80057682 | ||
|
|
8f868529f8 | ||
|
|
8e6da66609 | ||
|
|
ae4e81c937 | ||
|
|
ed1dc1eed9 | ||
|
|
50dc6c8195 | ||
|
|
bbbe7adb3a | ||
|
|
09a70ab98d | ||
|
|
84c0733a77 | ||
|
|
2f1bb884d7 | ||
|
|
9d36bfd13f | ||
|
|
734caada6c | ||
|
|
3ae209819a | ||
|
|
e3678118b4 | ||
|
|
d654c99a8e | ||
|
|
ee4729d31e | ||
|
|
32746e7f95 | ||
|
|
dac1551039 | ||
|
|
9a395bd741 | ||
|
|
e106427ebc | ||
|
|
6a858f49e6 | ||
|
|
87af2e752e | ||
|
|
959728aee3 | ||
|
|
ad63b7d9ed | ||
|
|
d898960494 | ||
|
|
073bb47586 | ||
|
|
0abc3dbfab | ||
|
|
820442c4d6 | ||
|
|
9145e739ba | ||
|
|
988f7f8805 | ||
|
|
e4dcfeccb9 | ||
|
|
c808fe2903 | ||
|
|
f603d3b58f | ||
|
|
1a312832ea | ||
|
|
85c45f0929 | ||
|
|
6abfe9f27b | ||
|
|
a84b35c105 | ||
|
|
8db8ca679e | ||
|
|
83bb2c6932 | ||
|
|
4d5c9fc614 | ||
|
|
c9c0a328dc | ||
|
|
7ab3e7434a | ||
|
|
fe4b54699b | ||
|
|
b69f9c5305 | ||
|
|
adc6676dc9 | ||
|
|
43c66d887b | ||
|
|
6970df2ead | ||
|
|
b24578ad70 | ||
|
|
2463a5f001 | ||
|
|
697ae61109 | ||
|
|
e20853fdb1 | ||
|
|
55437f397e | ||
|
|
729abc17f0 | ||
|
|
42090a5d47 | ||
|
|
88ea35ab67 | ||
|
|
a6a3340334 | ||
|
|
73a82a00b4 | ||
|
|
7d7b09df55 | ||
|
|
9fc3422913 | ||
|
|
f053f23ed6 | ||
|
|
8b093603f5 | ||
|
|
27365835fa | ||
|
|
04ce3f4b8f | ||
|
|
15a137644f | ||
|
|
9add74afa8 | ||
|
|
7b6afc5240 | ||
|
|
2b0b81b2c8 | ||
|
|
0d9dcfd541 | ||
|
|
772b219caa | ||
|
|
be57a1fc16 | ||
|
|
67a42e5685 | ||
|
|
6ace0bac91 | ||
|
|
9b2d5bf35a | ||
|
|
378d4c58a9 | ||
|
|
c5d650cf6b | ||
|
|
709fb3141b | ||
|
|
3e96b676da | ||
|
|
f761718957 | ||
|
|
b72206b531 | ||
|
|
ca74942001 | ||
|
|
57a15752c7 | ||
|
|
5c5f55ec16 | ||
|
|
25d82d6689 | ||
|
|
2e3f7c9e20 | ||
|
|
0001e7e023 | ||
|
|
d3a0e88eb0 | ||
|
|
752d556204 | ||
|
|
94529460e2 | ||
|
|
37864d6d37 | ||
|
|
54c083ccda | ||
|
|
44910bd3f8 | ||
|
|
b4f4aa010e | ||
|
|
521ee17daf | ||
|
|
2175b60990 | ||
|
|
ebb179ec68 | ||
|
|
ee8841b6d4 | ||
|
|
a0c900166f | ||
|
|
ac18bb6f00 | ||
|
|
464ab70c46 | ||
|
|
48d2905695 | ||
|
|
af7b7d2bfa | ||
|
|
1eda916f3e | ||
|
|
44f766863d | ||
|
|
2d3fe57d5a | ||
|
|
5be3c61859 | ||
|
|
a187bd2894 | ||
|
|
ecf27eae73 | ||
|
|
f45091349e | ||
|
|
7da00008e0 | ||
|
|
f26ee2bca8 |
4
.envrc
Normal file
4
.envrc
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export CC=clang
|
||||||
|
export CXX=clang++
|
||||||
|
export COMPILE_COMMANDS=ON
|
||||||
|
export BUILD_TYPE=Debug
|
||||||
6
.gitmodules
vendored
Normal file
6
.gitmodules
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[submodule "vendor/ImGuizmo"]
|
||||||
|
path = vendor/ImGuizmo
|
||||||
|
url = https://github.com/CedricGuillemet/ImGuizmo
|
||||||
|
[submodule "open_engine/vendor/nativefiledialog-extended"]
|
||||||
|
path = open_engine/vendor/nativefiledialog-extended
|
||||||
|
url = https://github.com/btzy/nativefiledialog-extended
|
||||||
140
.onedev-buildspec.yml
Normal file
140
.onedev-buildspec.yml
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
version: 46
|
||||||
|
jobs:
|
||||||
|
- name: Push to Gitea
|
||||||
|
steps:
|
||||||
|
- type: PushRepository
|
||||||
|
name: Push to Gitea
|
||||||
|
remoteUrl: https://gitea.anfer.fr/anfer/OpenEngine
|
||||||
|
passwordSecret: Gitea
|
||||||
|
force: false
|
||||||
|
condition: SUCCESSFUL
|
||||||
|
optional: false
|
||||||
|
jobExecutor: terra-executor
|
||||||
|
triggers:
|
||||||
|
- type: BranchUpdateTrigger
|
||||||
|
branches: main
|
||||||
|
paths: -.onedev-buildspec.yml
|
||||||
|
userMatch: anyone
|
||||||
|
projects: OpenEngine
|
||||||
|
- type: TagCreateTrigger
|
||||||
|
branches: main
|
||||||
|
projects: OpenEngine
|
||||||
|
retryCondition: never
|
||||||
|
maxRetries: 3
|
||||||
|
retryDelay: 30
|
||||||
|
timeout: 14400
|
||||||
|
- name: Compile for Linux
|
||||||
|
steps:
|
||||||
|
- type: CheckoutStep
|
||||||
|
name: Checkout
|
||||||
|
cloneCredential:
|
||||||
|
type: DefaultCredential
|
||||||
|
withLfs: false
|
||||||
|
withSubmodules: false
|
||||||
|
condition: SUCCESSFUL
|
||||||
|
optional: false
|
||||||
|
- type: SetupCacheStep
|
||||||
|
name: conan-cache
|
||||||
|
key: conan-cache-@file:./conanfile.txt@
|
||||||
|
loadKeys:
|
||||||
|
- conan-cache-@project_name@
|
||||||
|
paths:
|
||||||
|
- /root/.conan2
|
||||||
|
uploadStrategy: UPLOAD_IF_NOT_HIT
|
||||||
|
changeDetectionExcludes: /root/.conan2/p/*/dl /root/.conan2/logs
|
||||||
|
condition: SUCCESSFUL
|
||||||
|
optional: true
|
||||||
|
- type: CommandStep
|
||||||
|
name: Compile for Linux
|
||||||
|
runInContainer: true
|
||||||
|
image: erriss/erris-build_tools:V0.7
|
||||||
|
interpreter:
|
||||||
|
type: DefaultInterpreter
|
||||||
|
commands: |
|
||||||
|
#git clone --depth 1 https://github.com/dotnet/runtime.git
|
||||||
|
#cd runtime
|
||||||
|
#./build.sh -c Release -subset host
|
||||||
|
|
||||||
|
#cp artifacts/bin/native/net10.0-linux-Release-x64/nethost/libnethost.a /onedev-build/workspace/lib/
|
||||||
|
|
||||||
|
git submodule update --init --recursive
|
||||||
|
|
||||||
|
conan profile detect --force
|
||||||
|
conan install . -c tools.system.package_manager:mode=install --output-folder=build --build=missing -s build_type=${BUILD_TYPE}
|
||||||
|
|
||||||
|
cmake -S . -G Ninja -B build -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake
|
||||||
|
|
||||||
|
echo ====== Building =============================
|
||||||
|
cmake --build build --config ${BUILD_TYPE}
|
||||||
|
envVars:
|
||||||
|
- name: BUILD_TYPE
|
||||||
|
value: Debug
|
||||||
|
- name: CC
|
||||||
|
value: clang
|
||||||
|
- name: CXX
|
||||||
|
value: clang++
|
||||||
|
useTTY: true
|
||||||
|
condition: SUCCESSFUL
|
||||||
|
optional: false
|
||||||
|
- type: PublishArtifactStep
|
||||||
|
name: Get build artifacts
|
||||||
|
sourcePath: build
|
||||||
|
artifacts: editor/* open_engine/*
|
||||||
|
condition: SUCCESSFUL
|
||||||
|
optional: false
|
||||||
|
jobExecutor: luna-executor
|
||||||
|
triggers:
|
||||||
|
- type: BranchUpdateTrigger
|
||||||
|
branches: main
|
||||||
|
paths: -.onedev-buildspec.yml
|
||||||
|
userMatch: anyone
|
||||||
|
projects: OpenEngine
|
||||||
|
retryCondition: never
|
||||||
|
maxRetries: 3
|
||||||
|
retryDelay: 30
|
||||||
|
timeout: 14400
|
||||||
|
- name: Release to Gitea
|
||||||
|
steps:
|
||||||
|
- type: CommandStep
|
||||||
|
name: Release to Gitea
|
||||||
|
runInContainer: true
|
||||||
|
image: erriss/erris-build_tools:V0.8
|
||||||
|
interpreter:
|
||||||
|
type: DefaultInterpreter
|
||||||
|
commands: |
|
||||||
|
# 1. Create the Release metadata
|
||||||
|
RELEASE_JSON=$(printf '{"tag_name":"v0.0.%s","target_commitish":"main","name":"Release v0.0.%s","body":"Automated build from OneDev","draft":false,"prerelease":false}' "$ONEDEV_BUILD_NUMBER" "$ONEDEV_BUILD_NUMBER")
|
||||||
|
|
||||||
|
curl -X 'POST' \
|
||||||
|
"https://gitea.anfer.fr/api/v1/repos/anfer/OpenEngine/releases" \
|
||||||
|
-H "Authorization: token @secret:Gitea@" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "$RELEASE_JSON" > release_info.json
|
||||||
|
|
||||||
|
# 2. Extract the Release ID (using jq)
|
||||||
|
RELEASE_ID=$(jq '.id' release_info.json)
|
||||||
|
|
||||||
|
# 3. Upload your binary (oe_editor)
|
||||||
|
curl -X 'POST' \
|
||||||
|
"https://gitea.anfer.fr/api/v1/repos/anfer/OpenEngine/releases/$RELEASE_ID/assets?name=oe_editor" \
|
||||||
|
-H "Authorization: token @secret:Gitea@" \
|
||||||
|
-H "Content-Type: multipart/form-data" \
|
||||||
|
-F attachment=@@editor/oe_editor
|
||||||
|
envVars:
|
||||||
|
- name: ONEDEV_BUILD_NUMBER
|
||||||
|
value: '1'
|
||||||
|
useTTY: true
|
||||||
|
condition: SUCCESSFUL
|
||||||
|
optional: false
|
||||||
|
jobExecutor: terra-executor
|
||||||
|
triggers:
|
||||||
|
- type: DependencyFinishedTrigger
|
||||||
|
projects: OpenEngine
|
||||||
|
jobDependencies:
|
||||||
|
- jobName: Compile for Linux
|
||||||
|
requireSuccessful: true
|
||||||
|
artifacts: '**'
|
||||||
|
retryCondition: never
|
||||||
|
maxRetries: 3
|
||||||
|
retryDelay: 30
|
||||||
|
timeout: 14400
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 3.28)
|
cmake_minimum_required(VERSION 3.25.1)
|
||||||
|
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,8 @@
|
|||||||
#version 450 core
|
#version 450 core
|
||||||
|
|
||||||
layout(location = 0) in vec3 a_Position;
|
layout(location = 0) in vec3 a_Position;
|
||||||
layout(location = 1) in vec4 a_Color;
|
layout(location = 1) in vec3 a_Normal;
|
||||||
layout(location = 2) in vec3 a_Normal;
|
layout(location = 2) in vec2 a_TexCoord;
|
||||||
layout(location = 3) in vec2 a_TexCoord;
|
|
||||||
layout(location = 4) in int a_EntityID;
|
|
||||||
|
|
||||||
layout(std140, binding = 0) uniform Camera
|
layout(std140, binding = 0) uniform Camera
|
||||||
{
|
{
|
||||||
@@ -20,25 +18,20 @@ layout(std140, binding = 1) uniform Transform
|
|||||||
|
|
||||||
struct VertexOutput
|
struct VertexOutput
|
||||||
{
|
{
|
||||||
vec4 Color;
|
|
||||||
vec2 TexCoord;
|
vec2 TexCoord;
|
||||||
vec3 Normal;
|
vec3 Normal;
|
||||||
vec3 ViewPos;
|
vec3 ViewPos;
|
||||||
};
|
};
|
||||||
|
|
||||||
layout (location = 0) out VertexOutput Output;
|
layout (location = 0) out VertexOutput Output;
|
||||||
layout (location = 4) out flat int v_EntityID;
|
|
||||||
layout (location = 5) out vec4 v_Pos;
|
layout (location = 5) out vec4 v_Pos;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
Output.Color = a_Color;
|
|
||||||
Output.TexCoord = a_TexCoord;
|
Output.TexCoord = a_TexCoord;
|
||||||
Output.Normal = mat3(transpose(inverse(u_Transform))) * a_Normal;
|
Output.Normal = mat3(transpose(inverse(u_Transform))) * a_Normal;
|
||||||
Output.ViewPos = u_ViewPosition;
|
Output.ViewPos = u_ViewPosition;
|
||||||
|
|
||||||
v_EntityID = a_EntityID;
|
|
||||||
|
|
||||||
v_Pos = u_Transform * vec4(a_Position, 1.0);
|
v_Pos = u_Transform * vec4(a_Position, 1.0);
|
||||||
gl_Position = u_ViewProjection * v_Pos;
|
gl_Position = u_ViewProjection * v_Pos;
|
||||||
}
|
}
|
||||||
@@ -49,9 +42,22 @@ void main()
|
|||||||
layout (location = 0) out vec4 color;
|
layout (location = 0) out vec4 color;
|
||||||
layout (location = 1) out int color2;
|
layout (location = 1) out int color2;
|
||||||
|
|
||||||
|
layout (std140, binding = 2) uniform Material
|
||||||
|
{
|
||||||
|
vec4 u_Albedo;
|
||||||
|
float u_Roughness;
|
||||||
|
float u_Metallic;
|
||||||
|
float u_AmbientStrength;
|
||||||
|
float u_SpecularStrength;
|
||||||
|
};
|
||||||
|
|
||||||
|
layout(std140, binding = 3) uniform EditorID
|
||||||
|
{
|
||||||
|
int u_EntityID;
|
||||||
|
};
|
||||||
|
|
||||||
struct VertexOutput
|
struct VertexOutput
|
||||||
{
|
{
|
||||||
vec4 Color;
|
|
||||||
vec2 TexCoord;
|
vec2 TexCoord;
|
||||||
vec3 Normal;
|
vec3 Normal;
|
||||||
vec3 ViewPos;
|
vec3 ViewPos;
|
||||||
@@ -67,8 +73,7 @@ void main()
|
|||||||
vec3 lightColor = vec3(1.0f, 1.0f, 1.0f);
|
vec3 lightColor = vec3(1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
// Ambiant lighting
|
// Ambiant lighting
|
||||||
float ambientStrength = 0.8;
|
vec3 ambient = lightColor * u_AmbientStrength;
|
||||||
vec3 ambient = ambientStrength * lightColor;
|
|
||||||
|
|
||||||
// Diffuse lighting
|
// Diffuse lighting
|
||||||
vec3 norm = normalize(Input.Normal);
|
vec3 norm = normalize(Input.Normal);
|
||||||
@@ -78,16 +83,19 @@ void main()
|
|||||||
vec3 diffuse = diff * lightColor;
|
vec3 diffuse = diff * lightColor;
|
||||||
|
|
||||||
// Specular highlight
|
// Specular highlight
|
||||||
float specularStrength = 0.5;
|
|
||||||
vec3 viewDir = normalize(Input.ViewPos - v_Pos.xyz); // .xyz here too
|
vec3 viewDir = normalize(Input.ViewPos - v_Pos.xyz); // .xyz here too
|
||||||
vec3 reflectDir = reflect(-lightDir, norm);
|
vec3 reflectDir = reflect(-lightDir, norm);
|
||||||
|
|
||||||
float spec = pow(max(dot(viewDir, reflectDir), 0.0), 32);
|
float shininess = mix(2.0, 256.0, 1.0 - u_Roughness);
|
||||||
vec3 specular = specularStrength * spec * lightColor;
|
float spec = pow(max(dot(viewDir, reflectDir), 0.0), shininess);
|
||||||
|
vec3 specularColor = mix(vec3(1.0), u_Albedo.rgb, u_Metallic);
|
||||||
|
vec3 specular = u_SpecularStrength * spec * lightColor * specularColor;
|
||||||
|
|
||||||
vec3 result = (ambient + diffuse + specular) * Input.Color.rgb; // objectColor → Input.Color.rgb
|
// Total
|
||||||
|
//vec3 result = (ambient + diffuse + specular) * Input.Color.rgb; // objectColor → Input.Color.rgb
|
||||||
|
vec3 result = (ambient + diffuse + specular) * u_Albedo.rgb; // objectColor → Input.Color.rgb
|
||||||
|
|
||||||
// Output
|
// Output
|
||||||
color = vec4(result, 1.0); // vec3 → vec4
|
color = vec4(result, u_Albedo.w); // vec3 → vec4
|
||||||
color2 = v_EntityID;
|
color2 = u_EntityID;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,11 @@ spdlog/1.16.0
|
|||||||
entt/3.16.0
|
entt/3.16.0
|
||||||
yaml-cpp/0.8.0
|
yaml-cpp/0.8.0
|
||||||
joltphysics/5.2.0
|
joltphysics/5.2.0
|
||||||
|
fastgltf/0.9.0
|
||||||
|
glm/1.0.1
|
||||||
|
glfw/3.4
|
||||||
|
shaderc/2025.3
|
||||||
|
spirv-cross/1.4.321.0
|
||||||
|
|
||||||
[generators]
|
[generators]
|
||||||
CMakeDeps
|
CMakeDeps
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 3.28)
|
cmake_minimum_required(VERSION 3.25.1)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
|
||||||
@@ -19,10 +19,25 @@ add_executable(${PROJECT_EXECUTABLE_NAME}
|
|||||||
${SRC_FILES}
|
${SRC_FILES}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
file(GLOB NETHOST_DIR_CANDIDATES
|
||||||
|
"/usr/share/dotnet/packs/Microsoft.NETCore.App.Host.*-x64/*/runtimes/linux-x64/native"
|
||||||
|
"/usr/share/dotnet/packs/Microsoft.NETCore.App.Host.*-x64/*/runtimes/arch-x64/native"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Pick the first match
|
||||||
|
list(GET NETHOST_DIR_CANDIDATES 0 NETHOST_DIR)
|
||||||
|
|
||||||
|
if(NOT NETHOST_DIR)
|
||||||
|
message(FATAL_ERROR "Could not find NETCore native directory")
|
||||||
|
else()
|
||||||
|
message(STATUS "Found nethost dir: ${NETHOST_DIR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
target_include_directories(${PROJECT_EXECUTABLE_NAME} PRIVATE
|
target_include_directories(${PROJECT_EXECUTABLE_NAME} PRIVATE
|
||||||
"${PROJECT_SOURCE_DIR}/include"
|
"${PROJECT_SOURCE_DIR}/include"
|
||||||
"${PROJECT_SOURCE_DIR}/editor/include"
|
"${PROJECT_SOURCE_DIR}/editor/include"
|
||||||
"/usr/include/freetype2/"
|
"/usr/include/freetype2/"
|
||||||
|
"${NETHOST_DIR}"
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_EXECUTABLE_NAME} PRIVATE
|
target_link_libraries(${PROJECT_EXECUTABLE_NAME} PRIVATE
|
||||||
@@ -30,12 +45,12 @@ target_link_libraries(${PROJECT_EXECUTABLE_NAME} PRIVATE
|
|||||||
imgui::imgui
|
imgui::imgui
|
||||||
open_engine
|
open_engine
|
||||||
dl
|
dl
|
||||||
nethost
|
|
||||||
freetype
|
freetype
|
||||||
EnTT::EnTT
|
EnTT::EnTT
|
||||||
|
nethost
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_directories(${PROJECT_EXECUTABLE_NAME} PRIVATE
|
target_link_directories(${PROJECT_EXECUTABLE_NAME} PRIVATE
|
||||||
${PROJECT_SOURCE_DIR}/lib
|
${CMAKE_SOURCE_DIR}/lib
|
||||||
/usr/share/dotnet/packs/Microsoft.NETCore.App.Host.arch-x64/10.0.3/runtimes/arch-x64/native
|
${NETHOST_DIR}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,9 +3,14 @@
|
|||||||
|
|
||||||
#include <open_engine.hpp>
|
#include <open_engine.hpp>
|
||||||
|
|
||||||
|
#include "open_engine/fastgltf.hpp"
|
||||||
|
#include "open_engine/logging.hpp"
|
||||||
|
#include "open_engine/ref_scope.hpp"
|
||||||
|
#include "open_engine/renderer/model3d.hpp"
|
||||||
#include "open_engine/renderer/renderer3d.hpp"
|
#include "open_engine/renderer/renderer3d.hpp"
|
||||||
#include "open_engine/scene/components.hpp"
|
#include "open_engine/scene/components.hpp"
|
||||||
#include "panels/content_browser.hpp"
|
#include "panels/content_browser.hpp"
|
||||||
|
#include "panels/models_panel.hpp"
|
||||||
#include "panels/scene_hierarchy.hpp"
|
#include "panels/scene_hierarchy.hpp"
|
||||||
|
|
||||||
#include <Jolt/Physics/Collision/Shape/Shape.h>
|
#include <Jolt/Physics/Collision/Shape/Shape.h>
|
||||||
@@ -128,6 +133,23 @@ namespace OpenEngine {
|
|||||||
auto& mc2 = cube2.AddComponent<MeshComponent>(mesh2);
|
auto& mc2 = cube2.AddComponent<MeshComponent>(mesh2);
|
||||||
mc2.primitive_type = PrimitiveType::Cube;
|
mc2.primitive_type = PrimitiveType::Cube;
|
||||||
|
|
||||||
|
// ============================================================
|
||||||
|
|
||||||
|
Entity cube3 = scene->CreateEntity("glb");
|
||||||
|
Entity cube4 = scene->CreateEntity("glb2");
|
||||||
|
Entity cube5 = scene->CreateEntity("glb2");
|
||||||
|
cube3.AddComponent<TransformComponent>();
|
||||||
|
cube4.AddComponent<TransformComponent>();
|
||||||
|
cube5.AddComponent<TransformComponent>();
|
||||||
|
|
||||||
|
Ref<Model3D> model = Model3D::Create("./assets/models/cubes.glb");
|
||||||
|
Ref<Model3D> model2 = Model3D::Create("./assets/models/cube_legs.glb");
|
||||||
|
Ref<Model3D> monkey = Model3D::Create("./assets/models/monkey.glb");
|
||||||
|
|
||||||
|
cube3.AddComponent<ModelComponent>(model);
|
||||||
|
cube4.AddComponent<ModelComponent>(model2);
|
||||||
|
cube5.AddComponent<ModelComponent>(monkey);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
auto view = scene->GetRegistry().view<TagComponent>();
|
auto view = scene->GetRegistry().view<TagComponent>();
|
||||||
|
|
||||||
@@ -285,6 +307,10 @@ namespace OpenEngine {
|
|||||||
guizmo_operation = ImGuizmo::OPERATION::SCALE;
|
guizmo_operation = ImGuizmo::OPERATION::SCALE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case KeyCode::T: {
|
||||||
|
guizmo_operation = ImGuizmo::OPERATION::UNIVERSAL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case KeyCode::Delete: {
|
case KeyCode::Delete: {
|
||||||
scene->MarkEntityForDeletion(selected_entity);
|
scene->MarkEntityForDeletion(selected_entity);
|
||||||
scene_hierarchy.ClearSelection();
|
scene_hierarchy.ClearSelection();
|
||||||
@@ -560,6 +586,7 @@ namespace OpenEngine {
|
|||||||
DrawStats();
|
DrawStats();
|
||||||
scene_hierarchy.OnImGuiRender();
|
scene_hierarchy.OnImGuiRender();
|
||||||
browser.OnImGuiRender();
|
browser.OnImGuiRender();
|
||||||
|
ModelsPanelOnImGuiRender();
|
||||||
DrawViewport();
|
DrawViewport();
|
||||||
DrawPlayBar();
|
DrawPlayBar();
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,10 @@ namespace OpenEngine {
|
|||||||
void MeshOnImGuiRender(entt::registry®istry, entt::entity entity);
|
void MeshOnImGuiRender(entt::registry®istry, entt::entity entity);
|
||||||
void MaterialOnImGuiRender(entt::registry& registry, entt::entity entity);
|
void MaterialOnImGuiRender(entt::registry& registry, entt::entity entity);
|
||||||
void BodyOnImGuiRender(entt::registry& registry, entt::entity entity);
|
void BodyOnImGuiRender(entt::registry& registry, entt::entity entity);
|
||||||
void ShapeOnImGuiRender(entt::registry& registry, entt::entity entity);
|
void SphereShapeOnImGuiRender(entt::registry& registry, entt::entity entity);
|
||||||
|
void BoxShapeOnImGuiRender(entt::registry& registry, entt::entity entity);
|
||||||
|
void PlaneShapeOnImGuiRender(entt::registry& registry, entt::entity entity);
|
||||||
|
void ModelOnImGuiRender(entt::registry& registry, entt::entity entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // EDITOR_COMPONENT_HPP
|
#endif // EDITOR_COMPONENT_HPP
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
#include <open_engine.hpp>
|
#include <open_engine.hpp>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "/usr/share/dotnet/packs/Microsoft.NETCore.App.Host.arch-x64/10.0.3/runtimes/arch-x64/native/nethost.h"
|
#include <nethost.h>
|
||||||
#include "/usr/share/dotnet/packs/Microsoft.NETCore.App.Host.arch-x64/10.0.3/runtimes/arch-x64/native/hostfxr.h"
|
#include <hostfxr.h>
|
||||||
#include "/usr/share/dotnet/packs/Microsoft.NETCore.App.Host.arch-x64/10.0.3/runtimes/arch-x64/native/coreclr_delegates.h"
|
#include <coreclr_delegates.h>
|
||||||
|
|
||||||
class Modding : public OpenEngine::Layer
|
class Modding : public OpenEngine::Layer
|
||||||
{
|
{
|
||||||
|
|||||||
10
editor/include/panels/models_panel.hpp
Normal file
10
editor/include/panels/models_panel.hpp
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#ifndef MODELS_PANEL_HPP
|
||||||
|
#define MODELS_PANEL_HPP
|
||||||
|
|
||||||
|
namespace OpenEngine {
|
||||||
|
|
||||||
|
void ModelsPanelOnImGuiRender();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // MODELS_PANEL_HPP
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "open_engine/renderer/renderer3d.hpp"
|
#include "open_engine/renderer/renderer3d.hpp"
|
||||||
#include "open_engine/scene/components.hpp"
|
#include "open_engine/scene/components.hpp"
|
||||||
|
#include <Jolt/Physics/Body/MotionType.h>
|
||||||
|
#include <cstdint>
|
||||||
#include <editor_component.hpp>
|
#include <editor_component.hpp>
|
||||||
#include <entt/entity/fwd.hpp>
|
#include <entt/entity/fwd.hpp>
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
@@ -181,12 +183,11 @@ namespace OpenEngine {
|
|||||||
{
|
{
|
||||||
auto& mesh_component = registry.get<MeshComponent>(entity);
|
auto& mesh_component = registry.get<MeshComponent>(entity);
|
||||||
|
|
||||||
const char* items[] = { "Quad", "Cube" };
|
const char* items[] = { "None", "Quad", "Cube" };
|
||||||
static int item_selected_idx = 0;
|
|
||||||
|
|
||||||
|
int item_selected_idx = (int)mesh_component.primitive_type;
|
||||||
if (ImGui::BeginCombo("Mesh", items[item_selected_idx])) {
|
if (ImGui::BeginCombo("Mesh", items[item_selected_idx])) {
|
||||||
for (int n = 0; n < 2; n++)
|
for (int n = 0; n < 3; n++) {
|
||||||
{
|
|
||||||
const bool is_selected = (item_selected_idx == n);
|
const bool is_selected = (item_selected_idx == n);
|
||||||
if (ImGui::Selectable(items[n], is_selected))
|
if (ImGui::Selectable(items[n], is_selected))
|
||||||
item_selected_idx = n;
|
item_selected_idx = n;
|
||||||
@@ -196,25 +197,26 @@ namespace OpenEngine {
|
|||||||
ImGui::SetItemDefaultFocus();
|
ImGui::SetItemDefaultFocus();
|
||||||
}
|
}
|
||||||
ImGui::EndCombo();
|
ImGui::EndCombo();
|
||||||
|
}
|
||||||
|
|
||||||
if ((int)mesh_component.primitive_type == (item_selected_idx + 1))
|
if ((int)mesh_component.primitive_type == (item_selected_idx))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mesh_component.primitive_type = (PrimitiveType)(item_selected_idx + 1);
|
mesh_component.primitive_type = (PrimitiveType)(item_selected_idx);
|
||||||
switch (mesh_component.primitive_type) {
|
switch (mesh_component.primitive_type) {
|
||||||
case OpenEngine::PrimitiveType::Quad:
|
case OpenEngine::PrimitiveType::Quad:
|
||||||
{
|
{
|
||||||
mesh_component.mesh = CreateQuad((uint32_t)entity);
|
mesh_component.mesh = CreateQuad((uint32_t)entity);
|
||||||
break;
|
|
||||||
}
|
|
||||||
case OpenEngine::PrimitiveType::Cube:
|
|
||||||
{
|
|
||||||
mesh_component.mesh = CreateCube((uint32_t)entity);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case OpenEngine::PrimitiveType::Cube:
|
||||||
|
{
|
||||||
|
mesh_component.mesh = CreateCube((uint32_t)entity);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
mesh_component.mesh = nullptr;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,16 +235,92 @@ namespace OpenEngine {
|
|||||||
{
|
{
|
||||||
auto& body_comp = registry.get<PhysicsBodyComponent>(entity);
|
auto& body_comp = registry.get<PhysicsBodyComponent>(entity);
|
||||||
|
|
||||||
|
const char* items[] = { "Static", "Kinematic", "Dynamic" };
|
||||||
|
int item_selected_idx = body_comp.type;
|
||||||
|
|
||||||
|
if (ImGui::BeginCombo("Body type", items[item_selected_idx])) {
|
||||||
|
for (int n = 0; n < 3; n++)
|
||||||
|
{
|
||||||
|
const bool is_selected = (item_selected_idx == n);
|
||||||
|
if (ImGui::Selectable(items[n], is_selected))
|
||||||
|
item_selected_idx = n;
|
||||||
|
|
||||||
|
// Set the initial focus when opening the combo (scrolling + keyboard navigation focus)
|
||||||
|
if (is_selected)
|
||||||
|
ImGui::SetItemDefaultFocus();
|
||||||
|
}
|
||||||
|
ImGui::EndCombo();
|
||||||
|
}
|
||||||
|
|
||||||
|
body_comp.type = item_selected_idx;
|
||||||
|
|
||||||
ImGui::SliderFloat("Linear damping", &body_comp.linear_damping, 0, 1);
|
ImGui::SliderFloat("Linear damping", &body_comp.linear_damping, 0, 1);
|
||||||
ImGui::SliderFloat("Angular damping", &body_comp.angular_damping, 0, 1);
|
ImGui::SliderFloat("Angular damping", &body_comp.angular_damping, 0, 1);
|
||||||
ImGui::SliderFloat("Gravity factor", &body_comp.gravity_factor, 0, 1);
|
ImGui::SliderFloat("Gravity factor", &body_comp.gravity_factor, 0, 1);
|
||||||
|
ImGui::SliderFloat("Bounciness", &body_comp.restitution, 0, 1);
|
||||||
|
ImGui::SliderFloat("Friction", &body_comp.friction, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShapeOnImGuiRender(entt::registry ®istry, entt::entity entity)
|
void SphereShapeOnImGuiRender(entt::registry ®istry, entt::entity entity)
|
||||||
{
|
{
|
||||||
auto& shape_comp = registry.get<PhysicsShapeComponent>(entity);
|
auto& sphere_comp = registry.get<SphereShapeComponent>(entity);
|
||||||
|
|
||||||
ImGui::SliderFloat("Bounciness", &shape_comp.restitution, 0, 1);
|
ImGui::DragFloat("Radius",
|
||||||
ImGui::SliderFloat("Friction", &shape_comp.friction, 0, 1);
|
&sphere_comp.radius,
|
||||||
|
0.1f,
|
||||||
|
0.11f, FLT_MAX,
|
||||||
|
"%.2f",
|
||||||
|
ImGuiSliderFlags_AlwaysClamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BoxShapeOnImGuiRender(entt::registry ®istry, entt::entity entity)
|
||||||
|
{
|
||||||
|
auto& box_comp = registry.get<BoxShapeComponent>(entity);
|
||||||
|
|
||||||
|
ImGui::DragFloat3("Size",
|
||||||
|
glm::value_ptr(box_comp.size),
|
||||||
|
0.1f,
|
||||||
|
0.11f, FLT_MAX,
|
||||||
|
"%.2f",
|
||||||
|
ImGuiSliderFlags_AlwaysClamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlaneShapeOnImGuiRender(entt::registry& registry, entt::entity entity)
|
||||||
|
{
|
||||||
|
auto& planed_comp = registry.get<PlaneShapeComponent>(entity);
|
||||||
|
|
||||||
|
ImGui::DragFloat("Size",
|
||||||
|
&planed_comp.extent,
|
||||||
|
0.1f,
|
||||||
|
0.01f, FLT_MAX,
|
||||||
|
"%.2f",
|
||||||
|
ImGuiSliderFlags_AlwaysClamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModelOnImGuiRender(entt::registry& registry, entt::entity entity)
|
||||||
|
{
|
||||||
|
auto& model_comp = registry.get<ModelComponent>(entity);
|
||||||
|
|
||||||
|
bool opened = ImGui::TreeNodeEx(
|
||||||
|
(void*)(intptr_t)entity,
|
||||||
|
ImGuiTreeNodeFlags_None,
|
||||||
|
"Meshes");
|
||||||
|
|
||||||
|
if (opened) {
|
||||||
|
unsigned int i = 0;
|
||||||
|
for (auto& mesh : model_comp.model->GetMeshes())
|
||||||
|
ImGui::Text("Mesh: %i", i++);
|
||||||
|
|
||||||
|
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_ChildBg, {1, 1, 1, 1});
|
||||||
|
if (ImGui::BeginChild("Material list")) {
|
||||||
|
for (auto& mesh : model_comp.model->GetMeshes())
|
||||||
|
ImGui::Text("Material: %s", mesh.material.name.c_str());
|
||||||
|
ImGui::EndChild();
|
||||||
|
}
|
||||||
|
ImGui::PopStyleColor();
|
||||||
|
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
20
editor/src/panels/models_panel.cpp
Normal file
20
editor/src/panels/models_panel.cpp
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#include <panels/models_panel.hpp>
|
||||||
|
#include <open_engine.hpp>
|
||||||
|
|
||||||
|
#include "imgui.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace OpenEngine {
|
||||||
|
|
||||||
|
static std::vector<Ref<Model3D>> temp_model_list;
|
||||||
|
|
||||||
|
void ModelsPanelOnImGuiRender()
|
||||||
|
{
|
||||||
|
ImGui::Begin("Models");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -25,7 +25,10 @@ namespace OpenEngine {
|
|||||||
RegisterDrawer<MeshComponent>("Mesh", &MeshOnImGuiRender);
|
RegisterDrawer<MeshComponent>("Mesh", &MeshOnImGuiRender);
|
||||||
RegisterDrawer<MaterialComponent>("Material", &MaterialOnImGuiRender);
|
RegisterDrawer<MaterialComponent>("Material", &MaterialOnImGuiRender);
|
||||||
RegisterDrawer<PhysicsBodyComponent>("Physics Body", &BodyOnImGuiRender);
|
RegisterDrawer<PhysicsBodyComponent>("Physics Body", &BodyOnImGuiRender);
|
||||||
RegisterDrawer<PhysicsShapeComponent>("Physics Shape", &ShapeOnImGuiRender);
|
RegisterDrawer<SphereShapeComponent>("Sphere Shape", &SphereShapeOnImGuiRender);
|
||||||
|
RegisterDrawer<BoxShapeComponent>("Box Shape", &BoxShapeOnImGuiRender);
|
||||||
|
RegisterDrawer<PlaneShapeComponent>("Plane Shape", &PlaneShapeOnImGuiRender);
|
||||||
|
RegisterDrawer<ModelComponent>("Model", &ModelOnImGuiRender);
|
||||||
|
|
||||||
scene = context;
|
scene = context;
|
||||||
selected_context = {};
|
selected_context = {};
|
||||||
@@ -64,9 +67,24 @@ namespace OpenEngine {
|
|||||||
selected_context.AddComponent<PhysicsBodyComponent>();
|
selected_context.AddComponent<PhysicsBodyComponent>();
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
if (!selected_context.HasComponent<PhysicsShapeComponent>())
|
if (!selected_context.HasComponent<SphereShapeComponent>())
|
||||||
if (ImGui::MenuItem("Physics shape")) {
|
if (ImGui::MenuItem("Sphere shape")) {
|
||||||
selected_context.AddComponent<PhysicsShapeComponent>();
|
selected_context.AddComponent<SphereShapeComponent>();
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
if (!selected_context.HasComponent<BoxShapeComponent>())
|
||||||
|
if (ImGui::MenuItem("Box shape")) {
|
||||||
|
selected_context.AddComponent<BoxShapeComponent>();
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
if (!selected_context.HasComponent<PlaneShapeComponent>())
|
||||||
|
if (ImGui::MenuItem("Plane shape")) {
|
||||||
|
selected_context.AddComponent<PlaneShapeComponent>();
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
if (!selected_context.HasComponent<ModelComponent>())
|
||||||
|
if (ImGui::MenuItem("Model")) {
|
||||||
|
selected_context.AddComponent<ModelComponent>();
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
46
imgui.ini
46
imgui.ini
@@ -1,6 +1,6 @@
|
|||||||
[Window][WindowOverViewport_11111111]
|
[Window][WindowOverViewport_11111111]
|
||||||
Pos=0,24
|
Pos=0,24
|
||||||
Size=2552,1363
|
Size=2560,1371
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Debug##Default]
|
[Window][Debug##Default]
|
||||||
@@ -10,31 +10,31 @@ Collapsed=0
|
|||||||
|
|
||||||
[Window][Statistics]
|
[Window][Statistics]
|
||||||
Pos=0,24
|
Pos=0,24
|
||||||
Size=224,437
|
Size=409,439
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000003,0
|
DockId=0x00000003,0
|
||||||
|
|
||||||
[Window][Properties]
|
[Window][Properties]
|
||||||
Pos=2102,24
|
Pos=2110,24
|
||||||
Size=450,805
|
Size=450,810
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000007,0
|
DockId=0x00000007,0
|
||||||
|
|
||||||
[Window][Viewport]
|
[Window][Viewport]
|
||||||
Pos=226,61
|
Pos=411,61
|
||||||
Size=1874,956
|
Size=1697,964
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000012,0
|
DockId=0x00000012,0
|
||||||
|
|
||||||
[Window][Dear ImGui Demo]
|
[Window][Dear ImGui Demo]
|
||||||
Pos=2102,831
|
Pos=2110,836
|
||||||
Size=450,556
|
Size=450,559
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000008,0
|
DockId=0x00000008,0
|
||||||
|
|
||||||
[Window][Scene]
|
[Window][Scene]
|
||||||
Pos=0,463
|
Pos=0,465
|
||||||
Size=224,924
|
Size=409,930
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000004,0
|
DockId=0x00000004,0
|
||||||
|
|
||||||
@@ -143,8 +143,8 @@ Collapsed=0
|
|||||||
DockId=0x00000012,1
|
DockId=0x00000012,1
|
||||||
|
|
||||||
[Window][Assets]
|
[Window][Assets]
|
||||||
Pos=226,1019
|
Pos=411,1027
|
||||||
Size=1874,368
|
Size=1697,368
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x0000000C,0
|
DockId=0x0000000C,0
|
||||||
|
|
||||||
@@ -155,18 +155,24 @@ Collapsed=0
|
|||||||
DockId=0x0000000F,0
|
DockId=0x0000000F,0
|
||||||
|
|
||||||
[Window][##play_state_bar]
|
[Window][##play_state_bar]
|
||||||
Pos=226,24
|
Pos=411,24
|
||||||
Size=1874,35
|
Size=1697,35
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000011,0
|
DockId=0x00000011,0
|
||||||
|
|
||||||
|
[Window][Models]
|
||||||
|
Pos=411,1027
|
||||||
|
Size=1697,368
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x0000000C,1
|
||||||
|
|
||||||
[Docking][Data]
|
[Docking][Data]
|
||||||
DockSpace ID=0x08BD597D Window=0x1BBC0F80 Pos=0,24 Size=2552,1363 Split=X
|
DockSpace ID=0x08BD597D Window=0x1BBC0F80 Pos=0,24 Size=2560,1371 Split=X
|
||||||
DockNode ID=0x00000005 Parent=0x08BD597D SizeRef=820,1386 Split=X
|
DockNode ID=0x00000005 Parent=0x08BD597D SizeRef=820,1386 Split=X
|
||||||
DockNode ID=0x00000001 Parent=0x00000005 SizeRef=224,1386 Split=Y Selected=0xE601B12F
|
DockNode ID=0x00000001 Parent=0x00000005 SizeRef=409,1386 Split=Y Selected=0xE601B12F
|
||||||
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=255,417 Selected=0x553E127E
|
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=255,417 Selected=0x553E127E
|
||||||
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=255,883 Selected=0xE601B12F
|
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=255,883 Selected=0xE601B12F
|
||||||
DockNode ID=0x00000002 Parent=0x00000005 SizeRef=594,1386 Split=Y Selected=0xC450F867
|
DockNode ID=0x00000002 Parent=0x00000005 SizeRef=409,1386 Split=Y Selected=0xC450F867
|
||||||
DockNode ID=0x00000009 Parent=0x00000002 SizeRef=483,784 Split=Y Selected=0xC450F867
|
DockNode ID=0x00000009 Parent=0x00000002 SizeRef=483,784 Split=Y Selected=0xC450F867
|
||||||
DockNode ID=0x0000000B Parent=0x00000009 SizeRef=409,932 Split=X Selected=0xC450F867
|
DockNode ID=0x0000000B Parent=0x00000009 SizeRef=409,932 Split=X Selected=0xC450F867
|
||||||
DockNode ID=0x0000000D Parent=0x0000000B SizeRef=1080,993 Split=Y Selected=0xC450F867
|
DockNode ID=0x0000000D Parent=0x0000000B SizeRef=1080,993 Split=Y Selected=0xC450F867
|
||||||
@@ -175,9 +181,9 @@ DockSpace ID=0x08BD597D Window=0x1BBC0F80 Pos=0,24 Size=2552,1363
|
|||||||
DockNode ID=0x00000011 Parent=0x00000010 SizeRef=594,35 HiddenTabBar=1 Selected=0xAB37695D
|
DockNode ID=0x00000011 Parent=0x00000010 SizeRef=594,35 HiddenTabBar=1 Selected=0xAB37695D
|
||||||
DockNode ID=0x00000012 Parent=0x00000010 SizeRef=594,964 CentralNode=1 Selected=0xC450F867
|
DockNode ID=0x00000012 Parent=0x00000010 SizeRef=594,964 CentralNode=1 Selected=0xC450F867
|
||||||
DockNode ID=0x0000000E Parent=0x0000000B SizeRef=800,993 Selected=0x3EEA4247
|
DockNode ID=0x0000000E Parent=0x0000000B SizeRef=800,993 Selected=0x3EEA4247
|
||||||
DockNode ID=0x0000000C Parent=0x00000009 SizeRef=409,368 Selected=0x42C24103
|
DockNode ID=0x0000000C Parent=0x00000009 SizeRef=409,368 Selected=0xEAE75860
|
||||||
DockNode ID=0x0000000A Parent=0x00000002 SizeRef=483,600 Selected=0x1BCA3180
|
DockNode ID=0x0000000A Parent=0x00000002 SizeRef=483,600 Selected=0x1BCA3180
|
||||||
DockNode ID=0x00000006 Parent=0x08BD597D SizeRef=450,1386 Split=Y Selected=0x8C72BEA8
|
DockNode ID=0x00000006 Parent=0x08BD597D SizeRef=450,1386 Split=Y Selected=0x8C72BEA8
|
||||||
DockNode ID=0x00000007 Parent=0x00000006 SizeRef=444,810 Selected=0x8C72BEA8
|
DockNode ID=0x00000007 Parent=0x00000006 SizeRef=444,805 Selected=0x8C72BEA8
|
||||||
DockNode ID=0x00000008 Parent=0x00000006 SizeRef=444,559 Selected=0x5E5F7166
|
DockNode ID=0x00000008 Parent=0x00000006 SizeRef=444,556 Selected=0x5E5F7166
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 3.28)
|
cmake_minimum_required(VERSION 3.25.1)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 23)
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
|
|
||||||
@@ -14,6 +14,12 @@ find_package(imgui REQUIRED)
|
|||||||
find_package(EnTT REQUIRED)
|
find_package(EnTT REQUIRED)
|
||||||
find_package(yaml-cpp REQUIRED)
|
find_package(yaml-cpp REQUIRED)
|
||||||
find_package(Jolt REQUIRED)
|
find_package(Jolt REQUIRED)
|
||||||
|
find_package(fastgltf REQUIRED)
|
||||||
|
find_package(spdlog REQUIRED)
|
||||||
|
find_package(glm REQUIRED)
|
||||||
|
find_package(glfw3 REQUIRED)
|
||||||
|
find_package(shaderc REQUIRED)
|
||||||
|
find_package(spirv-cross REQUIRED)
|
||||||
|
|
||||||
file(GLOB_RECURSE SRC_FILES "src/*.cpp")
|
file(GLOB_RECURSE SRC_FILES "src/*.cpp")
|
||||||
file(GLOB IMGUIZMO_SRC_FILES "${CMAKE_SOURCE_DIR}/vendor/ImGuizmo/*.cpp")
|
file(GLOB IMGUIZMO_SRC_FILES "${CMAKE_SOURCE_DIR}/vendor/ImGuizmo/*.cpp")
|
||||||
@@ -34,7 +40,7 @@ target_include_directories(${PROJECT_EXECUTABLE_NAME} PRIVATE
|
|||||||
|
|
||||||
target_include_directories(${PROJECT_EXECUTABLE_NAME} PUBLIC
|
target_include_directories(${PROJECT_EXECUTABLE_NAME} PUBLIC
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||||
"/home/erris/.conan2/p/b/imguic69fe98538919/p/include"
|
#"/home/erris/.conan2/p/b/imguic69fe98538919/p/include"
|
||||||
"vendor/nativefiledialog-extended/src/include"
|
"vendor/nativefiledialog-extended/src/include"
|
||||||
"${CMAKE_SOURCE_DIR}/vendor/ImGuizmo"
|
"${CMAKE_SOURCE_DIR}/vendor/ImGuizmo"
|
||||||
)
|
)
|
||||||
@@ -44,16 +50,16 @@ target_include_directories(${PROJECT_EXECUTABLE_NAME} PUBLIC
|
|||||||
|
|
||||||
target_link_libraries(${PROJECT_EXECUTABLE_NAME} PUBLIC
|
target_link_libraries(${PROJECT_EXECUTABLE_NAME} PUBLIC
|
||||||
imgui::imgui
|
imgui::imgui
|
||||||
spdlog
|
spdlog::spdlog
|
||||||
glad
|
glad
|
||||||
glfw
|
glfw
|
||||||
glm
|
glm::glm
|
||||||
dl
|
dl
|
||||||
EnTT::EnTT
|
EnTT::EnTT
|
||||||
X11
|
X11
|
||||||
yaml-cpp::yaml-cpp
|
yaml-cpp::yaml-cpp
|
||||||
nfd
|
nfd
|
||||||
shaderc_combined
|
shaderc::shaderc
|
||||||
glslang
|
glslang
|
||||||
glslang-default-resource-limits
|
glslang-default-resource-limits
|
||||||
SPIRV
|
SPIRV
|
||||||
@@ -63,6 +69,7 @@ target_link_libraries(${PROJECT_EXECUTABLE_NAME} PUBLIC
|
|||||||
spirv-cross-glsl
|
spirv-cross-glsl
|
||||||
spirv-cross-reflect
|
spirv-cross-reflect
|
||||||
Jolt::Jolt
|
Jolt::Jolt
|
||||||
|
fastgltf::fastgltf
|
||||||
)
|
)
|
||||||
|
|
||||||
#target_link_directories(${PROJECT_EXECUTABLE_NAME} PRIVATE
|
#target_link_directories(${PROJECT_EXECUTABLE_NAME} PRIVATE
|
||||||
@@ -74,3 +81,5 @@ add_subdirectory(vendor/glad
|
|||||||
)
|
)
|
||||||
|
|
||||||
add_subdirectory("vendor/nativefiledialog-extended")
|
add_subdirectory("vendor/nativefiledialog-extended")
|
||||||
|
|
||||||
|
target_compile_options(open_engine PRIVATE -msse4.1 -msse4.2 -mavx -mavx2)
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include "open_engine/renderer/renderer2d.hpp"
|
#include "open_engine/renderer/renderer2d.hpp"
|
||||||
#include "open_engine/renderer/renderer3d.hpp"
|
#include "open_engine/renderer/renderer3d.hpp"
|
||||||
#include "open_engine/renderer/renderer.hpp"
|
#include "open_engine/renderer/renderer.hpp"
|
||||||
|
#include <open_engine/renderer/model3d.hpp>
|
||||||
#include "open_engine/renderer/texture.hpp"
|
#include "open_engine/renderer/texture.hpp"
|
||||||
#include "open_engine/renderer/buffer.hpp"
|
#include "open_engine/renderer/buffer.hpp"
|
||||||
#include "open_engine/renderer/shader.hpp"
|
#include "open_engine/renderer/shader.hpp"
|
||||||
|
|||||||
36
open_engine/include/open_engine/core/uuid.hpp
Normal file
36
open_engine/include/open_engine/core/uuid.hpp
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#ifndef UUID_HPP
|
||||||
|
#define UUID_HPP
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace OpenEngine {
|
||||||
|
|
||||||
|
class UUID
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
UUID();
|
||||||
|
UUID(uint64_t uuid);
|
||||||
|
UUID(const UUID&) = default;
|
||||||
|
|
||||||
|
operator uint64_t() const { return uuid; };
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint64_t uuid;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace std {
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct hash<OpenEngine::UUID>
|
||||||
|
{
|
||||||
|
std::size_t operator()(const OpenEngine::UUID& uuid) const
|
||||||
|
{
|
||||||
|
return hash<uint64_t>()((uint64_t)uuid);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // UUID_HPP
|
||||||
13
open_engine/include/open_engine/fastgltf.hpp
Normal file
13
open_engine/include/open_engine/fastgltf.hpp
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#ifndef FASTGLTF_HPP
|
||||||
|
#define FASTGLTF_HPP
|
||||||
|
|
||||||
|
#include "renderer/renderer3d.hpp"
|
||||||
|
#include "open_engine/ref_scope.hpp"
|
||||||
|
|
||||||
|
namespace OpenEngine {
|
||||||
|
|
||||||
|
Ref<Mesh> TestGLTF();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // FASTGLTF_HPP
|
||||||
38
open_engine/include/open_engine/gltf/gltf_model3d.hpp
Normal file
38
open_engine/include/open_engine/gltf/gltf_model3d.hpp
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#ifndef GLTF_MODEL3D_HPP
|
||||||
|
#define GLTF_MODEL3D_HPP
|
||||||
|
|
||||||
|
#include "open_engine/renderer/model3d.hpp"
|
||||||
|
|
||||||
|
#include <fastgltf/types.hpp>
|
||||||
|
#include <vector>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
namespace OpenEngine {
|
||||||
|
|
||||||
|
class GLTFModel3D : public Model3D
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GLTFModel3D(const char* path);
|
||||||
|
|
||||||
|
void loadPrimitive(fastgltf::Asset& asset,
|
||||||
|
fastgltf::Primitive& primitive,
|
||||||
|
Mesh& out);
|
||||||
|
virtual const Mesh& GetMesh(int index) const override;
|
||||||
|
virtual const std::vector<Mesh>& GetMeshes() const override;
|
||||||
|
|
||||||
|
virtual size_t GetMeshCount() const override { return meshes.size(); };
|
||||||
|
|
||||||
|
virtual std::vector<Mesh>::iterator begin() override { return meshes.begin(); };
|
||||||
|
virtual std::vector<Mesh>::iterator end() override { return meshes.end(); };
|
||||||
|
|
||||||
|
virtual std::vector<Mesh>::const_iterator begin() const override { return meshes.cbegin(); };
|
||||||
|
virtual std::vector<Mesh>::const_iterator end() const override { return meshes.end(); };
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string name;
|
||||||
|
std::vector<Mesh> meshes;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // GLTF_MODEL3D_HPP
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "open_engine/logging.hpp"
|
#include "open_engine/logging.hpp"
|
||||||
|
|
||||||
|
#include <iomanip>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
#ifndef PCH_HPP
|
#ifndef PCH_HPP
|
||||||
#define PCH_HPP
|
#define PCH_HPP
|
||||||
|
|
||||||
#include "open_engine/logging.hpp"
|
#include <open_engine/logging.hpp>
|
||||||
|
#include <shaderc/shaderc.hpp>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include <Jolt/Physics/Body/BodyActivationListener.h>
|
#include <Jolt/Physics/Body/BodyActivationListener.h>
|
||||||
|
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
using namespace JPH;
|
using namespace JPH;
|
||||||
using namespace JPH::literals;
|
using namespace JPH::literals;
|
||||||
@@ -73,6 +74,8 @@ namespace BroadPhaseLayers
|
|||||||
static constexpr uint NUM_LAYERS(2);
|
static constexpr uint NUM_LAYERS(2);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline JPH::Vec3 ToJolt(const glm::vec3& v) { return JPH::Vec3(v.x, v.y, v.z); };
|
||||||
|
|
||||||
class BPLayerInterfaceImpl final : public BroadPhaseLayerInterface
|
class BPLayerInterfaceImpl final : public BroadPhaseLayerInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -1,220 +0,0 @@
|
|||||||
let SessionLoad = 1
|
|
||||||
let s:so_save = &g:so | let s:siso_save = &g:siso | setg so=0 siso=0 | setl so=-1 siso=-1
|
|
||||||
let v:this_session=expand("<sfile>:p")
|
|
||||||
silent only
|
|
||||||
silent tabonly
|
|
||||||
cd ~/projects/open_engine/open_engine
|
|
||||||
if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
|
|
||||||
let s:wipebuf = bufnr('%')
|
|
||||||
endif
|
|
||||||
let s:shortmess_save = &shortmess
|
|
||||||
if &shortmess =~ 'A'
|
|
||||||
set shortmess=aoOA
|
|
||||||
else
|
|
||||||
set shortmess=aoO
|
|
||||||
endif
|
|
||||||
badd +1 ~/projects/open_engine/open_engine
|
|
||||||
badd +170 ~/projects/open_engine/open_engine/src/open_engine/imgui/imgui_layer.cpp
|
|
||||||
badd +4 ~/projects/open_engine/open_engine/include/open_engine/opengl/imgui_glfw.h
|
|
||||||
badd +35 ~/projects/open_engine/open_engine/include/open_engine/opengl/imgui_opengl.h
|
|
||||||
badd +23 ~/projects/open_engine/open_engine/src/open_engine/application.cpp
|
|
||||||
badd +47 ~/projects/open_engine/open_engine/CMakeLists.txt
|
|
||||||
badd +12 ~/projects/open_engine/open_engine/include/open_engine/imgui/imgui_layer.hpp
|
|
||||||
badd +123 ~/projects/open_engine/open_engine/src/open_engine/opengl/imgui_opengl.cpp
|
|
||||||
badd +89 ~/.conan2/p/b/imgui15e51a8fb5246/p/include/imgui.h
|
|
||||||
badd +7 ~/projects/open_engine/open_engine/.envrc
|
|
||||||
badd +5 ~/projects/open_engine/open_engine/include/open_engine/core.hpp
|
|
||||||
badd +11 ~/.conan2/p/b/imgui15e51a8fb5246/p/include/imgui_export_headers.h
|
|
||||||
badd +1 ~/projects/open_engine/open_engine/src/open_engine/opengl/build_opengl.cpp
|
|
||||||
badd +4 ~/projects/open_engine/open_engine/src/open_engine/opengl/imgui_build.cpp
|
|
||||||
badd +1 ~/projects/open_engine/open_engine/conanfile.txt
|
|
||||||
badd +1 ~/projects/open_engine/open_engine/build/imguiTargets.cmake
|
|
||||||
badd +8 ~/projects/open_engine/open_engine/include/open_engine/logging.hpp
|
|
||||||
badd +4 ~/projects/open_engine/open_engine/src/open_engine/logging.cpp
|
|
||||||
badd +110 ~/projects/open_engine/open_engine/src/open_engine/opengl/imgui_glfw.cpp
|
|
||||||
badd +1 ~/projects/open_engine/open_engine/include/open_engine/application.hpp
|
|
||||||
badd +21 ~/projects/open_engine/open_engine/src/open_engine/window/linux_window.cpp
|
|
||||||
badd +24 ~/projects/open_engine/open_engine/include/open_engine/window/window.hpp
|
|
||||||
badd +27 ~/projects/open_engine/open_engine/include/open_engine/window/linux_window.hpp
|
|
||||||
badd +7 ~/projects/open_engine/open_engine/include/open_engine/renderer/GraphicsContext.hpp
|
|
||||||
badd +12 ~/projects/open_engine/open_engine/include/open_engine/opengl/opengl_context.hpp
|
|
||||||
badd +10 ~/projects/open_engine/open_engine/src/open_engine/input/linux_input.cpp
|
|
||||||
badd +17 ~/projects/open_engine/open_engine/src/open_engine/opengl/opengl_context.cpp
|
|
||||||
badd +3295 ~/projects/open_engine/open_engine/vendor/glad/include/glad/glad.h
|
|
||||||
badd +148 ~/projects/open_engine/open_engine/vendor/glad/src/glad/glad.c
|
|
||||||
badd +13 ~/projects/open_engine/open_engine/include/open_engine/renderer/graphics_context.hpp
|
|
||||||
badd +80 ~/projects/open_engine/open_engine/src/open_engine/opengl/opengl_shader.cpp
|
|
||||||
badd +8 ~/projects/open_engine/open_engine/include/open_engine/opengl/opengl_shader.hpp
|
|
||||||
badd +8 ~/projects/open_engine/open_engine/include/open_engine/renderer/shader.hpp
|
|
||||||
badd +1 ~/projects/open_engine/open_engine/src/open_engine/renderer/shader.cpp
|
|
||||||
badd +1 ~/projects/open_engine/open_engine/include/open_engine/pch.hpp
|
|
||||||
badd +3 ~/projects/open_engine/open_engine/assets/shaders/fragment.frag.old
|
|
||||||
badd +1 ~/projects/open_engine/open_engine/assets/shaders/fragment.frag
|
|
||||||
badd +5 ~/projects/open_engine/open_engine/assets/shaders/vertex.vert
|
|
||||||
badd +1 ~/projects/open_engine/open_engine/\'
|
|
||||||
badd +66 ~/projects/open_engine/open_engine/include/open_engine/renderer/buffer.hpp
|
|
||||||
badd +56 ~/projects/open_engine/open_engine/src/open_engine/renderer/buffer.cpp
|
|
||||||
badd +18 ~/projects/open_engine/open_engine/include/open_engine/opengl/opengl_buffer.hpp
|
|
||||||
badd +34 ~/projects/open_engine/open_engine/src/open_engine/opengl/opengl_buffer.cpp
|
|
||||||
badd +2 ~/projects/open_engine/open_engine/src/open_engine/renderer/renderer.cpp
|
|
||||||
badd +5 ~/projects/open_engine/open_engine/include/open_engine/renderer/renderer.hpp
|
|
||||||
badd +1 ~/projects/open_engine/open_engine/src/open_engine/layer.cpp
|
|
||||||
badd +12 ~/projects/open_engine/open_engine/include/open_engine/layer.hpp
|
|
||||||
badd +21 ~/projects/open_engine/open_engine/include/open_engine/events/event.hpp
|
|
||||||
badd +11 ~/projects/open_engine/open_engine/src/open_engine/renderer/vertex_array.cpp
|
|
||||||
badd +8 ~/projects/open_engine/open_engine/include/open_engine/renderer/vertex_array.hpp
|
|
||||||
badd +27 ~/projects/open_engine/open_engine/src/open_engine/layer_stack.cpp
|
|
||||||
badd +1 ~/projects/open_engine/open_engine/include/open_engine/layer_stack.hpp
|
|
||||||
argglobal
|
|
||||||
%argdel
|
|
||||||
$argadd ~/projects/open_engine/open_engine
|
|
||||||
set stal=2
|
|
||||||
tabnew +setlocal\ bufhidden=wipe
|
|
||||||
tabrewind
|
|
||||||
edit ~/projects/open_engine/open_engine/include/open_engine/renderer/vertex_array.hpp
|
|
||||||
let s:save_splitbelow = &splitbelow
|
|
||||||
let s:save_splitright = &splitright
|
|
||||||
set splitbelow splitright
|
|
||||||
wincmd _ | wincmd |
|
|
||||||
vsplit
|
|
||||||
1wincmd h
|
|
||||||
wincmd w
|
|
||||||
let &splitbelow = s:save_splitbelow
|
|
||||||
let &splitright = s:save_splitright
|
|
||||||
wincmd t
|
|
||||||
let s:save_winminheight = &winminheight
|
|
||||||
let s:save_winminwidth = &winminwidth
|
|
||||||
set winminheight=0
|
|
||||||
set winheight=1
|
|
||||||
set winminwidth=0
|
|
||||||
set winwidth=1
|
|
||||||
exe 'vert 1resize ' . ((&columns * 127 + 127) / 255)
|
|
||||||
exe 'vert 2resize ' . ((&columns * 127 + 127) / 255)
|
|
||||||
argglobal
|
|
||||||
setlocal foldmethod=manual
|
|
||||||
setlocal foldexpr=0
|
|
||||||
setlocal foldmarker={{{,}}}
|
|
||||||
setlocal foldignore=#
|
|
||||||
setlocal foldlevel=0
|
|
||||||
setlocal foldminlines=1
|
|
||||||
setlocal foldnestmax=20
|
|
||||||
setlocal foldenable
|
|
||||||
silent! normal! zE
|
|
||||||
let &fdl = &fdl
|
|
||||||
let s:l = 8 - ((7 * winheight(0) + 13) / 27)
|
|
||||||
if s:l < 1 | let s:l = 1 | endif
|
|
||||||
keepjumps exe s:l
|
|
||||||
normal! zt
|
|
||||||
keepjumps 8
|
|
||||||
normal! 0
|
|
||||||
lcd ~/projects/open_engine/open_engine
|
|
||||||
wincmd w
|
|
||||||
argglobal
|
|
||||||
if bufexists(fnamemodify("~/projects/open_engine/open_engine/include/open_engine/renderer/vertex_array.hpp", ":p")) | buffer ~/projects/open_engine/open_engine/include/open_engine/renderer/vertex_array.hpp | else | edit ~/projects/open_engine/open_engine/include/open_engine/renderer/vertex_array.hpp | endif
|
|
||||||
if &buftype ==# 'terminal'
|
|
||||||
silent file ~/projects/open_engine/open_engine/include/open_engine/renderer/vertex_array.hpp
|
|
||||||
endif
|
|
||||||
setlocal foldmethod=manual
|
|
||||||
setlocal foldexpr=0
|
|
||||||
setlocal foldmarker={{{,}}}
|
|
||||||
setlocal foldignore=#
|
|
||||||
setlocal foldlevel=0
|
|
||||||
setlocal foldminlines=1
|
|
||||||
setlocal foldnestmax=20
|
|
||||||
setlocal foldenable
|
|
||||||
silent! normal! zE
|
|
||||||
let &fdl = &fdl
|
|
||||||
let s:l = 1 - ((0 * winheight(0) + 13) / 27)
|
|
||||||
if s:l < 1 | let s:l = 1 | endif
|
|
||||||
keepjumps exe s:l
|
|
||||||
normal! zt
|
|
||||||
keepjumps 1
|
|
||||||
normal! 0
|
|
||||||
lcd ~/projects/open_engine/open_engine
|
|
||||||
wincmd w
|
|
||||||
exe 'vert 1resize ' . ((&columns * 127 + 127) / 255)
|
|
||||||
exe 'vert 2resize ' . ((&columns * 127 + 127) / 255)
|
|
||||||
tabnext
|
|
||||||
edit ~/projects/open_engine/open_engine/assets/shaders/fragment.frag
|
|
||||||
let s:save_splitbelow = &splitbelow
|
|
||||||
let s:save_splitright = &splitright
|
|
||||||
set splitbelow splitright
|
|
||||||
wincmd _ | wincmd |
|
|
||||||
vsplit
|
|
||||||
1wincmd h
|
|
||||||
wincmd w
|
|
||||||
let &splitbelow = s:save_splitbelow
|
|
||||||
let &splitright = s:save_splitright
|
|
||||||
wincmd t
|
|
||||||
let s:save_winminheight = &winminheight
|
|
||||||
let s:save_winminwidth = &winminwidth
|
|
||||||
set winminheight=0
|
|
||||||
set winheight=1
|
|
||||||
set winminwidth=0
|
|
||||||
set winwidth=1
|
|
||||||
exe 'vert 1resize ' . ((&columns * 254 + 127) / 255)
|
|
||||||
exe 'vert 2resize ' . ((&columns * 0 + 127) / 255)
|
|
||||||
argglobal
|
|
||||||
setlocal foldmethod=manual
|
|
||||||
setlocal foldexpr=0
|
|
||||||
setlocal foldmarker={{{,}}}
|
|
||||||
setlocal foldignore=#
|
|
||||||
setlocal foldlevel=0
|
|
||||||
setlocal foldminlines=1
|
|
||||||
setlocal foldnestmax=20
|
|
||||||
setlocal foldenable
|
|
||||||
silent! normal! zE
|
|
||||||
let &fdl = &fdl
|
|
||||||
let s:l = 11 - ((8 * winheight(0) + 13) / 27)
|
|
||||||
if s:l < 1 | let s:l = 1 | endif
|
|
||||||
keepjumps exe s:l
|
|
||||||
normal! zt
|
|
||||||
keepjumps 11
|
|
||||||
normal! 020|
|
|
||||||
lcd ~/projects/open_engine/open_engine
|
|
||||||
wincmd w
|
|
||||||
argglobal
|
|
||||||
if bufexists(fnamemodify("~/projects/open_engine/open_engine/assets/shaders/vertex.vert", ":p")) | buffer ~/projects/open_engine/open_engine/assets/shaders/vertex.vert | else | edit ~/projects/open_engine/open_engine/assets/shaders/vertex.vert | endif
|
|
||||||
if &buftype ==# 'terminal'
|
|
||||||
silent file ~/projects/open_engine/open_engine/assets/shaders/vertex.vert
|
|
||||||
endif
|
|
||||||
balt ~/projects/open_engine/open_engine/assets/shaders/fragment.frag
|
|
||||||
setlocal foldmethod=manual
|
|
||||||
setlocal foldexpr=0
|
|
||||||
setlocal foldmarker={{{,}}}
|
|
||||||
setlocal foldignore=#
|
|
||||||
setlocal foldlevel=0
|
|
||||||
setlocal foldminlines=1
|
|
||||||
setlocal foldnestmax=20
|
|
||||||
setlocal foldenable
|
|
||||||
silent! normal! zE
|
|
||||||
let &fdl = &fdl
|
|
||||||
let s:l = 12 - ((11 * winheight(0) + 13) / 27)
|
|
||||||
if s:l < 1 | let s:l = 1 | endif
|
|
||||||
keepjumps exe s:l
|
|
||||||
normal! zt
|
|
||||||
keepjumps 12
|
|
||||||
normal! 022|
|
|
||||||
lcd ~/projects/open_engine/open_engine
|
|
||||||
wincmd w
|
|
||||||
exe 'vert 1resize ' . ((&columns * 254 + 127) / 255)
|
|
||||||
exe 'vert 2resize ' . ((&columns * 0 + 127) / 255)
|
|
||||||
tabnext 1
|
|
||||||
set stal=1
|
|
||||||
if exists('s:wipebuf') && len(win_findbuf(s:wipebuf)) == 0 && getbufvar(s:wipebuf, '&buftype') isnot# 'terminal'
|
|
||||||
silent exe 'bwipe ' . s:wipebuf
|
|
||||||
endif
|
|
||||||
unlet! s:wipebuf
|
|
||||||
set winheight=1 winwidth=20
|
|
||||||
let &shortmess = s:shortmess_save
|
|
||||||
let &winminheight = s:save_winminheight
|
|
||||||
let &winminwidth = s:save_winminwidth
|
|
||||||
let s:sx = expand("<sfile>:p:r")."x.vim"
|
|
||||||
if filereadable(s:sx)
|
|
||||||
exe "source " . fnameescape(s:sx)
|
|
||||||
endif
|
|
||||||
let &g:so = s:so_save | let &g:siso = s:siso_save
|
|
||||||
set hlsearch
|
|
||||||
doautoall SessionLoadPost
|
|
||||||
unlet SessionLoad
|
|
||||||
" vim: set ft=vim :
|
|
||||||
69
open_engine/include/open_engine/renderer/model3d.hpp
Normal file
69
open_engine/include/open_engine/renderer/model3d.hpp
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
#ifndef MODEL3D_HPP
|
||||||
|
#define MODEL3D_HPP
|
||||||
|
|
||||||
|
#include "open_engine/core/uuid.hpp"
|
||||||
|
#include "open_engine/renderer/vertex_array.hpp"
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <glm/glm.hpp>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace OpenEngine {
|
||||||
|
|
||||||
|
struct Material
|
||||||
|
{
|
||||||
|
glm::vec4 albedo = { 1.0f, 0.0f, 0.8f, 1.0f };
|
||||||
|
float roughness = 1.0f;
|
||||||
|
float metallic = 1.0f;
|
||||||
|
float ambient_strength = 1.0f;
|
||||||
|
float specular_strength = 1.0f;
|
||||||
|
std::string name = "un-named material";
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MeshVertex
|
||||||
|
{
|
||||||
|
glm::vec3 position;
|
||||||
|
glm::vec3 normal;
|
||||||
|
glm::vec2 text_coords;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Mesh
|
||||||
|
{
|
||||||
|
UUID uuid;
|
||||||
|
|
||||||
|
Material material;
|
||||||
|
|
||||||
|
Ref<VertexArray> vertex_array;
|
||||||
|
Ref<VertexBuffer> vertex_buffer;
|
||||||
|
Ref<IndexBuffer> index_buffer;
|
||||||
|
|
||||||
|
// TODO: Make them a ptr or something
|
||||||
|
std::vector<MeshVertex> vertices;
|
||||||
|
std::vector<uint32_t> indices;
|
||||||
|
};
|
||||||
|
|
||||||
|
// TODO: Model3D.Instanciate();
|
||||||
|
// Or Model3D.GetVertices() {return iterateaccessorwithindex bla bla bla}
|
||||||
|
// What data should Model3D hold in the end if it is not a renderable object?
|
||||||
|
class Model3D
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~Model3D() = default;
|
||||||
|
|
||||||
|
static Ref<Model3D> Create(const char* path);
|
||||||
|
|
||||||
|
virtual const Mesh& GetMesh(int index) const = 0;
|
||||||
|
virtual const std::vector<Mesh>& GetMeshes() const = 0;
|
||||||
|
|
||||||
|
virtual size_t GetMeshCount() const = 0;
|
||||||
|
|
||||||
|
virtual std::vector<Mesh>::iterator begin() = 0;
|
||||||
|
virtual std::vector<Mesh>::iterator end() = 0;
|
||||||
|
|
||||||
|
virtual std::vector<Mesh>::const_iterator begin() const = 0;
|
||||||
|
virtual std::vector<Mesh>::const_iterator end() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // MODEL3D_HPP
|
||||||
@@ -2,9 +2,8 @@
|
|||||||
#define RENDERER3D_HPP
|
#define RENDERER3D_HPP
|
||||||
|
|
||||||
#include "open_engine/renderer/editor_camera.hpp"
|
#include "open_engine/renderer/editor_camera.hpp"
|
||||||
#include "open_engine/renderer/vertex_array.hpp"
|
|
||||||
#include "open_engine/renderer/buffer.hpp"
|
|
||||||
#include "open_engine/scene/scene_camera.hpp"
|
#include "open_engine/scene/scene_camera.hpp"
|
||||||
|
#include "open_engine/renderer/model3d.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace OpenEngine {
|
namespace OpenEngine {
|
||||||
@@ -18,39 +17,12 @@ namespace OpenEngine {
|
|||||||
Cube
|
Cube
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MeshVertex
|
|
||||||
{
|
|
||||||
glm::vec3 position;
|
|
||||||
glm::vec4 color;
|
|
||||||
glm::vec3 normal;
|
|
||||||
glm::vec2 text_coords;
|
|
||||||
uint32_t id = -1;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Material
|
|
||||||
{
|
|
||||||
glm::vec4 albedo = { 1.0f, 1.0f, 1.0f, 1.0f };
|
|
||||||
float roughness = 1.0f;
|
|
||||||
float metallic = 1.0f;
|
|
||||||
float ambient_strength = 1.0f;
|
|
||||||
float specular_strength = 1.0f;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Mesh
|
|
||||||
{
|
|
||||||
Ref<VertexArray> vertex_array;
|
|
||||||
Ref<VertexBuffer> vertex_buffer;
|
|
||||||
Ref<IndexBuffer> index_buffer;
|
|
||||||
|
|
||||||
// TODO: Make them a ptr or something
|
|
||||||
std::vector<MeshVertex> vertices;
|
|
||||||
std::vector<uint32_t> indices;
|
|
||||||
};
|
|
||||||
|
|
||||||
Ref<Mesh> CreateMesh(const std::vector<MeshVertex>& vertices,
|
Ref<Mesh> CreateMesh(const std::vector<MeshVertex>& vertices,
|
||||||
const std::vector<uint32_t>& indices);
|
const std::vector<uint32_t>& indices);
|
||||||
|
void PopulateMesh(Mesh& mesh);
|
||||||
Ref<Mesh> CreateCube(uint32_t id = -1);
|
Ref<Mesh> CreateCube(uint32_t id = -1);
|
||||||
Ref<Mesh> CreateQuad(uint32_t id = -1, bool back_face = false);
|
Ref<Mesh> CreateQuad(uint32_t id = -1, bool back_face = false);
|
||||||
|
|
||||||
// ==================================================
|
// ==================================================
|
||||||
|
|
||||||
class Renderer3D
|
class Renderer3D
|
||||||
@@ -65,6 +37,12 @@ namespace OpenEngine {
|
|||||||
|
|
||||||
static void DrawMesh(const Ref<Mesh>& mesh, Material& material,
|
static void DrawMesh(const Ref<Mesh>& mesh, Material& material,
|
||||||
const glm::mat4& transform);
|
const glm::mat4& transform);
|
||||||
|
static void DrawMesh(const Ref<Mesh>& mesh, Material& material,
|
||||||
|
const glm::mat4& transform,
|
||||||
|
uint32_t entity_id);
|
||||||
|
static void DrawModel(const Ref<Model3D>& model,
|
||||||
|
const glm::mat4& transform,
|
||||||
|
uint32_t entity_id);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#define SHADER_HPP
|
#define SHADER_HPP
|
||||||
|
|
||||||
#include <open_engine/ref_scope.hpp>
|
#include <open_engine/ref_scope.hpp>
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace OpenEngine {
|
|||||||
class UniformBuffer
|
class UniformBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~UniformBuffer() {}
|
virtual ~UniformBuffer() = default;
|
||||||
virtual void SetData(const void* data, uint32_t size,
|
virtual void SetData(const void* data, uint32_t size,
|
||||||
uint32_t offset = 0) = 0;
|
uint32_t offset = 0) = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
#ifndef COMPONENTS_HPP
|
#ifndef COMPONENTS_HPP
|
||||||
#define COMPONENTS_HPP
|
#define COMPONENTS_HPP
|
||||||
|
|
||||||
#include "open_engine/scene/native_scriptable_entity.hpp"
|
|
||||||
#include "open_engine/renderer/renderer3d.hpp"
|
#include "open_engine/renderer/renderer3d.hpp"
|
||||||
#include "open_engine/scene/scene_camera.hpp"
|
#include "open_engine/scene/scene_camera.hpp"
|
||||||
#include "open_engine/renderer/texture.hpp"
|
#include "open_engine/renderer/texture.hpp"
|
||||||
#include "open_engine/renderer/renderer3d.hpp"
|
#include "open_engine/renderer/renderer3d.hpp"
|
||||||
#include "open_engine/physics.hpp"
|
#include "open_engine/physics.hpp"
|
||||||
|
#include "open_engine/core/uuid.hpp"
|
||||||
|
#include "open_engine/ref_scope.hpp"
|
||||||
|
#include "open_engine/renderer/model3d.hpp"
|
||||||
|
|
||||||
#include <Jolt/Physics/Body/BodyCreationSettings.h>
|
#include <Jolt/Physics/Body/BodyCreationSettings.h>
|
||||||
#include <Jolt/Physics/Body/BodyInterface.h>
|
#include <Jolt/Physics/Body/BodyInterface.h>
|
||||||
@@ -28,6 +30,15 @@
|
|||||||
|
|
||||||
namespace OpenEngine {
|
namespace OpenEngine {
|
||||||
|
|
||||||
|
struct IDComponent
|
||||||
|
{
|
||||||
|
UUID id;
|
||||||
|
|
||||||
|
IDComponent() = default;
|
||||||
|
IDComponent(const IDComponent&) = default;
|
||||||
|
IDComponent(const UUID& uuid) : id(uuid) {};
|
||||||
|
};
|
||||||
|
|
||||||
struct TagComponent
|
struct TagComponent
|
||||||
{
|
{
|
||||||
std::string tag;
|
std::string tag;
|
||||||
@@ -74,6 +85,8 @@ namespace OpenEngine {
|
|||||||
CameraComponent(const CameraComponent&) = default;
|
CameraComponent(const CameraComponent&) = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class NativeScriptableEntity;
|
||||||
|
|
||||||
struct NativeScriptComponent
|
struct NativeScriptComponent
|
||||||
{
|
{
|
||||||
NativeScriptableEntity* instance = nullptr;
|
NativeScriptableEntity* instance = nullptr;
|
||||||
@@ -81,9 +94,6 @@ namespace OpenEngine {
|
|||||||
NativeScriptableEntity* (*InstanciateScript)();
|
NativeScriptableEntity* (*InstanciateScript)();
|
||||||
void (*DestroyInstanceScript)(NativeScriptComponent*);
|
void (*DestroyInstanceScript)(NativeScriptComponent*);
|
||||||
|
|
||||||
void OnImGuiRender(Entity& entity)
|
|
||||||
{};
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void Bind()
|
void Bind()
|
||||||
{
|
{
|
||||||
@@ -119,30 +129,57 @@ namespace OpenEngine {
|
|||||||
|
|
||||||
struct PhysicsBodyComponent
|
struct PhysicsBodyComponent
|
||||||
{
|
{
|
||||||
enum class BodyType { Static = 0, Kinematic, Dynamic };
|
|
||||||
|
|
||||||
BodyID body;
|
BodyID body;
|
||||||
|
|
||||||
BodyType type = BodyType::Dynamic;
|
|
||||||
|
|
||||||
float linear_damping = 0.05f;
|
float linear_damping = 0.05f;
|
||||||
float angular_damping = 0.05f;
|
float angular_damping = 0.05f;
|
||||||
float gravity_factor = 1.0f;
|
float gravity_factor = 1.0f;
|
||||||
|
float restitution = 0.8f;
|
||||||
|
float friction = 0.5f;
|
||||||
|
|
||||||
EActivation initial_activation_state = EActivation::Activate;
|
int type = (int)EMotionType::Static;
|
||||||
|
int initial_activation_state = (int)EActivation::Activate;
|
||||||
|
int layer = (int)Layers::MOVING;
|
||||||
|
|
||||||
PhysicsBodyComponent() = default;
|
PhysicsBodyComponent() = default;
|
||||||
PhysicsBodyComponent(const PhysicsBodyComponent&) = default;
|
PhysicsBodyComponent(const PhysicsBodyComponent&) = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PhysicsShapeComponent
|
// TODO: Let's add more shapes
|
||||||
|
struct BoxShapeComponent
|
||||||
{
|
{
|
||||||
ShapeRefC shape;
|
glm::vec3 size = { 1.0f, 1.0f, 1.0f };
|
||||||
|
|
||||||
float restitution = 0.8f;
|
BoxShapeComponent() = default;
|
||||||
float friction = 0.5f;
|
BoxShapeComponent(const BoxShapeComponent&) = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SphereShapeComponent
|
||||||
|
{
|
||||||
|
float radius = 1.0f;
|
||||||
|
|
||||||
|
SphereShapeComponent() = default;
|
||||||
|
SphereShapeComponent(const SphereShapeComponent&) = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PlaneShapeComponent
|
||||||
|
{
|
||||||
|
float extent = 1.0f;
|
||||||
|
|
||||||
|
PlaneShapeComponent() = default;
|
||||||
|
PlaneShapeComponent(const PlaneShapeComponent&) = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ModelComponent
|
||||||
|
{
|
||||||
|
Ref<Model3D> model;
|
||||||
|
|
||||||
|
ModelComponent() = default;
|
||||||
|
ModelComponent(const ModelComponent&) = default;
|
||||||
|
ModelComponent(Ref<Model3D>& model)
|
||||||
|
: model(model)
|
||||||
|
{}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // COMPONENTS_HPP
|
#endif // COMPONENTS_HPP
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include "open_engine/core.hpp"
|
#include "open_engine/core.hpp"
|
||||||
|
|
||||||
|
#include "open_engine/core/uuid.hpp"
|
||||||
|
#include "open_engine/scene/components.hpp"
|
||||||
#include "open_engine/scene/scene.hpp"
|
#include "open_engine/scene/scene.hpp"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@@ -48,6 +50,8 @@ namespace OpenEngine {
|
|||||||
return scene->registry.all_of<T>(handle);
|
return scene->registry.all_of<T>(handle);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
UUID GetUUID() { return GetComponents<IDComponent>().id; };
|
||||||
|
|
||||||
operator bool() const { return handle != entt::null; };
|
operator bool() const { return handle != entt::null; };
|
||||||
operator entt::entity() const { return handle; };
|
operator entt::entity() const { return handle; };
|
||||||
operator uint32_t() const { return (uint32_t)handle; };
|
operator uint32_t() const { return (uint32_t)handle; };
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#ifndef NATIVE_SCRIPTABLE_ENTITY_HPP
|
#ifndef NATIVE_SCRIPTABLE_ENTITY_HPP
|
||||||
#define NATIVE_SCRIPTABLE_ENTITY_HPP
|
#define NATIVE_SCRIPTABLE_ENTITY_HPP
|
||||||
|
|
||||||
|
#include "open_engine/scene/native_scriptable_entity.hpp"
|
||||||
#include "open_engine/scene/entity.hpp"
|
#include "open_engine/scene/entity.hpp"
|
||||||
|
|
||||||
namespace OpenEngine {
|
namespace OpenEngine {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#ifndef SCENE_HPP
|
#ifndef SCENE_HPP
|
||||||
#define SCENE_HPP
|
#define SCENE_HPP
|
||||||
|
|
||||||
|
#include "open_engine/core/uuid.hpp"
|
||||||
#include "open_engine/renderer/editor_camera.hpp"
|
#include "open_engine/renderer/editor_camera.hpp"
|
||||||
#include "open_engine/physics.hpp"
|
#include "open_engine/physics.hpp"
|
||||||
|
|
||||||
@@ -18,11 +19,13 @@ namespace OpenEngine {
|
|||||||
public:
|
public:
|
||||||
Scene() = default;
|
Scene() = default;
|
||||||
~Scene() = default;
|
~Scene() = default;
|
||||||
|
Scene(Scene& other) {};
|
||||||
|
|
||||||
void OnRuntimeStart();
|
void OnRuntimeStart();
|
||||||
void OnRuntimeStop();
|
void OnRuntimeStop();
|
||||||
|
|
||||||
Entity CreateEntity(const std::string& name = std::string());
|
Entity CreateEntity(const std::string& name = std::string());
|
||||||
|
Entity CreateEntityWithUUID(UUID uuid, const std::string& name = std::string());
|
||||||
void DeleteEntity(entt::entity entity);
|
void DeleteEntity(entt::entity entity);
|
||||||
void MarkEntityForDeletion(Entity entity);
|
void MarkEntityForDeletion(Entity entity);
|
||||||
|
|
||||||
@@ -52,8 +55,6 @@ namespace OpenEngine {
|
|||||||
|
|
||||||
std::vector<entt::entity> pending_deletion;
|
std::vector<entt::entity> pending_deletion;
|
||||||
|
|
||||||
//BodyID sphere_id;
|
|
||||||
|
|
||||||
friend class SceneSerializer;
|
friend class SceneSerializer;
|
||||||
friend class Entity;
|
friend class Entity;
|
||||||
};
|
};
|
||||||
|
|||||||
24
open_engine/src/open_engine/core/uuid.cpp
Normal file
24
open_engine/src/open_engine/core/uuid.cpp
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#include <cstdint>
|
||||||
|
#include <pch.hpp>
|
||||||
|
|
||||||
|
#include <core/uuid.hpp>
|
||||||
|
|
||||||
|
#include <random>
|
||||||
|
|
||||||
|
namespace OpenEngine {
|
||||||
|
|
||||||
|
static std::random_device s_random_device;
|
||||||
|
static std::mt19937_64 s_engine(s_random_device());
|
||||||
|
static std::uniform_int_distribution<uint64_t> s_uniform_distribution;
|
||||||
|
|
||||||
|
UUID::UUID()
|
||||||
|
: uuid(s_uniform_distribution(s_engine))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
UUID::UUID(uint64_t uuid)
|
||||||
|
: uuid(uuid)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
86
open_engine/src/open_engine/fastgltf.cpp
Normal file
86
open_engine/src/open_engine/fastgltf.cpp
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
#include <pch.hpp>
|
||||||
|
|
||||||
|
#include "logging.hpp"
|
||||||
|
#include <fastgltf.hpp>
|
||||||
|
#include "ref_scope.hpp"
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <glm/fwd.hpp>
|
||||||
|
#include <fastgltf/core.hpp>
|
||||||
|
#include <fastgltf/types.hpp>
|
||||||
|
#include <fastgltf/tools.hpp>
|
||||||
|
#include <fastgltf/glm_element_traits.hpp>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace OpenEngine {
|
||||||
|
|
||||||
|
void loadPrimitive(fastgltf::Asset& asset,
|
||||||
|
fastgltf::Primitive& primitive,
|
||||||
|
Mesh& out)
|
||||||
|
{
|
||||||
|
if (primitive.indicesAccessor.has_value()) {
|
||||||
|
auto& accessor = asset.accessors[primitive.indicesAccessor.value()];
|
||||||
|
out.indices.resize(accessor.count);
|
||||||
|
|
||||||
|
fastgltf::iterateAccessorWithIndex<uint32_t>(asset, accessor,
|
||||||
|
[&](uint32_t index, size_t i) {
|
||||||
|
out.indices[i] = index;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto* position_iterator = primitive.findAttribute("POSITION");
|
||||||
|
auto& accessor = asset.accessors[position_iterator->accessorIndex];
|
||||||
|
out.vertices.resize(accessor.count);
|
||||||
|
|
||||||
|
fastgltf::iterateAccessorWithIndex<glm::vec3>(asset, accessor,
|
||||||
|
[&](glm::vec3 pos, size_t i) {
|
||||||
|
out.vertices[i].position = pos;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (auto* normal_iterator = primitive.findAttribute("NORMAL");
|
||||||
|
normal_iterator != primitive.attributes.end()) {
|
||||||
|
auto& accessor = asset.accessors[normal_iterator->accessorIndex];
|
||||||
|
|
||||||
|
fastgltf::iterateAccessorWithIndex<glm::vec3>(asset, accessor,
|
||||||
|
[&](glm::vec3 norm, size_t i) {
|
||||||
|
out.vertices[i].normal = norm;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
if (primitive.materialIndex.has_value()) {
|
||||||
|
auto& material = asset.materials[primitive.materialIndex.value()];
|
||||||
|
auto& pbr = material.pbrData;
|
||||||
|
|
||||||
|
auto& c = pbr.baseColorFactor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<Mesh> TestGLTF()
|
||||||
|
{
|
||||||
|
fastgltf::Parser parser;
|
||||||
|
Ref<Mesh> new_mesh = CreateRef<Mesh>();
|
||||||
|
|
||||||
|
auto data = fastgltf::GltfDataBuffer::FromPath("assets/models/cube.glb");
|
||||||
|
if (data.error() != fastgltf::Error::None)
|
||||||
|
OE_CORE_ERROR("Could not parse model");
|
||||||
|
|
||||||
|
auto asset = parser.loadGltfBinary(data.get(), ".",
|
||||||
|
fastgltf::Options::LoadExternalBuffers
|
||||||
|
);
|
||||||
|
if (asset.error() != fastgltf::Error::None)
|
||||||
|
OE_CORE_ERROR("Could not optain asset");
|
||||||
|
|
||||||
|
for (auto& mesh : asset->meshes)
|
||||||
|
for (auto& primitive : mesh.primitives)
|
||||||
|
loadPrimitive(asset.get(), primitive, *new_mesh);
|
||||||
|
|
||||||
|
return new_mesh;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
137
open_engine/src/open_engine/gltf/gltf_model3d.cpp
Normal file
137
open_engine/src/open_engine/gltf/gltf_model3d.cpp
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
#include "logging.hpp"
|
||||||
|
#include <pch.hpp>
|
||||||
|
|
||||||
|
#include <gltf/gltf_model3d.hpp>
|
||||||
|
|
||||||
|
#include <fastgltf/core.hpp>
|
||||||
|
#include <fastgltf/types.hpp>
|
||||||
|
#include <fastgltf/tools.hpp>
|
||||||
|
#include <fastgltf/glm_element_traits.hpp>
|
||||||
|
|
||||||
|
namespace OpenEngine {
|
||||||
|
|
||||||
|
void PopulateMesh(Mesh& mesh)
|
||||||
|
{
|
||||||
|
mesh.vertex_array = VertexArray::Create();
|
||||||
|
|
||||||
|
mesh.vertex_buffer = VertexBuffer::Create(mesh.vertices.size() * sizeof(MeshVertex));
|
||||||
|
mesh.vertex_buffer->SetData(mesh.vertices.data(), mesh.vertices.size() * sizeof(MeshVertex));
|
||||||
|
|
||||||
|
BufferLayout layout = {
|
||||||
|
{ ShaderDataType::Float3, "a_Position" },
|
||||||
|
{ ShaderDataType::Float3, "a_Normal" },
|
||||||
|
{ ShaderDataType::Float2, "a_TexCoord" }
|
||||||
|
};
|
||||||
|
|
||||||
|
mesh.vertex_buffer->SetLayout(layout);
|
||||||
|
mesh.vertex_array->AddVertexBuffer(mesh.vertex_buffer);
|
||||||
|
|
||||||
|
mesh.index_buffer = IndexBuffer::Create(mesh.indices.data(), mesh.indices.size());
|
||||||
|
mesh.vertex_array->SetIndexBuffer(mesh.index_buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<Mesh> CreateMesh(const std::vector<MeshVertex>& vertices,
|
||||||
|
const std::vector<uint32_t>& indices)
|
||||||
|
{
|
||||||
|
Ref<Mesh> mesh = CreateRef<Mesh>();
|
||||||
|
|
||||||
|
mesh->vertices = vertices;
|
||||||
|
mesh->indices = indices;
|
||||||
|
|
||||||
|
PopulateMesh(*mesh);
|
||||||
|
|
||||||
|
return mesh;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLTFModel3D::loadPrimitive(fastgltf::Asset& asset,
|
||||||
|
fastgltf::Primitive& primitive,
|
||||||
|
Mesh& out)
|
||||||
|
{
|
||||||
|
if (primitive.indicesAccessor.has_value()) {
|
||||||
|
auto& accessor = asset.accessors[primitive.indicesAccessor.value()];
|
||||||
|
out.indices.resize(accessor.count);
|
||||||
|
|
||||||
|
fastgltf::iterateAccessorWithIndex<uint32_t>(asset, accessor,
|
||||||
|
[&](uint32_t index, size_t i) {
|
||||||
|
out.indices[i] = index;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto* position_iterator = primitive.findAttribute("POSITION");
|
||||||
|
auto& accessor = asset.accessors[position_iterator->accessorIndex];
|
||||||
|
out.vertices.resize(accessor.count);
|
||||||
|
|
||||||
|
fastgltf::iterateAccessorWithIndex<glm::vec3>(asset, accessor,
|
||||||
|
[&](glm::vec3 pos, size_t i) {
|
||||||
|
out.vertices[i].position = pos;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (auto* normal_iterator = primitive.findAttribute("NORMAL");
|
||||||
|
normal_iterator != primitive.attributes.end()) {
|
||||||
|
auto& accessor = asset.accessors[normal_iterator->accessorIndex];
|
||||||
|
|
||||||
|
fastgltf::iterateAccessorWithIndex<glm::vec3>(asset, accessor,
|
||||||
|
[&](glm::vec3 norm, size_t i) {
|
||||||
|
out.vertices[i].normal = norm;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
if (primitive.materialIndex.has_value()) {
|
||||||
|
auto& material = asset.materials[primitive.materialIndex.value()];
|
||||||
|
auto& pbr = material.pbrData;
|
||||||
|
|
||||||
|
auto& color = pbr.baseColorFactor;
|
||||||
|
auto& roughness = pbr.roughnessFactor;
|
||||||
|
auto& metallic = pbr.metallicFactor;
|
||||||
|
|
||||||
|
out.material.name = material.name;
|
||||||
|
out.material.albedo = glm::vec4(color[0], color[1], color[2], color[3]);
|
||||||
|
out.material.roughness = roughness;
|
||||||
|
out.material.metallic = metallic;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GLTFModel3D::GLTFModel3D(const char* path)
|
||||||
|
{
|
||||||
|
fastgltf::Parser parser;
|
||||||
|
|
||||||
|
auto data = fastgltf::GltfDataBuffer::FromPath(path);
|
||||||
|
if (data.error() != fastgltf::Error::None)
|
||||||
|
OE_CORE_ERROR("Could not parse model");
|
||||||
|
|
||||||
|
auto asset = parser.loadGltfBinary(data.get(), ".",
|
||||||
|
fastgltf::Options::LoadExternalBuffers
|
||||||
|
);
|
||||||
|
if (asset.error() != fastgltf::Error::None)
|
||||||
|
OE_CORE_ERROR("Could not optain asset");
|
||||||
|
|
||||||
|
|
||||||
|
for (auto& mesh : asset->meshes) {
|
||||||
|
name = mesh.name;
|
||||||
|
|
||||||
|
for (auto& primitive : mesh.primitives) {
|
||||||
|
Mesh prim_mesh;
|
||||||
|
|
||||||
|
loadPrimitive(asset.get(), primitive, prim_mesh);
|
||||||
|
PopulateMesh(prim_mesh);
|
||||||
|
|
||||||
|
meshes.emplace_back(prim_mesh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const Mesh& GLTFModel3D::GetMesh(int index) const
|
||||||
|
{
|
||||||
|
return meshes[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Mesh>& GLTFModel3D::GetMeshes() const
|
||||||
|
{
|
||||||
|
return meshes;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -6,14 +6,12 @@
|
|||||||
#include <core/time.hpp>
|
#include <core/time.hpp>
|
||||||
#include <logging.hpp>
|
#include <logging.hpp>
|
||||||
|
|
||||||
#include <shaderc/shaderc.hpp>
|
|
||||||
#include <spirv_cross/spirv_cross.hpp>
|
#include <spirv_cross/spirv_cross.hpp>
|
||||||
#include <spirv_cross/spirv_glsl.hpp>
|
#include <spirv_cross/spirv_glsl.hpp>
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <glad/glad.h>
|
#include <glad/glad.h>
|
||||||
//#include <alloca.h>
|
|
||||||
|
|
||||||
namespace OpenEngine {
|
namespace OpenEngine {
|
||||||
|
|
||||||
@@ -30,7 +28,7 @@ namespace OpenEngine {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static shaderc_shader_kind GLShaderStageToShaderC(GLenum stage)
|
static ::shaderc_shader_kind GLShaderStageToShaderC(GLenum stage)
|
||||||
{
|
{
|
||||||
switch (stage)
|
switch (stage)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -38,7 +38,9 @@ namespace OpenEngine {
|
|||||||
|
|
||||||
tmp_allocator = CreateRef<TempAllocatorImpl>(10 * 1024 * 1024);
|
tmp_allocator = CreateRef<TempAllocatorImpl>(10 * 1024 * 1024);
|
||||||
|
|
||||||
job_system = CreateRef<JobSystemThreadPool>(cMaxPhysicsJobs, cMaxPhysicsBarriers, thread::hardware_concurrency() - 1);
|
job_system = CreateRef<JobSystemThreadPool>(cMaxPhysicsJobs,
|
||||||
|
cMaxPhysicsBarriers,
|
||||||
|
thread::hardware_concurrency() - 1);
|
||||||
|
|
||||||
physics_system.Init(
|
physics_system.Init(
|
||||||
1024,
|
1024,
|
||||||
@@ -49,10 +51,10 @@ namespace OpenEngine {
|
|||||||
object_vs_broadphase_layer_filter,
|
object_vs_broadphase_layer_filter,
|
||||||
object_vs_object_layer_filter);
|
object_vs_object_layer_filter);
|
||||||
|
|
||||||
physics_system.SetBodyActivationListener(&body_activation_listener);
|
//physics_system.SetBodyActivationListener(&body_activation_listener);
|
||||||
physics_system.SetContactListener(&contact_listener);
|
//physics_system.SetContactListener(&contact_listener);
|
||||||
|
|
||||||
// TODO: Move out of here and check the comment on Jolt's example
|
// TODO: Check the comment on Jolt's example
|
||||||
physics_system.OptimizeBroadPhase();
|
physics_system.OptimizeBroadPhase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
19
open_engine/src/open_engine/renderer/model3d.cpp
Normal file
19
open_engine/src/open_engine/renderer/model3d.cpp
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#include <pch.hpp>
|
||||||
|
|
||||||
|
#include <renderer/model3d.hpp>
|
||||||
|
|
||||||
|
#include <gltf/gltf_model3d.hpp>
|
||||||
|
#include <instrumentor.hpp>
|
||||||
|
#include <ref_scope.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
namespace OpenEngine {
|
||||||
|
|
||||||
|
Ref<Model3D> Model3D::Create(const char* path)
|
||||||
|
{
|
||||||
|
OE_PROFILE_FUNCTION();
|
||||||
|
|
||||||
|
return CreateRef<GLTFModel3D>(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#include "core/uuid.hpp"
|
||||||
#include "logging.hpp"
|
#include "logging.hpp"
|
||||||
#include "scene/scene_camera.hpp"
|
#include "scene/scene_camera.hpp"
|
||||||
#include <pch.hpp>
|
#include <pch.hpp>
|
||||||
@@ -19,37 +20,11 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#include <glad/glad.h>
|
#include <glad/glad.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace OpenEngine {
|
namespace OpenEngine {
|
||||||
|
|
||||||
// SHOULD BE MOVED ==================================
|
// SHOULD BE MOVED ==================================
|
||||||
Ref<Mesh> CreateMesh(const std::vector<MeshVertex>& vertices,
|
|
||||||
const std::vector<uint32_t>& indices)
|
|
||||||
{
|
|
||||||
Ref<Mesh> mesh = CreateRef<Mesh>();
|
|
||||||
mesh->vertices = vertices;
|
|
||||||
mesh->indices = indices;
|
|
||||||
|
|
||||||
mesh->vertex_array = VertexArray::Create();
|
|
||||||
|
|
||||||
mesh->vertex_buffer = VertexBuffer::Create(vertices.size() * sizeof(MeshVertex));
|
|
||||||
mesh->vertex_buffer->SetData(vertices.data(), vertices.size() * sizeof(MeshVertex));
|
|
||||||
|
|
||||||
BufferLayout layout = {
|
|
||||||
{ ShaderDataType::Float3, "a_Position" },
|
|
||||||
{ ShaderDataType::Float4, "a_Color" },
|
|
||||||
{ ShaderDataType::Float3, "a_Normal" },
|
|
||||||
{ ShaderDataType::Float2, "a_TexCoord" },
|
|
||||||
{ ShaderDataType::Int, "a_EntityID"}
|
|
||||||
};
|
|
||||||
mesh->vertex_buffer->SetLayout(layout);
|
|
||||||
mesh->vertex_array->AddVertexBuffer(mesh->vertex_buffer);
|
|
||||||
|
|
||||||
mesh->index_buffer = IndexBuffer::Create(indices.data(), indices.size());
|
|
||||||
mesh->vertex_array->SetIndexBuffer(mesh->index_buffer);
|
|
||||||
|
|
||||||
return mesh;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ref<Mesh> CreateQuad(uint32_t id, bool back_face)
|
Ref<Mesh> CreateQuad(uint32_t id, bool back_face)
|
||||||
{
|
{
|
||||||
@@ -61,16 +36,16 @@ namespace OpenEngine {
|
|||||||
if (back_face) {
|
if (back_face) {
|
||||||
vertices = {
|
vertices = {
|
||||||
// Front face (normal 0, 0, 1)
|
// Front face (normal 0, 0, 1)
|
||||||
{{-0.5f, -0.5f, 0.0f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,1}, {0,0}, id},
|
{{-0.5f, -0.5f, 0.0f}, {0,0,1}, {0,0}},
|
||||||
{{-0.5f, 0.5f, 0.0f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,1}, {0,1}, id},
|
{{-0.5f, 0.5f, 0.0f}, {0,0,1}, {0,1}},
|
||||||
{{ 0.5f, 0.5f, 0.0f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,1}, {1,1}, id},
|
{{ 0.5f, 0.5f, 0.0f}, {0,0,1}, {1,1}},
|
||||||
{{ 0.5f, -0.5f, 0.0f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,1}, {1,0}, id},
|
{{ 0.5f, -0.5f, 0.0f}, {0,0,1}, {1,0}},
|
||||||
|
|
||||||
// Back face (normal 0, 0, -1)
|
// Back face (normal 0, 0, -1)
|
||||||
{{-0.5f, -0.5f, -0.0f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,-1}, {0,0}, id},
|
{{-0.5f, -0.5f, -0.0f}, {0,0,-1}, {0,0}},
|
||||||
{{-0.5f, 0.5f, -0.0f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,-1}, {0,1}, id},
|
{{-0.5f, 0.5f, -0.0f}, {0,0,-1}, {0,1}},
|
||||||
{{ 0.5f, 0.5f, -0.0f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,-1}, {1,1}, id},
|
{{ 0.5f, 0.5f, -0.0f}, {0,0,-1}, {1,1}},
|
||||||
{{ 0.5f, -0.5f, -0.0f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,-1}, {1,0}, id}
|
{{ 0.5f, -0.5f, -0.0f}, {0,0,-1}, {1,0}}
|
||||||
};
|
};
|
||||||
|
|
||||||
indices = {
|
indices = {
|
||||||
@@ -82,10 +57,10 @@ namespace OpenEngine {
|
|||||||
} else {
|
} else {
|
||||||
vertices = {
|
vertices = {
|
||||||
// Front face (normal 0, 0, 1)
|
// Front face (normal 0, 0, 1)
|
||||||
{{-0.5f, -0.5f, 0.0f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,1}, {0,0}, id},
|
{{-0.5f, -0.5f, 0.0f}, {0,0,1}, {0,0}},
|
||||||
{{-0.5f, 0.5f, 0.0f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,1}, {0,1}, id},
|
{{-0.5f, 0.5f, 0.0f}, {0,0,1}, {0,1}},
|
||||||
{{ 0.5f, 0.5f, 0.0f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,1}, {1,1}, id},
|
{{ 0.5f, 0.5f, 0.0f}, {0,0,1}, {1,1}},
|
||||||
{{ 0.5f, -0.5f, 0.0f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,1}, {1,0}, id}
|
{{ 0.5f, -0.5f, 0.0f}, {0,0,1}, {1,0}}
|
||||||
};
|
};
|
||||||
|
|
||||||
indices = {
|
indices = {
|
||||||
@@ -103,40 +78,40 @@ namespace OpenEngine {
|
|||||||
OE_CORE_DEBUG("Creating cube with id {}.", id);
|
OE_CORE_DEBUG("Creating cube with id {}.", id);
|
||||||
std::vector<MeshVertex> vertices = {
|
std::vector<MeshVertex> vertices = {
|
||||||
// Front face (normal 0, 0, 1)
|
// Front face (normal 0, 0, 1)
|
||||||
{{-0.5f, -0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,1}, {0,0}, id},
|
{{-0.5f, -0.5f, 0.5f}, {0,0,1}, {0,0}},
|
||||||
{{-0.5f, 0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,1}, {0,1}, id},
|
{{-0.5f, 0.5f, 0.5f}, {0,0,1}, {0,1}},
|
||||||
{{ 0.5f, 0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,1}, {1,1}, id},
|
{{ 0.5f, 0.5f, 0.5f}, {0,0,1}, {1,1}},
|
||||||
{{ 0.5f, -0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,1}, {1,0}, id},
|
{{ 0.5f, -0.5f, 0.5f}, {0,0,1}, {1,0}},
|
||||||
|
|
||||||
// Back face (normal 0, 0, -1)
|
// Back face (normal 0, 0, -1)
|
||||||
{{-0.5f, -0.5f, -0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,-1}, {0,0}, id},
|
{{-0.5f, -0.5f, -0.5f}, {0,0,-1}, {0,0}},
|
||||||
{{-0.5f, 0.5f, -0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,-1}, {0,1}, id},
|
{{-0.5f, 0.5f, -0.5f}, {0,0,-1}, {0,1}},
|
||||||
{{ 0.5f, 0.5f, -0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,-1}, {1,1}, id},
|
{{ 0.5f, 0.5f, -0.5f}, {0,0,-1}, {1,1}},
|
||||||
{{ 0.5f, -0.5f, -0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,-1}, {1,0}, id},
|
{{ 0.5f, -0.5f, -0.5f}, {0,0,-1}, {1,0}},
|
||||||
|
|
||||||
// Left face (normal -1, 0, 0)
|
// Left face (normal -1, 0, 0)
|
||||||
{{-0.5f, -0.5f, -0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {-1,0,0}, {0,0}, id},
|
{{-0.5f, -0.5f, -0.5f}, {-1,0,0}, {0,0}},
|
||||||
{{-0.5f, 0.5f, -0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {-1,0,0}, {0,1}, id},
|
{{-0.5f, 0.5f, -0.5f}, {-1,0,0}, {0,1}},
|
||||||
{{-0.5f, 0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {-1,0,0}, {1,1}, id},
|
{{-0.5f, 0.5f, 0.5f}, {-1,0,0}, {1,1}},
|
||||||
{{-0.5f, -0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {-1,0,0}, {1,0}, id},
|
{{-0.5f, -0.5f, 0.5f}, {-1,0,0}, {1,0}},
|
||||||
|
|
||||||
// Right face (normal 1, 0, 0)
|
// Right face (normal 1, 0, 0)
|
||||||
{{ 0.5f, -0.5f, -0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {1,0,0}, {0,0}, id},
|
{{ 0.5f, -0.5f, -0.5f}, {1,0,0}, {0,0}},
|
||||||
{{ 0.5f, 0.5f, -0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {1,0,0}, {0,1}, id},
|
{{ 0.5f, 0.5f, -0.5f}, {1,0,0}, {0,1}},
|
||||||
{{ 0.5f, 0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {1,0,0}, {1,1}, id},
|
{{ 0.5f, 0.5f, 0.5f}, {1,0,0}, {1,1}},
|
||||||
{{ 0.5f, -0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {1,0,0}, {1,0}, id},
|
{{ 0.5f, -0.5f, 0.5f}, {1,0,0}, {1,0}},
|
||||||
|
|
||||||
// Top face (normal 0, 1, 0)
|
// Top face (normal 0, 1, 0)
|
||||||
{{-0.5f, 0.5f, -0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,1,0}, {0,0}, id},
|
{{-0.5f, 0.5f, -0.5f}, {0,1,0}, {0,0}},
|
||||||
{{-0.5f, 0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,1,0}, {0,1}, id},
|
{{-0.5f, 0.5f, 0.5f}, {0,1,0}, {0,1}},
|
||||||
{{ 0.5f, 0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,1,0}, {1,1}, id},
|
{{ 0.5f, 0.5f, 0.5f}, {0,1,0}, {1,1}},
|
||||||
{{ 0.5f, 0.5f, -0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,1,0}, {1,0}, id},
|
{{ 0.5f, 0.5f, -0.5f}, {0,1,0}, {1,0}},
|
||||||
|
|
||||||
// Bottom face (normal 0, -1, 0)
|
// Bottom face (normal 0, -1, 0)
|
||||||
{{-0.5f, -0.5f, -0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,-1,0}, {0,0}, id},
|
{{-0.5f, -0.5f, -0.5f}, {0,-1,0}, {0,0}},
|
||||||
{{-0.5f, -0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,-1,0}, {0,1}, id},
|
{{-0.5f, -0.5f, 0.5f}, {0,-1,0}, {0,1}},
|
||||||
{{ 0.5f, -0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,-1,0}, {1,1}, id},
|
{{ 0.5f, -0.5f, 0.5f}, {0,-1,0}, {1,1}},
|
||||||
{{ 0.5f, -0.5f, -0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,-1,0}, {1,0}, id},
|
{{ 0.5f, -0.5f, -0.5f}, {0,-1,0}, {1,0}},
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<uint32_t> indices = {
|
std::vector<uint32_t> indices = {
|
||||||
@@ -179,6 +154,8 @@ namespace OpenEngine {
|
|||||||
|
|
||||||
Material material_buffer;
|
Material material_buffer;
|
||||||
Ref<UniformBuffer> material_uniform_buffer;
|
Ref<UniformBuffer> material_uniform_buffer;
|
||||||
|
|
||||||
|
Ref<UniformBuffer> id_uniform_buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
static Renderer3DData renderer_data;
|
static Renderer3DData renderer_data;
|
||||||
@@ -194,6 +171,7 @@ namespace OpenEngine {
|
|||||||
renderer_data.camera_uniform_buffer = UniformBuffer::Create(sizeof(Renderer3DData::CameraData), 0);
|
renderer_data.camera_uniform_buffer = UniformBuffer::Create(sizeof(Renderer3DData::CameraData), 0);
|
||||||
renderer_data.transform_uniform_buffer = UniformBuffer::Create(sizeof(Renderer3DData::TransformData), 1);
|
renderer_data.transform_uniform_buffer = UniformBuffer::Create(sizeof(Renderer3DData::TransformData), 1);
|
||||||
renderer_data.material_uniform_buffer = UniformBuffer::Create(sizeof(Material), 2);
|
renderer_data.material_uniform_buffer = UniformBuffer::Create(sizeof(Material), 2);
|
||||||
|
renderer_data.id_uniform_buffer = UniformBuffer::Create(sizeof(uint32_t), 3);
|
||||||
|
|
||||||
glEnable(GL_DEBUG_OUTPUT);
|
glEnable(GL_DEBUG_OUTPUT);
|
||||||
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
||||||
@@ -205,8 +183,11 @@ namespace OpenEngine {
|
|||||||
|
|
||||||
void Renderer3D::Shutdown()
|
void Renderer3D::Shutdown()
|
||||||
{
|
{
|
||||||
renderer_data.camera_uniform_buffer.reset();
|
|
||||||
renderer_data.color_shader_3d.reset();
|
renderer_data.color_shader_3d.reset();
|
||||||
|
renderer_data.camera_uniform_buffer.reset();
|
||||||
|
renderer_data.transform_uniform_buffer.reset();
|
||||||
|
renderer_data.material_uniform_buffer.reset();
|
||||||
|
renderer_data.id_uniform_buffer.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer3D::BeginScene(const SceneCamera& camera, const glm::mat4& transform)
|
void Renderer3D::BeginScene(const SceneCamera& camera, const glm::mat4& transform)
|
||||||
@@ -251,4 +232,48 @@ namespace OpenEngine {
|
|||||||
|
|
||||||
RenderCommand::DrawIndexed(mesh->vertex_array, mesh->indices.size());
|
RenderCommand::DrawIndexed(mesh->vertex_array, mesh->indices.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Renderer3D::DrawMesh(const Ref<Mesh>& mesh, Material& material,
|
||||||
|
const glm::mat4& transform,
|
||||||
|
uint32_t entity_id)
|
||||||
|
{
|
||||||
|
OE_PROFILE_FUNCTION();
|
||||||
|
|
||||||
|
renderer_data.color_shader_3d->Bind();
|
||||||
|
|
||||||
|
renderer_data.transform_buffer.transform = transform;
|
||||||
|
renderer_data.transform_uniform_buffer->SetData(&renderer_data.transform_buffer, sizeof(Renderer3DData::TransformData));
|
||||||
|
|
||||||
|
renderer_data.material_buffer = material;
|
||||||
|
renderer_data.material_uniform_buffer->SetData(&renderer_data.material_buffer, sizeof(Material));
|
||||||
|
|
||||||
|
renderer_data.id_uniform_buffer->SetData(&entity_id, sizeof(uint32_t));
|
||||||
|
|
||||||
|
mesh->vertex_array->Bind();
|
||||||
|
|
||||||
|
RenderCommand::DrawIndexed(mesh->vertex_array, mesh->indices.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer3D::DrawModel(const Ref<Model3D>& model,
|
||||||
|
const glm::mat4& transform,
|
||||||
|
uint32_t entity_id)
|
||||||
|
{
|
||||||
|
OE_PROFILE_FUNCTION();
|
||||||
|
|
||||||
|
renderer_data.color_shader_3d->Bind();
|
||||||
|
|
||||||
|
renderer_data.transform_buffer.transform = transform;
|
||||||
|
renderer_data.transform_uniform_buffer->SetData(&renderer_data.transform_buffer, sizeof(Renderer3DData::TransformData));
|
||||||
|
|
||||||
|
for (auto& mesh : *model) {
|
||||||
|
renderer_data.material_buffer = mesh.material;
|
||||||
|
renderer_data.material_uniform_buffer->SetData(&renderer_data.material_buffer, sizeof(Material));
|
||||||
|
|
||||||
|
renderer_data.id_uniform_buffer->SetData(&entity_id, sizeof(uint32_t));
|
||||||
|
|
||||||
|
mesh.vertex_array->Bind();
|
||||||
|
|
||||||
|
RenderCommand::DrawIndexed(mesh.vertex_array, mesh.indices.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,69 +1,94 @@
|
|||||||
#include "logging.hpp"
|
#include "logging.hpp"
|
||||||
|
#include "physics.hpp"
|
||||||
|
#include "ref_scope.hpp"
|
||||||
|
#include "renderer/model3d.hpp"
|
||||||
|
#include <Jolt/Physics/Body/MotionType.h>
|
||||||
|
#include <Jolt/Physics/Collision/ObjectLayer.h>
|
||||||
|
#include <Jolt/Physics/Collision/Shape/ConvexShape.h>
|
||||||
#include <pch.hpp>
|
#include <pch.hpp>
|
||||||
|
|
||||||
#include <renderer/renderer3d.hpp>
|
#include <renderer/renderer3d.hpp>
|
||||||
#include <scene/components.hpp>
|
#include <scene/components.hpp>
|
||||||
|
#include <open_engine/scene/native_scriptable_entity.hpp>
|
||||||
#include <scene/entity.hpp>
|
#include <scene/entity.hpp>
|
||||||
#include <scene/scene.hpp>
|
#include <scene/scene.hpp>
|
||||||
#include <core/time.hpp>
|
#include <core/time.hpp>
|
||||||
|
|
||||||
#include <Jolt/Physics/Collision/Shape/Shape.h>
|
#include <Jolt/Physics/Collision/Shape/Shape.h>
|
||||||
|
#include <Jolt/Physics/Collision/Shape/PlaneShape.h>
|
||||||
|
#include <Jolt/Physics/Collision/Shape/BoxShape.h>
|
||||||
#include <Jolt/Physics/Collision/Shape/SphereShape.h>
|
#include <Jolt/Physics/Collision/Shape/SphereShape.h>
|
||||||
#include <Jolt/Physics/EActivation.h>
|
#include <Jolt/Physics/EActivation.h>
|
||||||
#include <Jolt/Math/Real.h>
|
#include <Jolt/Math/Real.h>
|
||||||
|
#include <Jolt/Math/Quat.h>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <entt/entity/fwd.hpp>
|
#include <entt/entity/fwd.hpp>
|
||||||
|
|
||||||
namespace OpenEngine {
|
namespace OpenEngine {
|
||||||
|
|
||||||
|
static Ref<ShapeSettings> CreateShape(entt::registry& reg, entt::entity e)
|
||||||
|
{
|
||||||
|
if (reg.any_of<BoxShapeComponent>(e)) {
|
||||||
|
auto& c = reg.get<BoxShapeComponent>(e);
|
||||||
|
return CreateRef<BoxShapeSettings>(ToJolt(c.size * 0.5f));
|
||||||
|
}
|
||||||
|
if (reg.any_of<SphereShapeComponent>(e)) {
|
||||||
|
auto& c = reg.get<SphereShapeComponent>(e);
|
||||||
|
return CreateRef<SphereShapeSettings>(c.radius);
|
||||||
|
}
|
||||||
|
if (reg.any_of<PlaneShapeComponent>(e)) {
|
||||||
|
auto& c = reg.get<PlaneShapeComponent>(e);
|
||||||
|
const Plane plane({ 0.0f, 1.0f, 0.0f }, 0);
|
||||||
|
return CreateRef<PlaneShapeSettings>(plane, nullptr, c.extent);
|
||||||
|
}
|
||||||
|
|
||||||
|
OE_CORE_ERROR("Entity {} has no shape component!", reg.get<TagComponent>(e).tag);
|
||||||
|
return nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
void Scene::OnRuntimeStart()
|
void Scene::OnRuntimeStart()
|
||||||
{
|
{
|
||||||
body_interface = &physics_engine.GetBodyInterface();
|
body_interface = &physics_engine.GetBodyInterface();
|
||||||
|
// TODO: Cleanup components aquisition
|
||||||
BoxShapeSettings floor_shape_settings(Vec3(100.0f, 1.0f, 100.0f));
|
auto view = registry.view<TransformComponent, PhysicsBodyComponent>();
|
||||||
floor_shape_settings.SetEmbedded(); // A ref counted object on the stack (base class RefTarget) should be marked as such to prevent it from being freed when its reference count goes to 0.
|
|
||||||
|
|
||||||
// Create the shape
|
|
||||||
ShapeSettings::ShapeResult floor_shape_result = floor_shape_settings.Create();
|
|
||||||
ShapeRefC floor_shape = floor_shape_result.Get(); // We don't expect an error here, but you can check floor_shape_result for HasError() / GetError()
|
|
||||||
|
|
||||||
// Create the settings for the body itself. Note that here you can also set other properties like the restitution / friction.
|
|
||||||
BodyCreationSettings floor_settings(floor_shape, RVec3(0.0_r, -1.0_r, 0.0_r), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING);
|
|
||||||
|
|
||||||
// Create the actual rigid body
|
|
||||||
Body *floor = body_interface->CreateBody(floor_settings); // Note that if we run out of bodies this can return nullptr
|
|
||||||
|
|
||||||
// Add it to the world
|
|
||||||
body_interface->AddBody(floor->GetID(), EActivation::DontActivate);
|
|
||||||
|
|
||||||
auto view = registry.view<PhysicsBodyComponent>();
|
|
||||||
for (auto e : view) {
|
for (auto e : view) {
|
||||||
Entity entity = { e, this };
|
Entity entity = { e, this };
|
||||||
|
|
||||||
TransformComponent* tc;
|
auto shape_settings = CreateShape(registry, e);
|
||||||
if (entity.HasComponent<TransformComponent>())
|
if (!shape_settings)
|
||||||
tc = &entity.GetComponents<TransformComponent>();
|
shape_settings = CreateRef<BoxShapeSettings>(Vec3(0.5f, 0.5f, 0.5f));
|
||||||
|
|
||||||
|
auto shape_result = shape_settings->Create();
|
||||||
|
if (shape_result.HasError()) {
|
||||||
|
OE_CORE_ERROR("Shape creation failed: {}", shape_result.GetError().c_str());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ShapeRefC shape = shape_result.Get();
|
||||||
|
|
||||||
auto& pbc = entity.GetComponents<PhysicsBodyComponent>();
|
auto& pbc = entity.GetComponents<PhysicsBodyComponent>();
|
||||||
|
auto& tc = entity.GetComponents<TransformComponent>();
|
||||||
|
|
||||||
PhysicsShapeComponent* psc;
|
glm::vec3& pos = tc.translation;
|
||||||
if (entity.HasComponent<PhysicsShapeComponent>())
|
glm::vec3& scale = tc.scale;
|
||||||
psc = &entity.GetComponents<PhysicsShapeComponent>();
|
glm::vec3& rot = tc.rotation;
|
||||||
|
|
||||||
glm::vec3& pos = tc->translation;
|
Quat quat = Quat::sEulerAngles(Vec3(rot.x, rot.y, rot.z));
|
||||||
BodyCreationSettings settings(
|
BodyCreationSettings settings(
|
||||||
new BoxShape(Vec3(0.5f, 0.5f, 0.5f)),
|
shape,
|
||||||
|
//new BoxShape(Vec3(scale.x * 0.5, scale.y * 0.5f, scale.z * 0.5f)),
|
||||||
Vec3(pos.x, pos.y, pos.z),
|
Vec3(pos.x, pos.y, pos.z),
|
||||||
Quat::sIdentity(),
|
quat,
|
||||||
EMotionType::Dynamic,
|
(EMotionType)pbc.type,
|
||||||
Layers::MOVING);
|
pbc.layer);
|
||||||
|
|
||||||
settings.mLinearDamping = pbc.linear_damping;
|
settings.mLinearDamping = pbc.linear_damping;
|
||||||
settings.mAngularDamping = pbc.angular_damping;
|
settings.mAngularDamping = pbc.angular_damping;
|
||||||
settings.mGravityFactor = pbc.gravity_factor;
|
settings.mGravityFactor = pbc.gravity_factor;
|
||||||
|
settings.mRestitution = pbc.restitution;
|
||||||
|
settings.mFriction = pbc.friction;
|
||||||
|
settings.mObjectLayer = (ObjectLayer)pbc.layer;
|
||||||
|
|
||||||
settings.mRestitution = psc->restitution;
|
pbc.body = body_interface->CreateAndAddBody(settings, (EActivation)pbc.initial_activation_state);
|
||||||
settings.mFriction = psc->friction;
|
|
||||||
|
|
||||||
pbc.body = body_interface->CreateAndAddBody(settings, EActivation::Activate);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,15 +100,21 @@ namespace OpenEngine {
|
|||||||
|
|
||||||
auto& pbc = entity.GetComponents<PhysicsBodyComponent>();
|
auto& pbc = entity.GetComponents<PhysicsBodyComponent>();
|
||||||
|
|
||||||
physics_engine.GetBodyInterface().RemoveBody(pbc.body);
|
body_interface->RemoveBody(pbc.body);
|
||||||
physics_engine.GetBodyInterface().DestroyBody(pbc.body);
|
body_interface->DestroyBody(pbc.body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity Scene::CreateEntity(const std::string& name)
|
Entity Scene::CreateEntity(const std::string& name)
|
||||||
|
{
|
||||||
|
return CreateEntityWithUUID(UUID(), name);
|
||||||
|
}
|
||||||
|
|
||||||
|
Entity Scene::CreateEntityWithUUID(UUID uuid, const std::string& name)
|
||||||
{
|
{
|
||||||
Entity entity = { registry.create(), this };
|
Entity entity = { registry.create(), this };
|
||||||
|
|
||||||
|
entity.AddComponent<IDComponent>(uuid);
|
||||||
auto& tag = entity.AddComponent<TagComponent>();
|
auto& tag = entity.AddComponent<TagComponent>();
|
||||||
tag.tag = name.empty() ? "Entity" : name;
|
tag.tag = name.empty() ? "Entity" : name;
|
||||||
|
|
||||||
@@ -150,15 +181,8 @@ namespace OpenEngine {
|
|||||||
|
|
||||||
body_interface->SetPosition(body.body, { pos.x, pos.y, pos.z }, EActivation::Activate);
|
body_interface->SetPosition(body.body, { pos.x, pos.y, pos.z }, EActivation::Activate);
|
||||||
|
|
||||||
PhysicsShapeComponent* shape;
|
body_interface->SetRestitution(body.body, body.restitution);
|
||||||
if (entity.HasComponent<PhysicsShapeComponent>()) {
|
body_interface->SetFriction(body.body, body.friction);
|
||||||
shape = &entity.GetComponents<PhysicsShapeComponent>();
|
|
||||||
|
|
||||||
body_interface->SetRestitution(body.body, shape->restitution);
|
|
||||||
body_interface->SetFriction(body.body, shape->friction);
|
|
||||||
body_interface->SetGravityFactor(body.body, body.gravity_factor);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OnUpdatePhysics();
|
OnUpdatePhysics();
|
||||||
@@ -169,10 +193,17 @@ namespace OpenEngine {
|
|||||||
auto& transform = entity.GetComponents<TransformComponent>();
|
auto& transform = entity.GetComponents<TransformComponent>();
|
||||||
auto& body = entity.GetComponents<PhysicsBodyComponent>();
|
auto& body = entity.GetComponents<PhysicsBodyComponent>();
|
||||||
|
|
||||||
auto position = physics_engine.GetBodyInterface().GetPosition(body.body);
|
auto position = body_interface->GetPosition(body.body);
|
||||||
|
auto rotation = body_interface->GetRotation(body.body).GetEulerAngles();
|
||||||
transform.translation.x = position.GetX();
|
transform.translation.x = position.GetX();
|
||||||
transform.translation.y = position.GetY();
|
transform.translation.y = position.GetY();
|
||||||
transform.translation.z = position.GetZ();
|
transform.translation.z = position.GetZ();
|
||||||
|
|
||||||
|
transform.rotation.x = rotation.GetX();
|
||||||
|
transform.rotation.y = rotation.GetY();
|
||||||
|
transform.rotation.z = rotation.GetZ();
|
||||||
|
|
||||||
|
body_interface->SetGravityFactor(body.body, body.gravity_factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneCamera* main_camera = nullptr;
|
SceneCamera* main_camera = nullptr;
|
||||||
@@ -194,14 +225,13 @@ namespace OpenEngine {
|
|||||||
|
|
||||||
auto view = registry.view<TransformComponent, MeshComponent>();
|
auto view = registry.view<TransformComponent, MeshComponent>();
|
||||||
|
|
||||||
for (const auto& entity : view) {
|
for (const auto& e : view) {
|
||||||
auto [transform, mesh] = view.get<TransformComponent, MeshComponent>(entity);
|
auto [transform, mesh] = view.get<TransformComponent, MeshComponent>(e);
|
||||||
|
Entity entity(e, this);
|
||||||
|
|
||||||
Material material;
|
Material material;
|
||||||
|
if (entity.HasComponent<MaterialComponent>())
|
||||||
Entity _entity(entity, this);
|
material = entity.GetComponents<MaterialComponent>().material;
|
||||||
if (_entity.HasComponent<MaterialComponent>())
|
|
||||||
material = _entity.GetComponents<MaterialComponent>().material;
|
|
||||||
|
|
||||||
Renderer3D::DrawMesh(mesh.mesh, material, GetTransformFromComp(transform));
|
Renderer3D::DrawMesh(mesh.mesh, material, GetTransformFromComp(transform));
|
||||||
/*
|
/*
|
||||||
@@ -234,7 +264,18 @@ namespace OpenEngine {
|
|||||||
if (_entity.HasComponent<MaterialComponent>())
|
if (_entity.HasComponent<MaterialComponent>())
|
||||||
material = _entity.GetComponents<MaterialComponent>().material;
|
material = _entity.GetComponents<MaterialComponent>().material;
|
||||||
|
|
||||||
Renderer3D::DrawMesh(mesh.mesh, material, GetTransformFromComp(transform));
|
if (mesh.mesh)
|
||||||
|
Renderer3D::DrawMesh(mesh.mesh, material, GetTransformFromComp(transform), (uint32_t)_entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto model_view = registry.view<TransformComponent, ModelComponent>();
|
||||||
|
|
||||||
|
for (const auto& entity : model_view) {
|
||||||
|
auto [transform, model_comp] = model_view.get<TransformComponent, ModelComponent>(entity);
|
||||||
|
|
||||||
|
Entity _entity(entity, this);
|
||||||
|
|
||||||
|
Renderer3D::DrawModel(model_comp.model, GetTransformFromComp(transform), (uint32_t)_entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
Renderer3D::EndScene();
|
Renderer3D::EndScene();
|
||||||
@@ -315,7 +356,27 @@ namespace OpenEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void Scene::OnComponentAdded<PhysicsShapeComponent>(Entity entity, PhysicsShapeComponent& component)
|
void Scene::OnComponentAdded<SphereShapeComponent>(Entity entity, SphereShapeComponent& component)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
void Scene::OnComponentAdded<BoxShapeComponent>(Entity entity, BoxShapeComponent& component)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
void Scene::OnComponentAdded<IDComponent>(Entity entity, IDComponent& component)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
void Scene::OnComponentAdded<PlaneShapeComponent>(Entity entity, PlaneShapeComponent& component)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
void Scene::OnComponentAdded<ModelComponent>(Entity entity, ModelComponent& component)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,11 +88,12 @@ namespace OpenEngine {
|
|||||||
|
|
||||||
static void SerializeEntity(YAML::Emitter& out, Entity entity)
|
static void SerializeEntity(YAML::Emitter& out, Entity entity)
|
||||||
{
|
{
|
||||||
out << YAML::BeginMap;
|
OE_CORE_ASSERT(entity.HasComponent<IDComponent>(), "Entity is missing UUID.");
|
||||||
out << YAML::Key << "Entity" << YAML::Value << "412741205"; // Needs random
|
|
||||||
|
|
||||||
if (entity.HasComponent<TagComponent>())
|
out << YAML::BeginMap;
|
||||||
{
|
out << YAML::Key << "Entity" << YAML::Value << entity.GetUUID(); // Needs random
|
||||||
|
|
||||||
|
if (entity.HasComponent<TagComponent>()) {
|
||||||
out << YAML::Key << "TagComponent";
|
out << YAML::Key << "TagComponent";
|
||||||
out << YAML::BeginMap; // TagComponent
|
out << YAML::BeginMap; // TagComponent
|
||||||
|
|
||||||
@@ -102,8 +103,7 @@ namespace OpenEngine {
|
|||||||
out << YAML::EndMap; // TagComponent
|
out << YAML::EndMap; // TagComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.HasComponent<TransformComponent>())
|
if (entity.HasComponent<TransformComponent>()) {
|
||||||
{
|
|
||||||
out << YAML::Key << "TransformComponent";
|
out << YAML::Key << "TransformComponent";
|
||||||
out << YAML::BeginMap; // TransformComponent
|
out << YAML::BeginMap; // TransformComponent
|
||||||
|
|
||||||
@@ -115,8 +115,7 @@ namespace OpenEngine {
|
|||||||
out << YAML::EndMap; // TransformComponent
|
out << YAML::EndMap; // TransformComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.HasComponent<CameraComponent>())
|
if (entity.HasComponent<CameraComponent>()) {
|
||||||
{
|
|
||||||
out << YAML::Key << "CameraComponent";
|
out << YAML::Key << "CameraComponent";
|
||||||
out << YAML::BeginMap; // CameraComponent
|
out << YAML::BeginMap; // CameraComponent
|
||||||
|
|
||||||
@@ -140,8 +139,7 @@ namespace OpenEngine {
|
|||||||
out << YAML::EndMap; // CameraComponent
|
out << YAML::EndMap; // CameraComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.HasComponent<SpriteRendererComponent>())
|
if (entity.HasComponent<SpriteRendererComponent>()) {
|
||||||
{
|
|
||||||
out << YAML::Key << "SpriteRendererComponent";
|
out << YAML::Key << "SpriteRendererComponent";
|
||||||
out << YAML::BeginMap; // SpriteRendererComponent
|
out << YAML::BeginMap; // SpriteRendererComponent
|
||||||
|
|
||||||
@@ -151,8 +149,7 @@ namespace OpenEngine {
|
|||||||
out << YAML::EndMap; // SpriteRendererComponent
|
out << YAML::EndMap; // SpriteRendererComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.HasComponent<MeshComponent>())
|
if (entity.HasComponent<MeshComponent>()) {
|
||||||
{
|
|
||||||
out << YAML::Key << "MeshComponent";
|
out << YAML::Key << "MeshComponent";
|
||||||
out << YAML::BeginMap; // MeshComponent
|
out << YAML::BeginMap; // MeshComponent
|
||||||
|
|
||||||
@@ -162,8 +159,7 @@ namespace OpenEngine {
|
|||||||
out << YAML::EndMap; // MeshComponent
|
out << YAML::EndMap; // MeshComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.HasComponent<MaterialComponent>())
|
if (entity.HasComponent<MaterialComponent>()) {
|
||||||
{
|
|
||||||
out << YAML::Key << "MaterialComponent";
|
out << YAML::Key << "MaterialComponent";
|
||||||
out << YAML::BeginMap; // MaterialComponent
|
out << YAML::BeginMap; // MaterialComponent
|
||||||
|
|
||||||
@@ -177,6 +173,54 @@ namespace OpenEngine {
|
|||||||
out << YAML::EndMap; // MaterialComponent
|
out << YAML::EndMap; // MaterialComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (entity.HasComponent<PhysicsBodyComponent>()) {
|
||||||
|
out << YAML::Key << "PhysicsBodyComponent";
|
||||||
|
out << YAML::BeginMap; // PhysicsBodyComponent
|
||||||
|
|
||||||
|
auto& pbc = entity.GetComponents<PhysicsBodyComponent>();
|
||||||
|
out << YAML::Key << "LinearDamping" << YAML::Value << pbc.linear_damping;
|
||||||
|
out << YAML::Key << "AngularDamping" << YAML::Value << pbc.angular_damping;
|
||||||
|
out << YAML::Key << "GravityFactor" << YAML::Value << pbc.gravity_factor;
|
||||||
|
out << YAML::Key << "Restitution" << YAML::Value << pbc.restitution;
|
||||||
|
out << YAML::Key << "Friction" << YAML::Value << pbc.friction;
|
||||||
|
|
||||||
|
out << YAML::Key << "Type" << YAML::Value << pbc.type;
|
||||||
|
out << YAML::Key << "ActivationState" << YAML::Value << pbc.initial_activation_state;
|
||||||
|
out << YAML::Key << "Layer" << YAML::Value << pbc.layer;
|
||||||
|
|
||||||
|
out << YAML::EndMap; // PhysicsBodyComponent
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entity.HasComponent<BoxShapeComponent>()) {
|
||||||
|
out << YAML::Key << "BoxShapeComponent";
|
||||||
|
out << YAML::BeginMap; //BoxShapeComponent
|
||||||
|
|
||||||
|
auto& bsc = entity.GetComponents<BoxShapeComponent>();
|
||||||
|
out << YAML::Key << "Size" << YAML::Value << bsc.size;
|
||||||
|
|
||||||
|
out << YAML::EndMap; //BoxShapeComponent
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entity.HasComponent<SphereShapeComponent>()) {
|
||||||
|
out << YAML::Key << "SphereShapeComponent";
|
||||||
|
out << YAML::BeginMap; //SphereShapeComponent
|
||||||
|
|
||||||
|
auto& ssc = entity.GetComponents<SphereShapeComponent>();
|
||||||
|
out << YAML::Key << "Radius" << YAML::Value << ssc.radius;
|
||||||
|
|
||||||
|
out << YAML::EndMap; //SphereShapeComponent
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entity.HasComponent<PlaneShapeComponent>()) {
|
||||||
|
out << YAML::Key << "PlaneShapeComponent";
|
||||||
|
out << YAML::BeginMap; //PlaneShapeComponent
|
||||||
|
|
||||||
|
auto& psc = entity.GetComponents<PlaneShapeComponent>();
|
||||||
|
out << YAML::Key << "Extent" << YAML::Value << psc.extent;
|
||||||
|
|
||||||
|
out << YAML::EndMap; //PlaneShapeComponent
|
||||||
|
}
|
||||||
|
|
||||||
out << YAML::EndMap;
|
out << YAML::EndMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,11 +263,10 @@ namespace OpenEngine {
|
|||||||
OE_CORE_TRACE("Deserializing scene '{0}'", sceneName);
|
OE_CORE_TRACE("Deserializing scene '{0}'", sceneName);
|
||||||
|
|
||||||
auto entities = data["Entities"];
|
auto entities = data["Entities"];
|
||||||
if (entities)
|
if (entities) {
|
||||||
{
|
|
||||||
for (auto entity : entities)
|
for (auto entity : entities)
|
||||||
{
|
{
|
||||||
uint64_t uuid = entity["Entity"].as<uint64_t>(); // TODO
|
uint64_t uuid = entity["Entity"].as<uint64_t>();
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
auto tagComponent = entity["TagComponent"];
|
auto tagComponent = entity["TagComponent"];
|
||||||
@@ -232,11 +275,10 @@ namespace OpenEngine {
|
|||||||
|
|
||||||
OE_CORE_TRACE("Deserialized entity with ID = {0}, name = {1}", uuid, name);
|
OE_CORE_TRACE("Deserialized entity with ID = {0}, name = {1}", uuid, name);
|
||||||
|
|
||||||
Entity deserializedEntity = context->CreateEntity(name);
|
Entity deserializedEntity = context->CreateEntityWithUUID(uuid, name);
|
||||||
|
|
||||||
auto transformComponent = entity["TransformComponent"];
|
auto transformComponent = entity["TransformComponent"];
|
||||||
if (transformComponent)
|
if (transformComponent) {
|
||||||
{
|
|
||||||
auto& tc = deserializedEntity.AddComponent<TransformComponent>();
|
auto& tc = deserializedEntity.AddComponent<TransformComponent>();
|
||||||
tc.translation = transformComponent["Translation"].as<glm::vec3>();
|
tc.translation = transformComponent["Translation"].as<glm::vec3>();
|
||||||
tc.rotation = transformComponent["Rotation"].as<glm::vec3>();
|
tc.rotation = transformComponent["Rotation"].as<glm::vec3>();
|
||||||
@@ -244,8 +286,7 @@ namespace OpenEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto cameraComponent = entity["CameraComponent"];
|
auto cameraComponent = entity["CameraComponent"];
|
||||||
if (cameraComponent)
|
if (cameraComponent) {
|
||||||
{
|
|
||||||
auto& cc = deserializedEntity.AddComponent<CameraComponent>();
|
auto& cc = deserializedEntity.AddComponent<CameraComponent>();
|
||||||
|
|
||||||
auto camera_props = cameraComponent["Camera"];
|
auto camera_props = cameraComponent["Camera"];
|
||||||
@@ -264,15 +305,13 @@ namespace OpenEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto spriteRendererComponent = entity["SpriteRendererComponent"];
|
auto spriteRendererComponent = entity["SpriteRendererComponent"];
|
||||||
if (spriteRendererComponent)
|
if (spriteRendererComponent) {
|
||||||
{
|
|
||||||
auto& src = deserializedEntity.AddComponent<SpriteRendererComponent>();
|
auto& src = deserializedEntity.AddComponent<SpriteRendererComponent>();
|
||||||
src.color = spriteRendererComponent["Color"].as<glm::vec4>();
|
src.color = spriteRendererComponent["Color"].as<glm::vec4>();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mesh_component = entity["MeshComponent"];
|
auto mesh_component = entity["MeshComponent"];
|
||||||
if (mesh_component)
|
if (mesh_component) {
|
||||||
{
|
|
||||||
auto& mesh = deserializedEntity.AddComponent<MeshComponent>();
|
auto& mesh = deserializedEntity.AddComponent<MeshComponent>();
|
||||||
mesh.primitive_type = (PrimitiveType)mesh_component["MeshType"].as<int>();
|
mesh.primitive_type = (PrimitiveType)mesh_component["MeshType"].as<int>();
|
||||||
switch (mesh.primitive_type) {
|
switch (mesh.primitive_type) {
|
||||||
@@ -292,8 +331,7 @@ namespace OpenEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto material_component = entity["MaterialComponent"];
|
auto material_component = entity["MaterialComponent"];
|
||||||
if (material_component)
|
if (material_component) {
|
||||||
{
|
|
||||||
auto& material = deserializedEntity.AddComponent<MaterialComponent>();
|
auto& material = deserializedEntity.AddComponent<MaterialComponent>();
|
||||||
material.material.albedo = material_component["Albedo"].as<glm::vec4>();
|
material.material.albedo = material_component["Albedo"].as<glm::vec4>();
|
||||||
material.material.roughness = material_component["Roughness"].as<float>();
|
material.material.roughness = material_component["Roughness"].as<float>();
|
||||||
@@ -301,11 +339,48 @@ namespace OpenEngine {
|
|||||||
material.material.ambient_strength = material_component["AmbiantStrength"].as<float>();
|
material.material.ambient_strength = material_component["AmbiantStrength"].as<float>();
|
||||||
material.material.specular_strength = material_component["SpecularStrength"].as<float>();
|
material.material.specular_strength = material_component["SpecularStrength"].as<float>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto physics_body_component = entity["PhysicsBodyComponent"];
|
||||||
|
if (physics_body_component) {
|
||||||
|
auto& pbc = deserializedEntity.AddComponent<PhysicsBodyComponent>();
|
||||||
|
|
||||||
|
pbc.linear_damping = physics_body_component["LinearDamping"].as<float>();
|
||||||
|
pbc.angular_damping = physics_body_component["AngularDamping"].as<float>();
|
||||||
|
pbc.gravity_factor = physics_body_component["GravityFactor"].as<float>();
|
||||||
|
pbc.restitution = physics_body_component["Restitution"].as<float>();
|
||||||
|
pbc.friction = physics_body_component["Friction"].as<float>();
|
||||||
|
|
||||||
|
pbc.type = physics_body_component["Type"].as<int>();
|
||||||
|
pbc.initial_activation_state = physics_body_component["ActivationState"].as<int>();
|
||||||
|
pbc.layer = physics_body_component["Layer"].as<int>();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto box_shape_component = entity["BoxShapeComponent"];
|
||||||
|
if (box_shape_component) {
|
||||||
|
auto& bsc = deserializedEntity.AddComponent<BoxShapeComponent>();
|
||||||
|
|
||||||
|
bsc.size = box_shape_component["Size"].as<glm::vec3>();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto sphere_shape_component = entity["SphereShapeComponent"];
|
||||||
|
if (sphere_shape_component) {
|
||||||
|
auto& ssc = deserializedEntity.AddComponent<SphereShapeComponent>();
|
||||||
|
|
||||||
|
ssc.radius = sphere_shape_component["Radius"].as<float>();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto plane_shape_component = entity["PlaneShapeComponent"];
|
||||||
|
if (sphere_shape_component) {
|
||||||
|
auto& psc = deserializedEntity.AddComponent<PlaneShapeComponent>();
|
||||||
|
|
||||||
|
psc.extent = plane_shape_component["Extent"].as<float>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SceneSerializer::DeserializeRuntime(const std::string& file_path)
|
bool SceneSerializer::DeserializeRuntime(const std::string& file_path)
|
||||||
{
|
{
|
||||||
OE_CORE_ASSERT(false, "Not implemented yet");
|
OE_CORE_ASSERT(false, "Not implemented yet");
|
||||||
|
|||||||
2
open_engine/vendor/glad/CMakeLists.txt
vendored
2
open_engine/vendor/glad/CMakeLists.txt
vendored
@@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 3.28)
|
cmake_minimum_required(VERSION 3.25.1)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
|
||||||
|
|||||||
1
open_engine/vendor/nativefiledialog-extended
vendored
Submodule
1
open_engine/vendor/nativefiledialog-extended
vendored
Submodule
Submodule open_engine/vendor/nativefiledialog-extended added at 74a6900e79
1
vendor/ImGuizmo
vendored
Submodule
1
vendor/ImGuizmo
vendored
Submodule
Submodule vendor/ImGuizmo added at a15acd87a3
Reference in New Issue
Block a user