Work on level editing
This commit is contained in:
parent
e52b06da03
commit
34873926e0
@ -1,19 +1,98 @@
|
||||
#scope_file
|
||||
|
||||
// @ToDo do a config tweak file thing like jblow has and add this there.
|
||||
CAMERA_INACTIVE_TIME_TO_ORBIT :: 20.0;
|
||||
|
||||
mouse2Active : bool;
|
||||
mouse2ActivationPosition : Vector2;
|
||||
mouse3Active : bool;
|
||||
mouse3ActivationPosition : Vector2;
|
||||
|
||||
cameraTilt : float;
|
||||
cameraDist : float = 10.0;
|
||||
cameraRotation : float;
|
||||
oldCameraRotation : float;
|
||||
oldCameraTilt : float;
|
||||
cameraCenter : Vector2;
|
||||
|
||||
lastInputTime : float64;
|
||||
|
||||
editY : s32;
|
||||
|
||||
pointerHit : bool;
|
||||
pointerX : s32;
|
||||
pointerY : s32;
|
||||
|
||||
get_level_editor_camera :: () -> Camera {
|
||||
camera: Camera;
|
||||
camera.near = 0.1;
|
||||
camera.far = 100;
|
||||
camera.far = 1000;
|
||||
camera.target = .{cameraCenter.x, xx editY, cameraCenter.y};
|
||||
if get_time() - lastInputTime > CAMERA_INACTIVE_TIME_TO_ORBIT { // idle rotating camera
|
||||
camera.position = camera.target;
|
||||
camera.position += normalize(Vector3.{xx sin(get_time()), 0.6, xx cos(get_time())}) * cameraDist;
|
||||
} else {
|
||||
cameraDir : Vector3 = .{1, 0, 0};
|
||||
qrotation : Quaternion = .{cos(cameraRotation/2.0),0,sin(cameraRotation/2.0),0};
|
||||
qtilt : Quaternion = .{cos(cameraTilt/2.0),sin(cameraTilt/2.0), 0, 0};
|
||||
|
||||
rotate(*cameraDir, qrotation * qtilt);
|
||||
|
||||
camera.position = camera.target;
|
||||
camera.position += cameraDir * cameraDist;
|
||||
}
|
||||
|
||||
camera.position = .{xx (sin(get_time()) * 2),xx sin(get_time() * 0.3),xx (cos(get_time()) * 2)};
|
||||
camera.target = .{0.5,0.5,0.5};
|
||||
camera.position += .{0.5, 0.5, 0.5};
|
||||
return camera;
|
||||
}
|
||||
|
||||
tick_level_editor_camera :: () {
|
||||
cameraSpeed :: 5.1;
|
||||
|
||||
forward : Vector3 = .{1, 0, 0};
|
||||
qrotation : Quaternion = .{cos(cameraRotation/2.0),0,sin(cameraRotation/2.0),0};
|
||||
rotate(*forward, qrotation);
|
||||
forward2d := Vector2.{forward.x, forward.z};
|
||||
|
||||
left : Vector3 = .{0, 0, 1};
|
||||
qrotation_left : Quaternion = .{cos(cameraRotation/2.0),0,sin(cameraRotation/2.0),0};
|
||||
rotate(*left, qrotation_left);
|
||||
left2d := Vector2.{left.x, left.z};
|
||||
|
||||
if input_button_states[#char "W"] & .DOWN {
|
||||
lastInputTime = get_time();
|
||||
cameraCenter += -cameraSpeed * (xx delta_time) * forward2d;
|
||||
}
|
||||
if input_button_states[#char "S"] & .DOWN {
|
||||
lastInputTime = get_time();
|
||||
cameraCenter += cameraSpeed * (xx delta_time) * forward2d;
|
||||
}
|
||||
|
||||
if input_button_states[#char "A"] & .DOWN {
|
||||
lastInputTime = get_time();
|
||||
cameraCenter += -cameraSpeed * (xx delta_time) * left2d;
|
||||
}
|
||||
if input_button_states[#char "D"] & .DOWN {
|
||||
lastInputTime = get_time();
|
||||
cameraCenter += cameraSpeed * (xx delta_time) * left2d;
|
||||
}
|
||||
|
||||
if input_button_states[Key_Code.ARROW_UP] & .START {
|
||||
lastInputTime = get_time();
|
||||
editY = min(editY + 1, 100);
|
||||
}
|
||||
|
||||
if input_button_states[Key_Code.ARROW_DOWN] & .START {
|
||||
lastInputTime = get_time();
|
||||
editY = max(editY - 1, 0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#scope_export
|
||||
|
||||
tick_level_editor :: () {
|
||||
tick_level_editor_camera();
|
||||
|
||||
}
|
||||
|
||||
@ -25,7 +104,7 @@ draw_level_editor :: () {
|
||||
vs_params : Trile_Vs_Params;
|
||||
vs_params.mvp = mvp.floats;
|
||||
|
||||
mesh := get_trile("test");
|
||||
mesh := get_trile_gfx("test");
|
||||
|
||||
sg_apply_pipeline(gPipelines.trile.pipeline);
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ current_tab : Trile_Editor_Tab = .TOOLSET;
|
||||
current_tool : Trile_Editor_Tool = .PAINT;
|
||||
current_mode : Trile_Editor_Tool_Mode = .AREA;
|
||||
|
||||
current_trile : Trile;
|
||||
current_trile : *Trile;
|
||||
|
||||
#scope_file
|
||||
|
||||
@ -106,6 +106,7 @@ handle_tool_click :: () {
|
||||
current_color : Vector3 = .{1.0, 0.0, 0.0};
|
||||
|
||||
tick_trile_editor :: () {
|
||||
if !current_trile then current_trile = get_trile("test");
|
||||
|
||||
if input_button_states[Key_Code.MOUSE_BUTTON_LEFT] & .START {
|
||||
handle_tool_click();
|
||||
@ -187,9 +188,7 @@ draw_tool_tab :: (theme: *GR.Overall_Theme, area: GR.Rect) {
|
||||
GR.slider(r, *brush_radius, 0, 12, 1, *theme.slider_theme);
|
||||
r.y += r.h * 2;
|
||||
if GR.button(r, "Save and gen", *theme.button_theme) {
|
||||
//temptest:
|
||||
print("Testing meshgen!\n");
|
||||
set_trile("test", generate_mesh_matias(*current_trile));
|
||||
set_trile_gfx("test", generate_trile_gfx_matias(current_trile));
|
||||
};
|
||||
}
|
||||
|
||||
@ -247,6 +246,7 @@ draw_trile :: () {
|
||||
hovered_trixel_y = -1;
|
||||
hovered_trixel_z = -1;
|
||||
|
||||
print("BURGER!\n");
|
||||
for x: 0..15 {
|
||||
for y: 0..15 {
|
||||
for z: 0..15 {
|
||||
@ -261,6 +261,7 @@ draw_trile :: () {
|
||||
}
|
||||
}
|
||||
}
|
||||
print("BURGER!\n");
|
||||
|
||||
trixel_count : s32 = 0;
|
||||
|
||||
@ -289,6 +290,7 @@ draw_trile :: () {
|
||||
}
|
||||
}
|
||||
|
||||
print("BURGER!\n");
|
||||
sg_update_buffer(gPipelines.trixel.bind.vertex_buffers[2], *(sg_range.{
|
||||
ptr = trixels.data,
|
||||
size = size_of(type_of(trixels)),
|
||||
|
||||
1
src/input/hotkeys.jai
Normal file
1
src/input/hotkeys.jai
Normal file
@ -0,0 +1 @@
|
||||
|
||||
@ -7,6 +7,7 @@ stbi :: #import "stb_image";
|
||||
|
||||
#load "trile.jai";
|
||||
#load "rendering/rendering.jai";
|
||||
#load "input/hotkeys.jai";
|
||||
#load "ui/ui.jai";
|
||||
#load "editor/editor.jai";
|
||||
#load "pipelines.jai";
|
||||
@ -79,6 +80,9 @@ init :: () {
|
||||
state.pass_action_clear.colors[0] = .{ load_action = .CLEAR, clear_value = .{ r = 0.6, g = 0.7, b = 1.0, a = 1 } };
|
||||
state.pass_action.colors[0] = .{ load_action = .LOAD };
|
||||
init_font_loads();
|
||||
|
||||
// Add empty trile.
|
||||
set_trile("test", Trile.{});
|
||||
}
|
||||
|
||||
init_after_mandatory_loads :: () {
|
||||
|
||||
@ -236,7 +236,6 @@ init_quads :: (quads: *Quads) { // NOTE: unsure about if this is correctly porte
|
||||
array_add(*(quads.*[idx]), quadset);
|
||||
}
|
||||
}
|
||||
print("qcount??: %", quads[0].count);
|
||||
}
|
||||
|
||||
// Looking at the side, what axis should be used as x,y and z,
|
||||
@ -413,7 +412,7 @@ generate_optimized_quad_mesh :: (trilept: *Trile, vecs: *[..]float, normals: *[.
|
||||
|
||||
Pool :: #import "Pool";
|
||||
|
||||
generate_mesh_matias :: (trileptr : *Trile) -> Mesh {
|
||||
generate_trile_gfx_matias :: (trileptr : *Trile) -> Trile_GFX {
|
||||
meshgenpool : Pool.Pool;
|
||||
Pool.set_allocators(*meshgenpool);
|
||||
new_context := context;
|
||||
@ -425,7 +424,6 @@ generate_mesh_matias :: (trileptr : *Trile) -> Mesh {
|
||||
quadNorms : [..]float;
|
||||
|
||||
generate_optimized_quad_mesh(trileptr,*quadVecs,*quadNorms);
|
||||
print("Quad vecs size: %\n", quadVecs.count);
|
||||
|
||||
quads_to_triangles(*quadVecs, *triangleVecs,*quadNorms, *triangleNorms);
|
||||
|
||||
@ -435,9 +433,9 @@ generate_mesh_matias :: (trileptr : *Trile) -> Mesh {
|
||||
trile_normal_buffer_info := sg_buffer_desc.{ data = .{ ptr = triangleNorms.data, size = xx (triangleNorms.count * 4) } };
|
||||
trile_normal_buffer := sg_make_buffer(*trile_normal_buffer_info);
|
||||
|
||||
print("Triangle vecs size: %\n", triangleVecs.count);
|
||||
Pool.reset(*meshgenpool);
|
||||
|
||||
print("Successfully generated mesh for trile with % triangles.\n", triangleVecs.count / 3 / 3);
|
||||
return .{ trile_vert_buffer, trile_normal_buffer, triangleVecs.count / 3 };
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ Sky_Vs_Params :: struct {
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = mat4(sky_vs_params[0], sky_vs_params[1], sky_vs_params[2], sky_vs_params[3]) * vec4(position.xyz * 500.0, 1.0);
|
||||
gl_Position = mat4(sky_vs_params[0], sky_vs_params[1], sky_vs_params[2], sky_vs_params[3]) * vec4(position.xyz * 1000.0, 1.0);
|
||||
pos = position;
|
||||
}
|
||||
|
||||
@ -54,10 +54,10 @@ vs_sky_source_glsl430 := u8.[
|
||||
0x20,0x73,0x6b,0x79,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,
|
||||
0x5d,0x2c,0x20,0x73,0x6b,0x79,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
|
||||
0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x70,0x6f,0x73,0x69,
|
||||
0x74,0x69,0x6f,0x6e,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x35,0x30,0x30,0x2e,0x30,
|
||||
0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x70,0x6f,0x73,0x20,
|
||||
0x3d,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
|
||||
0x74,0x69,0x6f,0x6e,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x31,0x30,0x30,0x30,0x2e,
|
||||
0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x70,0x6f,0x73,
|
||||
0x20,0x3d,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x7d,0x0a,0x0a,
|
||||
0x00,
|
||||
];
|
||||
/*
|
||||
#version 430
|
||||
@ -373,7 +373,7 @@ fs_sky_source_glsl430 := u8.[
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = mat4(sky_vs_params[0], sky_vs_params[1], sky_vs_params[2], sky_vs_params[3]) * vec4(position.xyz * 500.0, 1.0);
|
||||
gl_Position = mat4(sky_vs_params[0], sky_vs_params[1], sky_vs_params[2], sky_vs_params[3]) * vec4(position.xyz * 1000.0, 1.0);
|
||||
pos = position;
|
||||
}
|
||||
|
||||
@ -393,9 +393,9 @@ vs_sky_source_glsl300es := u8.[
|
||||
0x6b,0x79,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,
|
||||
0x20,0x73,0x6b,0x79,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,
|
||||
0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,
|
||||
0x6f,0x6e,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x35,0x30,0x30,0x2e,0x30,0x2c,0x20,
|
||||
0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x70,0x6f,0x73,0x20,0x3d,0x20,
|
||||
0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
0x6f,0x6e,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x31,0x30,0x30,0x30,0x2e,0x30,0x2c,
|
||||
0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x70,0x6f,0x73,0x20,0x3d,
|
||||
0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
@ -746,7 +746,7 @@ fs_sky_source_glsl300es := u8.[
|
||||
vertex main0_out main0(main0_in in [[stage_in]], constant sky_vs_params& _19 [[buffer(0)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
out.gl_Position = _19.mvp * float4(in.position.xyz * 500.0, 1.0);
|
||||
out.gl_Position = _19.mvp * float4(in.position.xyz * 1000.0, 1.0);
|
||||
out.pos = in.position;
|
||||
return out;
|
||||
}
|
||||
@ -780,11 +780,11 @@ vs_sky_source_metal_macos := u8.[
|
||||
0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,
|
||||
0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,0x31,0x39,0x2e,0x6d,0x76,0x70,
|
||||
0x20,0x2a,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,
|
||||
0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x35,0x30,0x30,0x2e,
|
||||
0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,
|
||||
0x2e,0x70,0x6f,0x73,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,
|
||||
0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,
|
||||
0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x31,0x30,0x30,0x30,
|
||||
0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,
|
||||
0x74,0x2e,0x70,0x6f,0x73,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,
|
||||
0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,
|
||||
0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
||||
|
||||
@ -72,7 +72,7 @@ vs_trile_source_glsl430 := u8.[
|
||||
|
||||
void main()
|
||||
{
|
||||
frag_color = vec4(fnormal.xyz, 1.0);
|
||||
frag_color = vec4((fnormal.xyz + vec3(1.0)) * 0.5, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
@ -85,8 +85,9 @@ fs_trile_source_glsl430 := u8.[
|
||||
0x76,0x65,0x63,0x34,0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x0a,0x76,
|
||||
0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,
|
||||
0x63,0x34,0x28,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x2e,0x78,0x79,0x7a,0x2c,0x20,
|
||||
0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
0x63,0x34,0x28,0x28,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x2e,0x78,0x79,0x7a,0x20,
|
||||
0x2b,0x20,0x76,0x65,0x63,0x33,0x28,0x31,0x2e,0x30,0x29,0x29,0x20,0x2a,0x20,0x30,
|
||||
0x2e,0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
@ -135,7 +136,7 @@ vs_trile_source_glsl300es := u8.[
|
||||
|
||||
void main()
|
||||
{
|
||||
frag_color = vec4(fnormal.xyz, 1.0);
|
||||
frag_color = vec4((fnormal.xyz + vec3(1.0)) * 0.5, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
@ -150,9 +151,10 @@ fs_trile_source_glsl300es := u8.[
|
||||
0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x6e,0x6f,
|
||||
0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,
|
||||
0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,
|
||||
0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x66,0x6e,0x6f,0x72,0x6d,
|
||||
0x61,0x6c,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,
|
||||
0x0a,0x00,
|
||||
0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x28,0x66,0x6e,0x6f,0x72,
|
||||
0x6d,0x61,0x6c,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x76,0x65,0x63,0x33,0x28,0x31,
|
||||
0x2e,0x30,0x29,0x29,0x20,0x2a,0x20,0x30,0x2e,0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,
|
||||
0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#include <metal_stdlib>
|
||||
@ -241,7 +243,7 @@ vs_trile_source_metal_macos := u8.[
|
||||
fragment main0_out main0(main0_in in [[stage_in]])
|
||||
{
|
||||
main0_out out = {};
|
||||
out.frag_color = float4(in.fnormal.xyz, 1.0);
|
||||
out.frag_color = float4((in.fnormal.xyz + float3(1.0)) * 0.5, 1.0);
|
||||
return out;
|
||||
}
|
||||
|
||||
@ -265,10 +267,11 @@ fs_trile_source_metal_macos := u8.[
|
||||
0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,
|
||||
0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,
|
||||
0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,
|
||||
0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
|
||||
0x6c,0x6f,0x61,0x74,0x34,0x28,0x28,0x69,0x6e,0x2e,0x66,0x6e,0x6f,0x72,0x6d,0x61,
|
||||
0x6c,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x31,
|
||||
0x2e,0x30,0x29,0x29,0x20,0x2a,0x20,0x30,0x2e,0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,
|
||||
0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
trile_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc: sg_shader_desc;
|
||||
|
||||
@ -10,7 +10,7 @@ layout(binding=0) uniform sky_vs_params {
|
||||
out vec4 pos;
|
||||
|
||||
void main() {
|
||||
gl_Position = mvp * (vec4(position.xyz * 500.0, 1.0));
|
||||
gl_Position = mvp * (vec4(position.xyz * 1000.0, 1.0));
|
||||
pos = position;
|
||||
}
|
||||
@end
|
||||
|
||||
@ -25,7 +25,7 @@ out vec4 frag_color;
|
||||
|
||||
|
||||
void main() {
|
||||
frag_color = vec4(fnormal.xyz, 1.0);
|
||||
frag_color = vec4((fnormal.xyz + vec3(1.0, 1.0, 1.0)) * 0.5, 1.0);
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@ -2,32 +2,67 @@
|
||||
|
||||
#scope_file
|
||||
|
||||
trile_table : Table(string, Mesh);
|
||||
trile_gfx_table : Table(string, Trile_GFX);
|
||||
trile_table : Table(string, Trile);
|
||||
|
||||
#scope_export
|
||||
|
||||
Mesh :: struct {
|
||||
Trile_GFX :: struct {
|
||||
vertex_buffer : sg_buffer;
|
||||
normal_buffer : sg_buffer;
|
||||
vertex_count : s64;
|
||||
};
|
||||
|
||||
get_trile :: (name: string) -> (Mesh, success: bool) {
|
||||
success, value := table_find(*trile_table, name);
|
||||
return success, value;
|
||||
// @Note: Creates the gfx things if they are not yet created.
|
||||
// Could be a bad idea to do this implicitly. Think about it
|
||||
// once it's more clear how this whole trile storage thing
|
||||
// will pan out. -ktjst
|
||||
get_trile_gfx :: (name: string) -> (Trile_GFX, success: bool) {
|
||||
value, success := table_find(*trile_gfx_table, name);
|
||||
if !success {
|
||||
// Check if such a trile exists.
|
||||
trile, success_with_trile := get_trile(name);
|
||||
if success_with_trile {
|
||||
// Okay, so we have the trile, let's generate the GFX stuff for it.
|
||||
gfx := generate_trile_gfx_matias(trile);
|
||||
set_trile_gfx(name, gfx, true);
|
||||
return gfx, true;
|
||||
} else {
|
||||
return .{}, false;
|
||||
}
|
||||
}
|
||||
return value, success;
|
||||
}
|
||||
|
||||
set_trile :: (name: string, meshptr: Mesh) {
|
||||
// @ToDo: free old mesh...
|
||||
// @ToDo: consider if string should be copied..
|
||||
table_set(*trile_table, name, meshptr);
|
||||
set_trile_gfx :: (name: string, gfx: Trile_GFX, skip_preexist_check: bool = false) {
|
||||
if !skip_preexist_check {
|
||||
old_gfx, success := get_trile_gfx(name);
|
||||
if success {
|
||||
sg_destroy_buffer(old_gfx.vertex_buffer);
|
||||
sg_destroy_buffer(old_gfx.normal_buffer);
|
||||
}
|
||||
}
|
||||
table_set(*trile_gfx_table, name, gfx);
|
||||
}
|
||||
|
||||
set_trile :: (name: string, trile: Trile) {
|
||||
table_set(*trile_table, name, trile);
|
||||
}
|
||||
|
||||
get_trile :: (name: string) -> (*Trile, success: bool) {
|
||||
trileptr := table_find_pointer(*trile_table, name);
|
||||
if !trileptr {
|
||||
print("Failed to get trile with name: %\n", name);
|
||||
return null, false;
|
||||
}
|
||||
return trileptr, true;
|
||||
}
|
||||
|
||||
Material :: struct {
|
||||
roughness : float = 0.5;
|
||||
metallic : float = 0;
|
||||
emittance : float = 0;
|
||||
color : Vector3 = .{0.5, 1.0, 0.5};
|
||||
color : Vector3 = .{1.0, 0.0, 1.0};
|
||||
}
|
||||
|
||||
Trixel :: struct {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user