98 lines
1.4 KiB
C++
98 lines
1.4 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 Texture
|
|
{
|
|
ColorU32 **texels;
|
|
unsigned int width;
|
|
unsigned int height;
|
|
};
|
|
|
|
struct TextureCoord
|
|
{
|
|
float u;
|
|
float v;
|
|
};
|
|
|
|
struct Face
|
|
{
|
|
unsigned int vertIndex[3];
|
|
unsigned int textureIndex[3];
|
|
Vector normal;
|
|
ColorF32 color;
|
|
};
|
|
|
|
struct Vertex
|
|
{
|
|
Point point;
|
|
Vector normal;
|
|
ColorF32 color;
|
|
};
|
|
|
|
struct Mesh_LocalData
|
|
{
|
|
std::vector<Vertex> verts;
|
|
std::vector<Face> faces;
|
|
std::vector<TextureCoord> uvs;
|
|
};
|
|
|
|
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, Texture &texture,
|
|
std::vector<TextureCoord> &uvs);
|
|
|
|
|
|
#define GEOMETRY_H
|
|
#endif
|
|
|