Add system for loading models in the editor

This commit is contained in:
kp 2024-09-08 00:20:32 -05:00
parent e3044c681b
commit e5ba584cc0
14 changed files with 26358 additions and 234 deletions

View file

@ -0,0 +1 @@
fumo/reimu_fumo.obj

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 MiB

File diff suppressed because it is too large Load diff

View file

@ -68,11 +68,24 @@ void main()
vec3 N = normalize((v_normal));
mat3 TBN = mat3(T, B, N);
vec3 norm = normalize(TBN * tangentNormal);
//norm = vec3(0,1,0);
if (texture(u_normal_texture, v_texcoord).x == 1.0)
{
// disable normal mapping if there's no normal texture
// is this the best way to go about this? idk, but it works for now
norm = vec3(0,1,0);
}
vec4 texv = texture(u_texture, v_texcoord);
vec4 ambient = vec4(0.1, 0.1, 0.1, 1.0) * 5.5, light = ambient;
// debug: output normal texture only
// v_output = texture(u_normal_texture, v_texcoord);
// return;
// debug: output normal
// v_output = vec4(norm, 1.0);
// return;
light += MakeLight(norm, vec3(2.0, 10.0, -24.0), vec3(0.7), /*5.0*/ 1000.0, 1.0, 1.0);
light += MakeLight(norm, vec3(5.0, 2.0, -7.0 + cos(u_time/35.0) * 2.0), vec3(1.0, 0.6, 0.0), 5.0, 0.6, 1.0);
light += MakeLight(norm, vec3(7, 2.0, -7.0 + -cos(u_time / 30.0) * 1.0), vec3(0.6, 0.9, 1.0), 5.0, 0.6, 1.0);

View file

