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

114 lines
1.5 KiB
C
Raw Normal View History

2018-09-05 02:50:27 +00:00
#ifndef GEOMETRY_H
#include "color.h"
#include "engine.h"
2018-09-05 02:50:27 +00:00
#include "point.h"
#include <cstdint>
2018-09-05 02:50:27 +00:00
2018-09-15 01:46:30 +00:00
#define VERTEX_LIMIT (20000)
#define FACE_LIMIT (30000)
#define MATERIAL_LIMIT (10)
struct Texture
{
ColorU32 **texels;
unsigned int width;
unsigned int height;
};
2018-09-15 01:46:30 +00:00
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;
};
2018-09-15 01:46:30 +00:00
struct UVList
2018-09-05 02:50:27 +00:00
{
2018-09-15 01:46:30 +00:00
UV data[VERTEX_LIMIT];
size_t size;
2018-09-11 02:51:59 +00:00
};
struct Vertex
{
Point point;
Vector normal;
ColorF32 color;
};
2018-09-15 01:46:30 +00:00
struct VertexList
2018-09-11 02:51:59 +00:00
{
2018-09-15 01:46:30 +00:00
Vertex data[VERTEX_LIMIT];
size_t size;
};
2018-09-15 01:46:30 +00:00
struct Face
{
2018-09-15 01:46:30 +00:00
int vertIndex[3];
int uvIndex[3];
int materialIndex;
};
struct FaceList
{
Face data[FACE_LIMIT];
size_t size;
2018-09-05 02:50:27 +00:00
};
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;
2018-09-05 02:50:27 +00:00
};
// PUBLIC FUNCTIONS
2018-09-15 01:46:30 +00:00
void ClipAndCull(
VertexList &verts, FaceList &localFaces,
FaceList &transFaces, Point &camPosition);
2018-09-11 02:51:59 +00:00
void RenderMesh(
2018-09-15 01:46:30 +00:00
Engine_Buffer &buffer, FaceList &faces, VertexList &verts,
UVList &uvs, TextureList &textures);
2018-09-05 02:50:27 +00:00
#define GEOMETRY_H
#endif