buhhh, fuhhhhhh

This commit is contained in:
kp 2024-08-14 00:37:23 -05:00
parent 89a7084a1f
commit ba0170c5ff
24 changed files with 4511 additions and 137 deletions

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,14 @@
# Blender MTL File: 'Konata_Anim_gun.blend'
# Material Count: 1
newmtl b93e90b3
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd C:\\Users\\KP\\Downloads\\b93e90b3.png
map_d C:\\Users\\KP\\Downloads\\b93e90b3.png

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,10 @@
newmtl m2material0
Ns 0.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd tx_eric_sp.png

File diff suppressed because it is too large Load diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 393 KiB

View file

@ -65,13 +65,13 @@ void main()
vec3 tangentNormal = normalize(texture(u_normal_texture, v_texcoord).xyz * 2.0 - 1.0);
vec3 T = normalize(v_tangent);
vec3 B = normalize(v_bitangent);
vec3 N = normalize(abs(v_normal));
vec3 N = normalize((v_normal));
mat3 TBN = mat3(T, B, N);
vec3 norm = normalize(TBN * tangentNormal);
//norm = vec3(0,1,0);
vec4 texv = texture(u_texture, v_texcoord);
vec4 ambient = vec4(0.1, 0.1, 0.1, 1.0) * 10.5, light = ambient;
vec4 ambient = vec4(0.1, 0.1, 0.1, 1.0) * 5.5, light = ambient;
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);

View file

