Made a world a little bit better
This commit is contained in:
parent
648621eb42
commit
8c07fd9681
@ -46,72 +46,9 @@ NODISCARD VecU8 generate_texture_data_struct_and_necc_methods(SpanU8 tex, SpanU8
|
||||
"size_t %s_get_size_in_bytes(const %s* self) {\n"
|
||||
SPACE "return self->pixels.len * sizeof(%s);\n"
|
||||
"}\n\n", tex, tex, memb));
|
||||
/* Method _to_bitmap_text()
|
||||
* We use the assumption that bytes in type member are tightly packed
|
||||
* Actually, our current method of texture read/write is super inefficient
|
||||
*/
|
||||
VecU8_append_vec(&res, VecU8_fmt(
|
||||
"VecU8 %s_to_bitmap_text(const %s* self) {\n"
|
||||
SPACE "assert(SIZE_MAX / self->pixels.len >= 100);\n"
|
||||
SPACE "size_t len = self->pixels.len * sizeof(%s);\n"
|
||||
SPACE "VecU8 res = VecU8_new_zeroinit(8 + len);\n"
|
||||
SPACE "size_t width = self->width;\n"
|
||||
SPACE "size_t height = self->pixels.len / self->width;\n"
|
||||
SPACE "assert(UINT32_MAX / width >= 10 && UINT32_MAX / height >= 10);\n"
|
||||
SPACE "for (int i = 0; i < 4; i++)\n"
|
||||
SPACE SPACE "*VecU8_mat(&res, 0 + i) = (width >> (8 * i)) & 0xff;\n"
|
||||
SPACE "for (int i = 0; i < 4; i++)\n"
|
||||
SPACE SPACE "*VecU8_mat(&res, 4 + i) = (height >> (8 * i)) & 0xff;\n"
|
||||
SPACE "memcpy(res.buf + 8, self->pixels.buf, len);\n"
|
||||
SPACE "return res;\n"
|
||||
"}\n\n", tex, tex, memb));
|
||||
/* Method _write_to_file
|
||||
* Aborts on failure */
|
||||
VecU8_append_vec(&res, VecU8_fmt(
|
||||
"void %s_write_to_file(const %s* self, const char* path) {\n"
|
||||
SPACE "VecU8 data = %s_to_bitmap_text(self);\n"
|
||||
SPACE "write_whole_file_or_abort(path, VecU8_to_span(&data));\n"
|
||||
SPACE "VecU8_drop(data);\n"
|
||||
"}\n\n", tex, tex, tex));
|
||||
/* Result<tex, SpanU8> structure */
|
||||
VecU8 g_resoftex = get_ResultType_inst_name(tex, cstr("SpanU8"));
|
||||
SpanU8 resoftex = VecU8_to_span(&g_resoftex);
|
||||
VecU8_append_vec(&res, generate_result_template_inst(tex, cstr("SpanU8"), false, true));
|
||||
/* I also add this, because why not?? Maye I will use it in the future... */
|
||||
/* Result<tex, VecU8> structure */
|
||||
VecU8_append_vec(&res, generate_result_template_inst(tex, cstr("VecU8"), false, false));
|
||||
/* Method _from_bitmap_text()
|
||||
* We assume that bytes are tightly packed in member type */
|
||||
VecU8_append_vec(&res, VecU8_fmt(
|
||||
"%s %s_from_bitmap_text(SpanU8 text) {\n"
|
||||
SPACE "if (text.len < 8)\n"
|
||||
SPACE SPACE "return (%s){.variant = Result_Err, .err = cstr(\"No header *crying emoji*\")};\n"
|
||||
SPACE "size_t width = 0, height = 0;\n"
|
||||
SPACE "for (int i = 0; i < 4; i++)\n"
|
||||
SPACE SPACE "width |= (((size_t)*SpanU8_at(text, 0 + i)) << (8 * i));\n"
|
||||
SPACE "for (int i = 0; i < 4; i++)\n"
|
||||
SPACE SPACE "height |= (((size_t)*SpanU8_at(text, 4 + i)) << (8 * i));\n"
|
||||
SPACE "if (SIZE_MAX / width / height < 100 || UINT32_MAX / width < 10 || UINT32_MAX / height < 10)\n"
|
||||
SPACE SPACE "return (%s){.variant = Result_Err, .err = cstr(\"Image is too big\")};\n"
|
||||
SPACE "size_t len = width * height * sizeof(%s);\n"
|
||||
SPACE "if (text.len < 8 + len)\n"
|
||||
SPACE SPACE "return (%s){.variant = Result_Err, .err = cstr(\"Texture size and file size mismatch\")};\n"
|
||||
SPACE "%s res = %s_new(width, height);\n"
|
||||
SPACE "memcpy(res.pixels.buf, text.data + 8, len);\n"
|
||||
SPACE "return (%s){.variant = Result_Ok, .ok = res};\n"
|
||||
"}\n\n", resoftex, tex, resoftex, resoftex, memb, resoftex, tex, tex, resoftex));
|
||||
/* Method _read_from_file */
|
||||
VecU8_append_vec(&res, VecU8_fmt(
|
||||
"%s %s_read_from_file(SpanU8 path) {\n"
|
||||
SPACE "VecU8 data = read_whole_file_or_abort(path);\n"
|
||||
SPACE "%s res = %s_from_bitmap_text(VecU8_to_span(&data));\n"
|
||||
SPACE "if (res.variant != Result_Ok) {\n"
|
||||
SPACE SPACE "fprintf(stderr, \"Tried loading bitmap texture from file, but encountered decoding error: \");\n"
|
||||
SPACE SPACE "SpanU8_fprint(res.err, stderr);\n"
|
||||
SPACE SPACE "abortf(\"\\n\");\n"
|
||||
SPACE "}\n"
|
||||
SPACE "VecU8_drop(data);\n"
|
||||
SPACE "return res.ok;\n"
|
||||
"}\n\n", tex, tex, resoftex, tex));
|
||||
/* Method _is_inside() */
|
||||
VecU8_append_vec(&res, VecU8_fmt(
|
||||
"bool %s_is_inside(const %s* self, S32 x, S32 y) {\n"
|
||||
@ -146,7 +83,6 @@ NODISCARD VecU8 generate_texture_data_struct_and_necc_methods(SpanU8 tex, SpanU8
|
||||
SPACE "}\n"
|
||||
"}\n\n", tex, tex, memb, tex, luminosity_formula));
|
||||
|
||||
VecU8_drop(g_resoftex);
|
||||
VecU8_drop(g_pixvec);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
typedef struct {
|
||||
VecU8 result;
|
||||
VecU8 nt_filename;
|
||||
VecU8 filename;
|
||||
} GeneratedHeader;
|
||||
|
||||
NODISCARD GeneratedHeader begin_header(SpanU8 filename) {
|
||||
@ -26,14 +26,13 @@ NODISCARD GeneratedHeader begin_header(SpanU8 filename) {
|
||||
VecU8_append_span(&res, cstr("\n#define "));
|
||||
VecU8_append_vec(&res, guard);
|
||||
VecU8_append_span(&res, cstr("\n/* Automatically generated file. Do not edit it. */\n\n"));
|
||||
return (GeneratedHeader){.result = res, .nt_filename = VecU8_fmt("%s%c", filename, 0) };
|
||||
return (GeneratedHeader){.result = res, .filename = VecU8_from_span(filename) };
|
||||
}
|
||||
|
||||
/* Codegen script's working directory should be `gen` */
|
||||
void finish_header(GeneratedHeader header) {
|
||||
VecU8_append_span(&header.result, cstr("#endif\n"));
|
||||
write_whole_file_or_abort((const char*)header.nt_filename.buf, VecU8_to_span(&header.result));
|
||||
VecU8_drop(header.nt_filename);
|
||||
write_file_by_path(header.filename, VecU8_to_span(&header.result));
|
||||
VecU8_drop(header.result);
|
||||
}
|
||||
|
||||
@ -43,9 +42,7 @@ void finish_header(GeneratedHeader header) {
|
||||
#define SPACE16 " "
|
||||
|
||||
void finish_layer(SpanU8 layer_name) {
|
||||
VecU8 nt_name = VecU8_fmt("%s/dorothy.txt%c", layer_name, 0);
|
||||
write_whole_file_or_abort((const char*)nt_name.buf, cstr(""));
|
||||
VecU8_drop(nt_name);
|
||||
write_file_by_path(VecU8_fmt("%s/dorothy.txt", layer_name), cstr(""));
|
||||
}
|
||||
|
||||
int get_number_of_parts_in_header_namespace(SpanU8 ns) {
|
||||
@ -88,9 +85,7 @@ NODISCARD VecU8 prepend_spaces_to_SpanU8_lines(SpanU8 lines, int tabulation){
|
||||
void generate_SOME_templ_inst_eve_header(SpanU8 layer, SpanU8 bonus_ns, VecU8 body, VecU8 name){
|
||||
VecU8 text = VecU8_fmt("/* Automatically generated file. Don't edit it.\n"
|
||||
"* Don't include it in more than one place */\n\n%v", body);
|
||||
VecU8 nt_path = VecU8_fmt("%s/eve/%s/%v.h%c", layer, bonus_ns, name, 0);
|
||||
write_whole_file_or_abort((const char*)nt_path.buf, VecU8_to_span(&text));
|
||||
VecU8_drop(nt_path);
|
||||
write_file_by_path(VecU8_fmt("%s/eve/%s/%v.h", layer, bonus_ns, name), VecU8_to_span(&text));
|
||||
VecU8_drop(text);
|
||||
}
|
||||
|
||||
|
||||
@ -16,24 +16,18 @@ typedef struct {
|
||||
};
|
||||
} Result_VecU8_or_int;
|
||||
|
||||
void Result_VecU8_or_int_drop(Result_VecU8_or_int obj) {
|
||||
if (obj.variant == Result_Ok)
|
||||
VecU8_drop(obj.Ok);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
Result_variant variant;
|
||||
int Err;
|
||||
} Result_ok_or_int;
|
||||
|
||||
void Result_ok_or_int_drop(Result_ok_or_int obj) {}
|
||||
|
||||
NODISCARD VecU8 read_whole_file_or_abort(SpanU8 path) {
|
||||
VecU8 filename = VecU8_fmt("%s%c", path, 0);
|
||||
FILE* fp = fopen((const char*)filename.buf, "rb");
|
||||
/* path is VecU8. Aborts on error */
|
||||
NODISCARD VecU8 read_file_by_path(VecU8 path){
|
||||
VecU8_append(&path, 0);
|
||||
FILE* fp = fopen((const char*)path.buf, "rb");
|
||||
if (!fp)
|
||||
abortf("Can't open file %s: %s\n", (const char*)filename.buf, strerror(errno));
|
||||
VecU8_drop(filename);
|
||||
abortf("Can't open file %s: %s\n", (const char*)path.buf, strerror(errno));
|
||||
VecU8_drop(path);
|
||||
if (fseek(fp, 0, SEEK_END) != 0) {
|
||||
abortf("fseek: %s\n", strerror(errno));
|
||||
}
|
||||
@ -46,23 +40,18 @@ NODISCARD VecU8 read_whole_file_or_abort(SpanU8 path) {
|
||||
}
|
||||
VecU8 result = (VecU8){.buf = safe_malloc(file_size), .len = file_size, .capacity = file_size};
|
||||
size_t nread = fread(result.buf, 1, (size_t)file_size, fp);
|
||||
if (nread < file_size) {
|
||||
if ((long)nread < file_size) {
|
||||
abortf("fread\n");
|
||||
}
|
||||
fclose(fp);
|
||||
return result;
|
||||
}
|
||||
|
||||
NODISCARD VecU8 read_file_by_path(VecU8 path){
|
||||
VecU8 content = read_whole_file_or_abort(VecU8_to_span(&path));
|
||||
VecU8_drop(path);
|
||||
return content;
|
||||
}
|
||||
|
||||
void write_whole_file_or_abort(const char* filename, SpanU8 content) {
|
||||
FILE* fd = fopen(filename, "wb");
|
||||
void write_file_by_path(VecU8 path, SpanU8 content){
|
||||
VecU8_append(&path, 0);
|
||||
FILE* fd = fopen((const char*)path.buf, "wb");
|
||||
if (!fd) {
|
||||
abortf("Can't open file %s: %s\n", filename, strerror(errno));
|
||||
abortf("Can't open file %s: %s\n", (const char*)path.buf, strerror(errno));
|
||||
}
|
||||
if (fwrite(content.data, 1, content.len, fd) < content.len) {
|
||||
abortf("fwrite\n");
|
||||
|
||||
@ -59,6 +59,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
vec3 pos;
|
||||
vec3 color;
|
||||
} ShinyMeshVertexInc;
|
||||
|
||||
typedef struct {
|
||||
@ -85,7 +86,6 @@ ShinyMeshTopology ShinyMeshTopology_clone(const ShinyMeshTopology* self) {
|
||||
|
||||
typedef struct{
|
||||
mat4 model_t;
|
||||
vec3 color_off;
|
||||
vec3 color_on;
|
||||
} ShinyMeshInstanceInc;
|
||||
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
#ifndef prototype1_src_l2_alice_model_file_h
|
||||
#define prototype1_src_l2_alice_model_file_h
|
||||
|
||||
#include "../../../gen/l1/VecAndSpan_vec2.h"
|
||||
#include "../../../gen/l1/VecAndSpan_vec3.h"
|
||||
#include "../../l1/system/fileio.h"
|
||||
#include "assets.h"
|
||||
#include "stdalign.h"
|
||||
@ -8,7 +10,7 @@
|
||||
static_assert(sizeof(float) == 4, "...");
|
||||
static_assert(sizeof(GenericMeshVertexInc) == 4 * (3 + 2), "...");
|
||||
static_assert(alignof(GenericMeshVertexInc) == 4, "...");
|
||||
static_assert(sizeof(ShinyMeshVertexInc) == 4 * (3), "...");
|
||||
static_assert(sizeof(ShinyMeshVertexInc) == 4 * (3 + 3), "...");
|
||||
static_assert(alignof(ShinyMeshVertexInc) == 4, "...");
|
||||
|
||||
/* Yes, at this point I really started thinking that maybe I should have written Alice as a template */
|
||||
@ -26,10 +28,8 @@ void alice_write_generic_mesh_to_file(GenericMeshTopology model, VecU8 file_path
|
||||
memcpy(buf, model.vertices.buf, model.vertices.len * sizeof(GenericMeshVertexInc));
|
||||
buf += model.vertices.len * sizeof(GenericMeshVertexInc);
|
||||
memcpy(buf, model.indexes.buf, model.indexes.len * sizeof(U32));
|
||||
VecU8_append(&file_path, 0);
|
||||
write_whole_file_or_abort((const char*)file_path.buf, VecU8_to_span(&res));
|
||||
write_file_by_path(file_path, VecU8_to_span(&res));
|
||||
GenericMeshTopology_drop(model);
|
||||
VecU8_drop(file_path);
|
||||
VecU8_drop(res);
|
||||
}
|
||||
|
||||
@ -71,10 +71,8 @@ void alice_write_shiny_mesh_to_file(ShinyMeshTopology model, VecU8 file_path){
|
||||
memcpy(buf, model.vertices.buf, model.vertices.len * sizeof(ShinyMeshVertexInc));
|
||||
buf += model.vertices.len * sizeof(ShinyMeshVertexInc);
|
||||
memcpy(buf, model.indexes.buf, model.indexes.len * sizeof(U32));
|
||||
VecU8_append(&file_path, 0);
|
||||
write_whole_file_or_abort((const char*)file_path.buf, VecU8_to_span(&res));
|
||||
write_file_by_path(file_path, VecU8_to_span(&res));
|
||||
ShinyMeshTopology_drop(model);
|
||||
VecU8_drop(file_path);
|
||||
VecU8_drop(res);
|
||||
}
|
||||
|
||||
@ -103,6 +101,14 @@ ShinyMeshTopology alice_expect_read_shiny_mesh_from_file(VecU8 file_path){
|
||||
return (ShinyMeshTopology){.vertices = vertices, .indexes = indexes};
|
||||
}
|
||||
|
||||
/* My life f****** sucks so much */
|
||||
// GenericMeshTopology alice_expect_read_generic_mesh_from_obj_file(VecU8 file_path){
|
||||
// Vecvec3 vertex_pos;
|
||||
// Vecvec2 vertex_tex;
|
||||
// VecU8 text = read_file_by_path(file_path);
|
||||
// VecGenericMeshVertexInc vertices;
|
||||
// }
|
||||
|
||||
/* No beauty, just pure brute force */
|
||||
|
||||
#endif
|
||||
@ -58,17 +58,16 @@ instance Storable AliceGenericMeshInstance where
|
||||
peek _ = error "Please don't"
|
||||
poke ptr (AliceGenericMeshInstance modelT) = poke (castPtr ptr :: Ptr Mat4) modelT
|
||||
|
||||
-- model_t color_off color_on
|
||||
data AliceShinyMeshInstance = AliceShinyMeshInstance Mat4 Vec3 Vec3
|
||||
-- model_t color_on
|
||||
data AliceShinyMeshInstance = AliceShinyMeshInstance Mat4 Vec3
|
||||
|
||||
instance Storable AliceShinyMeshInstance where
|
||||
sizeOf _ = sizeOf (undefined :: Mat4)
|
||||
sizeOf _ = sizeOf (undefined :: Mat4) + sizeOf (undefined :: Vec3)
|
||||
alignment _ = 4
|
||||
peek _ = error "Don't do that, please"
|
||||
poke ptr (AliceShinyMeshInstance modelT colorOff colorOn) = do
|
||||
poke ptr (AliceShinyMeshInstance modelT colorOn) = do
|
||||
poke (castPtr ptr :: Ptr Mat4) modelT
|
||||
poke (castPtr (ptr `plusPtr` (sizeOf (undefined :: Mat4)) ) :: Ptr Vec3) colorOff
|
||||
poke (castPtr (ptr `plusPtr` (sizeOf (undefined :: Mat4)) `plusPtr` (sizeOf (undefined :: Vec3))) :: Ptr Vec3) colorOn
|
||||
poke (castPtr (ptr `plusPtr` (sizeOf (undefined :: Mat4))) :: Ptr Vec3) colorOn
|
||||
|
||||
-- pos color
|
||||
data AlicePointLight = AlicePointLight Vec3 Vec3
|
||||
|
||||
@ -431,35 +431,35 @@ AlicePipeline0b create_graphics_pipeline_0_b(
|
||||
{
|
||||
.location = 1, .binding = 0,
|
||||
.format = VK_FORMAT_R32G32B32_SFLOAT,
|
||||
.offset = offsetof(ShinyMeshVertexInc, color),
|
||||
},
|
||||
{
|
||||
.location = 2, .binding = 0,
|
||||
.format = VK_FORMAT_R32G32B32_SFLOAT,
|
||||
.offset = offsetof(ShinyMeshVertex, normal),
|
||||
},
|
||||
|
||||
/* This is a mat4 datatype, so it will take 4 entire 'locations' */
|
||||
{
|
||||
.location = 2, .binding = 1,
|
||||
.location = 3, .binding = 1,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = offsetof(ShinyMeshInstanceInc, model_t) + offsetof(mat4, x)
|
||||
},
|
||||
{
|
||||
.location = 3, .binding = 1,
|
||||
.location = 4, .binding = 1,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = offsetof(ShinyMeshInstanceInc, model_t) + offsetof(mat4, y)
|
||||
},
|
||||
{
|
||||
.location = 4, .binding = 1,
|
||||
.location = 5, .binding = 1,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = offsetof(ShinyMeshInstanceInc, model_t) + offsetof(mat4, z)
|
||||
},
|
||||
{
|
||||
.location = 5, .binding = 1,
|
||||
.location = 6, .binding = 1,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = offsetof(ShinyMeshInstanceInc, model_t) + offsetof(mat4, w)
|
||||
},
|
||||
{
|
||||
.location = 6, .binding = 1,
|
||||
.format = VK_FORMAT_R32G32B32_SFLOAT,
|
||||
.offset = offsetof(ShinyMeshInstanceInc, color_off)
|
||||
},
|
||||
{
|
||||
.location = 7, .binding = 1,
|
||||
.format = VK_FORMAT_R32G32B32_SFLOAT,
|
||||
@ -1659,18 +1659,6 @@ static void alice_mainloop_h_wl_keyboard_key(
|
||||
alice->callbacks.on_wl_keyboard_key(alice->guest, keysym, key_action);
|
||||
if (key_action == WL_KEYBOARD_KEY_STATE_RELEASED) {
|
||||
if (keysym == XKB_KEY_1) {
|
||||
// vec3 p = alice->cam_info.pos;
|
||||
// p.y += 1.5f;
|
||||
// ShinyModelOnSceneMem* model = VecShinyModelOnSceneMem_mat(&alice->scene.shiny_models, 0);
|
||||
// assert(model->instance_attr.count >= 1);
|
||||
// VecObjectInfo_mat(&alice->scene.smeshnyavka_3, 0)->pos = p;
|
||||
// Scene_update_smeshnyavka_3(&alice->scene, 0);
|
||||
//
|
||||
// Pipeline0UBO* ubo = (Pipeline0UBO*)MargaretSubbuf_get_mapped(&alice->scene.pipeline0_ubo.staging_updatable);
|
||||
// assert(ubo->point_light_count >= 1);
|
||||
// ubo->point_light_arr[0].pos = p;
|
||||
//
|
||||
// printf("Point light source pos set to %f %f %f\n", p.x, p.y, p.z);
|
||||
} else if (keysym == XKB_KEY_2) {
|
||||
alice->rendering_config.hdr_factor /= 1.05f;
|
||||
printf("hdr factor decreased to %f\n", alice->rendering_config.hdr_factor);
|
||||
|
||||
@ -598,37 +598,37 @@ GenericMeshTopology generate_one_fourth_of_a_cylinder(float w, float r, U32 k) {
|
||||
|
||||
U32 quad_to_triangles_conv_arr[6] = {0, 1, 2, 0, 2, 3};
|
||||
|
||||
ShinyMeshTopology generate_shiny_cube(float r) {
|
||||
ShinyMeshTopology generate_shiny_cube(vec3 color) {
|
||||
ShinyMeshVertexInc vert[24] = {
|
||||
{{+r, +r, +r}},
|
||||
{{+r, -r, +r}},
|
||||
{{+r, -r, -r}},
|
||||
{{+r, +r, -r}},
|
||||
{{+1, +1, +1}, color},
|
||||
{{+1, -1, +1}, color},
|
||||
{{+1, -1, -1}, color},
|
||||
{{+1, +1, -1}, color},
|
||||
|
||||
{{-r, -r, -r}},
|
||||
{{-r, -r, +r}},
|
||||
{{-r, +r, +r}},
|
||||
{{-r, +r, -r}},
|
||||
{{-1, -1, -1}, color},
|
||||
{{-1, -1, +1}, color},
|
||||
{{-1, +1, +1}, color},
|
||||
{{-1, +1, -1}, color},
|
||||
|
||||
{{+r, +r, +r}},
|
||||
{{+r, +r, -r}},
|
||||
{{-r, +r, -r}},
|
||||
{{-r, +r, +r}},
|
||||
{{+1, +1, +1}, color},
|
||||
{{+1, +1, -1}, color},
|
||||
{{-1, +1, -1}, color},
|
||||
{{-1, +1, +1}, color},
|
||||
|
||||
{{-r, -r, -r}},
|
||||
{{+r, -r, -r}},
|
||||
{{+r, -r, +r}},
|
||||
{{-r, -r, +r}},
|
||||
{{-1, -1, -1}, color},
|
||||
{{+1, -1, -1}, color},
|
||||
{{+1, -1, +1}, color},
|
||||
{{-1, -1, +1}, color},
|
||||
|
||||
{{+r, +r, +r}},
|
||||
{{-r, +r, +r}},
|
||||
{{-r, -r, +r}},
|
||||
{{+r, -r, +r}},
|
||||
{{+1, +1, +1}, color},
|
||||
{{-1, +1, +1}, color},
|
||||
{{-1, -1, +1}, color},
|
||||
{{+1, -1, +1}, color},
|
||||
|
||||
{{-r, -r, -r}},
|
||||
{{-r, +r, -r}},
|
||||
{{+r, +r, -r}},
|
||||
{{+r, -r, -r}},
|
||||
{{-1, -1, -1}, color},
|
||||
{{-1, +1, -1}, color},
|
||||
{{+1, +1, -1}, color},
|
||||
{{+1, -1, -1}, color},
|
||||
};
|
||||
VecShinyMeshVertexInc vertices_vec = VecShinyMeshVertexInc_from_span(
|
||||
(SpanShinyMeshVertexInc){ .data = vert, .len = ARRAY_SIZE(vert) });
|
||||
@ -887,7 +887,7 @@ int gen_assets_for_r4() {
|
||||
mkdir_nofail("l2/textures");
|
||||
mkdir_nofail("l2/textures/r4");
|
||||
generate_one_forth_of_a_cylinder_with_bublazhuzhka(10, 2, 6);
|
||||
alice_write_shiny_mesh_to_file(generate_shiny_cube(0.3f), vcstr("l2/models/cube.AliceShinyMesh"));
|
||||
alice_write_shiny_mesh_to_file(generate_shiny_cube((vec3){0.6f, 0.6f, 0.7f}), vcstr("l2/models/cube.AliceShinyMesh"));
|
||||
alice_write_shiny_mesh_to_file(generate_shiny_lamp(0.3f, 0.13f, 0.19f), vcstr("l2/models/lamp.AliceShinyMesh"));
|
||||
r4_asset_gen_generic_mesh_quad(10, 10, vcstr("l2/models/quad.AliceGenericMesh"));
|
||||
r4_asset_gen_generic_mesh_cylinder(200, 0.4f, 0.17f, 30, vcstr("l2/models/puck.AliceGenericMesh"),
|
||||
|
||||
@ -186,10 +186,8 @@ void save_tree_to_file(const BufRBTree_SetS64* set, SpanU8 name){
|
||||
}
|
||||
VecU8_append_span(&graph, cstr("}\n"));
|
||||
mkdir_nofail("GRAPHS");
|
||||
VecU8 dot_filename_nt = VecU8_fmt("GRAPHS/GRAPH_%s.gv%c", name, 0);
|
||||
write_whole_file_or_abort((CSTR)dot_filename_nt.buf, VecU8_to_span(&graph));
|
||||
write_file_by_path(VecU8_fmt("GRAPHS/GRAPH_%s.gv", name), VecU8_to_span(&graph));
|
||||
VecU8_drop(graph);
|
||||
VecU8_drop(dot_filename_nt);
|
||||
VecU8 command_nt = VecU8_fmt("dot -Tpng GRAPHS/GRAPH_%s.gv -o GRAPHS/GRAPH_%s.png%c", name, name, 0);
|
||||
calling_system_func_nofail((CSTR)command_nt.buf);
|
||||
VecU8_drop(command_nt);
|
||||
|
||||
@ -118,10 +118,8 @@ void save_tree_to_file(const RBTree_SetS64* set, SpanU8 name){
|
||||
}
|
||||
VecU8_append_span(&graph, cstr("}\n"));
|
||||
mkdir_nofail("GRAPHS");
|
||||
VecU8 dot_filename_nt = VecU8_fmt("GRAPHS/GRAPH_%s.gv%c", name, 0);
|
||||
write_whole_file_or_abort((CSTR)dot_filename_nt.buf, VecU8_to_span(&graph));
|
||||
write_file_by_path(VecU8_fmt("GRAPHS/GRAPH_%s.gv", name), VecU8_to_span(&graph));
|
||||
VecU8_drop(graph);
|
||||
VecU8_drop(dot_filename_nt);
|
||||
VecU8 command_nt = VecU8_fmt("dot -Tpng GRAPHS/GRAPH_%s.gv -o GRAPHS/GRAPH_%s.png%c", name, name, 0);
|
||||
calling_system_func_nofail((CSTR)command_nt.buf);
|
||||
VecU8_drop(command_nt);
|
||||
|
||||
@ -35,9 +35,9 @@ puckSpots = [(Vec2 (-10) (-10)), (Vec2 (-15) (-15)) , (Vec2 (-18) (-18)), (Vec2
|
||||
|
||||
introText :: String
|
||||
introText = "Накануне новогодняя сессия 2025 года. Все были готовы провести экзамен по матану, но злой Гринч похитил 67 " ++
|
||||
"шайб с бергамотом Матвея и улетел. Вся надежда была потеряна, но в полёте Гринч выронил все, и те упали в Дубки. Тебе " ++
|
||||
"шайб с бергамотом Матвея и улетел. Вся надежда была потеряна, но в полёте Гринч выронил все шайбы, и те упали в Дубки. Тебе " ++
|
||||
"необходимо вернуть их Матвею.\n" ++
|
||||
"Естесственно, вернёшь ты их Гринчу, так как ты и сам не понимаешь преобразования Фурье и хочешь помочь сорвать" ++
|
||||
"Естесственно, вернёшь ты их Гринчу, так как ты и сам не понимаешь преобразования Фурье и хочешь помочь сорвать " ++
|
||||
"экзамен.\n\n" ++
|
||||
"Итак, ты в Дубках..."
|
||||
|
||||
@ -75,7 +75,7 @@ main = do
|
||||
|
||||
aliceSetPointLightCount alice 5
|
||||
forM_ [0..4] $ \i -> do
|
||||
aliceShinyMeshSetInst cube i (AliceShinyMeshInstance (mat4Transit (goodLightPos i)) (Vec3 0.0 0.0 0.0) (goodColorOfCube i))
|
||||
aliceShinyMeshSetInst cube i (AliceShinyMeshInstance (mat4Transit (goodLightPos i)) (goodColorOfCube i))
|
||||
aliceSetPointLight alice (fromIntegral i) (AlicePointLight (goodLightPos i) (goodColorOfCube i))
|
||||
|
||||
aliceGenericMeshResizeInstanceArr alice puck (fromIntegral $ length puckSpots)
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#version 450
|
||||
|
||||
layout(location = 0) in vec3 norm;
|
||||
layout(location = 1) in vec3 color_off;
|
||||
layout(location = 1) in vec3 color_off;
|
||||
layout(location = 2) in vec3 color_on;
|
||||
layout(location = 3) in vec3 pos;
|
||||
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
#version 450
|
||||
|
||||
layout(location = 0) in vec3 pos;
|
||||
layout(location = 1) in vec3 normal;
|
||||
layout(location = 1) in vec3 color;
|
||||
layout(location = 2) in vec3 normal;
|
||||
|
||||
layout(location = 2) in mat4 model_t;
|
||||
/* 2 <- 3, 4, 5 */
|
||||
layout(location = 6) in vec3 color_off;
|
||||
layout(location = 3) in mat4 model_t;
|
||||
/* 3 <- 4, 5, 6 */
|
||||
layout(location = 7) in vec3 color_on;
|
||||
layout(location = 8) in mat3 normal_t;
|
||||
/* 8 <- 9, 10 */
|
||||
@ -21,7 +21,7 @@ layout(push_constant, std430) uniform pc {
|
||||
|
||||
void main(){
|
||||
vsout_normal = normalize(normal_t * normal);
|
||||
vsout_color_off = color_off;
|
||||
vsout_color_off = color;
|
||||
vsout_color_on = color_on;
|
||||
vec4 real_pos = model_t * vec4(pos, 1);
|
||||
vsout_pos = real_pos.xyz;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user