Enhance graphics library functionality and structure

Added new function signatures in `assimp-vc143-mt.lib` for improved logging, parsing, and vector operations.
Added new metadata and configuration information in `assimp-vc143-mt.dll` for versioning and licensing compliance.
Added Sobol sequence generation in `Sobol.c` for quasi-random sampling.
Added window message handling in `Window.c` for rendering graphics.
Added ray-triangle intersection tests in `RayIntersection.c` for collision detection.
Added functions for loading mesh data in `Mesh.c` to support 3D model import.
Added functions for managing triangle collections in `Triangle.c` to enhance geometric data handling.
Added light evaluation functions in `LightEvaluation.c` and `SkyLight.c` for realistic rendering.
Added sampling and evaluation functions for simple lit materials in `SimpleLit.c`.
Changed various header files to include copyright and licensing information.
Changed existing functions in multiple files to improve performance and clarity.
Removed unused code in several files to streamline the library.
This commit is contained in:
2025-04-18 01:54:26 +09:00
parent b915d56f73
commit bfc94f0008
138 changed files with 28915 additions and 534 deletions

View File

@@ -0,0 +1,73 @@
#ifndef GEOMETRY_UTILITIES_H
#define GEOMETRY_UTILITIES_H
#include "Triangle.h"
inline void quad_create(vec3s center, vec3s forward, vec3s up, float size, uint8_t material_id, triangle_collection_t* collection)
{
float half_size = size / 2.0f;
vec3s right = glms_vec3_cross(forward, up);
vec3s scaled_right = glms_vec3_scale(right, half_size);
vec3s scaled_up = glms_vec3_scale(up, half_size);
vec3s temp_sub = glms_vec3_sub(center, scaled_right);
vec3s temp_add = glms_vec3_add(center, scaled_right);
vec3s top_left = glms_vec3_add(temp_sub, scaled_up);
vec3s top_right = glms_vec3_add(temp_add, scaled_up);
vec3s bottom_right = glms_vec3_sub(temp_add, scaled_up);
vec3s bottom_left = glms_vec3_sub(temp_sub, scaled_up);
triangle_create(top_left, top_right, bottom_left, material_id, collection);
triangle_create(top_right, bottom_right, bottom_left, material_id, collection);
}
inline void sphere_create(vec3s center, float radius, uint8_t material_id, triangle_collection_t* collection)
{
const int segments = 8;
const int rings = 8;
for (int i = 0; i < rings; i++)
{
float theta1 = (float)i / (float)rings * (float)M_PI;
float theta2 = (float)(i + 1) / (float)rings * (float)M_PI;
for (int j = 0; j < segments; j++)
{
float phi1 = (float)j / (float)segments * 2.0f * (float)M_PI;
float phi2 = (float)(j + 1) / (float)segments * 2.0f * (float)M_PI;
vec3s p1 = {
center.x + radius * sinf(theta1) * cosf(phi1),
center.y + radius * cosf(theta1),
center.z + radius * sinf(theta1) * sinf(phi1)
};
vec3s p2 = {
center.x + radius * sinf(theta2) * cosf(phi1),
center.y + radius * cosf(theta2),
center.z + radius * sinf(theta2) * sinf(phi1)
};
vec3s p3 = {
center.x + radius * sinf(theta2) * cosf(phi2),
center.y + radius * cosf(theta2),
center.z + radius * sinf(theta2) * sinf(phi2)
};
vec3s p4 = {
center.x + radius * sinf(theta1) * cosf(phi2),
center.y + radius * cosf(theta1),
center.z + radius * sinf(theta1) * sinf(phi2)
};
vec3s n1 = glms_vec3_normalize(glms_vec3_sub(p1, center));
vec3s n2 = glms_vec3_normalize(glms_vec3_sub(p2, center));
vec3s n3 = glms_vec3_normalize(glms_vec3_sub(p3, center));
vec3s n4 = glms_vec3_normalize(glms_vec3_sub(p4, center));
triangle_create_with_normals(p3, p2, p1, n3, n2, n1, material_id, collection);
triangle_create_with_normals(p3, p1, p4, n3, n1, n4, material_id, collection);
}
}
}
#endif // GEOMETRY_UTILITIES_H

18
header/Geometry/Mesh.h Normal file
View File

@@ -0,0 +1,18 @@
#ifndef MESH_H
#define MESH_H
#include "Material/Material.h"
#include "Geometry/Triangle.h"
#include <stdint.h>
typedef struct
{
uint64_t id;
uint64_t size;
} mesh_entity_t;
//HACK: We should handle the material from mesh, not user input.
mesh_entity_t mesh_load(const char* filename, uint8_t material_id, triangle_collection_t* triangles, material_collection_t* materials);
#endif // MESH_H

View File

@@ -0,0 +1,38 @@
#ifndef TRIANGLE_H
#define TRIANGLE_H
#include "Common.h"
#include <stdint.h>
typedef struct
{
vec3s point_1;
vec3s point_2;
vec3s point_3;
vec3s normal_1;
vec3s normal_2;
vec3s normal_3;
vec3s normal_face; // Interpolated normal, not used in the triangle itself, but for ray intersection.
uint8_t material_id;
}triangle_t;
//TODO: Handle triangle remove, we can use something like sparse set.
typedef struct
{
uint64_t count;
uint64_t size;
triangle_t* buffer;
}triangle_collection_t;
triangle_collection_t triangle_collection_create(size_t size);
void triangle_collection_resize(triangle_collection_t* collection, size_t size);
void triangle_collection_free(triangle_collection_t* collection);
void triangle_create_with_normals(const vec3s point1, const vec3s point2, const vec3s point3,
const vec3s normal1, const vec3s normal2, const vec3s normal3,
const uint8_t material_id, triangle_collection_t* collection);
void triangle_create(const vec3s point1, const vec3s point2, const vec3s point3, const uint8_t material_id, triangle_collection_t* collection);
#endif // TRIANGLE_H