mirror of
https://github.com/xtreme8000/CavEX.git
synced 2025-01-22 09:11:55 -05:00
Render player hand (almost) correct in first person
This commit is contained in:
parent
2075a08a02
commit
ecbb91027e
1 changed files with 44 additions and 27 deletions
|
@ -91,18 +91,6 @@ void screen_ingame_render3D(struct screen* s, mat4 view) {
|
|||
float sqrtLerpPI = sqrtf(dig_lerp) * GLM_PI;
|
||||
float sinHalfCircleWeird = sinf(glm_pow2(dig_lerp) * GLM_PI);
|
||||
|
||||
mat4 model;
|
||||
glm_translate_make(model,
|
||||
(vec3) {0.56F - sinf(sqrtLerpPI) * 0.4F,
|
||||
-0.52F + sinf(sqrtLerpPI * 2.0F) * 0.2F
|
||||
- 0.6F * place_lerp
|
||||
- 0.4F * sinf(swing_lerp * GLM_PI),
|
||||
-0.72F - sinHalfCircle * 0.2F});
|
||||
glm_rotate_y(model, glm_rad(45.0F), model);
|
||||
glm_rotate_y(model, glm_rad(-sinHalfCircleWeird * 20.0F), model);
|
||||
glm_rotate_z(model, glm_rad(-sinf(sqrtLerpPI) * 20.0F), model);
|
||||
glm_rotate_x(model, glm_rad(-sinf(sqrtLerpPI) * 80.0F), model);
|
||||
|
||||
struct block_data in_block
|
||||
= world_get_block(&gstate.world, floorf(gstate.camera.x),
|
||||
floorf(gstate.camera.y), floorf(gstate.camera.z));
|
||||
|
@ -110,27 +98,56 @@ void screen_ingame_render3D(struct screen* s, mat4 view) {
|
|||
|
||||
gfx_depth_range(0.0F, 0.1F);
|
||||
|
||||
mat4 model;
|
||||
struct item_data item;
|
||||
|
||||
if(inventory_get_slot(windowc_get_latest(gstate.windows[WINDOWC_INVENTORY]),
|
||||
slot + INVENTORY_SLOT_HOTBAR, &item)
|
||||
&& item_get(&item)) {
|
||||
glm_translate_make(model,
|
||||
(vec3) {0.56F - sinf(sqrtLerpPI) * 0.4F,
|
||||
-0.52F + sinf(sqrtLerpPI * 2.0F) * 0.2F
|
||||
- 0.6F * place_lerp
|
||||
- 0.4F * sinf(swing_lerp * GLM_PI),
|
||||
-0.72F - sinHalfCircle * 0.2F});
|
||||
glm_rotate_y(model, glm_rad(45.0F), model);
|
||||
glm_rotate_y(model, glm_rad(-sinHalfCircleWeird * 20.0F), model);
|
||||
glm_rotate_z(model, glm_rad(-sinf(sqrtLerpPI) * 20.0F), model);
|
||||
glm_rotate_x(model, glm_rad(-sinf(sqrtLerpPI) * 80.0F), model);
|
||||
|
||||
glm_scale_uni(model, 0.4F);
|
||||
glm_translate(model, (vec3) {-0.5F, -0.5F, -0.5F});
|
||||
render_item_update_light(light);
|
||||
items[item.id]->renderItem(item_get(&item), &item, model, false,
|
||||
R_ITEM_ENV_FIRSTPERSON);
|
||||
} else {
|
||||
glm_translate(model, (vec3) {0.0F, 0.2F, 0.0F});
|
||||
glm_rotate_y(model, glm_rad(-90.0F), model);
|
||||
glm_rotate_z(model, glm_rad(-120.0F), model);
|
||||
glm_scale_uni(model, 1.0F / 16.0F);
|
||||
glm_translate_make(model,
|
||||
(vec3) {0.64F - sinf(sqrtLerpPI) * 0.3F,
|
||||
-0.6F + sinf(sqrtLerpPI * 2.0F) * 0.4F
|
||||
- 0.4F * sinf(swing_lerp * GLM_PI),
|
||||
-0.72F - sinHalfCircle * 0.4F});
|
||||
glm_rotate_y(model, glm_rad(45.0F), model);
|
||||
glm_rotate_y(model, glm_rad(sinf(sqrtLerpPI) * 70.0F), model);
|
||||
glm_rotate_z(model, glm_rad(-sinHalfCircleWeird * 20.0F), model);
|
||||
|
||||
gfx_lighting(false);
|
||||
gfx_bind_texture(&texture_mob_char);
|
||||
// TODO: position, depth fix in inventory
|
||||
render_model_box(model, (vec3) {0.0F, 0.0F, 0.0F},
|
||||
(vec3) {2.0F, 12.0F, 2.0F}, (vec3) {0.0F, 0.0F, 0.0F},
|
||||
(ivec2) {44, 20}, (ivec3) {4, 4, 12}, 0.0F, true,
|
||||
|
||||
glm_translate(model, (vec3) {-1.0F, 3.6F, 3.5F});
|
||||
glm_rotate_z(model, glm_rad(120.0F), model);
|
||||
glm_rotate_x(model, glm_rad(200.0F), model);
|
||||
glm_rotate_y(model, glm_rad(-135.0F), model);
|
||||
glm_translate(model, (vec3) {5.6F, 0.0F, 0.0F});
|
||||
|
||||
glm_translate(model,
|
||||
(vec3) {-5.0F / 16.0F, 2.0F / 16.0F, 0.0F / 16.0F});
|
||||
glm_scale_uni(model, 1.0F / 16.0F);
|
||||
glm_translate(model, (vec3) {-3.0F, -2.0F, -2.0F});
|
||||
|
||||
// TODO: depth fix in inventory
|
||||
render_model_box(model, (vec3) {2, 12, 2}, (vec3) {2, 0, 2},
|
||||
(vec3) {180.0F, 0, 0}, (ivec2) {44, 20},
|
||||
(ivec3) {4, 4, 12}, 0.0F, false,
|
||||
gfx_lookup_light(light));
|
||||
}
|
||||
|
||||
|
@ -140,13 +157,13 @@ void screen_ingame_render3D(struct screen* s, mat4 view) {
|
|||
static void screen_ingame_update(struct screen* s, float dt) {
|
||||
if(gstate.camera_hit.hit && input_pressed(IB_ACTION2)
|
||||
&& !gstate.digging.active) {
|
||||
svin_rpc_send(&(struct server_rpc) {
|
||||
.type = SRPC_BLOCK_PLACE,
|
||||
.payload.block_place.x = gstate.camera_hit.x,
|
||||
.payload.block_place.y = gstate.camera_hit.y,
|
||||
.payload.block_place.z = gstate.camera_hit.z,
|
||||
.payload.block_place.side = gstate.camera_hit.side,
|
||||
});
|
||||
svin_rpc_send(&(struct server_rpc) {
|
||||
.type = SRPC_BLOCK_PLACE,
|
||||
.payload.block_place.x = gstate.camera_hit.x,
|
||||
.payload.block_place.y = gstate.camera_hit.y,
|
||||
.payload.block_place.z = gstate.camera_hit.z,
|
||||
.payload.block_place.side = gstate.camera_hit.side,
|
||||
});
|
||||
|
||||
if(inventory_get_hotbar_item(
|
||||
windowc_get_latest(gstate.windows[WINDOWC_INVENTORY]), NULL)) {
|
||||
|
|
Loading…
Reference in a new issue