diff options
author | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-08-15 13:06:27 +1000 |
---|---|---|
committer | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-08-15 13:06:27 +1000 |
commit | 938e3944fd7d55951e794224e6346488d3c701ea (patch) | |
tree | 74b1ffd98099a69392f3472768ea99ebe18c4586 | |
parent | d4df846c97a7fd216748806abdb729a11a0ce2ec (diff) |
cone wip
-rw-r--r-- | examples/skinned_animation/ex_skinned_animation.c | 16 | ||||
-rw-r--r-- | src/log.h | 5 | ||||
-rw-r--r-- | src/maths/primitives.c | 37 | ||||
-rw-r--r-- | src/maths/primitives.h | 1 | ||||
-rw-r--r-- | src/render/pbr.c | 16 | ||||
-rw-r--r-- | src/resources/gltf.c | 2 |
6 files changed, 59 insertions, 18 deletions
diff --git a/examples/skinned_animation/ex_skinned_animation.c b/examples/skinned_animation/ex_skinned_animation.c index f7db62e..e1ebd64 100644 --- a/examples/skinned_animation/ex_skinned_animation.c +++ b/examples/skinned_animation/ex_skinned_animation.c @@ -73,15 +73,13 @@ int main() { // TODO: Drawing should still just use the PBR pipeline Mesh* m = Mesh_Get(simple_skin->meshes[0]); - RenderEnt render_ents[1] = { - (RenderEnt ){ .mesh = simple_skin->meshes[0], - .material = m->material, - .animation_clip = simple_skin->animations->data[0], - .is_playing = true, - .t = 0.0, - .affine = mat4_ident(), - .flags = 0 } - }; + RenderEnt render_ents[1] = { (RenderEnt){ .mesh = simple_skin->meshes[0], + .material = m->material, + .animation_clip = simple_skin->animations->data[0], + .is_playing = true, + .t = 0.0, + .affine = mat4_ident(), + .flags = 0 } }; // ModelExtractRenderEnts(rend_ents, handle, mat4_translation(vec3(0, 0, 0)), 0); // draw_skinned_model(&core->renderer, &game.camera, simple_skin, tf, &our_scene); @@ -10,6 +10,11 @@ exit(1); \ } +#define TODO(msg) \ + do { \ + ERROR_EXIT("TODO: %s", msg); \ + } while (0) + #define LOG_WARN_ENABLED 1 #define LOG_INFO_ENABLED 1 diff --git a/src/maths/primitives.c b/src/maths/primitives.c index 05c31ca..3387084 100644 --- a/src/maths/primitives.c +++ b/src/maths/primitives.c @@ -2,6 +2,7 @@ #include "colours.h" #include "log.h" #include "maths.h" +#include "maths_types.h" #include "ral_types.h" #include "render_types.h" @@ -232,3 +233,39 @@ Geometry Geo_CreateUVsphere(f32 radius, u32 north_south_lines, u32 east_west_lin return geo; } + +Geometry Geo_CreateCylinder(f32 radius, f32 height, u32 resolution) { + TODO("implement cylinder meshing"); +} + +Geometry Geo_CreateCone(f32 radius, f32 height, u32 resolution) { + Vertex_darray* vertices = Vertex_darray_new(1); + u32_darray* indices = u32_darray_new(1); + + // tip + VERT_3D(vertices, vec3(0.0, height, 0.0), VEC3_Y, vec2(0, 0)); // TODO: fix uvs + + // base center + VERT_3D(vertices, VEC3_ZERO, VEC3_NEG_Y, vec2(0, 0)); // TODO: fix uvs + + // base circle + f32 step = TAU / resolution; + for (u32 i = 0; i < resolution; i++) { + f32 x = cos(step * i) * radius; + f32 z = sin(step * i) * radius; + VERT_3D(vertices, vec3(x, 0.0, z), VEC3_NEG_Z, vec2(0, 0)); + } + + // sides + for (u32 i = 0; i < resolution; i++) { + } + + Geometry geo = { + .format = VERTEX_STATIC_3D, + .vertices = vertices, + .has_indices = true, + .index_count = indices->len, + .indices = indices, + }; + return geo; +}
\ No newline at end of file diff --git a/src/maths/primitives.h b/src/maths/primitives.h index bcf71c8..4965545 100644 --- a/src/maths/primitives.h +++ b/src/maths/primitives.h @@ -9,6 +9,7 @@ Geometry Geo_CreatePlane(f32x2 extents, u32 tiling_u, u32 tiling_v); Geometry Geo_CreateCuboid(f32x3 extents); Geometry Geo_CreateCylinder(f32 radius, f32 height, u32 resolution); +Geometry Geo_CreateCone(f32 radius, f32 height, u32 resolution); Geometry Geo_CreateUVsphere(f32 radius, u32 north_south_lines, u32 east_west_lines); Geometry Geo_CreateIcosphere(f32 radius, f32 n_subdivisions); diff --git a/src/render/pbr.c b/src/render/pbr.c index cfa02fc..044e6eb 100644 --- a/src/render/pbr.c +++ b/src/render/pbr.c @@ -25,11 +25,11 @@ GPU_Renderpass* PBR_RPassCreate() { } void PBR_PipelinesCreate(PBR_Storage* storage, GPU_Renderpass* rpass) { - // Common shader bindings - ShaderDataLayout camera_data = Binding_Camera_GetLayout(NULL); - ShaderDataLayout model_data = Binding_Model_GetLayout(NULL); - ShaderDataLayout material_data = PBRMaterial_GetLayout(NULL); - ShaderDataLayout lights_data = Binding_Lights_GetLayout(NULL); + // Common shader bindings + ShaderDataLayout camera_data = Binding_Camera_GetLayout(NULL); + ShaderDataLayout model_data = Binding_Model_GetLayout(NULL); + ShaderDataLayout material_data = PBRMaterial_GetLayout(NULL); + ShaderDataLayout lights_data = Binding_Lights_GetLayout(NULL); // Static { @@ -144,9 +144,9 @@ void PBR_Execute(PBR_Storage* storage, Camera camera, TextureHandle shadowmap_te Binding_Model model_data = { .model = renderable.affine }; GPU_EncodeBindShaderData(enc, 1, Binding_Model_GetLayout(&model_data)); - AnimDataUniform anim_data = {0}; - for (int i =0; i < 4; i++) { - anim_data.bone_matrices[i] = mat4_ident(); + AnimDataUniform anim_data = { 0 }; + for (int i = 0; i < 4; i++) { + anim_data.bone_matrices[i] = mat4_ident(); } GPU_EncodeBindShaderData(enc, 3, AnimData_GetLayout(&anim_data)); // Calculate matrices here diff --git a/src/resources/gltf.c b/src/resources/gltf.c index c5f1fd1..76ba0a5 100644 --- a/src/resources/gltf.c +++ b/src/resources/gltf.c @@ -168,7 +168,7 @@ bool model_load_gltf_str(const char* file_string, const char* filepath, Str8 rel // --- Skin size_t num_skins = data->skins_count; bool is_skinned = false; - Armature main_skeleton = {0}; + Armature main_skeleton = { 0 }; if (num_skins == 1) { is_skinned = true; } else if (num_skins > 1) { |