Initial upload
This commit is contained in:
21
source/Geometry.c
Normal file
21
source/Geometry.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "Geometry.h"
|
||||
|
||||
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, bottom_left, top_right, material_id, collection);
|
||||
triangle_create(top_right, bottom_right, bottom_left, material_id, collection);
|
||||
}
|
||||
Reference in New Issue
Block a user