summaryrefslogtreecommitdiff
path: root/Userland/Applications/3DFileViewer
diff options
context:
space:
mode:
authorPedro Pereira <pmh.pereira@gmail.com>2021-11-05 01:30:46 +0000
committerAndreas Kling <kling@serenityos.org>2021-11-13 12:52:22 +0100
commit5fd58a266373067eb341d5ccf8ee5b18e0c4735f (patch)
treed0e2ccb2c2165cbc4347f59818f2bfb80f5ae8da /Userland/Applications/3DFileViewer
parent7fb8af73bfde77edd0e71432030070c9c9a920e1 (diff)
downloadserenity-5fd58a266373067eb341d5ccf8ee5b18e0c4735f.zip
3DFileViewer: Add 'normals' to Mesh constructor
This change allows a Mesh object to be created with a vector of normals.
Diffstat (limited to 'Userland/Applications/3DFileViewer')
-rw-r--r--Userland/Applications/3DFileViewer/Mesh.cpp4
-rw-r--r--Userland/Applications/3DFileViewer/Mesh.h4
-rw-r--r--Userland/Applications/3DFileViewer/WavefrontOBJLoader.cpp2
3 files changed, 7 insertions, 3 deletions
diff --git a/Userland/Applications/3DFileViewer/Mesh.cpp b/Userland/Applications/3DFileViewer/Mesh.cpp
index 0bae181b07..335962bb64 100644
--- a/Userland/Applications/3DFileViewer/Mesh.cpp
+++ b/Userland/Applications/3DFileViewer/Mesh.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (c) 2021, Jesse Buhagiar <jooster669@gmail.com>
* Copyright (c) 2021, Mathieu Gaillard <gaillard.mathieu.39@gmail.com>
+ * Copyright (c) 2021, Pedro Pereira <pmh.pereira@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -22,9 +23,10 @@ const Color colors[] {
Color::White
};
-Mesh::Mesh(Vector<Vertex> vertices, Vector<TexCoord> tex_coords, Vector<Triangle> triangles)
+Mesh::Mesh(Vector<Vertex> vertices, Vector<TexCoord> tex_coords, Vector<Vertex> normals, Vector<Triangle> triangles)
: m_vertex_list(move(vertices))
, m_tex_coords(move(tex_coords))
+ , m_normal_list(move(normals))
, m_triangle_list(move(triangles))
{
}
diff --git a/Userland/Applications/3DFileViewer/Mesh.h b/Userland/Applications/3DFileViewer/Mesh.h
index ce5c718e7b..abd280f4b4 100644
--- a/Userland/Applications/3DFileViewer/Mesh.h
+++ b/Userland/Applications/3DFileViewer/Mesh.h
@@ -1,6 +1,7 @@
/*
* Copyright (c) 2021, Jesse Buhagiar <jooster669@gmail.com>
* Copyright (c) 2021, Mathieu Gaillard <gaillard.mathieu.39@gmail.com>
+ * Copyright (c) 2021, Pedro Pereira <pmh.pereira@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -16,7 +17,7 @@ class Mesh : public RefCounted<Mesh> {
public:
Mesh() = delete;
- Mesh(Vector<Vertex> vertices, Vector<TexCoord> tex_coords, Vector<Triangle> triangles);
+ Mesh(Vector<Vertex> vertices, Vector<TexCoord> tex_coords, Vector<Vertex> normals, Vector<Triangle> triangles);
size_t vertex_count() const { return m_vertex_list.size(); }
@@ -29,5 +30,6 @@ public:
private:
Vector<Vertex> m_vertex_list;
Vector<TexCoord> m_tex_coords;
+ Vector<Vertex> m_normal_list;
Vector<Triangle> m_triangle_list;
};
diff --git a/Userland/Applications/3DFileViewer/WavefrontOBJLoader.cpp b/Userland/Applications/3DFileViewer/WavefrontOBJLoader.cpp
index bb881c333a..4ef2a87c13 100644
--- a/Userland/Applications/3DFileViewer/WavefrontOBJLoader.cpp
+++ b/Userland/Applications/3DFileViewer/WavefrontOBJLoader.cpp
@@ -127,5 +127,5 @@ RefPtr<Mesh> WavefrontOBJLoader::load(Core::File& file)
}
dbgln("Wavefront: Done.");
- return adopt_ref(*new Mesh(vertices, tex_coords, triangles));
+ return adopt_ref(*new Mesh(vertices, tex_coords, normals, triangles));
}