Compare commits
No commits in common. 'fd8973d10dacc328c996f5854d15d70cd4bccbf8' and 'c607ebcc724f3d9a2ee6eae3e197930010a971a2' have entirely different histories.
fd8973d10d
...
c607ebcc72
40 changed files with 195 additions and 1091 deletions
Before Width: | Height: | Size: 77 KiB |
Before Width: | Height: | Size: 77 KiB |
Before Width: | Height: | Size: 69 KiB |
Before Width: | Height: | Size: 88 KiB |
Before Width: | Height: | Size: 87 KiB |
Before Width: | Height: | Size: 79 KiB |
@ -1,49 +0,0 @@ |
|||||||
#version 450 core |
|
||||||
|
|
||||||
layout(location = 0) out vec4 color; |
|
||||||
|
|
||||||
in vec4 v_color; |
|
||||||
in vec3 v_textureCoordinates; |
|
||||||
in flat float v_textureIndex; |
|
||||||
|
|
||||||
uniform samplerCube u_textures[32]; |
|
||||||
|
|
||||||
void main() |
|
||||||
{ |
|
||||||
vec4 textureColor = v_color; |
|
||||||
switch(int(v_textureIndex)) { |
|
||||||
case 0: break; // Texture unit 0 is reserved for no texture |
|
||||||
case 1: textureColor *= texture(u_textures[1], v_textureCoordinates); break; |
|
||||||
case 2: textureColor *= texture(u_textures[2], v_textureCoordinates); break; |
|
||||||
case 3: textureColor *= texture(u_textures[3], v_textureCoordinates); break; |
|
||||||
case 4: textureColor *= texture(u_textures[4], v_textureCoordinates); break; |
|
||||||
case 5: textureColor *= texture(u_textures[5], v_textureCoordinates); break; |
|
||||||
case 6: textureColor *= texture(u_textures[6], v_textureCoordinates); break; |
|
||||||
case 7: textureColor *= texture(u_textures[7], v_textureCoordinates); break; |
|
||||||
case 8: textureColor *= texture(u_textures[8], v_textureCoordinates); break; |
|
||||||
case 9: textureColor *= texture(u_textures[9], v_textureCoordinates); break; |
|
||||||
case 10: textureColor *= texture(u_textures[10], v_textureCoordinates); break; |
|
||||||
case 11: textureColor *= texture(u_textures[11], v_textureCoordinates); break; |
|
||||||
case 12: textureColor *= texture(u_textures[12], v_textureCoordinates); break; |
|
||||||
case 13: textureColor *= texture(u_textures[13], v_textureCoordinates); break; |
|
||||||
case 14: textureColor *= texture(u_textures[14], v_textureCoordinates); break; |
|
||||||
case 15: textureColor *= texture(u_textures[15], v_textureCoordinates); break; |
|
||||||
case 16: textureColor *= texture(u_textures[16], v_textureCoordinates); break; |
|
||||||
case 17: textureColor *= texture(u_textures[17], v_textureCoordinates); break; |
|
||||||
case 18: textureColor *= texture(u_textures[18], v_textureCoordinates); break; |
|
||||||
case 19: textureColor *= texture(u_textures[19], v_textureCoordinates); break; |
|
||||||
case 20: textureColor *= texture(u_textures[20], v_textureCoordinates); break; |
|
||||||
case 21: textureColor *= texture(u_textures[21], v_textureCoordinates); break; |
|
||||||
case 22: textureColor *= texture(u_textures[22], v_textureCoordinates); break; |
|
||||||
case 23: textureColor *= texture(u_textures[23], v_textureCoordinates); break; |
|
||||||
case 24: textureColor *= texture(u_textures[24], v_textureCoordinates); break; |
|
||||||
case 25: textureColor *= texture(u_textures[25], v_textureCoordinates); break; |
|
||||||
case 26: textureColor *= texture(u_textures[26], v_textureCoordinates); break; |
|
||||||
case 27: textureColor *= texture(u_textures[27], v_textureCoordinates); break; |
|
||||||
case 28: textureColor *= texture(u_textures[28], v_textureCoordinates); break; |
|
||||||
case 29: textureColor *= texture(u_textures[29], v_textureCoordinates); break; |
|
||||||
case 30: textureColor *= texture(u_textures[30], v_textureCoordinates); break; |
|
||||||
case 31: textureColor *= texture(u_textures[31], v_textureCoordinates); break; |
|
||||||
} |
|
||||||
color = textureColor; |
|
||||||
} |
|
@ -1,20 +0,0 @@ |
|||||||
#version 450 core |
|
||||||
|
|
||||||
layout(location = 0) in vec3 a_position; |
|
||||||
layout(location = 1) in vec4 a_color; |
|
||||||
layout(location = 2) in float a_textureIndex; |
|
||||||
|
|
||||||
out vec4 v_color; |
|
||||||
out vec3 v_textureCoordinates; |
|
||||||
out flat float v_textureIndex; |
|
||||||
|
|
||||||
uniform mat4 u_projectionView; |
|
||||||
|
|
||||||
void main() |
|
||||||
{ |
|
||||||
v_color = a_color; |
|
||||||
v_textureCoordinates = a_position; |
|
||||||
v_textureIndex = a_textureIndex; |
|
||||||
// Vclip = Camera projection * Camera view * Model transform * Vlocal |
|
||||||
gl_Position = u_projectionView * vec4(a_position, 1.0f); |
|
||||||
} |
|
@ -1,111 +1,50 @@ |
|||||||
{ |
{ |
||||||
"init": "assets/lua/scene1-init.lua", |
"init": "assets/lua/scene1-init.lua", |
||||||
"entities": [ |
"camera": { |
||||||
{ |
"name": "Camera", |
||||||
"id": { "id": 12312312 }, |
|
||||||
"tag": { "tag": "Camera" }, |
|
||||||
"transform" : { |
|
||||||
"translate": [ 0.0, 0.0, 1.0 ], |
"translate": [ 0.0, 0.0, 1.0 ], |
||||||
"rotate": [ 0.0, 0.0, -1.0 ], |
"rotate": [ 0.0, 0.0, -1.0 ], |
||||||
"scale": [1.0, 1.0, 1.0] |
"scale": [ 1.0, 1.0, 1.0 ], |
||||||
}, |
"type": "perspective", |
||||||
"camera": { "type": "perspective" }, |
"script": { |
||||||
"lua-scripts": [ |
"type": "lua", |
||||||
{ "path": "assets/lua/cameracontroller.lua" } |
"name": "assets/lua/cameracontroller.lua" |
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
"id": { "id": 212563732 }, |
|
||||||
"tag": { "tag": "Skybox" }, |
|
||||||
"transform" : { |
|
||||||
"translate": [0.0, 0.0, 0.0], |
|
||||||
"rotate": [0.0, 0.0, 0.0], |
|
||||||
"scale": [100.0, 100.0, 100.0] |
|
||||||
}, |
|
||||||
"cubemap": { |
|
||||||
"color": [ 1.0, 1.0, 1.0, 1.0 ], |
|
||||||
"texture": "assets/gfx/skybox.jpg" |
|
||||||
} |
} |
||||||
}, |
}, |
||||||
|
"quad": [ |
||||||
{ |
{ |
||||||
"id": { "id": 564564564 }, |
"name": "Quad", |
||||||
"tag": { "tag": "Quad" }, |
|
||||||
"transform" : { |
|
||||||
"translate": [ 0.0, 0.0, 0.0 ], |
"translate": [ 0.0, 0.0, 0.0 ], |
||||||
"rotate": [ 0.0, 0.0, 0.0 ], |
"rotate": [ 0.0, 0.0, 0.0 ], |
||||||
"scale": [ 1.0, 1.0, 1.0 ] |
"scale": [ 1.0, 1.0, 1.0 ], |
||||||
}, |
|
||||||
"sprite": { |
|
||||||
"color": [ 1.0, 1.0, 1.0, 1.0 ], |
"color": [ 1.0, 1.0, 1.0, 1.0 ], |
||||||
"texture": "assets/gfx/test.png" |
"texture": "assets/gfx/test.png" |
||||||
} |
|
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"id": { "id": 97897897 }, |
"name": "Quad 2", |
||||||
"tag": { "tag": "Quad 2" }, |
|
||||||
"transform" : { |
|
||||||
"translate": [ 1.1, 0.0, 0.0 ], |
"translate": [ 1.1, 0.0, 0.0 ], |
||||||
"rotate": [ 0.0, 0.0, 0.0 ], |
"rotate": [ 0.0, 0.0, 0.0 ], |
||||||
"scale": [ 1.0, 1.0, 1.0 ] |
"scale": [ 1.0, 1.0, 1.0 ], |
||||||
}, |
|
||||||
"sprite": { |
|
||||||
"color": [ 0.5, 0.6, 0.8, 1.0 ], |
"color": [ 0.5, 0.6, 0.8, 1.0 ], |
||||||
"texture": "assets/gfx/test.png" |
"texture": "assets/gfx/test.png" |
||||||
} |
|
||||||
}, |
|
||||||
{ |
|
||||||
"id": { "id": 3424242 }, |
|
||||||
"tag": { "tag": "Quad 3" }, |
|
||||||
"transform" : { |
|
||||||
"translate": [ 2.2, 1.0, 0.0 ], |
|
||||||
"rotate": [ 0.0, 0.0, -20.0 ], |
|
||||||
"scale": [ 1.0, 1.0, 1.0 ] |
|
||||||
}, |
}, |
||||||
"sprite": { |
|
||||||
"color": [ 1.0, 1.0, 1.0, 1.0 ], |
|
||||||
"texture": "assets/gfx/test-inverted.png" |
|
||||||
}, |
|
||||||
"children": [ |
|
||||||
{ |
{ |
||||||
"id": { "id": 4345472 }, |
"name": "Quad 3", |
||||||
"tag": { "tag": "Quad 4" }, |
"translate": [ 2.2, 0.0, 0.0 ], |
||||||
"transform" : { |
|
||||||
"translate": [ 0.85, 0.0, 0.0 ], |
|
||||||
"rotate": [ 0.0, 0.0, 0.0 ], |
"rotate": [ 0.0, 0.0, 0.0 ], |
||||||
"scale": [ 0.5, 0.5, 1.0 ] |
"scale": [ 1.0, 1.0, 1.0 ], |
||||||
}, |
|
||||||
"sprite": { |
|
||||||
"color": [ 1.0, 1.0, 1.0, 1.0 ], |
"color": [ 1.0, 1.0, 1.0, 1.0 ], |
||||||
"texture": "assets/gfx/test-inverted.png" |
"texture": "assets/gfx/test-inverted.png" |
||||||
}, |
|
||||||
"children": [ |
|
||||||
{ |
|
||||||
"id": { "id": 5234723 }, |
|
||||||
"tag": { "tag": "Quad 5" }, |
|
||||||
"transform" : { |
|
||||||
"translate": [ 1.0, 0.0, 0.0 ], |
|
||||||
"rotate": [ 0.0, 0.0, -20.0 ], |
|
||||||
"scale": [ 0.5, 0.5, 1.0 ] |
|
||||||
}, |
|
||||||
"sprite": { |
|
||||||
"color": [ 1.0, 1.0, 1.0, 1.0 ], |
|
||||||
"texture": "assets/gfx/test-inverted.png" |
|
||||||
} |
|
||||||
} |
|
||||||
] |
|
||||||
} |
} |
||||||
] |
], |
||||||
}, |
"text": [ |
||||||
{ |
{ |
||||||
"id": { "id": 675754 }, |
"name": "Text", |
||||||
"tag": { "tag": "Text" }, |
|
||||||
"text": { |
|
||||||
"content": "Hello World!", |
"content": "Hello World!", |
||||||
"font": "assets/fnt/open-sans", |
"font": "assets/fnt/open-sans", |
||||||
"font-size": 24, |
"font-size": 24, |
||||||
"line-spacing": 1.0, |
"line-spacing": 1.0, |
||||||
"width": 150 |
"width": 150 |
||||||
} |
} |
||||||
} |
|
||||||
] |
] |
||||||
} |
} |
||||||
|
@ -1,26 +0,0 @@ |
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Riyyi |
|
||||||
* |
|
||||||
* SPDX-License-Identifier: MIT |
|
||||||
*/ |
|
||||||
|
|
||||||
#include "ruc/format/print.h" |
|
||||||
#include "ruc/json/json.h" |
|
||||||
|
|
||||||
#include "inferno/component/cameracomponent.h" |
|
||||||
|
|
||||||
namespace Inferno { |
|
||||||
|
|
||||||
void fromJson(const ruc::Json& json, CameraComponent& value) |
|
||||||
{ |
|
||||||
VERIFY(json.type() == ruc::Json::Type::Object); |
|
||||||
|
|
||||||
if (json.exists("type")) { |
|
||||||
value.type = json.at("type").get<std::string>() == "orthographic" ? CameraType::Orthographic : CameraType::Perspective; |
|
||||||
} |
|
||||||
if (json.exists("zoom-level")) { |
|
||||||
json.at("zoom-level").getTo(value.zoomLevel); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} // namespace Inferno
|
|
@ -1,27 +0,0 @@ |
|||||||
/*
|
|
||||||
* Copyright (C) 2024 Riyyi |
|
||||||
* |
|
||||||
* SPDX-License-Identifier: MIT |
|
||||||
*/ |
|
||||||
|
|
||||||
#include "ruc/json/json.h" |
|
||||||
|
|
||||||
#include "inferno/component/cubemap-component.h" |
|
||||||
#include "inferno/component/spritecomponent.h" // TODO: Move glm::x toJson/fromJson to separate file |
|
||||||
#include "inferno/render/texture.h" |
|
||||||
|
|
||||||
namespace Inferno { |
|
||||||
|
|
||||||
void fromJson(const ruc::Json& json, CubemapComponent& value) |
|
||||||
{ |
|
||||||
VERIFY(json.type() == ruc::Json::Type::Object); |
|
||||||
|
|
||||||
if (json.exists("color")) { |
|
||||||
json.at("color").getTo(value.color); |
|
||||||
} |
|
||||||
if (json.exists("texture") && json.at("texture").type() == ruc::Json::Type::String) { |
|
||||||
value.texture = TextureManager::the().load(json.at("texture").asString(), Texture::Type::Cubemap); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} // namespace Inferno
|
|
@ -1,25 +0,0 @@ |
|||||||
/*
|
|
||||||
* Copyright (C) 2024 Riyyi |
|
||||||
* |
|
||||||
* SPDX-License-Identifier: MIT |
|
||||||
*/ |
|
||||||
|
|
||||||
#pragma once |
|
||||||
|
|
||||||
#include <memory> // std::shared_ptr |
|
||||||
|
|
||||||
#include "glm/ext/vector_float4.hpp" // glm::vec4 |
|
||||||
#include "ruc/json/json.h" |
|
||||||
|
|
||||||
#include "inferno/render/texture.h" |
|
||||||
|
|
||||||
namespace Inferno { |
|
||||||
|
|
||||||
struct CubemapComponent { |
|
||||||
glm::vec4 color { 1.0f }; |
|
||||||
std::shared_ptr<Texture> texture; |
|
||||||
}; |
|
||||||
|
|
||||||
void fromJson(const ruc::Json& json, CubemapComponent& value); |
|
||||||
|
|
||||||
} // namespace Inferno
|
|
@ -1,22 +0,0 @@ |
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Riyyi |
|
||||||
* |
|
||||||
* SPDX-License-Identifier: MIT |
|
||||||
*/ |
|
||||||
|
|
||||||
#include "ruc/json/json.h" |
|
||||||
|
|
||||||
#include "inferno/component/id-component.h" |
|
||||||
|
|
||||||
namespace Inferno { |
|
||||||
|
|
||||||
void fromJson(const ruc::Json& json, IDComponent& value) |
|
||||||
{ |
|
||||||
VERIFY(json.type() == ruc::Json::Type::Object); |
|
||||||
|
|
||||||
if (json.exists("id")) { |
|
||||||
json.at("id").getTo(value.id); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} // namespace Inferno
|
|
@ -1,28 +0,0 @@ |
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Riyyi |
|
||||||
* |
|
||||||
* SPDX-License-Identifier: MIT |
|
||||||
*/ |
|
||||||
|
|
||||||
#pragma once |
|
||||||
|
|
||||||
#include "ruc/json/json.h" |
|
||||||
|
|
||||||
#include "inferno/uid.h" |
|
||||||
|
|
||||||
namespace Inferno { |
|
||||||
|
|
||||||
struct IDComponent { |
|
||||||
UID id; |
|
||||||
|
|
||||||
IDComponent() = default; |
|
||||||
IDComponent(UID id) |
|
||||||
: id(id) |
|
||||||
{ |
|
||||||
} |
|
||||||
IDComponent(const IDComponent&) = default; |
|
||||||
}; |
|
||||||
|
|
||||||
void fromJson(const ruc::Json& json, IDComponent& value); |
|
||||||
|
|
||||||
} // namespace Inferno
|
|
@ -1,21 +0,0 @@ |
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Riyyi |
|
||||||
* |
|
||||||
* SPDX-License-Identifier: MIT |
|
||||||
*/ |
|
||||||
|
|
||||||
#include "ruc/json/json.h" |
|
||||||
|
|
||||||
#include "inferno/component/luascriptcomponent.h" |
|
||||||
|
|
||||||
namespace Inferno { |
|
||||||
|
|
||||||
void fromJson(const ruc::Json& json, LuaScriptComponent& value) |
|
||||||
{ |
|
||||||
VERIFY(json.type() == ruc::Json::Type::Object); |
|
||||||
|
|
||||||
VERIFY(json.exists("path"), "path not found"); |
|
||||||
json.at("path").getTo(value.path); |
|
||||||
} |
|
||||||
|
|
||||||
} // namespace Inferno
|
|
@ -1,21 +0,0 @@ |
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Riyyi |
|
||||||
* |
|
||||||
* SPDX-License-Identifier: MIT |
|
||||||
*/ |
|
||||||
|
|
||||||
#include "ruc/json/json.h" |
|
||||||
|
|
||||||
#include "inferno/component/nativescriptcomponent.h" |
|
||||||
|
|
||||||
namespace Inferno { |
|
||||||
|
|
||||||
void fromJson(const ruc::Json& json, NativeScriptComponent& value) |
|
||||||
{ |
|
||||||
VERIFY(json.type() == ruc::Json::Type::Object); |
|
||||||
|
|
||||||
VERIFY(json.exists("name"), "name not found"); |
|
||||||
json.at("name").getTo(value.name); |
|
||||||
} |
|
||||||
|
|
||||||
} // namespace Inferno
|
|
@ -1,22 +0,0 @@ |
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Riyyi |
|
||||||
* |
|
||||||
* SPDX-License-Identifier: MIT |
|
||||||
*/ |
|
||||||
|
|
||||||
#include "ruc/json/json.h" |
|
||||||
|
|
||||||
#include "inferno/component/tagcomponent.h" |
|
||||||
|
|
||||||
namespace Inferno { |
|
||||||
|
|
||||||
void fromJson(const ruc::Json& json, TagComponent& value) |
|
||||||
{ |
|
||||||
VERIFY(json.type() == ruc::Json::Type::Object); |
|
||||||
|
|
||||||
if (json.exists("tag")) { |
|
||||||
json.at("tag").getTo(value.tag); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} // namespace Inferno
|
|
@ -1,38 +0,0 @@ |
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Riyyi |
|
||||||
* |
|
||||||
* SPDX-License-Identifier: MIT |
|
||||||
*/ |
|
||||||
|
|
||||||
#include <cstdint> |
|
||||||
#include <random> |
|
||||||
|
|
||||||
#include "ruc/format/log.h" |
|
||||||
#include "ruc/json/json.h" |
|
||||||
|
|
||||||
#include "inferno/uid.h" |
|
||||||
|
|
||||||
namespace Inferno { |
|
||||||
|
|
||||||
static std::random_device s_seed; |
|
||||||
static std::mt19937_64 s_engine(s_seed()); |
|
||||||
static std::uniform_int_distribution<uint64_t> s_distribution; |
|
||||||
|
|
||||||
UID::UID() |
|
||||||
: m_uid(s_distribution(s_engine)) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
UID::UID(uint64_t uid) |
|
||||||
: m_uid(uid) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
void fromJson(const ruc::Json& json, UID& value) |
|
||||||
{ |
|
||||||
VERIFY(json.type() == ruc::Json::Type::Number); |
|
||||||
|
|
||||||
value = UID((int64_t)json.asDouble()); |
|
||||||
} |
|
||||||
|
|
||||||
} // namespace Inferno
|
|
@ -1,47 +0,0 @@ |
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Riyyi |
|
||||||
* |
|
||||||
* SPDX-License-Identifier: MIT |
|
||||||
*/ |
|
||||||
|
|
||||||
#pragma once |
|
||||||
|
|
||||||
#include <cstdint> // uint64_t |
|
||||||
|
|
||||||
#include "ruc/json/json.h" |
|
||||||
|
|
||||||
namespace Inferno { |
|
||||||
|
|
||||||
class UID { |
|
||||||
public: |
|
||||||
UID(); |
|
||||||
UID(uint64_t uid); |
|
||||||
|
|
||||||
// Comparison operator for std::map
|
|
||||||
bool operator<(const UID& other) const |
|
||||||
{ |
|
||||||
return m_uid < other.m_uid; |
|
||||||
} |
|
||||||
|
|
||||||
operator uint64_t() const { return m_uid; } |
|
||||||
|
|
||||||
private: |
|
||||||
uint64_t m_uid; |
|
||||||
}; |
|
||||||
|
|
||||||
void fromJson(const ruc::Json& json, UID& value); |
|
||||||
|
|
||||||
} // namespace Inferno
|
|
||||||
|
|
||||||
namespace std { |
|
||||||
|
|
||||||
// Hash function for std::unordered_map
|
|
||||||
template<> |
|
||||||
struct hash<Inferno::UID> { |
|
||||||
size_t operator()(const Inferno::UID& uid) const |
|
||||||
{ |
|
||||||
return hash<uint64_t>()(static_cast<uint64_t>(uid)); |
|
||||||
} |
|
||||||
}; |
|
||||||
|
|
||||||
} // namespace std
|
|
Loading…
Reference in new issue