From af441960e73bb1ecf8e3d2a43e585d08471150b2 Mon Sep 17 00:00:00 2001 From: kp Date: Wed, 7 Aug 2024 04:59:01 -0500 Subject: [PATCH] Add skybox selection and fix UV issues --- Data/sandbox-log.txt | 384 +++++++++++++++++++++++++++++++--- KP3Dii/src/KP3D_Map.cpp | 28 ++- KP3Dii/src/KP3D_Map.h | 18 +- KP3Dii/src/KP3D_Resources.cpp | 54 ++++- KP3Dii/src/KP3D_Resources.h | 2 + Sandbox/src/Editor.cpp | 176 ++++++++++++---- Sandbox/src/Editor.h | 11 +- Sandbox/src/Sandbox.cpp | 11 +- 8 files changed, 581 insertions(+), 103 deletions(-) diff --git a/Data/sandbox-log.txt b/Data/sandbox-log.txt index 69b9315..f06dcba 100644 --- a/Data/sandbox-log.txt +++ b/Data/sandbox-log.txt @@ -1,40 +1,356 @@ -[03:38:05 PM] Info: Starting... +[04:55:10 AM] Info: Starting... KP3D version 2 =============================== Copyright (C) kpworld.xyz 2018-2024 Contact me! @kp_cftsz -[03:38:05 PM] Info: Initializing SDL -[03:38:05 PM] Info: Initializing OpenGL -[03:38:05 PM] Info: OpenGL version: 4.6.0 NVIDIA 536.23 -[03:38:05 PM] Info: Initializing GLEW -[03:38:05 PM] Info: Initializing SDL_mixer -[03:38:05 PM] Info: Reticulating splines... -[03:38:05 PM] Info: Ready! -[03:38:05 PM] Info: Loading script: build-cylinder.scm -[03:38:05 PM] Info: Loading script: build-stairs.scm -[03:38:05 PM] Info: Loading material resource: block.png -[03:38:05 PM] Info: Found normal map texture: materials/block_n.png -[03:38:05 PM] Info: Loading material resource: brick2.jpg -[03:38:05 PM] Info: Found normal map texture: materials/brick2_n.jpg -[03:38:05 PM] Info: Loading material resource: bricks.jpg -[03:38:05 PM] Info: Found normal map texture: materials/bricks_n.jpg -[03:38:05 PM] Info: Loading material resource: FLAT5_7.png -[03:38:05 PM] Info: Found normal map texture: materials/FLAT5_7_n.png -[03:38:05 PM] Info: Loading material resource: floor0.png -[03:38:05 PM] Info: Found normal map texture: materials/floor0_n.png -[03:38:05 PM] Info: Loading material resource: floor1.png -[03:38:05 PM] Info: Found normal map texture: materials/floor1_n.png -[03:38:05 PM] Info: Loading material resource: GRASS2.png -[03:38:05 PM] Info: Found normal map texture: materials/GRASS2_n.png -[03:38:05 PM] Info: Loading material resource: hardwood.jpg -[03:38:05 PM] Info: Found normal map texture: materials/hardwood_n.jpg -[03:38:05 PM] Info: Map init -[03:38:05 PM] Info: Finalized mesh with 49 batches -[03:38:14 PM] Info: Finalized mesh with 54 batches -[03:38:15 PM] Info: Finalized mesh with 54 batches -[03:38:18 PM] Info: Finalized mesh with 54 batches -[03:38:33 PM] Info: Finalized mesh with 60 batches -[03:38:41 PM] Info: Finalized mesh with 68 batches -[03:38:41 PM] Info: Finalized mesh with 68 batches +[04:55:10 AM] Info: Initializing SDL +[04:55:10 AM] Info: Initializing OpenGL +[04:55:10 AM] Info: OpenGL version: 4.6.0 NVIDIA 536.23 +[04:55:10 AM] Info: Initializing GLEW +[04:55:10 AM] Info: Initializing SDL_mixer +[04:55:10 AM] Info: Reticulating splines... +[04:55:10 AM] Info: Ready! +[04:55:10 AM] Info: Loading script: build-cylinder.scm +[04:55:10 AM] Info: Loading script: build-stairs.scm +[04:55:10 AM] Info: Loading material resource: block.png +[04:55:10 AM] Info: Found normal map texture: materials/block_n.png +[04:55:10 AM] Info: Loading material resource: brick2.jpg +[04:55:10 AM] Info: Found normal map texture: materials/brick2_n.jpg +[04:55:10 AM] Info: Loading material resource: bricks.jpg +[04:55:10 AM] Info: Found normal map texture: materials/bricks_n.jpg +[04:55:10 AM] Info: Loading material resource: FLAT5_7.png +[04:55:10 AM] Info: Found normal map texture: materials/FLAT5_7_n.png +[04:55:10 AM] Info: Loading material resource: floor0.png +[04:55:10 AM] Info: Found normal map texture: materials/floor0_n.png +[04:55:10 AM] Info: Loading material resource: floor1.png +[04:55:10 AM] Info: Found normal map texture: materials/floor1_n.png +[04:55:10 AM] Info: Loading material resource: GRASS2.png +[04:55:10 AM] Info: Found normal map texture: materials/GRASS2_n.png +[04:55:10 AM] Info: Loading material resource: hardwood.jpg +[04:55:10 AM] Info: Found normal map texture: materials/hardwood_n.jpg +[04:55:10 AM] Info: Loading texture resource: .kp3d/banner.png +[04:55:10 AM] Info: Loading texture resource: .kp3d/crosshair.png +[04:55:10 AM] Info: Loading texture resource: .kp3d/empty.png +[04:55:10 AM] Info: Loading texture resource: .kp3d/logo.png +[04:55:10 AM] Info: Loading texture resource: .kp3d/map_grid.png +[04:55:10 AM] Info: Loading texture resource: .kp3d/not_found.png +[04:55:10 AM] Info: Loading texture resource: .kp3d/skybox.png +[04:55:10 AM] Info: Loading texture resource: .kp3d/uv_test.png +[04:55:10 AM] Info: Loading texture resource: .kp3d/water.png +[04:55:10 AM] Info: Loading texture resource: dot.png +[04:55:10 AM] Info: Loading texture resource: editor/stem.png +[04:55:10 AM] Info: Loading texture resource: logo.png +[04:55:10 AM] Info: Loading texture resource: skyboxes/sky50e2dd1d496fc.jpg +[04:55:10 AM] Info: Loading texture resource: skyboxes/sky8.jpg +[04:55:10 AM] Info: Loading texture resource: skyboxes/sky9.jpg +[04:55:10 AM] Info: Loading texture resource: skyboxes/skybox.jpg +[04:55:10 AM] Info: Loading texture resource: skyboxes/skybox_11.jpg +[04:55:10 AM] Info: Loading texture resource: skyboxes/skybox_14.jpg +[04:55:10 AM] Info: Loading texture resource: skyboxes/skybox_15.jpg +[04:55:10 AM] Info: Loading texture resource: skyboxes/skybox_3.jpg +[04:55:10 AM] Info: Loading texture resource: skybox_16.jpg +[04:55:10 AM] Info: Map init +[04:55:10 AM] Info: Finalized mesh with 49 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:23 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:24 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:25 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:26 AM] Info: Finalized mesh with 48 batches +[04:55:27 AM] Info: Finalized mesh with 48 batches +[04:55:27 AM] Info: Finalized mesh with 48 batches +[04:55:27 AM] Info: Finalized mesh with 48 batches +[04:55:27 AM] Info: Finalized mesh with 48 batches +[04:55:27 AM] Info: Finalized mesh with 48 batches +[04:55:27 AM] Info: Finalized mesh with 48 batches +[04:55:27 AM] Info: Finalized mesh with 48 batches +[04:55:27 AM] Info: Finalized mesh with 48 batches +[04:55:27 AM] Info: Finalized mesh with 48 batches +[04:55:27 AM] Info: Finalized mesh with 48 batches +[04:55:27 AM] Info: Finalized mesh with 48 batches +[04:55:27 AM] Info: Finalized mesh with 48 batches +[04:55:27 AM] Info: Finalized mesh with 48 batches +[04:55:27 AM] Info: Finalized mesh with 48 batches +[04:55:27 AM] Info: Finalized mesh with 48 batches +[04:55:27 AM] Info: Finalized mesh with 48 batches +[04:55:27 AM] Info: Finalized mesh with 48 batches +[04:55:27 AM] Info: Finalized mesh with 48 batches +[04:55:27 AM] Info: Finalized mesh with 48 batches +[04:55:27 AM] Info: Finalized mesh with 48 batches +[04:55:27 AM] Info: Finalized mesh with 48 batches +[04:55:30 AM] Info: Finalized mesh with 48 batches +[04:55:30 AM] Info: Finalized mesh with 48 batches +[04:55:30 AM] Info: Finalized mesh with 48 batches +[04:55:30 AM] Info: Finalized mesh with 48 batches +[04:55:30 AM] Info: Finalized mesh with 48 batches +[04:55:30 AM] Info: Finalized mesh with 48 batches +[04:55:30 AM] Info: Finalized mesh with 48 batches +[04:55:30 AM] Info: Finalized mesh with 48 batches +[04:55:30 AM] Info: Finalized mesh with 48 batches +[04:55:30 AM] Info: Finalized mesh with 48 batches +[04:55:30 AM] Info: Finalized mesh with 48 batches +[04:55:30 AM] Info: Finalized mesh with 48 batches +[04:55:30 AM] Info: Finalized mesh with 48 batches +[04:55:30 AM] Info: Finalized mesh with 48 batches +[04:55:30 AM] Info: Finalized mesh with 48 batches +[04:55:30 AM] Info: Finalized mesh with 48 batches +[04:55:30 AM] Info: Finalized mesh with 48 batches +[04:55:30 AM] Info: Finalized mesh with 48 batches +[04:55:30 AM] Info: Finalized mesh with 48 batches +[04:55:30 AM] Info: Finalized mesh with 48 batches +[04:55:30 AM] Info: Finalized mesh with 48 batches +[04:55:30 AM] Info: Finalized mesh with 48 batches +[04:55:30 AM] Info: Finalized mesh with 48 batches +[04:55:31 AM] Info: Finalized mesh with 48 batches +[04:55:31 AM] Info: Finalized mesh with 47 batches +[04:55:31 AM] Info: Finalized mesh with 48 batches +[04:55:31 AM] Info: Finalized mesh with 48 batches +[04:55:31 AM] Info: Finalized mesh with 48 batches +[04:55:31 AM] Info: Finalized mesh with 48 batches +[04:55:31 AM] Info: Finalized mesh with 48 batches +[04:55:31 AM] Info: Finalized mesh with 48 batches +[04:55:31 AM] Info: Finalized mesh with 48 batches +[04:55:31 AM] Info: Finalized mesh with 48 batches +[04:55:31 AM] Info: Finalized mesh with 48 batches +[04:55:31 AM] Info: Finalized mesh with 48 batches +[04:55:31 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:32 AM] Info: Finalized mesh with 48 batches +[04:55:33 AM] Info: Finalized mesh with 48 batches +[04:55:33 AM] Info: Finalized mesh with 48 batches +[04:55:33 AM] Info: Finalized mesh with 48 batches +[04:55:33 AM] Info: Finalized mesh with 48 batches +[04:55:34 AM] Info: Finalized mesh with 48 batches +[04:55:34 AM] Info: Finalized mesh with 48 batches +[04:55:34 AM] Info: Finalized mesh with 48 batches +[04:55:34 AM] Info: Finalized mesh with 48 batches +[04:55:34 AM] Info: Finalized mesh with 48 batches +[04:55:34 AM] Info: Finalized mesh with 48 batches +[04:55:34 AM] Info: Finalized mesh with 48 batches +[04:55:34 AM] Info: Finalized mesh with 48 batches +[04:55:34 AM] Info: Finalized mesh with 48 batches +[04:55:34 AM] Info: Finalized mesh with 48 batches +[04:55:34 AM] Info: Finalized mesh with 48 batches +[04:55:34 AM] Info: Finalized mesh with 48 batches +[04:55:34 AM] Info: Finalized mesh with 48 batches +[04:55:34 AM] Info: Finalized mesh with 48 batches +[04:55:34 AM] Info: Finalized mesh with 48 batches +[04:55:34 AM] Info: Finalized mesh with 48 batches diff --git a/KP3Dii/src/KP3D_Map.cpp b/KP3Dii/src/KP3D_Map.cpp index 77523e3..448f781 100644 --- a/KP3Dii/src/KP3D_Map.cpp +++ b/KP3Dii/src/KP3D_Map.cpp @@ -304,6 +304,10 @@ void Map::BuildQuad(Sector& sector, Wall& wall, Flat& flat_topr, Flat& flat_bott // Fix up the UVs so they keep the right scale float tw = texture_scale / wall.materials[mat_type]->textures[MAT_TEX_DIFFUSE].GetWidth(); float th = texture_scale / wall.materials[mat_type]->textures[MAT_TEX_DIFFUSE].GetHeight(); + if (flip) + tw *= -1; + // TODO: Consider offsetting the UV by the length of the wall beside it + // This will mitigate most texture alignment issues you'd otherwise have to fix manually Vertex3D vtxa = Vertex3D(fva, Vec2(au * tw + uv_offset.x/128.0f, av * th + uv_offset.y/128.0f)); Vertex3D vtxb = Vertex3D(fvb, Vec2(bu * tw + uv_offset.x/128.0f, bv * th + uv_offset.y/128.0f)); Vertex3D vtxc = Vertex3D(fvc, Vec2(cu * tw + uv_offset.x/128.0f, cv * th + uv_offset.y/128.0f)); @@ -558,7 +562,7 @@ void Map::Init() m_mesh.Reset(); sectors.reserve(10000); - BuildSkybox("skybox_16.jpg"); + BuildSkybox(res::texture_cache["skyboxes/skybox_14.jpg"].get()); BuildGrid(); //static Texture tex, tex2, tex3, tex4; @@ -820,8 +824,14 @@ void Map::Render() kp3d::Renderer3D::PopShader(); } -void Map::BuildSkybox(const std::string& texture_path, float scale) +void Map::BuildSkybox(const Texture* texture, float scale) { + if (const auto& old_batches = skybox_data.mesh.GetBatchesRef(); + !old_batches.empty() && old_batches.back().texture == texture) + return; + + skybox_data.texture = texture; + float lxo = 3.0f / 4.0f, lyo = 1.0f / 3.0f; // left quad uv offset float rxo = 1.0f / 4.0f, ryo = 1.0f / 3.0f; // right quad uv offset float fxo = 2.0f / 4.0f, fyo = 1.0f / 3.0f; // front quad uv offset @@ -869,19 +879,19 @@ void Map::BuildSkybox(const std::string& texture_path, float scale) Vertex3D(Vec3(-1.0f, 1.0f, 1.0f), Vec2(-(kxo + u), -(kyo + v))), Vertex3D(Vec3( 1.0f, -1.0f, 1.0f), Vec2(-(kxo + n), -(kyo + n))) }; - m_skybox_data.texture.Load(texture_path); - m_skybox_data.mesh.Reset(); - m_skybox_data.mesh.AddBatch(&m_skybox_data.texture, skybox_vertex_data, true); - m_skybox_data.mesh.Finalize(); - m_skybox_data.transform.scale = Vec3(scale); + // m_skybox_data.texture.Load(texture_path); + skybox_data.mesh.Reset(); + skybox_data.mesh.AddBatch(skybox_data.texture, skybox_vertex_data, true); + skybox_data.mesh.Finalize(); + skybox_data.transform.scale = Vec3(scale); } void Map::RenderSkybox() { glDisable(GL_DEPTH_TEST); Renderer3D::PushShader(Renderer3D::GetDefaultShader()); - m_skybox_data.transform.translation = Renderer3D::GetPrimaryCamera()->position; - Renderer3D::DrawMesh(m_skybox_data.mesh, m_skybox_data.transform); + skybox_data.transform.translation = Renderer3D::GetPrimaryCamera()->position; + Renderer3D::DrawMesh(skybox_data.mesh, skybox_data.transform); glEnable(GL_DEPTH_TEST); } diff --git a/KP3Dii/src/KP3D_Map.h b/KP3Dii/src/KP3D_Map.h index 8fa74b7..b76b5a3 100644 --- a/KP3Dii/src/KP3D_Map.h +++ b/KP3Dii/src/KP3D_Map.h @@ -49,8 +49,16 @@ struct Wall UFLAG_DOUBLESIDED = 1 << 1 }; - const Material* materials[3]; - XYf uv_offset[3]; + const Material* materials[3] = { + nullptr, + nullptr, + nullptr + }; + XYf uv_offset[3] = { + {0, 0}, + {0, 0}, + {0, 0} + }; XYf start; XYf end; @@ -112,7 +120,7 @@ struct Sector struct Skybox { - Texture texture; + const Texture* texture; StaticMesh mesh; Transform transform; }; @@ -154,7 +162,7 @@ public: void Update(); void Render(); - void BuildSkybox(const std::string& texture_path, float scale = 128.0f); + void BuildSkybox(const Texture* texture, float scale = 128.0f); void RenderSkybox(); void BuildGrid(float y = 0.0f); @@ -168,6 +176,7 @@ public: bool render_wireframe = true; float texture_scale = 128.0f; Vec3 grid_box[6]; + Skybox skybox_data; float test_u = -1.5f, test_l = 3.0f; @@ -177,7 +186,6 @@ private: Shader m_grid_shader; float m_grid_y = 0.0f; Texture m_grid_texture; - Skybox m_skybox_data; Transform m_transform; Texture m_dot; std::vector m_dots; diff --git a/KP3Dii/src/KP3D_Resources.cpp b/KP3Dii/src/KP3D_Resources.cpp index 703ff4b..625e67d 100644 --- a/KP3Dii/src/KP3D_Resources.cpp +++ b/KP3Dii/src/KP3D_Resources.cpp @@ -10,13 +10,14 @@ namespace kp3d::res { std::unordered_map> material_cache; +std::unordered_map> texture_cache; void LoadMaterials() { material_cache.clear(); // Load every available texture - for (const auto& entry: std::filesystem::recursive_directory_iterator(kp3d::sys::GetTextureDir() + "materials/")) + for (const auto& entry: std::filesystem::recursive_directory_iterator(sys::GetTextureDir() + "materials/")) { if (entry.is_directory()) continue; @@ -24,13 +25,13 @@ void LoadMaterials() std::filesystem::path entry_path = entry.path(); std::string path_str = entry_path.string(); - if (!kp3d::str::EndsWith(path_str, ".png") && !kp3d::str::EndsWith(path_str, ".jpg")) + if (!str::EndsWith(path_str, ".png") && !str::EndsWith(path_str, ".jpg")) continue; - std::string filename = std::filesystem::proximate(path_str, kp3d::sys::GetTextureDir() + "materials/").string(); + std::string filename = std::filesystem::proximate(path_str, sys::GetTextureDir() + "materials/").string(); std::replace(filename.begin(), filename.end(), '\\', '/'); - if (kp3d::str::EndsWith(path_str, "_n.png") || kp3d::str::EndsWith(path_str, "_n.jpg")) + if (str::EndsWith(path_str, "_n.png") || str::EndsWith(path_str, "_n.jpg")) continue; KP3D_LOG_INFO("Loading material resource: {}", filename); @@ -47,4 +48,49 @@ void LoadMaterials() } } +void LoadTextures() +{ + // Load every available texture + for (const auto& entry: std::filesystem::recursive_directory_iterator(sys::GetTextureDir())) + { + if (entry.is_directory()) + continue; + + std::filesystem::path entry_path = entry.path(); + std::string path_str = entry_path.string(); + + if (!str::EndsWith(path_str, ".png") && !str::EndsWith(path_str, ".jpg")) + continue; + + std::string filename = std::filesystem::proximate(path_str, sys::GetTextureDir()).string(); + std::replace(filename.begin(), filename.end(), '\\', '/'); + + if (str::StartsWith(filename, "materials/")) + { + // We can either just continue or make this point to the texture in the material cache. + // I think I'll opt for the latter. + // We can change this behavior if we decide it's not necessary though I guess. + std::string mat_path = filename.substr(10); + if (str::EndsWith(mat_path, "_n.png") || str::EndsWith(mat_path, "_n.jpg")) + continue; + if (!material_cache.count(mat_path)) + { + KP3D_LOG_WARNING("LoadTextures() apparently called before LoadMaterials()! Found {} ({})", mat_path, filename); + } + else + { + // Initializing a shared pointer from an already existing pointer to something + // Not sure how to feel about this... + texture_cache.emplace(filename, &material_cache[mat_path]->textures[MAT_TEX_DIFFUSE]); + continue; + } + } + + KP3D_LOG_INFO("Loading texture resource: {}", filename); + + texture_cache.emplace(filename, std::make_shared()); + texture_cache[filename]->Load(filename, true, Texture::FILTER_LINEAR); + } +} + } // namespace kp3d::res diff --git a/KP3Dii/src/KP3D_Resources.h b/KP3Dii/src/KP3D_Resources.h index 08f47d9..5a2a4c3 100644 --- a/KP3Dii/src/KP3D_Resources.h +++ b/KP3Dii/src/KP3D_Resources.h @@ -11,7 +11,9 @@ namespace kp3d::res { extern std::unordered_map> material_cache; +extern std::unordered_map> texture_cache; void LoadMaterials(); +void LoadTextures(); } // namespace kp3d::res diff --git a/Sandbox/src/Editor.cpp b/Sandbox/src/Editor.cpp index 26c4a14..aaefa43 100644 --- a/Sandbox/src/Editor.cpp +++ b/Sandbox/src/Editor.cpp @@ -1,3 +1,6 @@ +// +// WARNING: This code is messy atm, will clean later (allegedly) +// #include "Editor.h" #include @@ -237,16 +240,16 @@ void Editor::Update() KEY_SHORTCUT(SPACE, m_mode = MODE_NORMAL); KEY_SHORTCUT(V, m_mode = MODE_BUILD); - KEY_SHORTCUT(Z, { if (sandbox->IsKeyDown(kp3d::KEY_LCTRL)) Undo(); }); - KEY_SHORTCUT(Y, { if (sandbox->IsKeyDown(kp3d::KEY_LCTRL)) Redo(); }); + KEY_SHORTCUT(F2, show_grid ^= 1); + KEY_SHORTCUT(TAB, show_selection_info ^= 1); switch (m_mode) { @@ -257,7 +260,8 @@ void Editor::Update() void Editor::RenderMap() { - sandbox->map.RenderGrid(); + if (show_grid) + sandbox->map.RenderGrid(); switch (m_mode) { @@ -296,7 +300,7 @@ void Editor::RebuildMap() { double start = kp3d::CurrentTimeInMilliseconds().count(); sandbox->map.Rebuild(kp3d::GEN_NORMALS); - + sandbox->map.BuildSkybox(sandbox->map.skybox_data.texture); m_build_time = kp3d::CurrentTimeInMilliseconds().count() - start; } @@ -859,28 +863,43 @@ void Editor::RenderUI() ImGui::BeginMainMenuBar(); if (ImGui::BeginMenu("File")) { - if (ImGui::MenuItem("Exit")) exit(0); + if (ImGui::MenuItem("Save", "Ctrl+S")) {} + if (ImGui::MenuItem("Save As...", "Ctrl+Shift+S")) {} + ImGui::Separator(); + if (ImGui::MenuItem("Exit", "Alt+F4")) exit(0); ImGui::EndMenu(); } if (ImGui::BeginMenu("Edit")) { - if (ImGui::MenuItem("Undo")) Undo(); - if (ImGui::MenuItem("Redo")) Redo(); + if (ImGui::MenuItem("Undo", "Ctrl+Z")) Undo(); + if (ImGui::MenuItem("Redo", "Ctrl+Y")) Redo(); + ImGui::Separator(); + if (ImGui::MenuItem("Set Skybox...")) + RenderUITextureSelect(&sandbox->map.skybox_data.texture, "skyboxes/"); + ImGui::EndMenu(); + } + if (ImGui::BeginMenu("Mode")) + { + if (ImGui::MenuItem("Normal Mode", "Space")) m_mode = MODE_NORMAL; + if (ImGui::MenuItem("Build Mode", "V")) m_mode = MODE_BUILD; ImGui::EndMenu(); } if (ImGui::BeginMenu("View")) { - ImGui::Checkbox("Info Overlay", &show_info_overlay); - ImGui::Checkbox("Selection Info", &show_selection_info); + ImGui::MenuItem("Show Info Overlay", nullptr, &show_info_overlay); + // ImGui::Checkbox("Selection Info", &show_selection_info); + ImGui::MenuItem("Show Selection Info", "Tab", &show_selection_info); ImGui::Separator(); - ImGui::Checkbox("Wireframe", &sandbox->map.render_wireframe); + ImGui::MenuItem("Show Wireframe", "F1", &sandbox->map.render_wireframe); + ImGui::MenuItem("Show Grid", "F2", &show_grid); ImGui::Separator(); - ImGui::Checkbox("Console", &kp3d::console::open); + ImGui::MenuItem("Open Console", "`", & kp3d::console::open); ImGui::EndMenu(); } if (ImGui::BeginMenu("Help")) { - ImGui::Checkbox("About KP3Dii", &show_about_view); + if (ImGui::MenuItem("About KP3Dii...", nullptr)) + show_about_view = true; ImGui::EndMenu(); } ImGui::EndMainMenuBar(); @@ -964,6 +983,9 @@ void Editor::RenderUI() if (!m_materials_to_update.empty()) RenderUIMaterialModal(); + if (!m_textures_to_update.empty()) + RenderUITextureModal(); + anything_hovered = ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow) || ImGui::IsAnyItemHovered(); } @@ -1068,7 +1090,6 @@ void Editor::RenderUIMaterialSelect(const char* name, int type, const kp3d::Mate std::string str = "Set " + kp3d::str::ToLower(name) + " material..."; if (ImGui::Button(str.c_str())) {} } - } void Editor::RenderUIMaterialModal() @@ -1079,43 +1100,31 @@ void Editor::RenderUIMaterialModal() ImGui::SetNextWindowSize(ImVec2(960, 720), ImGuiCond_FirstUseEver); if (ImGui::BeginPopupModal("Select Material")) { - ImGui::InputText("Filter by Name", m_tex_filter_buf, std::size(m_tex_filter_buf)); - + ImGui::InputText("Filter by Name", m_mat_filter_buf, std::size(m_mat_filter_buf)); ImGui::Separator(); - - bool should_remove_texture = false; - if (ImGui::Button("Remove material")) - should_remove_texture = true; - - bool should_close = false; - if (ImGui::Button("Cancel")) - should_close = true; + bool should_remove_texture = ImGui::Button("Remove material"); + bool should_close = ImGui::Button("Cancel"); ImGui::SameLine(); - - if (ImGui::Button("Clear search")) - memset(m_tex_filter_buf, 0, 512); - + if (ImGui::Button("Clear search")) memset(m_mat_filter_buf, 0, 512); ImGui::Separator(); - - ImGui::BeginChild("TextureList"); + ImGui::BeginChild("MaterialList"); int i = 1; const kp3d::Material* chosen_tex = nullptr; bool should_update_texture = false; using namespace std::regex_constants; for (const auto& [path, tex_ptr] : kp3d::res::material_cache) { - if (strlen(m_tex_filter_buf) > 0) + if (strlen(m_mat_filter_buf) > 0) { try { - if (!std::regex_search(path, std::regex(std::string(m_tex_filter_buf), icase))) + if (!std::regex_search(path, std::regex(std::string(m_mat_filter_buf), icase))) continue; } catch (std::regex_error& e) { } } - const kp3d::Material* tex = tex_ptr.get(); ImGui::BeginGroup(); ImGui::PushID(i); @@ -1129,18 +1138,13 @@ void Editor::RenderUIMaterialModal() } ImGui::PopID(); ImGui::EndGroup(); - //int ww = (int)ImGui::GetTopMostPopupModal()->Size.x; int ww = (int)ImGui::GetWindowSize().x; - - // Some ugly hardcoding here - // Basically this controls the texture preview line wrapping - if (i % ((ww <= 256 ? 602 : ww - 96) / 128) != 0) + if (i % ((ww <= 256 ? 602 : ww - 96) / 128) != 0) // line wrap hack ImGui::SameLine(); i++; } ImGui::EndChild(); - // Should we rebuild the map when we change stuff? I guess. if (should_remove_texture) { for (auto mats : m_materials_to_update) @@ -1170,7 +1174,103 @@ void Editor::RenderUIMaterialModal() ImGui::EndPopup(); } +} +// Should probably rename this as its behavior doesn't reflect RenderUIMaterialSelect +void Editor::RenderUITextureSelect(const kp3d::Texture** texture, const char* filter) +{ + memset(m_tex_filter_buf, '\0', std::size(m_tex_filter_buf)); + + if (filter) + strcpy(m_tex_filter_buf, filter); + + m_textures_to_update.clear(); + m_textures_to_update.push_back(texture); + should_show_texture_modal = true; + +} + +void Editor::RenderUITextureModal() +{ + if (should_show_texture_modal) + ImGui::OpenPopup("Select Texture"); + + ImGui::SetNextWindowSize(ImVec2(960, 720), ImGuiCond_FirstUseEver); + if (ImGui::BeginPopupModal("Select Texture")) + { + ImGui::InputText("Filter by Name##tex", m_tex_filter_buf, std::size(m_tex_filter_buf)); + ImGui::Separator(); + bool should_remove_texture = ImGui::Button("Remove texture##tex"); + bool should_close = ImGui::Button("Cancel##tex"); + ImGui::SameLine(); + if (ImGui::Button("Clear search##tex")) memset(m_tex_filter_buf, 0, 512); + ImGui::Separator(); + ImGui::BeginChild("TextureList"); + int i = 10000; + const kp3d::Texture* chosen_tex = nullptr; + bool should_update_texture = false; + using namespace std::regex_constants; + for (const auto& [path, tex_ptr] : kp3d::res::texture_cache) + { + if (strlen(m_tex_filter_buf) > 0) + { + try + { + if (!std::regex_search(path, std::regex(std::string(m_tex_filter_buf), icase))) + continue; + } + catch (std::regex_error& e) + { + } + } + const kp3d::Texture* tex = tex_ptr.get(); + ImGui::BeginGroup(); + ImGui::PushID(i); + bool tex_img_button = ImGui::ImageButton((ImTextureID)tex->GetGLID(), {128, 128}); + if (ImGui::IsItemHovered()) + ImGui::SetTooltip(path.c_str()); + if (tex_img_button) + { + should_update_texture = true; + chosen_tex = tex; + } + ImGui::PopID(); + ImGui::EndGroup(); + int ww = (int)ImGui::GetWindowSize().x; + if (i % ((ww <= 256 ? 602 : ww - 96) / 128) != 0) // line wrap hack + ImGui::SameLine(); + i++; + } + ImGui::EndChild(); + if (should_remove_texture) + { + for (auto texs: m_textures_to_update) + *texs = nullptr; + m_textures_to_update.clear(); + ImGui::CloseCurrentPopup(); + should_show_texture_modal = false; + RebuildMap(); + } + + if (should_close) + { + ImGui::CloseCurrentPopup(); + should_show_texture_modal = false; + RebuildMap(); + } + + if (should_update_texture) + { + for (auto texs: m_textures_to_update) + *texs = chosen_tex; + m_textures_to_update.clear(); + ImGui::CloseCurrentPopup(); + should_show_texture_modal = false; + RebuildMap(); + } + + ImGui::EndPopup(); + } } void Editor::OnScrollWheel(const kp3d::ScrollWheelEvent* e) diff --git a/Sandbox/src/Editor.h b/Sandbox/src/Editor.h index eb4267a..da1ba00 100644 --- a/Sandbox/src/Editor.h +++ b/Sandbox/src/Editor.h @@ -51,11 +51,12 @@ public: void RenderUIAbout(); void RenderUIMaterialSelect(const char* name, int type, const kp3d::Material** material); void RenderUIMaterialModal(); + void RenderUITextureSelect(const kp3d::Texture** texture, const char* filter = nullptr); + void RenderUITextureModal(); void OnScrollWheel(const kp3d::ScrollWheelEvent* e); void OnKeyPress(const kp3d::KeyPressEvent* e); - // Undo/redo stack struct MapData { @@ -87,10 +88,14 @@ private: bool show_info_overlay = true; bool show_selection_info = false; bool show_about_view = false; - bool should_show_material_modal = false; - char m_tex_filter_buf[512]; + bool show_grid = true; bool editing_gizmo = false; + bool should_show_material_modal = false; + bool should_show_texture_modal = false; + char m_mat_filter_buf[512]; + char m_tex_filter_buf[512]; std::vector m_materials_to_update; + std::vector m_textures_to_update; WallUpdate wall_update; bool can_wall_update = false; diff --git a/Sandbox/src/Sandbox.cpp b/Sandbox/src/Sandbox.cpp index b526cc2..5e76ab5 100644 --- a/Sandbox/src/Sandbox.cpp +++ b/Sandbox/src/Sandbox.cpp @@ -17,6 +17,7 @@ Sandbox::Sandbox(const std::string& path): kp3d::Game(path, "sandbox-cfg.json", "sandbox-log.txt") { kp3d::res::LoadMaterials(); + kp3d::res::LoadTextures(); tex.Load("logo.png"); crosshair.Load(".kp3d/crosshair.png"); @@ -71,16 +72,6 @@ void Sandbox::Update() map.render_wireframe ^= 1; KeyReset(kp3d::KEY_F1); } - if (IsKeyDown(kp3d::KEY_F2)) - { - map.Rebuild(kp3d::GEN_NORMALS); - KeyReset(kp3d::KEY_F2); - } - if (IsKeyDown(kp3d::KEY_F3)) - { - map.Rebuild(kp3d::GEN_SMOOTH_NORMALS); - KeyReset(kp3d::KEY_F3); - } if (IsKeyDown(kp3d::KEY_B)) { //map.Init();