| 355 | } |
| 356 | |
| 357 | void Renderer::PrepareRopes(RenderView& view) |
| 358 | { |
| 359 | for (const auto& rope : Ropes) |
| 360 | { |
| 361 | if (!rope.active) |
| 362 | continue; |
| 363 | |
| 364 | auto translationMatrix = Matrix::CreateTranslation(rope.position.ToVector3()); |
| 365 | auto absolutePoints = std::array<Vector3, 24>{}; |
| 366 | |
| 367 | for (int i = 0; i < rope.segment.size(); i++) |
| 368 | { |
| 369 | const auto* segment = &rope.PrevMeshSegments[i]; |
| 370 | |
| 371 | auto relPos = Vector3(segment->x >> FP_SHIFT, segment->y >> FP_SHIFT, segment->z >> FP_SHIFT); |
| 372 | auto prevOutput = Vector3::Transform(relPos, translationMatrix); |
| 373 | |
| 374 | segment = &rope.meshSegment[i]; |
| 375 | |
| 376 | relPos = Vector3(segment->x >> FP_SHIFT, segment->y >> FP_SHIFT, segment->z >> FP_SHIFT); |
| 377 | auto currentOutput = Vector3::Transform(relPos, translationMatrix); |
| 378 | |
| 379 | auto absolutePos = Vector3::Lerp(prevOutput, currentOutput, GetInterpolationFactor()); |
| 380 | absolutePoints[i] = absolutePos; |
| 381 | } |
| 382 | |
| 383 | for (int i = 0; i < (rope.segment.size() - 1); i++) |
| 384 | { |
| 385 | const auto& pos0 = absolutePoints[i]; |
| 386 | const auto& pos1 = absolutePoints[i + 1]; |
| 387 | auto pos = (pos0 + pos1) / 2; |
| 388 | |
| 389 | auto dir = pos1 - pos0; |
| 390 | dir.Normalize(); |
| 391 | |
| 392 | AddSpriteBillboardConstrained( |
| 393 | &_sprites[Objects[ID_DEFAULT_SPRITES].meshIndex + SPR_EMPTY1], |
| 394 | pos, _rooms[rope.room].AmbientLight * g_Level.Items[rope.index].Model.Color, |
| 395 | PI_DIV_2, 1.0f, Vector2(32.0f, Vector3::Distance(pos0, pos1)), BlendMode::AlphaBlend, dir, false, view); |
| 396 | } |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | void Renderer::DrawLines2D() |
| 401 | { |