add movement animation
This commit is contained in:
parent
ae145e1142
commit
79f7a84e60
@ -123,8 +123,8 @@ void keyboard(unsigned char key, int x, int y)
|
|||||||
{
|
{
|
||||||
case 'a': vehicleAngleSpeed -= 0.001f; break;
|
case 'a': vehicleAngleSpeed -= 0.001f; break;
|
||||||
case 'd': vehicleAngleSpeed += 0.001f; break;
|
case 'd': vehicleAngleSpeed += 0.001f; break;
|
||||||
case 'w': vehicleSpeed += 0.01f; break;
|
case 'w': vehicleSpeed += 0.001f; break;
|
||||||
case 's': vehicleSpeed -= 0.01f; break;
|
case 's': vehicleSpeed -= 0.001f; break;
|
||||||
case 'z': vehiclePos += vehicleSide * moveSpeed; break;
|
case 'z': vehiclePos += vehicleSide * moveSpeed; break;
|
||||||
case 'x': vehiclePos -= vehicleSide * moveSpeed; break;
|
case 'x': vehiclePos -= vehicleSide * moveSpeed; break;
|
||||||
//case 'h': rotation_y = glm::quat(1, 0, 0, 0); rotation_x = glm::quat(1, 0, 0, 0); rotationCamera = glm::quat(1, 0, 0, 0); break;
|
//case 'h': rotation_y = glm::quat(1, 0, 0, 0); rotation_x = glm::quat(1, 0, 0, 0); rotationCamera = glm::quat(1, 0, 0, 0); break;
|
||||||
@ -145,17 +145,17 @@ void keyboard(unsigned char key, int x, int y)
|
|||||||
void changeVehicleSpeed() {
|
void changeVehicleSpeed() {
|
||||||
|
|
||||||
if (vehicleAngleSpeed > 0.01f) {
|
if (vehicleAngleSpeed > 0.01f) {
|
||||||
vehicleAngleSpeed = 0.009f;
|
vehicleAngleSpeed = 0.01f;
|
||||||
}
|
}
|
||||||
if (vehicleAngleSpeed < -0.01f) {
|
if (vehicleAngleSpeed < -0.01f) {
|
||||||
vehicleAngleSpeed = -0.009f;
|
vehicleAngleSpeed = -0.01f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vehicleSpeed > 0.06f) {
|
if (vehicleSpeed > 0.01f) {
|
||||||
vehicleSpeed = 0.05f;
|
vehicleSpeed = 0.01f;
|
||||||
}
|
}
|
||||||
if (vehicleSpeed < -0.06f) {
|
if (vehicleSpeed < -0.01f) {
|
||||||
vehicleSpeed = -0.05f;
|
vehicleSpeed = -0.01f;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (lastClickedButtonFrontal)
|
switch (lastClickedButtonFrontal)
|
||||||
@ -411,7 +411,7 @@ void drawScene()
|
|||||||
glm::vec3 shipScale = glm::vec3(0.01, 0.01, 0.01);
|
glm::vec3 shipScale = glm::vec3(0.01, 0.01, 0.01);
|
||||||
shipInitialTransformation = glm::scale(shipInitialTransformation, shipScale);
|
shipInitialTransformation = glm::scale(shipInitialTransformation, shipScale);
|
||||||
|
|
||||||
shipInitialTransformation = shipInitialTransformation * glm::translate(glm::vec3(0, 0, 0)) * glm::rotate(glm::radians(-1.4f), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(0.1f));
|
shipInitialTransformation = shipInitialTransformation * glm::translate(glm::vec3(0, 0, 0)) * glm::rotate(glm::radians(-1.4f - vehicleAngleSpeed * 100), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(0.1f));
|
||||||
glm::mat4 shipModelMatrix = glm::translate(vehiclePos + vehicleDir) * glm::rotate(-vehicleAngle, glm::vec3(0, 1, 0)) * shipInitialTransformation;
|
glm::mat4 shipModelMatrix = glm::translate(vehiclePos + vehicleDir) * glm::rotate(-vehicleAngle, glm::vec3(0, 1, 0)) * shipInitialTransformation;
|
||||||
drawObjectColor(shipContext, shipModelMatrix, glm::vec3(0.6f));
|
drawObjectColor(shipContext, shipModelMatrix, glm::vec3(0.6f));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user