add inertia & update drop visuals
This commit is contained in:
parent
b93668ba94
commit
a4cf1e4820
@ -36,9 +36,7 @@ end
|
|||||||
function on_grounded(force)
|
function on_grounded(force)
|
||||||
local matrix = mat4.idt()
|
local matrix = mat4.idt()
|
||||||
mat4.rotate(matrix, {0, 1, 0}, math.random()*360, matrix)
|
mat4.rotate(matrix, {0, 1, 0}, math.random()*360, matrix)
|
||||||
if model == "aabb" then
|
mat4.rotate(matrix, {1, 0, 0}, 90, matrix)
|
||||||
mat4.rotate(matrix, {1, 0, 0}, 90, matrix)
|
|
||||||
end
|
|
||||||
mat4.scale(matrix, scale, matrix)
|
mat4.scale(matrix, scale, matrix)
|
||||||
rig:set_matrix(0, matrix)
|
rig:set_matrix(0, matrix)
|
||||||
inair = false
|
inair = false
|
||||||
|
|||||||
@ -348,12 +348,22 @@ void WorldRenderer::renderHands(const Camera& camera, const Assets& assets) {
|
|||||||
// configure model matrix
|
// configure model matrix
|
||||||
const glm::vec3 itemOffset(0.08f, 0.035f, -0.1);
|
const glm::vec3 itemOffset(0.08f, 0.035f, -0.1);
|
||||||
|
|
||||||
|
static glm::mat4 prevRotation(1.0f);
|
||||||
|
|
||||||
|
const float speed = 24.0f;
|
||||||
glm::mat4 matrix = glm::translate(glm::mat4(1.0f), itemOffset);
|
glm::mat4 matrix = glm::translate(glm::mat4(1.0f), itemOffset);
|
||||||
matrix = glm::scale(matrix, glm::vec3(0.1f));
|
matrix = glm::scale(matrix, glm::vec3(0.1f));
|
||||||
matrix = camera.rotation * matrix *
|
glm::mat4 rotation = camera.rotation;
|
||||||
|
glm::quat rot0 = glm::quat_cast(prevRotation);
|
||||||
|
glm::quat rot1 = glm::quat_cast(rotation);
|
||||||
|
glm::quat finalRot =
|
||||||
|
glm::slerp(rot0, rot1, static_cast<float>(engine->getDelta() * speed));
|
||||||
|
rotation = glm::mat4_cast(finalRot);
|
||||||
|
matrix = rotation * matrix *
|
||||||
glm::rotate(
|
glm::rotate(
|
||||||
glm::mat4(1.0f), -glm::pi<float>() * 0.5f, glm::vec3(0, 1, 0)
|
glm::mat4(1.0f), -glm::pi<float>() * 0.5f, glm::vec3(0, 1, 0)
|
||||||
);
|
);
|
||||||
|
prevRotation = rotation;
|
||||||
auto offset = -(camera.position - player->getPosition());
|
auto offset = -(camera.position - player->getPosition());
|
||||||
float angle = glm::radians(player->cam.x - 90);
|
float angle = glm::radians(player->cam.x - 90);
|
||||||
float cos = glm::cos(angle);
|
float cos = glm::cos(angle);
|
||||||
@ -361,8 +371,8 @@ void WorldRenderer::renderHands(const Camera& camera, const Assets& assets) {
|
|||||||
|
|
||||||
float newX = offset.x * cos - offset.z * sin;
|
float newX = offset.x * cos - offset.z * sin;
|
||||||
float newZ = offset.x * sin + offset.z * cos;
|
float newZ = offset.x * sin + offset.z * cos;
|
||||||
matrix = matrix *
|
offset = glm::vec3(newX, offset.y, newZ);
|
||||||
glm::translate(glm::mat4(1.0f), glm::vec3(newX, offset.y, newZ));
|
matrix = matrix * glm::translate(glm::mat4(1.0f), offset);
|
||||||
|
|
||||||
// render
|
// render
|
||||||
texture_names_map map = {};
|
texture_names_map map = {};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user