117 lines
1.6 KiB
C++
117 lines
1.6 KiB
C++
#ifndef GEOMETRY_H
|
|
|
|
#include "color.h"
|
|
#include "engine.h"
|
|
#include "point.h"
|
|
#include <cstdint>
|
|
|
|
|
|
// CONSTANTS
|
|
#define VERTEX_LIMIT (20000)
|
|
#define FACE_LIMIT (30000)
|
|
#define MATERIAL_LIMIT (10)
|
|
#define TEXTURE_SIZE_LIMIT (1024)
|
|
|
|
|
|
// STRUCTURES
|
|
struct Texture
|
|
{
|
|
ColorU32 texels[TEXTURE_SIZE_LIMIT][TEXTURE_SIZE_LIMIT];
|
|
unsigned int width;
|
|
unsigned int height;
|
|
};
|
|
|
|
struct TextureList
|
|
{
|
|
Texture data[MATERIAL_LIMIT];
|
|
size_t size;
|
|
};
|
|
|
|
struct Material
|
|
{
|
|
ColorF32 ambient;
|
|
ColorF32 diffuse;
|
|
ColorF32 specular;
|
|
float specularExp;
|
|
float opacity;
|
|
};
|
|
|
|
struct MaterialList
|
|
{
|
|
Material data[MATERIAL_LIMIT];
|
|
size_t size;
|
|
};
|
|
|
|
struct UV
|
|
{
|
|
float u;
|
|
float v;
|
|
};
|
|
|
|
struct UVList
|
|
{
|
|
UV data[VERTEX_LIMIT];
|
|
size_t size;
|
|
};
|
|
|
|
struct Vertex
|
|
{
|
|
Point point;
|
|
Vector normal;
|
|
ColorF32 color;
|
|
};
|
|
|
|
struct VertexList
|
|
{
|
|
Vertex data[VERTEX_LIMIT];
|
|
size_t size;
|
|
};
|
|
|
|
struct Face
|
|
{
|
|
int vertIndex[3];
|
|
int uvIndex[3];
|
|
int materialIndex;
|
|
};
|
|
|
|
struct FaceList
|
|
{
|
|
Face data[FACE_LIMIT];
|
|
size_t size;
|
|
};
|
|
|
|
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;
|
|
};
|
|
|
|
|
|
// PUBLIC FUNCTIONS
|
|
void ClipAndCull(
|
|
VertexList &verts, FaceList &localFaces,
|
|
FaceList &transFaces, Point &camPosition);
|
|
|
|
void RenderMesh(
|
|
Engine_Buffer &buffer, FaceList &faces, VertexList &verts,
|
|
UVList &uvs, TextureList &textures);
|
|
|
|
|
|
#define GEOMETRY_H
|
|
#endif
|
|
|