| 73 | } |
| 74 | |
| 75 | void CubeMapEffect::UpdateFaces(std::shared_ptr<GraphicsEngine> const& engine, |
| 76 | std::shared_ptr<Spatial> const& scene, Culler& culler, |
| 77 | Vector4<float> const& envOrigin, Vector4<float> const& envDVector, |
| 78 | Vector4<float> const& envUVector, Vector4<float> const& envRVector) |
| 79 | { |
| 80 | std::array<Vector4<float>, 6> dVector = |
| 81 | { |
| 82 | -envRVector, |
| 83 | envRVector, |
| 84 | envUVector, |
| 85 | -envUVector, |
| 86 | envDVector, |
| 87 | -envDVector |
| 88 | }; |
| 89 | |
| 90 | std::array<Vector4<float>, 6> uVector = |
| 91 | { |
| 92 | envUVector, |
| 93 | envUVector, |
| 94 | -envDVector, |
| 95 | envDVector, |
| 96 | envUVector, |
| 97 | envUVector |
| 98 | }; |
| 99 | |
| 100 | std::array<Vector4<float>, 6> rVector = |
| 101 | { |
| 102 | envDVector, |
| 103 | -envDVector, |
| 104 | envRVector, |
| 105 | envRVector, |
| 106 | envRVector, |
| 107 | -envRVector |
| 108 | }; |
| 109 | |
| 110 | // The camera is oriented six times along the coordinate axes and using |
| 111 | // a frustum with a 90-degree field of view and an aspect ratio of 1 (the |
| 112 | // cube faces are squares). |
| 113 | for (uint32_t face = 0; face < 6; ++face) |
| 114 | { |
| 115 | mCamera->SetFrame(envOrigin, dVector[face], uVector[face], rVector[face]); |
| 116 | culler.ComputeVisibleSet(mCamera, scene); |
| 117 | |
| 118 | // We need to update the constant buffers that store pvwMatrices. |
| 119 | // TODO: For the sample application, we know the effects are Texture2Effect. |
| 120 | // Generally, do we need the ability to query a VisualEffect object for any |
| 121 | // constant buffers that store pvwMatrices? |
| 122 | Matrix4x4<float> pvMatrix = mCamera->GetProjectionViewMatrix(); |
| 123 | for (auto visual : culler.GetVisibleSet()) |
| 124 | { |
| 125 | auto effect = std::dynamic_pointer_cast<Texture2Effect>(visual->GetEffect()); |
| 126 | if (effect) |
| 127 | { |
| 128 | // Compute the new projection-view-world matrix. The matrix |
| 129 | // *element.first is the model-to-world matrix for the associated |
| 130 | // object. |
| 131 | Matrix4x4<float> wMatrix = visual->worldTransform; |
| 132 | Matrix4x4<float> pvwMatrix = DoTransform(pvMatrix, wMatrix); |
nothing calls this directly
no test coverage detected