@ -1,223 +1,226 @@
[11:49:42 PM] Info: Starting...
[00:19:47 AM] Info: Starting...
KP3D version 2
===============================
Copyright (C) kpworld.xyz 2018-2024
Contact me! @kp_cftsz
[11:49:42 PM] Info: Initializing SDL
[11:49:42 PM] Info: Initializing OpenGL
[11:49:42 PM] Info: OpenGL version: 4.6.0 NVIDIA 536.23
[11:49:42 PM] Info: Initializing GLEW
[11:49:42 PM] Info: Initializing SDL_mixer
[11:49:42 PM] Info: Reticulating splines...
[11:49:42 PM] Info: Ready!
[11:49:42 PM] Info: Loading script: build-cylinder.scm
[11:49:42 PM] Info: Loading script: build-stairs.scm
[11:49:42 PM] Info: Loading material resource: block.png
[11:49:42 PM] Info: Found normal map texture: materials/block_n.png
[11:49:42 PM] Info: Loading material resource: brick2.jpg
[11:49:42 PM] Info: Found normal map texture: materials/brick2_n.jpg
[11:49:42 PM] Info: Loading material resource: bricks.jpg
[11:49:43 PM] Info: Found normal map texture: materials/bricks_n.jpg
[11:49:43 PM] Info: Loading material resource: FLAT5_7.png
[11:49:43 PM] Info: Found normal map texture: materials/FLAT5_7_n.png
[11:49:43 PM] Info: Loading material resource: floor0.png
[11:49:43 PM] Info: Found normal map texture: materials/floor0_n.png
[11:49:43 PM] Info: Loading material resource: floor1.png
[11:49:43 PM] Info: Found normal map texture: materials/floor1_n.png
[11:49:43 PM] Info: Loading material resource: GRASS2.png
[11:49:43 PM] Info: Found normal map texture: materials/GRASS2_n.png
[11:49:43 PM] Info: Loading material resource: hardwood.jpg
[11:49:43 PM] Info: Found normal map texture: materials/hardwood_n.jpg
[11:49:43 PM] Info: Loading texture resource: .kp3d/banner.png
[11:49:43 PM] Info: Loading texture resource: .kp3d/crosshair.png
[11:49:43 PM] Info: Loading texture resource: .kp3d/empty.png
[11:49:43 PM] Info: Loading texture resource: .kp3d/logo.png
[11:49:43 PM] Info: Loading texture resource: .kp3d/map_grid.png
[11:49:43 PM] Info: Loading texture resource: .kp3d/not_found.png
[11:49:43 PM] Info: Loading texture resource: .kp3d/skybox.png
[11:49:43 PM] Info: Loading texture resource: .kp3d/uv_test.png
[11:49:43 PM] Info: Loading texture resource: .kp3d/water.png
[11:49:43 PM] Info: Loading texture resource: dot.png
[11:49:43 PM] Info: Loading texture resource: editor/stem.png
[11:49:43 PM] Info: Loading texture resource: logo.png
[11:49:43 PM] Info: Loading texture resource: skyboxes/sky50e2dd1d496fc.jpg
[11:49:43 PM] Info: Loading texture resource: skyboxes/sky8.jpg
[11:49:43 PM] Info: Loading texture resource: skyboxes/sky9.jpg
[11:49:43 PM] Info: Loading texture resource: skyboxes/skybox.jpg
[11:49:43 PM] Info: Loading texture resource: skyboxes/skybox_11.jpg
[11:49:43 PM] Info: Loading texture resource: skyboxes/skybox_14.jpg
[11:49:43 PM] Info: Loading texture resource: skyboxes/skybox_15.jpg
[11:49:43 PM] Info: Loading texture resource: skyboxes/skybox_3.jpg
[11:49:43 PM] Info: Loading texture resource: skybox_16.jpg
[11:49:43 PM] Info: Map init
[11:49:43 PM] Info: Finalized mesh with 49 batches
[11:49:43 PM] Info: # of bones for model konata/Konata_Anim_2.dae: 23
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Pelvis: 432
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine: 279
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine1: 350
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 515
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 132
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 25
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 6
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 219
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_UpperArm: 226
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Forearm: 342
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Hand: 254
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Clavicle: 172
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_UpperArm: 208
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Forearm: 333
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Hand: 248
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Thigh: 475
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Calf: 382
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Foot: 319
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Toe0: 159
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Thigh: 490
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Calf: 359
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Foot: 304
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Toe0: 154
[11:49:43 PM] Info: # of bones for model konata/Konata_Anim_2.dae: 7
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine: 312
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine1: 168
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 164
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 154
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 408
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 3912
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 14
[11:49:43 PM] Info: # of bones for model konata/Konata_Anim_2.dae: 8
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 30
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 26
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 123
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 1027
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 87
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_UpperArm: 5
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Clavicle: 64
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_UpperArm: 3
[11:49:43 PM] Info: Starting animation
[11:49:43 PM] Info: # of bones for model konata/Konata_Anim_2.dae: 23
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Pelvis: 432
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine: 279
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine1: 350
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 515
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 132
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 25
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 6
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 219
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_UpperArm: 226
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Forearm: 342
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Hand: 254
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Clavicle: 172
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_UpperArm: 208
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Forearm: 333
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Hand: 248
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Thigh: 475
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Calf: 382
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Foot: 319
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Toe0: 159
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Thigh: 490
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Calf: 359
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Foot: 304
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Toe0: 154
[11:49:43 PM] Info: # of bones for model konata/Konata_Anim_2.dae: 7
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine: 312
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine1: 168
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 164
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 154
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 408
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 3912
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 14
[11:49:43 PM] Info: # of bones for model konata/Konata_Anim_2.dae: 8
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 30
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 26
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 123
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 1027
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 87
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_UpperArm: 5
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Clavicle: 64
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_UpperArm: 3
[11:49:43 PM] Info: Starting animation
[11:49:43 PM] Info: # of bones for model konata/Konata_Anim_2.dae: 23
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Pelvis: 432
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine: 279
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine1: 350
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 515
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 132
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 25
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 6
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 219
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_UpperArm: 226
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Forearm: 342
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Hand: 254
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Clavicle: 172
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_UpperArm: 208
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Forearm: 333
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Hand: 248
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Thigh: 475
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Calf: 382
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Foot: 319
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Toe0: 159
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Thigh: 490
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Calf: 359
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Foot: 304
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Toe0: 154
[11:49:43 PM] Info: # of bones for model konata/Konata_Anim_2.dae: 7
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine: 312
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine1: 168
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 164
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 154
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 408
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 3912
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 14
[11:49:43 PM] Info: # of bones for model konata/Konata_Anim_2.dae: 8
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 30
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 26
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 123
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 1027
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 87
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_UpperArm: 5
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Clavicle: 64
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_UpperArm: 3
[11:49:43 PM] Info: Starting animation
[11:49:43 PM] Info: # of bones for model konata/Konata_Anim_2.dae: 23
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Pelvis: 432
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine: 279
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine1: 350
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 515
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 132
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 25
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 6
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 219
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_UpperArm: 226
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Forearm: 342
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Hand: 254
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Clavicle: 172
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_UpperArm: 208
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Forearm: 333
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Hand: 248
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Thigh: 475
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Calf: 382
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Foot: 319
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Toe0: 159
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Thigh: 490
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Calf: 359
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Foot: 304
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Toe0: 154
[11:49:43 PM] Info: # of bones for model konata/Konata_Anim_2.dae: 7
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine: 312
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine1: 168
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 164
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 154
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 408
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 3912
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 14
[11:49:43 PM] Info: # of bones for model konata/Konata_Anim_2.dae: 8
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 30
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 26
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 123
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 1027
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 87
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_UpperArm: 5
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Clavicle: 64
[11:49:43 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_UpperArm: 3
[11:49:43 PM] Info: Starting animation
[00:19:47 AM] Info: Initializing SDL
[00:19:47 AM] Info: Initializing OpenGL
[00:19:47 AM] Info: OpenGL version: 4.6.0 NVIDIA 536.23
[00:19:47 AM] Info: Initializing GLEW
[00:19:47 AM] Info: Initializing SDL_mixer
[00:19:47 AM] Info: Reticulating splines...
[00:19:47 AM] Info: Ready!
[00:19:47 AM] Info: Loading script: build-cylinder.scm
[00:19:47 AM] Info: Loading script: build-stairs.scm
[00:19:47 AM] Info: Loading material resource: block.png
[00:19:47 AM] Info: Found normal map texture: materials/block_n.png
[00:19:47 AM] Info: Loading material resource: brick2.jpg
[00:19:47 AM] Info: Found normal map texture: materials/brick2_n.jpg
[00:19:47 AM] Info: Loading material resource: bricks.jpg
[00:19:47 AM] Info: Found normal map texture: materials/bricks_n.jpg
[00:19:47 AM] Info: Loading material resource: FLAT5_7.png
[00:19:47 AM] Info: Found normal map texture: materials/FLAT5_7_n.png
[00:19:47 AM] Info: Loading material resource: floor0.png
[00:19:47 AM] Info: Found normal map texture: materials/floor0_n.png
[00:19:47 AM] Info: Loading material resource: floor1.png
[00:19:47 AM] Info: Found normal map texture: materials/floor1_n.png
[00:19:47 AM] Info: Loading material resource: GRASS2.png
[00:19:47 AM] Info: Found normal map texture: materials/GRASS2_n.png
[00:19:47 AM] Info: Loading material resource: hardwood.jpg
[00:19:47 AM] Info: Found normal map texture: materials/hardwood_n.jpg
[00:19:47 AM] Info: Loading texture resource: .kp3d/banner.png
[00:19:47 AM] Info: Loading texture resource: .kp3d/crosshair.png
[00:19:47 AM] Info: Loading texture resource: .kp3d/empty.png
[00:19:47 AM] Info: Loading texture resource: .kp3d/logo.png
[00:19:47 AM] Info: Loading texture resource: .kp3d/map_grid.png
[00:19:47 AM] Info: Loading texture resource: .kp3d/not_found.png
[00:19:47 AM] Info: Loading texture resource: .kp3d/skybox.png
[00:19:47 AM] Info: Loading texture resource: .kp3d/uv_test.png
[00:19:47 AM] Info: Loading texture resource: .kp3d/water.png
[00:19:47 AM] Info: Loading texture resource: dot.png
[00:19:47 AM] Info: Loading texture resource: editor/stem.png
[00:19:47 AM] Info: Loading texture resource: logo.png
[00:19:47 AM] Info: Loading texture resource: skyboxes/sky50e2dd1d496fc.jpg
[00:19:47 AM] Info: Loading texture resource: skyboxes/sky8.jpg
[00:19:47 AM] Info: Loading texture resource: skyboxes/sky9.jpg
[00:19:47 AM] Info: Loading texture resource: skyboxes/skybox.jpg
[00:19:48 AM] Info: Loading texture resource: skyboxes/skybox_11.jpg
[00:19:48 AM] Info: Loading texture resource: skyboxes/skybox_14.jpg
[00:19:48 AM] Info: Loading texture resource: skyboxes/skybox_15.jpg
[00:19:48 AM] Info: Loading texture resource: skyboxes/skybox_3.jpg
[00:19:48 AM] Info: Loading texture resource: skybox_16.jpg
[00:19:48 AM] Info: Loading model resource: fumo.txt
[00:19:48 AM] Info: Map init
[00:19:48 AM] Info: Finalized mesh with 49 batches
[00:19:48 AM] Info: # of bones for model konata/Konata_Anim_2.dae: 23
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Pelvis: 432
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine: 279
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine1: 350
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 515
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 132
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 25
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 6
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 219
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_UpperArm: 226
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Forearm: 342
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Hand: 254
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Clavicle: 172
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_UpperArm: 208
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Forearm: 333
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Hand: 248
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Thigh: 475
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Calf: 382
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Foot: 319
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Toe0: 159
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Thigh: 490
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Calf: 359
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Foot: 304
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Toe0: 154
[00:19:48 AM] Info: # of bones for model konata/Konata_Anim_2.dae: 7
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine: 312
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine1: 168
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 164
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 154
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 408
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 3912
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 14
[00:19:48 AM] Info: # of bones for model konata/Konata_Anim_2.dae: 8
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 30
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 26
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 123
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 1027
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 87
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_UpperArm: 5
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Clavicle: 64
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_UpperArm: 3
[00:19:48 AM] Info: Starting animation
[00:19:48 AM] Info: # of bones for model konata/Konata_Anim_2.dae: 23
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Pelvis: 432
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine: 279
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine1: 350
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 515
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 132
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 25
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 6
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 219
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_UpperArm: 226
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Forearm: 342
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Hand: 254
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Clavicle: 172
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_UpperArm: 208
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Forearm: 333
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Hand: 248
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Thigh: 475
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Calf: 382
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Foot: 319
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Toe0: 159
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Thigh: 490
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Calf: 359
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Foot: 304
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Toe0: 154
[00:19:48 AM] Info: # of bones for model konata/Konata_Anim_2.dae: 7
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine: 312
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine1: 168
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 164
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 154
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 408
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 3912
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 14
[00:19:48 AM] Info: # of bones for model konata/Konata_Anim_2.dae: 8
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 30
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 26
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 123
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 1027
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 87
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_UpperArm: 5
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Clavicle: 64
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_UpperArm: 3
[00:19:48 AM] Info: Starting animation
[00:19:48 AM] Info: # of bones for model konata/Konata_Anim_2.dae: 23
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Pelvis: 432
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine: 279
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine1: 350
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 515
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 132
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 25
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 6
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 219
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_UpperArm: 226
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Forearm: 342
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Hand: 254
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Clavicle: 172
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_UpperArm: 208
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Forearm: 333
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Hand: 248
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Thigh: 475
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Calf: 382
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Foot: 319
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Toe0: 159
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Thigh: 490
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Calf: 359
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Foot: 304
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Toe0: 154
[00:19:48 AM] Info: # of bones for model konata/Konata_Anim_2.dae: 7
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine: 312
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine1: 168
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 164
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 154
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 408
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 3912
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 14
[00:19:48 AM] Info: # of bones for model konata/Konata_Anim_2.dae: 8
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 30
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 26
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 123
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 1027
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 87
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_UpperArm: 5
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Clavicle: 64
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_UpperArm: 3
[00:19:48 AM] Info: Starting animation
[00:19:48 AM] Info: # of bones for model konata/Konata_Anim_2.dae: 23
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Pelvis: 432
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine: 279
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine1: 350
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 515
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 132
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 25
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 6
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 219
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_UpperArm: 226
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Forearm: 342
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Hand: 254
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Clavicle: 172
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_UpperArm: 208
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Forearm: 333
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Hand: 248
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Thigh: 475
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Calf: 382
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Foot: 319
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Toe0: 159
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Thigh: 490
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Calf: 359
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Foot: 304
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Toe0: 154
[00:19:48 AM] Info: # of bones for model konata/Konata_Anim_2.dae: 7
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine: 312
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine1: 168
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 164
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 154
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 408
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 3912
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 14
[00:19:48 AM] Info: # of bones for model konata/Konata_Anim_2.dae: 8
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 30
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 26
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 123
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 1027
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 87
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_UpperArm: 5
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Clavicle: 64
[00:19:48 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_UpperArm: 3
[00:19:48 AM] Info: Starting animation
[00:19:51 AM] Info: Placed thing at {5.47038, -1.5, -7.50712}
[00:19:57 AM] Info: Finalized mesh with 48 batches

View file

@ -56,6 +56,7 @@ public:
bool playing = false;
bool noflip = false;
void (*func_intercept_transform)(TransformOp op, float ticks, const std::string& bone_name, kp3d::Vec3& transform) = nullptr;
Transform relative_transform;
private:
uint GetBoneID(const aiBone* bone);

View file

@ -96,7 +96,7 @@ void LoadTextures()
void LoadModels()
{
// Load every available texture
// Load every available model
for (const auto& entry: std::filesystem::recursive_directory_iterator(sys::GetModelDir()))
{
if (entry.is_directory())
@ -105,7 +105,17 @@ void LoadModels()
std::filesystem::path entry_path = entry.path();
std::string path_str = entry_path.string();
if (!str::EndsWith(path_str, ".fbx") && !str::EndsWith(path_str, ".obj"))
// Models work kinda weird in this. We use a .txt to mark which file to load along with transform information on each line
// indicating relative translation, rotation and scale respectively. This is used to "correct" models that use weird
// coordinate systems to make them easier to operate on when used for entities/"things."
//
// Example of the format:
// fumo/reimu_fumo.obj
// 0/0/0
// 0/-1/0
// 1/1/1
//
if (!str::EndsWith(path_str, ".txt"))
continue;
std::string filename = std::filesystem::proximate(path_str, sys::GetModelDir()).string();
@ -113,8 +123,52 @@ void LoadModels()
KP3D_LOG_INFO("Loading model resource: {}", filename);
model_cache.emplace(filename, std::make_shared<Model>());
model_cache[filename]->Load(filename);
std::string metadata;
sys::LoadTextFile(path_str, metadata);
std::vector<std::string> lines = str::SplitLines(metadata);
if (lines.empty())
KP3D_LOG_ERROR("Invalid model metadata file: {}", path_str);
std::string mesh_path = lines[0];
Vec3 relative_translation;
Vec3 relative_rotation;
Vec3 relative_scale(1.0f);
if (lines.size() >= 4)
{
std::vector<std::string> translation_str = str::SplitTokens(lines[1], "/");
std::vector<std::string> rotation_str = str::SplitTokens(lines[2], "/");
std::vector<std::string> scale_str = str::SplitTokens(lines[3], "/");
if (translation_str.size() != 3 || rotation_str.size() != 3 || scale_str.size() != 3)
{
KP3D_LOG_ERROR("Malformed model metadata in file: {}", path_str);
return;
}
int parse_status = 0;
relative_translation = {
str::Stof(translation_str[0], &parse_status),
str::Stof(translation_str[1], &parse_status),
str::Stof(translation_str[2], &parse_status)
};
relative_rotation = {
str::Stof(rotation_str[0], &parse_status),
str::Stof(rotation_str[1], &parse_status),
str::Stof(rotation_str[2], &parse_status)
};
relative_scale = {
str::Stof(scale_str[0], &parse_status),
str::Stof(scale_str[1], &parse_status),
str::Stof(scale_str[2], &parse_status)
};
if (parse_status)
{
KP3D_LOG_ERROR("Error parsing model metadata in file: {}", path_str);
return;
}
}
model_cache.emplace(mesh_path, std::make_shared<Model>());
model_cache[mesh_path]->Load(mesh_path);
model_cache[mesh_path]->relative_transform = {relative_translation, relative_rotation, relative_scale};
}
}

View file

@ -121,7 +121,7 @@ std::vector<std::string> SplitTokens(std::string s, const std::string& delimiter
return res;
}
float Stof(const std::string& str)
float Stof(const std::string& str, int* status)
{
if (str.empty())
return 0.0f;
@ -136,10 +136,13 @@ float Stof(const std::string& str)
KP3D_LOG_ERROR("Stof failure: {}", str);
}
if (status)
(*status)++;
return 0.0f;
}
int Stoi(const std::string& str)
int Stoi(const std::string& str, int* status)
{
if (str.empty())
return 0;
@ -154,6 +157,9 @@ int Stoi(const std::string& str)
KP3D_LOG_ERROR("Stoi failure: {}", str);
}
if (status)
(*status)++;
return 0;
}

