mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-27 18:48:36 +02:00
~ | Modified portal map and portal
This commit is contained in:
@ -3,21 +3,22 @@ CAM -3.31413 5.09653 9.67312 -19.6 -74.7992 0 1 90 5
|
||||
MAT 100 200 100 0.0 0.0 0.0 CHK 10.0 // 0
|
||||
MAT 200 200 200 0.0 0.0 0.0 // 1
|
||||
|
||||
MAT 255 255 255 0 1 0 DIE -1 // 2 portal
|
||||
MAT 255 255 255 0 1 0 DIE -1 // 3 portal
|
||||
MAT 200 100 100 0 1 0 LAM -1 // 2 portal
|
||||
MAT 100 200 100 0 1 0 LAM -1 // 3 portal
|
||||
MAT 200 100 200 0 1 0 LAM -1 // 4 portal
|
||||
MAT 100 100 200 0 1 0 LAM -1 // 5 portal
|
||||
|
||||
MAT 255 255 255 0 1 0 DIE -1 // 4 portal
|
||||
MAT 255 255 255 0 1 0 DIE -1 // 5 portal
|
||||
MAT 255 255 255 0 1 0 DIE -1 // 6 portal void
|
||||
|
||||
qu -15 0 -15 30 0 0 0 0 30 0 0
|
||||
|
||||
# long tunnel entrance
|
||||
po -9 0 3.0 3 0 0 0 3 0 0 2
|
||||
po 6 0 0 3 0 0 0 3 0 1 2
|
||||
po -9 0 3 3 0 0 0 3 0 0 6
|
||||
po 6 0 0 3 0 0 0 3 0 1 6
|
||||
|
||||
# long tunnel entrance behind
|
||||
po -9 0 -6 3 0 0 0 3 0 1 3
|
||||
po 6 0 -3 3 0 0 0 3 0 0 3
|
||||
po -9 0 -6 3 0 0 0 3 0 1 6
|
||||
po 6 0 -3 3 0 0 0 3 0 0 6
|
||||
|
||||
# long tunnel
|
||||
qu -9.0 0 -6 0 3 0 0 0 9 0 1
|
||||
@ -30,30 +31,30 @@ qu 6 0 -3 0 3 0 0 0 3 0 1
|
||||
qu 6 3 -3 3 0 0 0 0 3 0 1
|
||||
|
||||
#small tunnel entrance
|
||||
po 6 0 0 3 0 0 0 3 0 0 4
|
||||
po -9 0 3 3 0 0 0 3 0 1 4
|
||||
po 6 0 0 3 0 0 0 3 0 0 6
|
||||
po -9 0 3 3 0 0 0 3 0 1 6
|
||||
|
||||
#small tunnel entrance behind
|
||||
po 6 0 -3 3 0 0 0 3 0 1 5
|
||||
po -9 0 -6 3 0 0 0 3 0 0 5
|
||||
po 6 0 -3 3 0 0 0 3 0 1 6
|
||||
po -9 0 -6 3 0 0 0 3 0 0 6
|
||||
|
||||
|
||||
##############
|
||||
|
||||
MAT 200 100 100 0.0 0.0 0.0 CHK 5.0 // 6
|
||||
MAT 200 100 100 0.0 0.0 0.0 CHK 5.0 // 7
|
||||
|
||||
#floor 1
|
||||
qu 15 0 15 15 0 0 0 0 -15 0 6
|
||||
qu 27 0 15 15 0 0 0 0 -15 0 6
|
||||
qu 15 0 15 15 0 0 0 0 -15 0 7
|
||||
qu 27 0 15 15 0 0 0 0 -15 0 7
|
||||
|
||||
#upstairs
|
||||
qu 15 0 0 15 0 0 0 5 -15 0 6
|
||||
qu 27 0 0 15 0 0 0 5 -15 0 6
|
||||
qu 15 0 0 15 0 0 0 5 -15 0 7
|
||||
qu 27 0 0 15 0 0 0 5 -15 0 7
|
||||
|
||||
#floor 2
|
||||
|
||||
qu 15 5 -15 15 0 0 0 0 -15 0 6
|
||||
qu 27 5 -15 15 0 0 0 0 -15 0 6
|
||||
qu 15 5 -15 15 0 0 0 0 -15 0 7
|
||||
qu 27 5 -15 15 0 0 0 0 -15 0 7
|
||||
|
||||
#upward tunnel
|
||||
qu 21 -7.5 -15 0 0 15 0 15 5 0 1
|
||||
@ -66,16 +67,20 @@ qu 36 -7.5 -15 0 0 15 0 15 5 0 1
|
||||
qu 33 9.165 -15 0 -5 15 3 0 0 0 1
|
||||
|
||||
#upward tunnel entrance
|
||||
po 21 0 0 0 4.165 0 3 0 0 1 2
|
||||
po 36 5 -15 0 4.165 0 -3 0 0 1 2
|
||||
po 21 0 0 0 4.165 0 3 0 0 1 6
|
||||
po 36 5 -15 0 4.165 0 -3 0 0 1 6
|
||||
|
||||
#upward tunnel entrance behind
|
||||
po 21 5 -15 0 4.165 0 3 0 0 0 3
|
||||
po 33 0 0 0 4.165 0 3 0 0 0 3
|
||||
|
||||
|
||||
# po 24 5 -15 0 4.165 0 -3 0 0 0 3
|
||||
# po 33 0 0 0 4.165 0 3 0 0 0 3
|
||||
upward tunnel entrance behind
|
||||
po 24 5 -15 0 4.165 0 -3 0 0 0 6
|
||||
po 33 0 0 0 4.165 0 3 0 0 0 6
|
||||
|
||||
po 33 5 -15 0 4.165 0 3 0 0 1 6
|
||||
po 24 0 0 0 4.165 0 -3 0 0 1 6
|
||||
|
||||
po 21 5 -15 0 4.165 0 3 0 0 0 6
|
||||
po 36 0 0 0 4.165 0 -3 0 0 0 6
|
||||
|
||||
sp 34.5 7.5 -18 1 2
|
||||
sp 22.5 2.5 3 1 3
|
||||
sp 22.5 7.5 -18 1 4
|
||||
sp 34.5 2.5 3 1 5
|
@ -79,13 +79,17 @@ void Camera::update(Scene *scene, float delta_time, Renderer &renderer)
|
||||
|
||||
int Camera::portalTeleport(Scene *scene, float delta_time, Renderer &renderer)
|
||||
{
|
||||
static bool tp_last_frame = false;
|
||||
if (tp_last_frame)
|
||||
static int max_cooldown = 10;
|
||||
static int tp_cooldown = max_cooldown;
|
||||
if (tp_cooldown > 0)
|
||||
{
|
||||
tp_last_frame = false;
|
||||
tp_cooldown -= 1;
|
||||
return (0);
|
||||
}
|
||||
|
||||
GPUObject portal;
|
||||
float min_distance = std::numeric_limits<float>::max();
|
||||
|
||||
for (const GPUObject &obj : scene->getObjectData())
|
||||
{
|
||||
if (obj.type != (int)Object::Type::PORTAL)
|
||||
@ -112,17 +116,33 @@ int Camera::portalTeleport(Scene *scene, float delta_time, Renderer &renderer)
|
||||
float distance_future_pos = glm::length(future_pos - _position);
|
||||
float distance_portal = glm::length(point_projected - _position);
|
||||
|
||||
float imprecision = 0.1f;
|
||||
if (distance_portal <= distance_future_pos && glm::dot(glm::normalize(future_pos - _position), obj.normal) > 0.0f)
|
||||
{
|
||||
if (distance_portal < min_distance)
|
||||
{
|
||||
min_distance = distance_portal;
|
||||
portal = obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (min_distance == std::numeric_limits<float>::max())
|
||||
return (0);
|
||||
|
||||
std::cout << "Teleport" << std::endl;
|
||||
tp_last_frame = true;
|
||||
|
||||
GPUObject linked_portal = scene->getObjectData()[obj.radius];
|
||||
float imprecision = 0.1f;
|
||||
tp_cooldown = max_cooldown;
|
||||
|
||||
glm::mat3 portal_transform = glm::mat3(linked_portal.transform) * glm::inverse(glm::mat3(obj.transform));
|
||||
glm::vec3 future_pos = _position + _velocity * delta_time;
|
||||
float distance_future_pos = glm::length(future_pos - _position);
|
||||
|
||||
if (dot(obj.normal, linked_portal.normal) > 0.0)
|
||||
GPUObject linked_portal = scene->getObjectData()[portal.radius];
|
||||
|
||||
glm::mat3 portal_transform = glm::mat3(linked_portal.transform) * glm::inverse(glm::mat3(portal.transform));
|
||||
|
||||
if (dot(portal.normal, linked_portal.normal) > 0.0)
|
||||
{
|
||||
glm::mat3 reflection = glm::mat3(1.0) - 2.0f * glm::outerProduct(linked_portal.normal, linked_portal.normal);
|
||||
portal_transform *= reflection;
|
||||
@ -131,14 +151,14 @@ int Camera::portalTeleport(Scene *scene, float delta_time, Renderer &renderer)
|
||||
//teleportation
|
||||
|
||||
glm::vec3 previous_position = _position;
|
||||
glm::vec3 relative_pos = _position - obj.position;
|
||||
glm::vec3 relative_pos = _position - portal.position;
|
||||
glm::vec3 transformed_relative_pos = portal_transform * relative_pos;
|
||||
|
||||
float remaining_distance = distance_future_pos - distance_portal + imprecision;
|
||||
float remaining_distance = distance_future_pos - min_distance + imprecision;
|
||||
glm::vec3 new_movement = remaining_distance * portal_transform * linked_portal.normal;
|
||||
|
||||
_position = linked_portal.position + transformed_relative_pos - new_movement;
|
||||
// _position = (linked_portal.position) + (_position - obj.position) - (((distance_future_pos - distance_portal + imprecision)) * linked_portal.normal);
|
||||
// _position = (linked_portal.position) + (_position - portal.position) - (((distance_future_pos - distance_portal + imprecision)) * linked_portal.normal);
|
||||
|
||||
// view direction
|
||||
|
||||
@ -155,11 +175,6 @@ int Camera::portalTeleport(Scene *scene, float delta_time, Renderer &renderer)
|
||||
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void Camera::processMouse(float xoffset, float yoffset, bool constraint_pitch = true)
|
||||
{
|
||||
|
Reference in New Issue
Block a user