@ -1,6 +1,7 @@
#version 330 core
uniform mat4 u_mvp;
uniform mat4 u_mv;
layout (location = 0) in vec3 position;
layout (location = 1) in vec3 normal;
@ -26,8 +27,8 @@ uniform int u_has_bones;
void main()
{
v_position = position;
v_proj_normal = vec4(u_mv * vec4(normal, 1.0)).xyz;
v_normal = normal;
v_proj_normal = vec4(u_mvp * vec4(normal, 1.0)).xyz;
v_texcoord = vec2(texcoord.x, -texcoord.y);
v_tangent = tangent;
v_bitangent = bitangent;

View file

@ -1,111 +1,273 @@
[04:12:58 PM] Info: Starting...
[00:35:31 AM] Info: Starting...
KP3D version 2
===============================
Copyright (C) kpworld.xyz 2018-2024
Contact me! @kp_cftsz
[04:12:58 PM] Info: Initializing SDL
[04:12:58 PM] Info: Initializing OpenGL
[04:12:58 PM] Info: OpenGL version: 4.6.0 NVIDIA 536.23
[04:12:58 PM] Info: Initializing GLEW
[04:12:58 PM] Info: Initializing SDL_mixer
[04:12:58 PM] Info: Reticulating splines...
[04:12:59 PM] Info: Ready!
[04:12:59 PM] Info: Loading script: build-cylinder.scm
[04:12:59 PM] Info: Loading script: build-stairs.scm
[04:12:59 PM] Info: Loading material resource: block.png
[04:12:59 PM] Info: Found normal map texture: materials/block_n.png
[04:12:59 PM] Info: Loading material resource: brick2.jpg
[04:12:59 PM] Info: Found normal map texture: materials/brick2_n.jpg
[04:12:59 PM] Info: Loading material resource: bricks.jpg
[04:12:59 PM] Info: Found normal map texture: materials/bricks_n.jpg
[04:12:59 PM] Info: Loading material resource: FLAT5_7.png
[04:12:59 PM] Info: Found normal map texture: materials/FLAT5_7_n.png
[04:12:59 PM] Info: Loading material resource: floor0.png
[04:12:59 PM] Info: Found normal map texture: materials/floor0_n.png
[04:12:59 PM] Info: Loading material resource: floor1.png
[04:12:59 PM] Info: Found normal map texture: materials/floor1_n.png
[04:12:59 PM] Info: Loading material resource: GRASS2.png
[04:12:59 PM] Info: Found normal map texture: materials/GRASS2_n.png
[04:12:59 PM] Info: Loading material resource: hardwood.jpg
[04:12:59 PM] Info: Found normal map texture: materials/hardwood_n.jpg
[04:12:59 PM] Info: Loading texture resource: .kp3d/banner.png
[04:12:59 PM] Info: Loading texture resource: .kp3d/crosshair.png
[04:12:59 PM] Info: Loading texture resource: .kp3d/empty.png
[04:12:59 PM] Info: Loading texture resource: .kp3d/logo.png
[04:12:59 PM] Info: Loading texture resource: .kp3d/map_grid.png
[04:12:59 PM] Info: Loading texture resource: .kp3d/not_found.png
[04:12:59 PM] Info: Loading texture resource: .kp3d/skybox.png
[04:12:59 PM] Info: Loading texture resource: .kp3d/uv_test.png
[04:12:59 PM] Info: Loading texture resource: .kp3d/water.png
[04:12:59 PM] Info: Loading texture resource: dot.png
[04:12:59 PM] Info: Loading texture resource: editor/stem.png
[04:12:59 PM] Info: Loading texture resource: logo.png
[04:12:59 PM] Info: Loading texture resource: skyboxes/sky50e2dd1d496fc.jpg
[04:12:59 PM] Info: Loading texture resource: skyboxes/sky8.jpg
[04:12:59 PM] Info: Loading texture resource: skyboxes/sky9.jpg
[04:12:59 PM] Info: Loading texture resource: skyboxes/skybox.jpg
[04:12:59 PM] Info: Loading texture resource: skyboxes/skybox_11.jpg
[04:12:59 PM] Info: Loading texture resource: skyboxes/skybox_14.jpg
[04:12:59 PM] Info: Loading texture resource: skyboxes/skybox_15.jpg
[04:12:59 PM] Info: Loading texture resource: skyboxes/skybox_3.jpg
[04:12:59 PM] Info: Loading texture resource: skybox_16.jpg
[04:12:59 PM] Info: # of bones for model konata/Konata_PistolAnimations.dae: 23
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Pelvis: 432
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine: 279
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine1: 350
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 515
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 132
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 25
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 6
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 219
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_UpperArm: 226
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Forearm: 342
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Hand: 254
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Clavicle: 172
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_UpperArm: 208
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Forearm: 333
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Hand: 248
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Thigh: 475
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Calf: 382
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Foot: 319
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Toe0: 159
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Thigh: 490
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Calf: 359
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Foot: 304
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Toe0: 154
[04:12:59 PM] Info: # of bones for model konata/Konata_PistolAnimations.dae: 7
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine: 312
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine1: 168
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 164
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 154
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 408
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 3912
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 14
[04:12:59 PM] Info: # of bones for model konata/Konata_PistolAnimations.dae: 8
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 30
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 26
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 123
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 1027
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 87
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_UpperArm: 5
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Clavicle: 64
[04:12:59 PM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_UpperArm: 3
[04:12:59 PM] Info: Map init
[04:12:59 PM] Info: Finalized mesh with 49 batches
[04:13:05 PM] Info: Starting animation
[04:13:14 PM] Info: Starting animation
[04:13:19 PM] Info: Starting animation
[04:13:26 PM] Info: Starting animation
[04:13:27 PM] Info: Starting animation
[04:13:30 PM] Info: Starting animation
[04:13:30 PM] Info: Starting animation
[04:13:31 PM] Info: Starting animation
[04:13:31 PM] Info: Starting animation
[04:13:31 PM] Info: Starting animation
[04:13:32 PM] Info: Starting animation
[04:13:32 PM] Info: Starting animation
[04:13:32 PM] Info: Starting animation
[04:13:33 PM] Info: Starting animation
[04:13:34 PM] Info: Starting animation
[00:35:31 AM] Info: Initializing SDL
[00:35:32 AM] Info: Initializing OpenGL
[00:35:32 AM] Info: OpenGL version: 4.6.0 NVIDIA 536.23
[00:35:32 AM] Info: Initializing GLEW
[00:35:32 AM] Info: Initializing SDL_mixer
[00:35:32 AM] Info: Reticulating splines...
[00:35:32 AM] Info: Ready!
[00:35:32 AM] Info: Loading script: build-cylinder.scm
[00:35:32 AM] Info: Loading script: build-stairs.scm
[00:35:32 AM] Info: Loading material resource: block.png
[00:35:32 AM] Info: Found normal map texture: materials/block_n.png
[00:35:32 AM] Info: Loading material resource: brick2.jpg
[00:35:32 AM] Info: Found normal map texture: materials/brick2_n.jpg
[00:35:32 AM] Info: Loading material resource: bricks.jpg
[00:35:32 AM] Info: Found normal map texture: materials/bricks_n.jpg
[00:35:32 AM] Info: Loading material resource: FLAT5_7.png
[00:35:32 AM] Info: Found normal map texture: materials/FLAT5_7_n.png
[00:35:32 AM] Info: Loading material resource: floor0.png
[00:35:32 AM] Info: Found normal map texture: materials/floor0_n.png
[00:35:32 AM] Info: Loading material resource: floor1.png
[00:35:32 AM] Info: Found normal map texture: materials/floor1_n.png
[00:35:32 AM] Info: Loading material resource: GRASS2.png
[00:35:32 AM] Info: Found normal map texture: materials/GRASS2_n.png
[00:35:32 AM] Info: Loading material resource: hardwood.jpg
[00:35:32 AM] Info: Found normal map texture: materials/hardwood_n.jpg
[00:35:32 AM] Info: Loading texture resource: .kp3d/banner.png
[00:35:32 AM] Info: Loading texture resource: .kp3d/crosshair.png
[00:35:32 AM] Info: Loading texture resource: .kp3d/empty.png
[00:35:32 AM] Info: Loading texture resource: .kp3d/logo.png
[00:35:32 AM] Info: Loading texture resource: .kp3d/map_grid.png
[00:35:32 AM] Info: Loading texture resource: .kp3d/not_found.png
[00:35:32 AM] Info: Loading texture resource: .kp3d/skybox.png
[00:35:32 AM] Info: Loading texture resource: .kp3d/uv_test.png
[00:35:32 AM] Info: Loading texture resource: .kp3d/water.png
[00:35:32 AM] Info: Loading texture resource: dot.png
[00:35:32 AM] Info: Loading texture resource: editor/stem.png
[00:35:32 AM] Info: Loading texture resource: logo.png
[00:35:32 AM] Info: Loading texture resource: skyboxes/sky50e2dd1d496fc.jpg
[00:35:32 AM] Info: Loading texture resource: skyboxes/sky8.jpg
[00:35:32 AM] Info: Loading texture resource: skyboxes/sky9.jpg
[00:35:32 AM] Info: Loading texture resource: skyboxes/skybox.jpg
[00:35:32 AM] Info: Loading texture resource: skyboxes/skybox_11.jpg
[00:35:32 AM] Info: Loading texture resource: skyboxes/skybox_14.jpg
[00:35:32 AM] Info: Loading texture resource: skyboxes/skybox_15.jpg
[00:35:32 AM] Info: Loading texture resource: skyboxes/skybox_3.jpg
[00:35:32 AM] Info: Loading texture resource: skybox_16.jpg
[00:35:32 AM] Info: Map init
[00:35:32 AM] Info: Finalized mesh with 49 batches
[00:35:32 AM] Info: # of bones for model konata/Konata_Anim_2.dae: 23
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Pelvis: 432
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine: 279
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine1: 350
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 515
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 132
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 25
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 6
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 219
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_UpperArm: 226
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Forearm: 342
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Hand: 254
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Clavicle: 172
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_UpperArm: 208
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Forearm: 333
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Hand: 248
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Thigh: 475
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Calf: 382
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Foot: 319
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Toe0: 159
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Thigh: 490
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Calf: 359
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Foot: 304
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Toe0: 154
[00:35:32 AM] Info: # of bones for model konata/Konata_Anim_2.dae: 7
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine: 312
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine1: 168
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 164
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 154
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 408
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 3912
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 14
[00:35:32 AM] Info: # of bones for model konata/Konata_Anim_2.dae: 8
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 30
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 26
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 123
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 1027
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 87
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_UpperArm: 5
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Clavicle: 64
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_UpperArm: 3
[00:35:32 AM] Info: Starting animation
[00:35:32 AM] Info: # of bones for model konata/Konata_Anim_2.dae: 23
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Pelvis: 432
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine: 279
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine1: 350
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 515
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 132
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 25
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 6
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 219
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_UpperArm: 226
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Forearm: 342
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Hand: 254
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Clavicle: 172
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_UpperArm: 208
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Forearm: 333
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Hand: 248
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Thigh: 475
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Calf: 382
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Foot: 319
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Toe0: 159
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Thigh: 490
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Calf: 359
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Foot: 304
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Toe0: 154
[00:35:32 AM] Info: # of bones for model konata/Konata_Anim_2.dae: 7
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine: 312
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine1: 168
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 164
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 154
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 408
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 3912
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 14
[00:35:32 AM] Info: # of bones for model konata/Konata_Anim_2.dae: 8
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 30
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 26
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 123
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 1027
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 87
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_UpperArm: 5
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Clavicle: 64
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_UpperArm: 3
[00:35:32 AM] Info: Starting animation
[00:35:32 AM] Info: # of bones for model konata/Konata_Anim_2.dae: 23
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Pelvis: 432
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine: 279
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine1: 350
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 515
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 132
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 25
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 6
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 219
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_UpperArm: 226
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Forearm: 342
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Hand: 254
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Clavicle: 172
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_UpperArm: 208
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Forearm: 333
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Hand: 248
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Thigh: 475
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Calf: 382
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Foot: 319
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Toe0: 159
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Thigh: 490
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Calf: 359
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Foot: 304
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Toe0: 154
[00:35:32 AM] Info: # of bones for model konata/Konata_Anim_2.dae: 7
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine: 312
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine1: 168
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 164
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 154
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 408
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 3912
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 14
[00:35:32 AM] Info: # of bones for model konata/Konata_Anim_2.dae: 8
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 30
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 26
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 123
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 1027
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 87
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_UpperArm: 5
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Clavicle: 64
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_UpperArm: 3
[00:35:32 AM] Info: Starting animation
[00:35:32 AM] Info: # of bones for model konata/Konata_Anim_2.dae: 23
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Pelvis: 432
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine: 279
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine1: 350
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 515
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 132
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 25
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 6
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 219
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_UpperArm: 226
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Forearm: 342
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Hand: 254
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Clavicle: 172
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_UpperArm: 208
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Forearm: 333
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Hand: 248
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Thigh: 475
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Calf: 382
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Foot: 319
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Toe0: 159
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Thigh: 490
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Calf: 359
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Foot: 304
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Toe0: 154
[00:35:32 AM] Info: # of bones for model konata/Konata_Anim_2.dae: 7
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine: 312
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine1: 168
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 164
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 154
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 408
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 3912
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 14
[00:35:32 AM] Info: # of bones for model konata/Konata_Anim_2.dae: 8
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine2: 30
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Spine4: 26
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Neck1: 123
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_Head1: 1027
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_Clavicle: 87
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_R_UpperArm: 5
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_Clavicle: 64
[00:35:32 AM] Info: Num weights for Konatap_ARM_ValveBiped_Bip01_L_UpperArm: 3
[00:35:32 AM] Info: Starting animation
[00:35:36 AM] Info: Placed thing at {5.26188, -1.5, -6.73907}
[00:35:36 AM] Info: Placed thing at {1.00024, -0.697385, -3.0449}
[00:35:37 AM] Info: Placed thing at {3.23716, -1, -6.85953}
[00:35:38 AM] Info: Placed thing at {1.00011, 0.231866, -7.71429}
[00:35:38 AM] Info: Placed thing at {1.00005, 1.9619, -9.9808}
[00:35:39 AM] Info: Placed thing at {3.27247, -1, -10.8426}
[00:35:39 AM] Info: Placed thing at {2.521, 1.6355, -12.0001}
[00:35:44 AM] Info: Finalized mesh with 48 batches
[00:35:44 AM] Info: Finalized mesh with 48 batches
[00:35:45 AM] Info: Finalized mesh with 48 batches
[00:35:45 AM] Info: Finalized mesh with 48 batches
[00:35:45 AM] Info: Finalized mesh with 48 batches
[00:35:46 AM] Info: Placed thing at {2.05471, -0.999999, -9.61414}
[00:35:46 AM] Info: Placed thing at {1.00006, 0.612172, -9.76453}
[00:35:47 AM] Info: Placed thing at {1.00002, 2.27179, -11.4373}
[00:35:47 AM] Info: Placed thing at {3.81551, 0.859955, -12}
[00:35:47 AM] Info: Placed thing at {1.00011, 2.62292, -7.87849}
[00:35:48 AM] Info: Placed thing at {3.53319, 5, -2.9424}
[00:35:48 AM] Info: Placed thing at {10.085, -1, -3.54519}
[00:35:48 AM] Info: Placed thing at {7.28894, -0.181061, -9}
[00:35:48 AM] Info: Placed thing at {6.71537, 4, -9.0765}
[00:35:49 AM] Info: Placed thing at {6.89502, 4, -7.56984}
[00:35:49 AM] Info: Placed thing at {4.03265, 4, -8.52186}
[00:35:49 AM] Info: Placed thing at {6.89496, -1.5, -7.56997}
[00:35:49 AM] Info: Placed thing at {7.09904, -1.5, -6.25198}
[00:35:49 AM] Info: Placed thing at {11.0001, 3.38072, -8.04484}
[00:35:50 AM] Info: Placed thing at {5.09783, -1.5, -7.97788}
[00:36:44 AM] Info: Finalized mesh with 48 batches
[00:36:44 AM] Info: Finalized mesh with 48 batches
[00:36:45 AM] Info: Finalized mesh with 48 batches
[00:36:45 AM] Info: Finalized mesh with 48 batches
[00:36:45 AM] Info: Finalized mesh with 48 batches
[00:36:46 AM] Info: Finalized mesh with 48 batches
[00:36:46 AM] Info: Finalized mesh with 48 batches
[00:36:46 AM] Info: Finalized mesh with 48 batches
[00:36:46 AM] Info: Finalized mesh with 48 batches
[00:36:46 AM] Info: Finalized mesh with 48 batches
[00:36:47 AM] Info: Finalized mesh with 48 batches
[00:36:47 AM] Info: Finalized mesh with 48 batches
[00:36:47 AM] Info: Finalized mesh with 48 batches
[00:36:47 AM] Info: Finalized mesh with 48 batches
[00:36:48 AM] Info: Finalized mesh with 48 batches
[00:36:48 AM] Info: Finalized mesh with 48 batches
[00:36:56 AM] Info: Finalized mesh with 48 batches
[00:36:57 AM] Info: Finalized mesh with 48 batches
[00:36:58 AM] Info: Finalized mesh with 48 batches
[00:36:58 AM] Info: Finalized mesh with 48 batches
[00:36:59 AM] Info: Finalized mesh with 48 batches
[00:36:59 AM] Info: Finalized mesh with 48 batches
[00:37:00 AM] Info: Finalized mesh with 48 batches

View file

@ -153,6 +153,7 @@ void Model::ParseSingleBone(MeshDef& def, const aiBone* bone)
{
Mat4 offset = ConvertAssimpMatrix(bone->mOffsetMatrix);
BoneInfo bi(offset);
bi.bone_idx = bone_id;
m_bone_info.push_back(bi);
}
@ -227,6 +228,14 @@ void Model::ReadNodeHierarchy(float ticks, const aiNode* node, const Mat4& paren
// Interpolate scaling and generate transformation matrix
aiVector3D scaling;
CalcInterpScaling(scaling, ticks, node_anim);
if (func_intercept_transform)
{
Vec3 i_scale(0.0f);
func_intercept_transform(SCALE, ticks, node_name, i_scale);
scaling.x += i_scale.x;
scaling.y += i_scale.y;
scaling.z += i_scale.z;
}
Mat4 scaling_m;
scaling_m.InitScale({ scaling.x, scaling.y, scaling.z });
@ -236,11 +245,27 @@ void Model::ReadNodeHierarchy(float ticks, const aiNode* node, const Mat4& paren
Mat4 rotation_m;
rotation_m.InitIdentity();
Quaternion qt(rotation_q.x, rotation_q.y, rotation_q.z, rotation_q.w);
if (func_intercept_transform)
{
Vec3 i_rot(0.0f);
func_intercept_transform(ROTATE, ticks, node_name, i_rot);
qt.x += i_rot.x;
qt.y += i_rot.y;
qt.z += i_rot.z;
}
rotation_m = qt.ToMat4();
// And translation.
aiVector3D translation;
CalcInterpPosition(translation, ticks, node_anim);
if (func_intercept_transform)
{
Vec3 i_trans(0.0f);
func_intercept_transform(TRANSLATE, ticks, node_name, i_trans);
translation.x += i_trans.x;
translation.y += i_trans.y;
translation.z += i_trans.z;
}
Mat4 translation_m;
translation_m.InitTranslation({ translation.x, translation.y, translation.z });
@ -256,6 +281,7 @@ void Model::ReadNodeHierarchy(float ticks, const aiNode* node, const Mat4& paren
Mat4 git = ConvertAssimpMatrix(m_global_inverse_transform);
uint bone_idx = m_bone_name_to_index_map[node_name];
m_bone_info[bone_idx].final_transformation = git * global_transformation * m_bone_info[bone_idx].offset_matrix;
}
@ -396,7 +422,7 @@ ErrCode Model::LoadModel(const std::string& path)
std::string parent_dir = kp3d_path.substr(0, kp3d_path.find_last_of("/\\"));
m_scene = m_importer.ReadFile(
kp3d_path, aiProcess_Triangulate | aiProcess_GenSmoothNormals | aiProcess_FlipUVs | aiProcess_OptimizeMeshes
kp3d_path, aiProcess_Triangulate | aiProcess_GenSmoothNormals | aiProcess_FlipUVs | aiProcess_OptimizeMeshes | aiProcess_CalcTangentSpace
);
if (!m_scene)
{
@ -427,14 +453,19 @@ ErrCode Model::LoadModel(const std::string& path)
const aiVector3D pos = model->mVertices[i];
const aiVector3D nor = model->mNormals[i];
const aiVector3D tex = model->HasTextureCoords(0) ? model->mTextureCoords[0][i] : aiVector3D(0.0f, 0.0f, 0.0f);
const aiVector3D t = model->mTangents[i];
const aiVector3D b = model->mBitangents[i];
Vec3 tv = {t.x, t.y, -t.z};
Vec3 bv = {b.x, b.y, -b.z};
if (noflip)
{
def.vertices.push_back(Vertex3D(Vec3{pos.x, pos.y, pos.z}, Vec3{nor.x, nor.y, nor.z}, Vec2{tex.x, -tex.y}));
def.vertices.push_back(Vertex3D(Vec3{pos.x, pos.y, pos.z}, Vec3{nor.x, nor.y, nor.z}, Vec2{tex.x, -tex.y}, tv, bv));
continue;
}
def.vertices.push_back(Vertex3D(Vec3{pos.x, pos.y, -pos.z}, Vec3{nor.x, nor.y, -nor.z}, Vec2{tex.x, -tex.y}));
def.vertices.push_back(Vertex3D(Vec3{pos.x, pos.y, pos.z}, Vec3{nor.x, nor.y, nor.z}, Vec2{tex.x, -tex.y}, tv, bv));
}
for (size_t i = 0; i < model->mNumFaces; i++)
@ -485,11 +516,11 @@ ErrCode Model::LoadModel(const std::string& path)
}
if (model->HasBones())
m->AddSkinnedBatch(tex ? tex : default_tex, def.vertices, def.indices, def.bones, false, normal_tex);
m->AddSkinnedBatch(tex ? tex : default_tex, def.vertices, def.indices, def.bones, !noflip, normal_tex);
else
m->AddIndexedBatch(tex ? tex : default_tex, def.vertices, def.indices, normal_tex);
m->Finalize();
m->Finalize(NO_GEN_NORMALS);
m_meshes.push_back(m);
}

View file

@ -8,6 +8,7 @@
#include "KP3D_StaticMesh.h"
#include "KP3D_Texture.h"
#include "KP3D_Math.h"
#include "KP3D_Transform.h"
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
@ -16,6 +17,12 @@ namespace kp3d {
struct MeshDef;
enum TransformOp {
TRANSLATE,
ROTATE,
SCALE
};
class Model
{
public:
@ -48,6 +55,7 @@ public:
uint64 last_start_millis = 0;
bool playing = false;
bool noflip = false;
void (*func_intercept_transform)(TransformOp op, float ticks, const std::string& bone_name, kp3d::Vec3& transform) = nullptr;
private:
uint GetBoneID(const aiBone* bone);

View file

@ -176,12 +176,17 @@ void Renderer3D::DrawMesh(StaticMesh& mesh, const Mat4& m, bool bind_shader, uin
glAlphaFunc(GL_GREATER, 0.1f);
glEnable(GL_ALPHA_TEST);
// kp3d::Mat4 cam_translation_matrix, cam_rotation_matrix;
// cam_translation_matrix.InitTranslation(-r3d_state->v->position);
// cam_rotation_matrix.InitRotation(r3d_state->v->forward, r3d_state->v->up, r3d_state->v->right);
// kp3d::Mat4 cam_matrix = cam_rotation_matrix * cam_translation_matrix;
for (const RenderBatch3D& batch: mesh.m_batches)
{
if (bind_shader)
r3d_state->shader->Bind();
r3d_state->shader->SetUniform("u_mvp", m);
r3d_state->shader->SetUniform("u_mv", modelview);
r3d_state->shader->SetUniform("u_mv", modelview * *r3d_state->p);
r3d_state->shader->SetUniform("u_campos", r3d_state->v->position);
r3d_state->shader->SetUniform("u_camdir", r3d_state->v->forward);
r3d_state->shader->SetUniform("u_time", r3d_state->time);
@ -214,7 +219,9 @@ void Renderer3D::DrawMesh(StaticMesh& mesh, const Mat4& m, bool bind_shader, uin
}
else
{
glActiveTexture(GL_TEXTURE0);
glActiveTexture(GL_TEXTURE1);
Renderer2D::GetDefaultTexture().Bind();
r3d_state->shader->SetUniform("u_normal_texture", 1);
}
glBindBuffer(GL_ARRAY_BUFFER, batch.gl_vbo_id);
@ -280,6 +287,8 @@ void Renderer3D::DrawMesh(StaticMesh& mesh, const Mat4& m, bool bind_shader, uin
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
glActiveTexture(GL_TEXTURE0);
}
void Renderer3D::DrawMesh(StaticMesh& mesh, Transform& m, bool bind_shader, uint (*func_highlight)(const RenderBatch3D&))

View file

@ -20,10 +20,12 @@ Vertex3D::Vertex3D(Vec3 position, Vec2 uv):
{
}
Vertex3D::Vertex3D(Vec3 position, Vec3 normal, Vec2 uv):
Vertex3D::Vertex3D(Vec3 position, Vec3 normal, Vec2 uv, Vec3 atangent, Vec3 bitangent):
position(std::move(position)),
normal(std::move(normal)),
uv(std::move(uv))
uv(std::move(uv)),
atangent(std::move(atangent)),
bitangent(std::move(bitangent))
{
}

View file

@ -19,7 +19,7 @@ class Vertex3D
public:
Vertex3D();
Vertex3D(Vec3 position, Vec2 uv);
Vertex3D(Vec3 position, Vec3 normal, Vec2 uv);
Vertex3D(Vec3 position, Vec3 normal, Vec2 uv, Vec3 atangent = {}, Vec3 bitangent = {});
public:
Vec3 position;
@ -50,6 +50,7 @@ public:
public:
Mat4 offset_matrix;
Mat4 final_transformation;
size_t bone_idx;
};
struct RenderBatch3D

View file

@ -135,15 +135,19 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="src\Actor.cpp" />
<ClCompile Include="src\Editor.cpp" />
<ClCompile Include="src\Main.cpp" />
<ClCompile Include="src\Player.cpp" />
<ClCompile Include="src\Sandbox.cpp" />
</ItemGroup>
<ItemGroup>
<None Include=".clang-format" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\Actor.h" />
<ClInclude Include="src\Editor.h" />
<ClInclude Include="src\Player.h" />
<ClInclude Include="src\Sandbox.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View file

@ -4,6 +4,8 @@
<ClCompile Include="src\Main.cpp" />
<ClCompile Include="src\Sandbox.cpp" />
<ClCompile Include="src\Editor.cpp" />
<ClCompile Include="src\Actor.cpp" />
<ClCompile Include="src\Player.cpp" />
</ItemGroup>
<ItemGroup>
<None Include=".clang-format" />
@ -11,5 +13,7 @@
<ItemGroup>
<ClInclude Include="src\Sandbox.h" />
<ClInclude Include="src\Editor.h" />
<ClInclude Include="src\Actor.h" />
<ClInclude Include="src\Player.h" />
</ItemGroup>
</Project>

45
Sandbox/src/Actor.cpp Normal file
View file

@ -0,0 +1,45 @@
#include "Actor.h"
#include "KP3D_Renderer3D.h"
#include "Sandbox.h"
Actor::Actor(kp3d::Vec3 position)
{
model.reset(new kp3d::Model());
model->noflip = true;
model->Load("konata/Konata_Anim_2.dae");
// I have doubts this is the best way to go about this, but in any case, this gives us a means of playing with bones while the
// animation is playing. This is sort of our way around the problem of "combining" animations, e.g. looking up and down while
// walking.
model->func_intercept_transform = [](kp3d::TransformOp op, float ticks, const std::string& bone, kp3d::Vec3& trans)
{
if (op == kp3d::ROTATE)
{
if (bone == "Konatap_ARM_ValveBiped_Bip01_Spine2")
trans.z += kp3d::ToRadians(sandbox->camera.pitch * 0.5f);
}
};
model->SetAnimation(0);
model->StartAnimation();
model_transform = {position, {kp3d::ToRadians(-90.0f), 0.0f, 0.0f}, kp3d::Vec3(1.0f)};
}
void Actor::Update()
{
model->UpdateAnimation();
float angle = 0.0f;// kp3d::ToDegrees(atan2f(-sandbox->camera.position.z, sandbox->camera.position.x));
angle += -sandbox->camera.yaw - 90.0f;
model_transform.rotation.y = kp3d::ToRadians(angle);
}
void Actor::Render()
{
kp3d::Renderer3D::PushShader(kp3d::Renderer3D::GetMapShader());
kp3d::Renderer3D::DrawModel(*model, model_transform);
kp3d::Renderer3D::PopShader();
}

22
Sandbox/src/Actor.h Normal file
View file

@ -0,0 +1,22 @@
#pragma once
#include <memory>
#include <KP3D_Common.h>
#include <KP3D_Transform.h>
#include <KP3D_Model.h>
#include <KP3D_Texture.h>
#include <KP3D_Math.h>
class Actor
{
public:
Actor(kp3d::Vec3 position = {0.0f, 0.0f, 0.0f});
void Update();
void Render();
public:
kp3d::Transform transform, model_transform;
std::shared_ptr<kp3d::Model> model;
};

View file

@ -880,6 +880,7 @@ void Editor::UpdateModeThings()
{
using namespace kp3d;
// Placing/moving things
struct Target
{
Vec3 position;
@ -967,6 +968,25 @@ void Editor::UpdateModeThings()
{
m_hovered_thing = nullptr;
}
// Deleting things
if (sandbox->IsKeyDown(KEY_DELETE))
{
PushAction();
sandbox->map.things.erase(
std::remove_if(
sandbox->map.things.begin(),
sandbox->map.things.end(),
[this](const Thing& thing) { return &thing == m_selected_thing; }
),
sandbox->map.things.end()
);
m_selected_thing = nullptr;
m_hovered_thing = nullptr;
sandbox->KeyReset(KEY_DELETE);
}
}
void Editor::RenderModeThings()
@ -1506,7 +1526,7 @@ void Editor::OnKeyPress(const kp3d::KeyPressEvent* e)
void Editor::PushAction()
{
const size_t MAX_UNDOS = 50;
previous_maps.push_back({sandbox->map.sectors});
previous_maps.push_back({sandbox->map.sectors, sandbox->map.things});
if (previous_maps.size() > MAX_UNDOS)
previous_maps.erase(previous_maps.begin());
changes++;
@ -1517,8 +1537,9 @@ void Editor::Undo()
if (previous_maps.empty())
return;
next_maps.push_back({sandbox->map.sectors});
next_maps.push_back({sandbox->map.sectors, sandbox->map.things });
sandbox->map.sectors = previous_maps.back().sectors;
sandbox->map.things = previous_maps.back().things;
previous_maps.pop_back();
changes--;
RebuildMap();
@ -1531,6 +1552,7 @@ void Editor::Redo()
PushAction();
sandbox->map.sectors = next_maps.back().sectors;
sandbox->map.things = next_maps.back().things;
next_maps.pop_back();
changes++;
RebuildMap();

View file

@ -68,7 +68,7 @@ public:
struct MapData
{
std::vector<std::shared_ptr<kp3d::Sector>> sectors;
// things...
std::vector<kp3d::Thing> things;
};
std::vector<MapData> previous_maps;
std::vector<MapData> next_maps;

61
Sandbox/src/Player.cpp Normal file
View file

@ -0,0 +1,61 @@
#include "Player.h"
#include <memory>
#include "Sandbox.h"
#include <KP3D_Model.h>
#include <KP3D_Renderer3D.h>
std::shared_ptr<kp3d::Model> vm_model, vm_model_arms;
kp3d::Transform vm_transform;
kp3d::Camera vm_dummy;
float ticks = 0.0f;
void InitPlayer()
{
vm_model.reset(new kp3d::Model());
vm_model->Load("pistol/gun.obj");
vm_model_arms.reset(new kp3d::Model());
vm_model_arms->Load("konata/Konata_Arms.obj");
vm_dummy.yaw = 90.0f;
vm_dummy.UpdateMatrix();
}
void UpdatePlayer()
{
ticks++;
}
void RenderPlayer()
{
kp3d::Transform base_transform, arms_transform, gun_transform;
base_transform.translation.x += 1.0f;
base_transform.translation.y -= 0.75f + sinf(ticks / 24.0f) * 0.1f;
base_transform.translation.z += 2.2f;
arms_transform.scale = kp3d::Vec3(10.0f);
arms_transform.translation.x = 0.2f;
arms_transform.translation.y = -11.7f;
arms_transform.translation.z = -4.5f;
gun_transform.translation += base_transform.translation;
gun_transform.rotation += base_transform.rotation;
arms_transform.translation += base_transform.translation;
arms_transform.rotation += base_transform.rotation;
arms_transform.translation *= 0.1f;
gun_transform.translation *= 0.1f;
arms_transform.scale *= 0.1f;
gun_transform.scale *= 0.1f;
// glDisable(GL_DEPTH_TEST);
// glEnable(GL_CULL_FACE);
kp3d::Renderer3D::PushShader(kp3d::Renderer3D::GetMapShader());
kp3d::Renderer3D::DrawModel(*vm_model_arms, arms_transform.GetProjectedTransformationMatrix(vm_dummy, sandbox->projection));
kp3d::Renderer3D::DrawModel(*vm_model, gun_transform.GetProjectedTransformationMatrix(vm_dummy, sandbox->projection));
kp3d::Renderer3D::PopShader();
// glDisable(GL_CULL_FACE);
// glEnable(GL_DEPTH_TEST);
}

5
Sandbox/src/Player.h Normal file
View file

@ -0,0 +1,5 @@
#pragma once
void InitPlayer();
void UpdatePlayer();
void RenderPlayer();

View file

@ -10,6 +10,8 @@
#include <KP3D_StringUtils.h>
#include <KP3D_Resources.h>
#include "Player.h"
static kp3d::Texture tex;
static std::vector<kp3d::XYf> points;
@ -19,14 +21,13 @@ Sandbox::Sandbox(const std::string& path):
kp3d::res::LoadMaterials();
kp3d::res::LoadTextures();
seal.noflip = true;
seal.Load("konata/Konata_PistolAnimations.dae");
tex.Load("logo.png");
crosshair.Load(".kp3d/crosshair.png");
projection.InitPerspective(70.0f, (float) GetWidth() / (float) GetHeight());
map.Init();
InitPlayer();
using namespace ksi;
kp3d::console::environment.Set("spawn-thingy", {CELL_FUNCTION_CPP, [&](std::list<Cell> args) -> Cell {
float x = FromCell<float>(args.front());
@ -47,6 +48,11 @@ Sandbox::Sandbox(const std::string& path):
}});
m_mode = MODE_MENU;
actors.emplace_back(kp3d::Vec3{-2.0f, 0.0f, -2.0f});
actors.emplace_back(kp3d::Vec3{-0.0f, 0.0f, -0.0f});
actors.emplace_back(kp3d::Vec3{5.0f, -0.5f, -5.0f});
actors.emplace_back(kp3d::Vec3{0.0f, 0.0f, -10.0f});
}
Sandbox::~Sandbox()
@ -100,14 +106,12 @@ void Sandbox::Update()
//if (IsKeyDown(kp3d::KEY_F)) camera.Rotate(kp3d::Camera::AXIS_Y, -qerf_speed);
ResetMouseCursor([&](float x, float y) { camera.UpdateMouseLook({x, y}); });
camera.UpdateMatrix();
projection.InitPerspective(70.0f, (float)GetWidth() / (float)GetHeight()); // INEFFICIENT!
seal.SetAnimation(0);
if (IsKeyDown(kp3d::KEY_L))
{
seal.StartAnimation();
KeyReset(kp3d::KEY_L);
}
seal.UpdateAnimation();
for (Actor& a: actors)
a.Update();
UpdatePlayer();
}
void Sandbox::Render()
@ -123,10 +127,10 @@ void Sandbox::Render()
if (m_mode == MODE_EDIT)
editor.RenderMap();
kp3d::Renderer3D::DrawBillboard(tex, {}, { 1, 1 });
kp3d::Transform trans{ {0.0f, 0.0f, 0}, {kp3d::ToRadians(-90), 0, 0}, kp3d::Vec3(1.0f)};
kp3d::Renderer3D::PushShader(kp3d::Renderer3D::GetMapShader());
kp3d::Renderer3D::DrawModel(seal, trans);
kp3d::Renderer3D::PopShader();
for (Actor& a: actors)
a.Render();
if (m_mode == MODE_GAME)
RenderPlayer();
kp3d::Renderer3D::End();
// 2D scene

View file

@ -9,6 +9,7 @@
#include <KP3D_Model.h>
#include "Editor.h"
#include "Actor.h"
enum Mode
{
@ -36,7 +37,7 @@ public:
kp3d::Texture crosshair;
kp3d::Mat4 projection;
kp3d::Model seal;
std::vector<Actor> actors;
private:
// KP3D essentials