View file

@ -29,7 +29,7 @@ std::vector<std::string> SplitWhitespace(const std::string& str);
std::vector<std::string> SplitLines(const std::string& str);
std::vector<std::string> SplitTokens(std::string str, const std::string& delim);
float Stof(const std::string& str);
int Stoi(const std::string& str);
float Stof(const std::string& str, int* status = nullptr);
int Stoi(const std::string& str, int* status = nullptr);
} // namespace kp3d::str

View file

@ -47,9 +47,11 @@ void Thing::Render()
Renderer3D::DrawBillboard(*default_sprite.get(), transform.translation, {1.0f, 1.0f});
break;
case Display::MESH:
if (display.data.mesh.model)
Renderer3D::DrawModel(*display.data.mesh.model, transform);
break;
case Display::SPRITES:
if (display.data.sprites.textures[0][0])
Renderer3D::DrawBillboardSprites(display.data.sprites.textures[display.data.sprites.current_sprite], transform.rotation.y, transform.translation, {1.0f, 1.0f});
break;
}

View file

@ -264,7 +264,7 @@ void Editor::Update()
void Editor::RenderMap()
{
if (show_grid)
if (show_grid && m_mode == MODE_BUILD)
sandbox->map.RenderGrid();
switch (m_mode)
@ -1076,7 +1076,7 @@ void Editor::RenderUI()
ImGui::MenuItem("Show Selection Info", "Tab", &show_selection_info);
ImGui::Separator();
ImGui::MenuItem("Show Wireframe", "F1", &sandbox->map.render_wireframe);
ImGui::MenuItem("Show Grid", "F2", &show_grid);
ImGui::MenuItem("Show Build Mode Grid", "F2", &show_grid);
ImGui::Separator();
ImGui::MenuItem("Open Console", "`", & kp3d::console::open);
ImGui::EndMenu();
@ -1128,6 +1128,33 @@ void Editor::RenderUI()
ImGui::CheckboxFlags("Visible", (unsigned int*)(&m_selected_thing->flags), kp3d::Thing::FLAG_VISIBLE);
ImGui::CheckboxFlags("Grounded", (unsigned int*)(&m_selected_thing->flags), kp3d::Thing::FLAG_GROUNDED);
ImGui::CheckboxFlags("Collisions", (unsigned int*)(&m_selected_thing->flags), kp3d::Thing::FLAG_COLLISIONS);
ImGui::SeparatorText("Display");
ImGui::RadioButton("None", reinterpret_cast<int*>(&m_selected_thing->display.type), (int)kp3d::Display::NONE);
ImGui::RadioButton("3D Mesh", reinterpret_cast<int*>(&m_selected_thing->display.type), (int)kp3d::Display::MESH);
ImGui::RadioButton("2D Sprites", reinterpret_cast<int*>(&m_selected_thing->display.type), (int)kp3d::Display::SPRITES);
ImGui::RadioButton("Other", reinterpret_cast<int*>(&m_selected_thing->display.type), (int)kp3d::Display::OTHER);
switch (m_selected_thing->display.type)
{
case kp3d::Display::NONE:
break;
case kp3d::Display::MESH:
if (m_selected_thing->display.data.mesh.model)
{
ImGui::Text("Selected: %s\n", m_selected_thing->display.data.mesh.model->GetPath());
ImGui::SameLine();
}
if (ImGui::Button("Set Mesh..."))
{
if (!m_selected_thing->display.data.mesh.model)
m_selected_thing->display.data.mesh.model = new kp3d::Model();
RenderUIMeshSelect(&m_selected_thing->display.data.mesh.model);
}
break;
case kp3d::Display::SPRITES:
break;
case kp3d::Display::OTHER:
break;
}
}
else
{
@ -1197,9 +1224,10 @@ void Editor::RenderUI()
if (!m_materials_to_update.empty())
RenderUIMaterialModal();
if (!m_textures_to_update.empty())
RenderUITextureModal();
if (!m_meshes_to_update.empty())
RenderUIMeshModal();
anything_hovered = ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow) || ImGui::IsAnyItemHovered();
}
@ -1331,7 +1359,7 @@ void Editor::RenderUIMaterialModal()
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)
for (const auto& [path, tex_ptr]: kp3d::res::material_cache)
{
if (strlen(m_mat_filter_buf) > 0)
{
@ -1406,7 +1434,6 @@ void Editor::RenderUITextureSelect(const kp3d::Texture** texture, const char* fi
m_textures_to_update.clear();
m_textures_to_update.push_back(texture);
should_show_texture_modal = true;
}
void Editor::RenderUITextureModal()
@ -1429,7 +1456,7 @@ void Editor::RenderUITextureModal()
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)
for (const auto& [path, tex_ptr]: kp3d::res::texture_cache)
{
if (strlen(m_tex_filter_buf) > 0)
{
@ -1492,6 +1519,81 @@ void Editor::RenderUITextureModal()
}
}
// Should probably rename this as its behavior doesn't reflect RenderUIMaterialSelect
void Editor::RenderUIMeshSelect(kp3d::Model** mesh)
{
m_meshes_to_update.clear();
m_meshes_to_update.push_back(mesh);
should_show_mesh_modal = true;
}
void Editor::RenderUIMeshModal()
{
if (should_show_mesh_modal)
ImGui::OpenPopup("Select Mesh");
ImGui::SetNextWindowSize(ImVec2(960, 720), ImGuiCond_FirstUseEver);
if (ImGui::BeginPopupModal("Select Mesh"))
{
bool should_remove_mesh = ImGui::Button("Remove mesh##mesh");
bool should_close = ImGui::Button("Cancel##mesh");
ImGui::Separator();
ImGui::BeginChild("MeshList");
int i = 1000;
kp3d::Model* chosen_mesh = nullptr;
bool should_update_mesh = false;
for (auto& [path, mesh_ptr]: kp3d::res::model_cache)
{
kp3d::Model* mesh = mesh_ptr.get();
ImGui::BeginGroup();
ImGui::PushID(i);
bool mesh_img_button = ImGui::Button(path.c_str(), {128, 128});
if (ImGui::IsItemHovered())
ImGui::SetTooltip(path.c_str());
if (mesh_img_button)
{
should_update_mesh = true;
chosen_mesh = mesh;
}
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_mesh)
{
for (auto meshes: m_meshes_to_update)
*meshes = nullptr;
m_meshes_to_update.clear();
ImGui::CloseCurrentPopup();
should_show_mesh_modal = false;
RebuildMap();
}
if (should_close)
{
ImGui::CloseCurrentPopup();
should_show_mesh_modal = false;
RebuildMap();
}
if (should_update_mesh)
{
for (auto meshes: m_meshes_to_update)
*meshes = chosen_mesh;
m_meshes_to_update.clear();
ImGui::CloseCurrentPopup();
should_show_mesh_modal = false;
RebuildMap();
}
ImGui::EndPopup();
}
}
void Editor::OnScrollWheel(const kp3d::ScrollWheelEvent* e)
{
using namespace kp3d;

View file

@ -60,6 +60,8 @@ public:
void RenderUIMaterialModal();
void RenderUITextureSelect(const kp3d::Texture** texture, const char* filter = nullptr);
void RenderUITextureModal();
void RenderUIMeshSelect(kp3d::Model** mesh);
void RenderUIMeshModal();
void OnScrollWheel(const kp3d::ScrollWheelEvent* e);
void OnKeyPress(const kp3d::KeyPressEvent* e);
@ -99,10 +101,12 @@ private:
bool editing_gizmo = false;
bool should_show_material_modal = false;
bool should_show_texture_modal = false;
bool should_show_mesh_modal = false;
char m_mat_filter_buf[512];
char m_tex_filter_buf[512];
std::vector<const kp3d::Material**> m_materials_to_update;
std::vector<const kp3d::Texture**> m_textures_to_update;
std::vector<kp3d::Model**> m_meshes_to_update;
kp3d::Thing* m_hovered_thing = nullptr,* m_selected_thing = nullptr;
WallUpdate wall_update;

View file

@ -7,12 +7,16 @@
#include <KP3D_Model.h>
#include <KP3D_Renderer3D.h>
namespace {
std::shared_ptr<kp3d::Model> vm_model, vm_model_arms;
kp3d::Transform vm_transform;
kp3d::Camera vm_dummy;
float ticks = 0.0f;
} // namespace
void InitPlayer()
{
vm_model.reset(new kp3d::Model());

View file

@ -20,6 +20,7 @@ Sandbox::Sandbox(const std::string& path):
{
kp3d::res::LoadMaterials();
kp3d::res::LoadTextures();
kp3d::res::LoadModels();
tex.Load("logo.png");
crosshair.Load(".kp3d/crosshair.png");