mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-11 02:29:21 +00:00
3DFileViewer: Support textured models
Models that contain UV co-ordinates are now supported, and will display with a texture wrapped around it, provided a `bmp` with the same name as the object is in the same directory as the 3D Model.
This commit is contained in:
parent
3287709df9
commit
343e66b816
Notes:
sideshowbarker
2024-07-18 17:21:59 +09:00
Author: https://github.com/Quaker762
Commit: 343e66b816
Pull-request: https://github.com/SerenityOS/serenity/pull/7024
Reviewed-by: https://github.com/alimpfard
Reviewed-by: https://github.com/ccapitalK
Reviewed-by: https://github.com/predmond
Reviewed-by: https://github.com/sunverwerth
7 changed files with 13657 additions and 9899 deletions
|
@ -22,8 +22,9 @@ const Color colors[] {
|
|||
Color::White
|
||||
};
|
||||
|
||||
Mesh::Mesh(Vector<Vertex> vertices, Vector<Triangle> triangles)
|
||||
Mesh::Mesh(Vector<Vertex> vertices, Vector<TexCoord> tex_coords, Vector<Triangle> triangles)
|
||||
: m_vertex_list(move(vertices))
|
||||
, m_tex_coords(move(tex_coords))
|
||||
, m_triangle_list(move(triangles))
|
||||
{
|
||||
}
|
||||
|
@ -74,18 +75,27 @@ void Mesh::draw()
|
|||
m_vertex_list.at(m_triangle_list[i].a).y,
|
||||
m_vertex_list.at(m_triangle_list[i].a).z);
|
||||
|
||||
if (is_textured())
|
||||
glTexCoord2f(m_tex_coords.at(m_triangle_list[i].tex_coord_index0).u, 1.0f - m_tex_coords.at(m_triangle_list[i].tex_coord_index0).v);
|
||||
|
||||
// Vertex 2
|
||||
glVertex3f(
|
||||
m_vertex_list.at(m_triangle_list[i].b).x,
|
||||
m_vertex_list.at(m_triangle_list[i].b).y,
|
||||
m_vertex_list.at(m_triangle_list[i].b).z);
|
||||
|
||||
if (is_textured())
|
||||
glTexCoord2f(m_tex_coords.at(m_triangle_list[i].tex_coord_index1).u, 1.0f - m_tex_coords.at(m_triangle_list[i].tex_coord_index1).v);
|
||||
|
||||
// Vertex 3
|
||||
glVertex3f(
|
||||
m_vertex_list.at(m_triangle_list[i].c).x,
|
||||
m_vertex_list.at(m_triangle_list[i].c).y,
|
||||
m_vertex_list.at(m_triangle_list[i].c).z);
|
||||
|
||||
if (is_textured())
|
||||
glTexCoord2f(m_tex_coords.at(m_triangle_list[i].tex_coord_index2).u, 1.0f - m_tex_coords.at(m_triangle_list[i].tex_coord_index2).v);
|
||||
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue