summaryrefslogtreecommitdiff
path: root/themes
diff options
context:
space:
mode:
authormattkae <mattkae@protonmail.com>2022-06-22 20:32:28 -0400
committermattkae <mattkae@protonmail.com>2022-06-22 20:32:28 -0400
commit29059f552223d70bdab287b0d121567cec0ed6c7 (patch)
tree2e729f819b9d8e6d632d92e1ba98ccbab2b8fd26 /themes
parent430d60baf909a01c2b167c65071f0e003d770aaf (diff)
Update of resume
Diffstat (limited to 'themes')
-rw-r--r--themes/Renderer3d.cpp18
-rw-r--r--themes/Renderer3d.h2
2 files changed, 17 insertions, 3 deletions
diff --git a/themes/Renderer3d.cpp b/themes/Renderer3d.cpp
index a7779e2..300a73b 100644
--- a/themes/Renderer3d.cpp
+++ b/themes/Renderer3d.cpp
@@ -11,6 +11,7 @@
const char* vertexShader =
"attribute vec4 position; \n"
"attribute vec4 color; \n"
+"attribute vec4 normal \n"
"uniform mat4 projection; \n"
"uniform mat4 view; \n"
"uniform mat4 model; \n"
@@ -47,6 +48,7 @@ void Renderer3D::load(WebglContext* inContext) {
useShader(shader);
attributes.position = getShaderAttribute(shader, "position");
attributes.color = getShaderAttribute(shader, "color");
+ attributes.normal = getShaderAttribute(shader, "normal");
uniforms.projection = getShaderUniform(shader, "projection");
uniforms.view = getShaderUniform(shader, "view");
uniforms.model = getShaderUniform(shader, "model");
@@ -177,9 +179,19 @@ Mesh3d Mesh3d_fromObj(Renderer3D* renderer, const char* content, const i32 len)
lt.v.indices[lt.idx] = atoi(buffer);
lt.idx++;
}
- result.indices.add(lt.v.indices[0] - 1);
- result.indices.add(lt.v.indices[1] - 1);
- result.indices.add(lt.v.indices[2] - 1);
+
+ auto v1idx = lt.v.indices[0] - 1;
+ auto v2idx = lt.v.indices[1] - 1;
+ auto v3idx = lt.v.indices[2] - 1;
+
+ result.indices.add(v1idx);
+ result.indices.add(v2idx);
+ result.indices.add(v3idx);
+
+ auto v1 = result.vertices[v1idx];
+ auto v2 = result.vertices[v2idx];
+ auto v3 = result.vertices[v3idx];
+ auto normal = (v1 - v2).cross(v1 - v3);
break;
case LineType_Comment:
i = readPastLine(i, content);
diff --git a/themes/Renderer3d.h b/themes/Renderer3d.h
index 71fc8fe..7e89c93 100644
--- a/themes/Renderer3d.h
+++ b/themes/Renderer3d.h
@@ -10,6 +10,7 @@ struct Renderer3D;
struct Vertex3d {
Vector4 position;
Vector4 color;
+ Vector4 normal;
};
struct Mesh3d {
@@ -36,6 +37,7 @@ struct Renderer3D {
struct {
i32 position;
i32 color;
+ i32 normal;
} attributes;
struct {