Skip to content
Snippets Groups Projects
Commit 681c9ca8 authored by JonShard's avatar JonShard
Browse files

Merged with dev. So many models here now :P

parents 9cd7e6b6 177a6a2e
No related branches found
No related tags found
No related merge requests found
Showing
with 1935 additions and 183 deletions
......@@ -5,6 +5,40 @@ enc_temp_folder/
CMakeSettings.json
*.DS_Store
# big assets
*teapot-top.yml
*teapot-base.yml
\ No newline at end of file
#
# ASSETS WHITELIST
#
# * Whitelist assets we want to keep
assets/textures/*
!assets/textures/.gitkeep
!assets/textures/brickwall-nrm.jpg
!assets/textures/brickwall.jpg
!assets/textures/checkers.jpg
assets/shaders/*
!assets/shaders/.gitkeep
!assets/shaders/base.glsl
!assets/shaders/default.glsl
assets/materials/*
!assets/materials/.gitkeep
!assets/materials/default.yml
assets/models/*
!assets/models/.gitkeep
!assets/models/cube.yml
!assets/models/Icosphere.yml
!assets/models/Suzanne.yml
assets/scenes/*
!assets/scenes/.gitkeep
tool/*
tool/discover.py
tool/default.blend
tool/export.py
tool/test-discover.cpp
\ No newline at end of file
......@@ -66,6 +66,9 @@ target_sources(
PRIVATE ${SRCDIR}/src/VertexArray.cpp
PRIVATE ${SRCDIR}/src/VertexBuffer.cpp
PRIVATE ${SRCDIR}/src/Watcher.cpp
PRIVATE ${SRCDIR}/src/UniformBuffer.cpp
PRIVATE ${SRCDIR}/src/ShaderIntrospector.cpp
)
#
......@@ -88,7 +91,7 @@ configure_directory(${SRCDIR}/assets/shaders ${BINDIR}/assets/shaders)
configure_directory(${SRCDIR}/assets/models ${BINDIR}/assets/models)
configure_directory(${SRCDIR}/assets/textures ${BINDIR}/assets/textures)
configure_file(${SRCDIR}/tool/discover.py ${BINDIR}/discover.py COPYONLY)
###############################
......@@ -156,6 +159,17 @@ target_link_libraries(
)
endif()
# Test discover.py and test-discover.cpp
add_executable(test_discover "${SRCDIR}/tool/test-discover.cpp")
set_target_properties(
test_discover
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
RUNTIME_OUTPUT_DIRECTORY "${BINDIR}"
)
message("CMAKE_BINARY_DIR: " ${BINDIR})
message("OPENGL_LIBRARIES" ${OPENGL_LIBRARIES})
......
maps: 2
maps: 3
mainTex: scifi
bumpTex: scifi_nrm
specTex: scifi_spec
mainTexture: brickwall
specularTex: brickwall-nrm
values: 1
test: 0.5
values: 4
opacity: 1
intensity: 1
bumpiness: 1
specularity: 0
maps: 1
mainTexture: brickwall
maps: 0
values: 0
values: 4
opacity: 1
intensity: 1
bumpiness: 1
specularity: 0
vertices: 42
v: 0.000000 0.000000 -1.000000 0.000 0.000 -1.000 0.000 0.000 255 255 255 255
v: 0.723607 -0.525725 -0.447220 0.724 -0.526 -0.447 0.000 0.000 255 255 255 255
v: -0.276388 -0.850649 -0.447220 -0.276 -0.851 -0.447 0.000 0.000 255 255 255 255
v: -0.894426 0.000000 -0.447216 -0.894 0.000 -0.447 0.000 0.000 255 255 255 255
v: -0.276388 0.850649 -0.447220 -0.276 0.851 -0.447 0.000 0.000 255 255 255 255
v: 0.723607 0.525725 -0.447220 0.724 0.526 -0.447 0.000 0.000 255 255 255 255
v: 0.276388 -0.850649 0.447220 0.276 -0.851 0.447 0.000 0.000 255 255 255 255
v: -0.723607 -0.525725 0.447220 -0.724 -0.526 0.447 0.000 0.000 255 255 255 255
v: -0.723607 0.525725 0.447220 -0.724 0.526 0.447 0.000 0.000 255 255 255 255
v: 0.276388 0.850649 0.447220 0.276 0.851 0.447 0.000 0.000 255 255 255 255
v: 0.894426 0.000000 0.447216 0.894 0.000 0.447 0.000 0.000 255 255 255 255
v: 0.000000 0.000000 1.000000 0.000 0.000 1.000 0.000 0.000 255 255 255 255
v: -0.162456 -0.499995 -0.850654 -0.162 -0.500 -0.851 0.000 0.000 255 255 255 255
v: 0.425323 -0.309011 -0.850654 0.425 -0.309 -0.851 0.000 0.000 255 255 255 255
v: 0.262869 -0.809012 -0.525738 0.263 -0.809 -0.526 0.000 0.000 255 255 255 255
v: 0.850648 0.000000 -0.525736 0.851 0.000 -0.526 0.000 0.000 255 255 255 255
v: 0.425323 0.309011 -0.850654 0.425 0.309 -0.851 0.000 0.000 255 255 255 255
v: -0.525730 0.000000 -0.850652 -0.526 0.000 -0.851 0.000 0.000 255 255 255 255
v: -0.688189 -0.499997 -0.525736 -0.688 -0.500 -0.526 0.000 0.000 255 255 255 255
v: -0.162456 0.499995 -0.850654 -0.162 0.500 -0.851 0.000 0.000 255 255 255 255
v: -0.688189 0.499997 -0.525736 -0.688 0.500 -0.526 0.000 0.000 255 255 255 255
v: 0.262869 0.809012 -0.525738 0.263 0.809 -0.526 0.000 0.000 255 255 255 255
v: 0.951058 -0.309013 0.000000 0.951 -0.309 0.000 0.000 0.000 255 255 255 255
v: 0.951058 0.309013 0.000000 0.951 0.309 0.000 0.000 0.000 255 255 255 255
v: 0.000000 -1.000000 0.000000 0.000 -1.000 0.000 0.000 0.000 255 255 255 255
v: 0.587786 -0.809017 0.000000 0.588 -0.809 0.000 0.000 0.000 255 255 255 255
v: -0.951058 -0.309013 0.000000 -0.951 -0.309 0.000 0.000 0.000 255 255 255 255
v: -0.587786 -0.809017 0.000000 -0.588 -0.809 0.000 0.000 0.000 255 255 255 255
v: -0.587786 0.809017 0.000000 -0.588 0.809 0.000 0.000 0.000 255 255 255 255
v: -0.951058 0.309013 0.000000 -0.951 0.309 0.000 0.000 0.000 255 255 255 255
v: 0.587786 0.809017 0.000000 0.588 0.809 0.000 0.000 0.000 255 255 255 255
v: 0.000000 1.000000 0.000000 0.000 1.000 0.000 0.000 0.000 255 255 255 255
v: 0.688189 -0.499997 0.525736 0.688 -0.500 0.526 0.000 0.000 255 255 255 255
v: -0.262869 -0.809012 0.525738 -0.263 -0.809 0.526 0.000 0.000 255 255 255 255
v: -0.850648 0.000000 0.525736 -0.851 0.000 0.526 0.000 0.000 255 255 255 255
v: -0.262869 0.809012 0.525738 -0.263 0.809 0.526 0.000 0.000 255 255 255 255
v: 0.688189 0.499997 0.525736 0.688 0.500 0.526 0.000 0.000 255 255 255 255
v: 0.162456 -0.499995 0.850654 0.162 -0.500 0.851 0.000 0.000 255 255 255 255
v: 0.525730 0.000000 0.850652 0.526 0.000 0.851 0.000 0.000 255 255 255 255
v: -0.425323 -0.309011 0.850654 -0.425 -0.309 0.851 0.000 0.000 255 255 255 255
v: -0.425323 0.309011 0.850654 -0.425 0.309 0.851 0.000 0.000 255 255 255 255
v: 0.162456 0.499995 0.850654 0.162 0.500 0.851 0.000 0.000 255 255 255 255
meshes: 1
mesh: blendermesh
material: default
shader: default
triangles: 80
t: 0 13 12
t: 1 13 15
t: 0 12 17
t: 0 17 19
t: 0 19 16
t: 1 15 22
t: 2 14 24
t: 3 18 26
t: 4 20 28
t: 5 21 30
t: 1 22 25
t: 2 24 27
t: 3 26 29
t: 4 28 31
t: 5 30 23
t: 6 32 37
t: 7 33 39
t: 8 34 40
t: 9 35 41
t: 10 36 38
t: 38 41 11
t: 38 36 41
t: 36 9 41
t: 41 40 11
t: 41 35 40
t: 35 8 40
t: 40 39 11
t: 40 34 39
t: 34 7 39
t: 39 37 11
t: 39 33 37
t: 33 6 37
t: 37 38 11
t: 37 32 38
t: 32 10 38
t: 23 36 10
t: 23 30 36
t: 30 9 36
t: 31 35 9
t: 31 28 35
t: 28 8 35
t: 29 34 8
t: 29 26 34
t: 26 7 34
t: 27 33 7
t: 27 24 33
t: 24 6 33
t: 25 32 6
t: 25 22 32
t: 22 10 32
t: 30 31 9
t: 30 21 31
t: 21 4 31
t: 28 29 8
t: 28 20 29
t: 20 3 29
t: 26 27 7
t: 26 18 27
t: 18 2 27
t: 24 25 6
t: 24 14 25
t: 14 1 25
t: 22 23 10
t: 22 15 23
t: 15 5 23
t: 16 21 5
t: 16 19 21
t: 19 4 21
t: 19 20 4
t: 19 17 20
t: 17 3 20
t: 17 18 3
t: 17 12 18
t: 12 2 18
t: 15 16 5
t: 15 13 16
t: 13 0 16
t: 12 14 2
t: 12 13 14
t: 13 1 14
This diff is collapsed.
......@@ -41,7 +41,6 @@ v: 1.0 1.0 -1.0 0.577 0.577 -0.577 1 0 255 255 255 80
v: -1.0 1.0 1.0 -0.577 0.577 0.577 0 1 255 255 255 80
v: 1.0 1.0 1.0 0.577 0.577 0.577 1 1 255 255 255 80
meshes: 2
mesh: innercube
......@@ -67,8 +66,8 @@ mesh: innercube
t: 11 10 12
mesh: outercube
material: default
shader: base
material: brick
shader: edge
triangles: 12
t: 14 15 16
t: 16 17 14
......
#shader vertex
#version 410 core
#version 410
layout(location = 0) in vec4 position;
layout(location = 1) in vec3 normal;
layout(location = 2) in vec2 uv;
layout(location = 3) in vec4 vertex_color_from_program;
layout(location = 3) in vec4 vertex_color;
noperspective out vec2 texCoord;
smooth out vec4 vertex_color_out;
out vec2 texCoord;
out vec4 vertex_color_out;
out vec4 pos;
uniform mat4 projection = mat4(1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1);
uniform mat4 m2w;
uniform float time = 0;
uniform mat4 view = mat4(1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1);
layout(std140) uniform OK_Matrices{
mat4 projection;
mat4 view;
vec4 view_position;
};
uniform mat4 model = mat4(1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1);
uniform float time = 0;
mat4 rotate(float x, float y, float z) {
return mat4(
(cos(y + z) + cos(y - z)) / 2, (-sin(y + z) + sin(y - z)) / 2, -sin(y), 0,
(cos(x + y + z) - cos(x - y + z) + cos(x + y - z) - cos(x - y - z) + 2 * sin(x + z) - 2 * sin(x - z)) / 4, (2 * cos(x + z) + 2 * cos(x - z) - sin(x + y + z) + sin(x - y + z) + sin(x + y - z) - sin(x - y - z)) / 4, (-sin(x + y) - sin(x - y)) / 2, 0,
(-2 * cos(x + z) + 2 * cos(x - z) + sin(x + y + z) - sin(x - y + z) + sin(x + y - z) - sin(x - y - z)) / 4, (cos(x + y + z) - cos(x - y + z) - cos(x + y - z) + cos(x - y - z) + 2 * sin(x + z) + 2 * sin(x - z)) / 4, (cos(x + y) + cos(x - y)) / 2, 0,
0, 0, 0, 1
(cos(y + z) + cos(y - z)) / 2, (-sin(y + z) + sin(y - z)) / 2, -sin(y), 0,
(cos(x + y + z) - cos(x - y + z) + cos(x + y - z) - cos(x - y - z) + 2 * sin(x + z) - 2 * sin(x - z)) / 4, (2 * cos(x + z) + 2 * cos(x - z) - sin(x + y + z) + sin(x - y + z) + sin(x + y - z) - sin(x - y - z)) / 4, (-sin(x + y) - sin(x - y)) / 2, 0,
(-2 * cos(x + z) + 2 * cos(x - z) + sin(x + y + z) - sin(x - y + z) + sin(x + y - z) - sin(x - y - z)) / 4, (cos(x + y + z) - cos(x - y + z) - cos(x + y - z) + cos(x - y - z) + 2 * sin(x + z) + 2 * sin(x - z)) / 4, (cos(x + y) + cos(x - y)) / 2, 0,
0, 0, 0, 1
);
}
out vec3 fragVert;
out vec3 fragNormal;
vec4 MVP(in vec4 position) {
return projection * view * m2w * position;
}
void main() {
// model to world space transformations = transform
// translation * rotation * scale * vertexPos;
float F = sqrt(position.x*position.x + position.y*position.y + position.z*position.z) * 0.01;
mat4 rot = rotate(0, time*F, 0);
float F = sqrt(position.x*position.x + position.y*position.y + position.z*position.z);
gl_Position = projection * view * model * position;
vertex_color_out = vertex_color_from_program;
texCoord = uv;
pos = gl_Position;
}
vec4 rotatedNormal = rot * vec4(normal, 1);
// Pass some variables to the fragment shader
//fragNormal = vec3(rotatedNormal);
vertex_color_out = rotatedNormal;
texCoord = uv;
fragNormal = mat3(transpose(inverse(m2w))) * normal;
vec4 out_position = MVP(position);
gl_Position = out_position;
fragVert = vec3(m2w * position);
}
#shader fragment
#version 410
#version 140
#define MAX_LIGHTS 8
in vec4 gl_FragCoord;
// in vec2 gl_PointCoord; // @NOTE Not supported on [macos, openGL 4.1]
noperspective in vec2 texCoord;
smooth in vec4 vertex_color_out;
in vec4 pos;
in vec2 texCoord;
in vec3 fragNormal;
in vec3 fragVert;
out vec4 out_color;
uniform float time = 0;
uniform sampler2D mainTexture;
uniform float test = 1;
uniform sampler2D mainTex;
uniform sampler2D bumpTex;
uniform sampler2D specTex;
uniform float opacity = 0;
uniform float specularity = 1;
uniform float intensity = 1;
uniform float bumpiness = 1;
uniform mat4 m2w;
layout(std140) uniform OK_Matrices{
mat4 projection;
mat4 view;
vec4 view_position;
};
struct OK_Light {
vec4 position;
vec4 intensities;
};
layout(std140) uniform OK_Lights{
OK_Light light[MAX_LIGHTS];
//float spread;
//float constant;
//float linear;
//float quadratic;
};
vec3 OK_PointLight(in vec3 position, in vec3 intensities/*, in float constant, in float linear, in float quadratic*/) {
//Ambience
float ambientStrength = 0.1;
vec3 ambient = ambientStrength * intensities;
vec3 bump = texture(bumpTex, texCoord).rgb*intensity;
// Diffussion
vec3 norm = normalize(fragNormal*bump);
vec3 lightDir = normalize(position - fragVert);
float diffusion = max(dot(norm, lightDir), 0.0);
vec3 diffuse = diffusion * intensities;
// Specularity
//float specularStrength = 0.5;
//vec3 viewDir = normalize(view_position.xyz - fragVert);
//vec3 reflectDir = reflect(-lightDir, norm);
//float specPower = pow(max(dot(viewDir, reflectDir), 0.0), 32);
//vec3 specular = specularStrength * specPower * intensities;
// Attenuation
//float distance = length(position - fragVert);
float attenuation = 1.0; // /(constant + linear * distance + quadratic * (distance * distance));
return (ambient*attenuation + diffuse * attenuation /*+ specular*specularity*attenuation*/);
}
void main() {
out_color = test*vec4(texture(mainTexture, texCoord).rgb * vertex_color_out.rgb, vertex_color_out.a);
vec3 diff = texture(mainTex, texCoord).rgb;
vec3 bump = texture(bumpTex, texCoord).rgb;
vec3 spec = texture(specTex, texCoord).rgb;
vec3 light0 = OK_PointLight(light[0].position.xyz, light[0].intensities.rgb /*,light[0].constant,light[0].linear, light[0].quadratic*/);
vec3 light1 = OK_PointLight(light[1].position.xyz, light[1].intensities.rgb /*,light[1].constant,light[1].linear, light[1].quadratic*/);
vec3 light2 = OK_PointLight(light[2].position.xyz, light[2].intensities.rgb /*,light[1].constant,light[1].linear, light[1].quadratic*/);
//out_color = vec4(fragNormal, 1)*0.2 + 0.8*vec4(texture(mainTex, texCoord).rgb , vertex_color_out.a);
out_color = vec4((light0+ light1+ light2) * diff, 1);
}
//out_color = vec4(texture(mainTexture, texCoord).rgb * vertex_color_out.rgb, vertex_color_out.a);
//out_color = vec4(texture(mainTexture, texCoord).rgb * vertex_color_out.rgb, vertex_color_out.a);
\ No newline at end of file
#shader vertex
#version 410 core
#version 410
layout(location = 0) in vec4 position;
layout(location = 1) in vec3 normal;
layout(location = 2) in vec2 uv;
layout(location = 3) in vec4 vertex_color_from_program;
layout(location = 3) in vec4 vertex_color;
out vec2 texCoord;
out vec4 vertex_color_out;
out vec4 pos;
uniform mat4 m2w;
uniform float time = 0;
uniform mat4 projection = mat4(1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1);
layout(std140) uniform OK_Matrices{
mat4 projection;
mat4 view;
vec4 view_position;
};
uniform mat4 view = mat4(1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1);
uniform float time = 0;
mat4 rotate(float x, float y, float z) {
return mat4(
(cos(y + z) + cos(y - z)) / 2, (-sin(y + z) + sin(y - z)) / 2, -sin(y), 0,
(cos(x + y + z) - cos(x - y + z) + cos(x + y - z) - cos(x - y - z) + 2 * sin(x + z) - 2 * sin(x - z)) / 4, (2 * cos(x + z) + 2 * cos(x - z) - sin(x + y + z) + sin(x - y + z) + sin(x + y - z) - sin(x - y - z)) / 4, (-sin(x + y) - sin(x - y)) / 2, 0,
(-2 * cos(x + z) + 2 * cos(x - z) + sin(x + y + z) - sin(x - y + z) + sin(x + y - z) - sin(x - y - z)) / 4, (cos(x + y + z) - cos(x - y + z) - cos(x + y - z) + cos(x - y - z) + 2 * sin(x + z) + 2 * sin(x - z)) / 4, (cos(x + y) + cos(x - y)) / 2, 0,
0, 0, 0, 1
(cos(y + z) + cos(y - z)) / 2, (-sin(y + z) + sin(y - z)) / 2, -sin(y), 0,
(cos(x + y + z) - cos(x - y + z) + cos(x + y - z) - cos(x - y - z) + 2 * sin(x + z) - 2 * sin(x - z)) / 4, (2 * cos(x + z) + 2 * cos(x - z) - sin(x + y + z) + sin(x - y + z) + sin(x + y - z) - sin(x - y - z)) / 4, (-sin(x + y) - sin(x - y)) / 2, 0,
(-2 * cos(x + z) + 2 * cos(x - z) + sin(x + y + z) - sin(x - y + z) + sin(x + y - z) - sin(x - y - z)) / 4, (cos(x + y + z) - cos(x - y + z) - cos(x + y - z) + cos(x - y - z) + 2 * sin(x + z) + 2 * sin(x - z)) / 4, (cos(x + y) + cos(x - y)) / 2, 0,
0, 0, 0, 1
);
}
void main() {
out vec3 fragVert;
out vec3 fragNormal;
vec4 MVP(in vec4 position) {
return projection * view * m2w * position;
}
// model to world space transformations = transform
// translation * rotation * scale * vertexPos;
mat4 translation = mat4( 1,0,0,0,
0,1,0,0,
0,0,1,0,
0,0,0,0);
void main() {
mat4 rot = mat4(0.525322, 0.000000, -0.850904, 0.000000,
0.000000, 1.000000, 0.000000, 0.000000,
0.850904, 0.000000, 0.525322, 0.000000,
0.000000, 0.000000, 0.000000, 1.000000);
float F = sqrt(position.x*position.x + position.y*position.y + position.z*position.z) * 0.01;
mat4 rot = rotate(0, time*F, 0);
float F = sqrt(position.x*position.x + position.y*position.y + position.z*position.z);
gl_Position = projection * translation * view * rotate(time*0.1*F, time*0.333334*F, time*0.1666666667*F) * position;
vec4 rotatedNormal = rot * vec4(normal, 1);
// Pass some variables to the fragment shader
//fragNormal = vec3(rotatedNormal);
vertex_color_out = rotatedNormal;
texCoord = uv;
fragNormal = mat3(transpose(inverse(m2w))) * normal;
vec4 out_position = MVP(position);
gl_Position = out_position;
fragVert = vec3(m2w * position);
}
#shader fragment
#version 410
#version 140
#define MAX_LIGHTS 8
in vec4 gl_FragCoord;
in vec2 texCoord;
in vec3 fragNormal;
in vec3 fragVert;
out vec4 out_color;
uniform float time = 0;
uniform sampler2D mainTexture;
uniform sampler2D mainTex;
uniform sampler2D bumpTex;
uniform sampler2D specTex;
uniform float opacity = 0;
uniform float specularity = 1;
uniform float intensity = 1;
uniform float bumpiness = 1;
uniform mat4 m2w;
layout(std140) uniform OK_Matrices{
mat4 projection;
mat4 view;
vec4 view_position;
};
struct OK_Light {
vec4 position;
vec4 intensities;
};
layout(std140) uniform OK_Lights{
OK_Light light[MAX_LIGHTS];
//float spread;
//float constant;
//float linear;
//float quadratic;
};
vec3 OK_PointLight(in vec3 position, in vec3 intensities/*, in float constant, in float linear, in float quadratic*/) {
//Ambience
float ambientStrength = 0.1;
vec3 ambient = ambientStrength * intensities;
// Diffussion
vec3 norm = normalize(fragNormal);
vec3 lightDir = normalize(position - fragVert);
float diffusion = max(dot(norm, lightDir), 0.0);
vec3 diffuse = diffusion * intensities;
// Specularity
//float specularStrength = 0.5;
//vec3 viewDir = normalize(view_position.xyz - fragVert);
//vec3 reflectDir = reflect(-lightDir, norm);
//float specPower = pow(max(dot(viewDir, reflectDir), 0.0), 32);
//vec3 specular = specularStrength * specPower * intensities;
// Attenuation
//float distance = length(position - fragVert);
float attenuation = 1.0; // /(constant + linear * distance + quadratic * (distance * distance));
return (ambient*attenuation + diffuse * attenuation /*+ specular*specularity*attenuation*/);
}
void main() {
out_color = .5*vec4(texture(mainTexture, texCoord).rgb, 1);
vec3 light0 = OK_PointLight(light[0].position.xyz, light[0].intensities.rgb /*,light[0].constant,light[0].linear, light[0].quadratic*/);
vec3 light1 = OK_PointLight(light[1].position.xyz, light[1].intensities.rgb /*,light[1].constant,light[1].linear, light[1].quadratic*/);
vec3 light2 = OK_PointLight(light[2].position.xyz, light[2].intensities.rgb /*,light[1].constant,light[1].linear, light[1].quadratic*/);
//out_color = vec4(fragNormal, 1)*0.2 + 0.8*vec4(texture(mainTex, texCoord).rgb , vertex_color_out.a);
out_color = vec4((light0+ light1+ light2), 1);
}
//out_color = vec4(texture(mainTexture, texCoord).rgb * vertex_color_out.rgb, vertex_color_out.a);
\ No newline at end of file
assets/textures/example.jpg

32.5 KiB

assets/textures/example_nrm.jpg

91.3 KiB

assets/textures/nrm_test.jpg

37.5 KiB

assets/textures/scifi.jpg

111 KiB

assets/textures/scifi_nrm.jpg

206 KiB

assets/textures/scifi_spec.jpg

162 KiB

import os
import bpy
# input
out = ""
scale = .02
meshtag = "Top"
outfile = open("top.yml", "w")
def writeVertexWithoutUVandColor(outfile, vcontainer):
global scale
outfile.write("vertices: {}\n".format(len(vcontainer)))
for vc in vcontainer:
outfile.write("v: {:9.6f} {:9.6f} {:9.6f} {:6.3f} {:6.3f} {:6.3f} {:6.3f} {:6.3f} {:3} {:3} {:3} {:3}\n".format(
vc.co[0]*scale,
(vc.co[1]*scale)-0.5,
vc.co[2]*scale,
vc.normal[0],
vc.normal[1],
vc.normal[2],
0, 0, 255, 255, 255, 255))
def writeTriangles(outfile, polygons):
outfile.write("triangles: {}\n".format(len(polygons)))
for p in polygons:
if len(p.vertices) != 3:
print("ERROR, TRIANGULATE YOUR MESH!!!!")
exit(-1)
outfile.write("t: {} {} {}\n".format(
p.vertices[0],
p.vertices[1],
p.vertices[2]
))
# processing
mesh = bpy.data.objects[meshtag].data
print("Mesh: ", mesh)
vertexContainer = mesh.vertices
print("Vertices: ", vertexContainer)
hasUV = mesh.uv_layers.active
print("HasUV: ", hasUV)
polygons = mesh.polygons
print("Polygons: ", polygons)
print("HashUV is None")
writeVertexWithoutUVandColor(outfile, vertexContainer)
outfile.write("\n")
# iterate all meshes
outfile.write("meshes: 1\n")
outfile.write("mesh: " + meshtag + "\n")
outfile.write("material: default\n")
outfile.write("shader: default\n")
writeTriangles(outfile, polygons)
outfile.write("\n")
outfile.close()
......@@ -9,8 +9,8 @@ namespace overkill::C
constexpr int VersionMajor = 4;
constexpr int VersionMinor = 1;
constexpr int WinWidth = 800;
constexpr int WinHeight = 600;
constexpr int WinWidth = 1000;
constexpr int WinHeight = 800;
constexpr char WinName[] = "Assignment 2 - Cube";
constexpr float FOV = 88.0f;
constexpr float MaxFOV = 88.2f;
......@@ -22,25 +22,17 @@ namespace overkill::C
constexpr float NearClip = 0.1f;
constexpr float FarClip = 100.0f;
constexpr float CameraOffset = -70; //How far back the camera is from the center of the scene.
const glm::vec4 ClearColor { 1.0f, .8f, .6f, 1.0f};
const glm::vec4 ClearColor { 0.05f, 0.06f, 0.075f, 1.0f }; // Sexy blue
constexpr char PathBaseShader[] = "assets/shaders/base.shader";
constexpr char PathBaseTexture[] = "assets/textures/Checkers.jpg";
constexpr float PI = 3.14159265359f;
constexpr char TexturesFolder[] = "assets/textures/";
constexpr char TexturesExtension[] = ".jpg";
constexpr char TexturesFolder[] = "assets/textures";
constexpr char ShadersFolder[] = "assets/shaders";
constexpr char MaterialsFolder[] = "assets/materials";
constexpr char ModelsFolder[] = "assets/models";
constexpr char ScenesFolder[] = "assets/scenes";
constexpr char ShadersFolder[] = "assets/shaders/";
constexpr char ShadersExtension[] = ".glsl";
constexpr char MaterialsFolder[] = "assets/materials/";
constexpr char MaterialsExtension[] = ".yml";
constexpr char ModelsFolder[] = "assets/models/";
constexpr char ModelsExtension[] = ".yml";
constexpr char ScenesFolder[] = "assets/scenes/";
constexpr char ScenesExtension[] = ".yml";
constexpr unsigned int MAX_LIGHTS = 8; //inject it into shaders
}
#pragma once
#include <string>
#include <vector>
......@@ -39,4 +38,26 @@ public:
};
struct Transform
{
const glm::vec3 right{ 1.0f,0.0f,0.0f };
const glm::vec3 up{ 0.0f,1.0f,0.0f };
const glm::vec3 forward{ 0.0f,0.0f,1.0f };
const glm::vec3 one{ 1.0f, 1.0f, 1.0f };
const glm::vec3 zero{ 0.0f ,0.0f ,0.0f };
glm::vec3 m_position = zero;
glm::vec3 m_rotation = zero;
glm::vec3 m_scale = one;
auto modelToWorld()->glm::mat4;
};
struct Light : public Transform
{
glm::vec3 intensities = one; //a.k.a the color of the light
};
}
\ No newline at end of file
......@@ -12,6 +12,7 @@
namespace overkill
{
class Renderer;
class EntityModel : public Entity
{
......@@ -20,24 +21,23 @@ private:
glm::vec3 m_scale;
glm::mat4 m_transformMatrix;
glm::mat4 getModelMatrix(glm::mat4 parentModelMatrix = glm::mat4(1));
public:
EntityModel(C::Tag modelTag, int entityID = -1,
EntityModel(C::Tag modelTag, int entityID,
glm::vec3 pos = glm::vec3(0,0,0), glm::vec3 rot = glm::vec3(0,0,0),
glm::vec3 scale = glm::vec3(1,1,1), glm::vec3 vel = glm::vec3(0,0,0),
glm::vec3 angVel = glm::vec3(0,0,0));
int getModel();
glm::vec3 getScale();
glm::mat4 getModelMatrix(glm::mat4 parentModelMatrix = glm::mat4(1));
void setModelByID(int modelID);
void setModelByTag(C::Tag tag);
void setScale(glm::vec3 scale = glm::vec3(1));
void addChild(int childID);
void update(float dt, glm::mat4 parentMatrix = glm::mat4(1));
void draw();
void draw(float t);
};
}
\ No newline at end of file
}
......@@ -13,7 +13,7 @@
#include <overkill/gl_caller.hpp>
#include <overkill/Input.hpp>
#include <overkill/Watcher.hpp>
namespace overkill::Init
{
......@@ -27,6 +27,5 @@ auto GLFW(
void GLEW();
void OpenGL(const glm::vec4 background);
void Watcher();
} // ::Init::overkill
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment