1
0
Fork 0
2018-soft-3d-renderer/include/geometry.h

82 lines
1.2 KiB
C++

#ifndef GEOMETRY_H
#include "color.h"
#include "engine.h"
#include "point.h"
#include <cstdint>
#include <vector>
// STRUCTURES
struct Material
{
ColorF32 kAmbient;
ColorF32 kDiffuse;
};
struct Face
{
unsigned int vertIndex[3];
Vector normal;
ColorF32 color;
};
struct Vertex
{
Point point;
Vector normal;
ColorF32 color;
};
struct Mesh_LocalData
{
std::vector<Vertex> verts;
std::vector<Face> faces;
};
struct Mesh_TransformedData
{
std::vector<Vertex> verts;
std::vector<Face> faces;
};
struct Mesh
{
inline Mesh(void)
{
position.x = 0.0f;
position.y = 0.0f;
position.z = 0.0f;
rotation[0] = 0.0f;
rotation[1] = 0.0f;
rotation[2] = 0.0f;
scale = 1.0f;
}
Point position;
float rotation[3];
float scale;
Material material;
bool smooth;
Mesh_LocalData local;
Mesh_TransformedData transformed;
};
// PUBLIC FUNCTIONS
void CullBackfaces(
Mesh_LocalData &local, Mesh_TransformedData &transformed,
Point &camPosition);
void RenderMesh(
Engine_Buffer &buffer, Mesh_TransformedData &mesh, bool smooth);
#define GEOMETRY_H
#endif