Blob Blame Raw

#ifndef MODEL_H
#define MODEL_H


#include <vector>

#include "geometry.h"


class Triangle {
public:
    Vector3 vertices[3];
    Vector3 normal;

    void normalize()
        { normal = (vertices[2] - vertices[0]).cross(vertices[1] - vertices[0]).norm(); }
    bool check(Real precision) const
        { return (vertices[2] - vertices[0]).cross(vertices[1] - vertices[0]).len_sqr() > precision*precision; }
};

typedef std::vector<Triangle> TriangleList;

class Model {
public:
    Vector4 color;
    TriangleList triangles;
    
    Model(const Vector4 &color = Vector4(0.5, 0.5, 0.5, 0.5)):
        color(color) { }
    
    void normalize();
    void transform(const Matrix4 &matrix);
    void draw() const;
};

#endif