| 978 | } |
| 979 | |
| 980 | void Renderer::DrawObjectIn3DSpace(const DisplayItem& item) |
| 981 | { |
| 982 | if (!item.GetVisible()) |
| 983 | return; |
| 984 | |
| 985 | float alpha = GetInterpolationFactor(); |
| 986 | auto color = item.GetInterpolatedColor(alpha); |
| 987 | |
| 988 | if (color.A() <= EPSILON) |
| 989 | return; |
| 990 | |
| 991 | auto objectNumber = item.GetObjectID(); |
| 992 | auto pos = item.GetInterpolatedPosition(alpha); |
| 993 | auto orient = item.GetInterpolatedOrientation(alpha); |
| 994 | auto scale = item.GetInterpolatedScale(alpha); |
| 995 | int meshBits = item.GetMeshBits(); |
| 996 | |
| 997 | unsigned int stride = sizeof(Vertex); |
| 998 | unsigned int offset = 0; |
| 999 | |
| 1000 | float aspectRatio = (float)(_screenWidth) / _screenHeight; |
| 1001 | |
| 1002 | auto viewMatrix = Matrix::CreateLookAt(g_DrawItems.GetInterpolatedCameraPosition(alpha), g_DrawItems.GetInterpolatedCameraTargetPosition(alpha), Vector3::Up); |
| 1003 | auto projMatrix = Matrix::CreatePerspectiveFieldOfView(g_DrawItems.GetInterpolatedFov(alpha), aspectRatio, DISPLAY_ITEM_NEAR_PLANE, DISPLAY_ITEM_FAR_PLANE); |
| 1004 | |
| 1005 | auto& moveableObject = _moveableObjects[objectNumber]; |
| 1006 | if (!moveableObject.has_value()) |
| 1007 | return; |
| 1008 | |
| 1009 | const auto& object = Objects[objectNumber]; |
| 1010 | if (!object.Animations.empty()) |
| 1011 | { |
| 1012 | int animNumber = item.GetAnimNumber(); |
| 1013 | int frameNumber = item.GetFrameNumber(); |
| 1014 | int prevFrameNumber = item.GetPrevFrameNumber(); |
| 1015 | |
| 1016 | auto interpData = KeyframeInterpolationData( |
| 1017 | GetAnimData(object, animNumber).Keyframes[prevFrameNumber], |
| 1018 | GetAnimData(object, animNumber).Keyframes[frameNumber], |
| 1019 | alpha); |
| 1020 | UpdateAnimation(nullptr, *moveableObject, interpData, UINT_MAX); |
| 1021 | } |
| 1022 | |
| 1023 | SetBlendMode(BlendMode::Opaque); |
| 1024 | SetCullMode(CullMode::CounterClockwise); |
| 1025 | SetDepthState(DepthState::Write); |
| 1026 | |
| 1027 | // Set vertex buffer. |
| 1028 | _context->IASetVertexBuffers(0, 1, _moveablesVertexBuffer.Buffer.GetAddressOf(), &stride, &offset); |
| 1029 | _context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); |
| 1030 | _context->IASetInputLayout(_inputLayout.Get()); |
| 1031 | _context->IASetIndexBuffer(_moveablesIndexBuffer.Buffer.Get(), DXGI_FORMAT_R32_UINT, 0); |
| 1032 | |
| 1033 | // Set shaders. |
| 1034 | _shaders.Bind(Shader::Inventory); |
| 1035 | |
| 1036 | // Set matrices. |
| 1037 | auto hudCamera = CCameraMatrixBuffer{}; |
no test coverage detected