1234567891011121314151617181920212223242526 |
- #include "client/rendering/Mesh.h"
- #include "rendering/Attributes.h"
- Mesh::Triangle::Triangle(const Vertex& a, const Vertex& b, const Vertex& c)
- : a(a), b(b), c(c) {
- normalA = (b.position - a.position).cross(c.position - a.position);
- normalB = normalA;
- normalC = normalA;
- }
- Mesh::Mesh() : vertices(0) {
- }
- bool Mesh::init() {
- vertexBuffer.init(Attributes().addFloat(3).addFloat(2).addFloat(3));
- return false;
- }
- void Mesh::build(const TypedBuffer<Triangle>& buffer) {
- vertices = buffer.getLength() * 3;
- vertexBuffer.setStaticData(buffer.getByteLength(), buffer);
- }
- void Mesh::draw() {
- vertexBuffer.draw(vertices);
- }
|