summaryrefslogtreecommitdiff
path: root/engine/src/vertex.rs
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src/vertex.rs')
-rw-r--r--engine/src/vertex.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/engine/src/vertex.rs b/engine/src/vertex.rs
index 9df646f..bb0e890 100644
--- a/engine/src/vertex.rs
+++ b/engine/src/vertex.rs
@@ -10,6 +10,7 @@ pub struct Vertex
pos: Vec3<f32>,
color: Color<f32>,
texture_coords: Vec2<f32>,
+ normal: Vec3<f32>,
}
#[derive(Debug, Default)]
@@ -18,6 +19,7 @@ pub struct Builder
pos: Option<Vec3<f32>>,
color: Option<Color<f32>>,
texture_coords: Vec2<f32>,
+ normal: Option<Vec3<f32>>,
}
impl Builder
@@ -53,15 +55,25 @@ impl Builder
}
#[must_use]
+ pub fn normal(mut self, normal: Vec3<f32>) -> Self
+ {
+ self.normal = Some(normal);
+
+ self
+ }
+
+ #[must_use]
pub fn build(self) -> Option<Vertex>
{
let pos = self.pos?;
- let color = self.color?;
+ let color = self.color.unwrap_or_default();
+ let normal = self.normal.unwrap_or_default();
Some(Vertex {
pos,
color,
texture_coords: self.texture_coords,
+ normal,
})
}
}
@@ -89,6 +101,12 @@ impl Vertex
component_cnt: AttributeComponentCnt::Two,
component_size: size_of::<f32>(),
},
+ Attribute {
+ index: 3,
+ component_type: AttributeComponentType::Float,
+ component_cnt: AttributeComponentCnt::Three,
+ component_size: size_of::<f32>(),
+ },
]
}
}