mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 02:12:45 +00:00 
			
		
		
		
	 ed41f48ea4
			
		
	
	
		ed41f48ea4
		
	
	
	
	
		
			
			This change calculates the face-normal of the triangle by adding the three vertex-normals and then normalizing. This results in an average of the three vertex-normals.
		
			
				
	
	
		
			37 lines
		
	
	
	
		
			972 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
	
		
			972 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * 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
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/RefCounted.h>
 | |
| #include <AK/Vector.h>
 | |
| 
 | |
| #include "Common.h"
 | |
| 
 | |
| class Mesh : public RefCounted<Mesh> {
 | |
| public:
 | |
|     Mesh() = delete;
 | |
| 
 | |
|     Mesh(Vector<Vertex> vertices, Vector<TexCoord> tex_coords, Vector<Vertex> normals, Vector<Triangle> triangles);
 | |
| 
 | |
|     size_t vertex_count() const { return m_vertex_list.size(); }
 | |
| 
 | |
|     size_t triangle_count() const { return m_triangle_list.size(); }
 | |
| 
 | |
|     void draw(float uv_scale);
 | |
| 
 | |
|     bool is_textured() const { return m_tex_coords.size() > 0; }
 | |
| 
 | |
|     bool has_normals() const { return m_normal_list.size() > 0; }
 | |
| 
 | |
| private:
 | |
|     Vector<Vertex> m_vertex_list;
 | |
|     Vector<TexCoord> m_tex_coords;
 | |
|     Vector<Vertex> m_normal_list;
 | |
|     Vector<Triangle> m_triangle_list;
 | |
| };
 |