mirror of
https://github.com/hannobraun/Fornjot
synced 2025-09-02 07:26:26 +00:00
Convert Vertex
into struct
This commit is contained in:
parent
94e157bbf0
commit
9b4ae17a13
@ -7,7 +7,7 @@ pub fn export(mesh: &Mesh) -> anyhow::Result<()> {
|
|||||||
.vertices()
|
.vertices()
|
||||||
.iter()
|
.iter()
|
||||||
.copied()
|
.copied()
|
||||||
.map(|vertex| vertex.map(Into::into))
|
.map(|vertex| vertex.point.map(Into::into))
|
||||||
.map(|[x, y, z]| threemf::model::Vertex { x, y, z })
|
.map(|[x, y, z]| threemf::model::Vertex { x, y, z })
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
@ -22,6 +22,10 @@ impl Mesh {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type Vertex = [f32; 3];
|
#[derive(Clone, Copy)]
|
||||||
|
pub struct Vertex {
|
||||||
|
pub point: [f32; 3],
|
||||||
|
}
|
||||||
|
|
||||||
pub type Index = u32;
|
pub type Index = u32;
|
||||||
pub type Triangle = [Index; 3];
|
pub type Triangle = [Index; 3];
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use crate::geometry::Mesh;
|
use crate::geometry::{Mesh, Vertex};
|
||||||
|
|
||||||
pub fn model() -> anyhow::Result<Mesh> {
|
pub fn model() -> anyhow::Result<Mesh> {
|
||||||
let mut mesh = Mesh::default();
|
let mut mesh = Mesh::default();
|
||||||
@ -13,7 +13,7 @@ pub fn model() -> anyhow::Result<Mesh> {
|
|||||||
[-0.5, 0.5, 0.5], // 6
|
[-0.5, 0.5, 0.5], // 6
|
||||||
[0.5, 0.5, 0.5], // 7
|
[0.5, 0.5, 0.5], // 7
|
||||||
]
|
]
|
||||||
.map(|vertex| mesh.push_vertex(vertex));
|
.map(|vertex| mesh.push_vertex(Vertex { point: vertex }));
|
||||||
|
|
||||||
[
|
[
|
||||||
[0, 4, 6], // left
|
[0, 4, 6], // left
|
||||||
|
@ -193,7 +193,7 @@ impl Renderer {
|
|||||||
|
|
||||||
for triangle in mesh.triangles() {
|
for triangle in mesh.triangles() {
|
||||||
let triangle = triangle
|
let triangle = triangle
|
||||||
.map(|index| Vec3::from(mesh.vertices()[index as usize]));
|
.map(|index| Vec3::from(mesh.vertices()[index as usize].point));
|
||||||
let normal = {
|
let normal = {
|
||||||
let [a, b, c] = triangle;
|
let [a, b, c] = triangle;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user