|
|
@ -53,7 +53,9 @@ int Camera::add_relative_impulse(DIRECTION impulse_direction, float speed) {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float val = movement.z;
|
|
|
|
movement += SphereToCart(dir) * speed;
|
|
|
|
movement += SphereToCart(dir) * speed;
|
|
|
|
|
|
|
|
movement.z = val;
|
|
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -79,8 +81,16 @@ int Camera::update(double delta_time) {
|
|
|
|
position.y += static_cast<float>(movement.y * delta_time * multiplier);
|
|
|
|
position.y += static_cast<float>(movement.y * delta_time * multiplier);
|
|
|
|
position.z += static_cast<float>(movement.z * delta_time * multiplier);
|
|
|
|
position.z += static_cast<float>(movement.z * delta_time * multiplier);
|
|
|
|
|
|
|
|
|
|
|
|
movement *= static_cast<float>(friction_coefficient * delta_time * multiplier);
|
|
|
|
movement.x *= static_cast<float>(friction_coefficient * delta_time * multiplier);
|
|
|
|
|
|
|
|
movement.y *= static_cast<float>(friction_coefficient * delta_time * multiplier);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (position.z < 3.0f){
|
|
|
|
|
|
|
|
position.z = 3.0f;
|
|
|
|
|
|
|
|
movement.z = -0.1;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// gravity
|
|
|
|
|
|
|
|
movement.z -= 0.7f * delta_time;
|
|
|
|
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -117,6 +127,8 @@ void Camera::recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Even
|
|
|
|
else if (held_event->code == sf::Keyboard::D) {
|
|
|
|
else if (held_event->code == sf::Keyboard::D) {
|
|
|
|
add_relative_impulse(Camera::DIRECTION::RIGHT, default_impulse);
|
|
|
|
add_relative_impulse(Camera::DIRECTION::RIGHT, default_impulse);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
else if (event->type == vr::Event::KeyPressed) {
|
|
|
|
else if (event->type == vr::Event::KeyPressed) {
|
|
|
@ -128,6 +140,8 @@ void Camera::recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Even
|
|
|
|
mouse_enabled = false;
|
|
|
|
mouse_enabled = false;
|
|
|
|
else
|
|
|
|
else
|
|
|
|
mouse_enabled = true;
|
|
|
|
mouse_enabled = true;
|
|
|
|
|
|
|
|
} else if (key_event->code == sf::Keyboard::Space) {
|
|
|
|
|
|
|
|
movement.z = 0.25f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -198,20 +212,20 @@ void Camera::render_gui() {
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::Begin("Camera");
|
|
|
|
ImGui::Begin("Camera");
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::Columns(2);
|
|
|
|
ImGui::Columns(2);
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::Text("Camera Inclination");
|
|
|
|
ImGui::Text("Camera Inclination");
|
|
|
|
ImGui::Text("Camera Azimuth");
|
|
|
|
ImGui::Text("Camera Azimuth");
|
|
|
|
ImGui::Text("Camera Pos_X");
|
|
|
|
ImGui::Text("Camera Pos_X");
|
|
|
|
ImGui::Text("Camera Poz_Y");
|
|
|
|
ImGui::Text("Camera Poz_Y");
|
|
|
|
ImGui::Text("Camera Poz_Z");
|
|
|
|
ImGui::Text("Camera Poz_Z");
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::NextColumn();
|
|
|
|
ImGui::NextColumn();
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::Text("%f", direction.x);
|
|
|
|
ImGui::Text("%f", direction.x);
|
|
|
|
ImGui::Text("%f", direction.y);
|
|
|
|
ImGui::Text("%f", direction.y);
|
|
|
|
ImGui::Text("%f", position.x);
|
|
|
|
ImGui::Text("%f", position.x);
|
|
|
|
ImGui::Text("%f", position.y);
|
|
|
|
ImGui::Text("%f", position.y);
|
|
|
|
ImGui::Text("%f", position.z);
|
|
|
|
ImGui::Text("%f", position.z);
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::Separator();
|
|
|
|
ImGui::Separator();
|
|
|
|