| 124 | } |
| 125 | |
| 126 | void ReflectionProbe::transformReflectionCamera(const Camera* sourceCamera) { |
| 127 | float offset = Vec3::dot(_node->getWorldPosition(), _node->getUp()); |
| 128 | _cameraWorldPos = reflect(sourceCamera->getNode()->getWorldPosition(), _node->getUp(), offset); |
| 129 | _cameraNode->setWorldPosition(_cameraWorldPos); |
| 130 | |
| 131 | _forward = Vec3::FORWARD; |
| 132 | _forward.transformQuat(sourceCamera->getNode()->getWorldRotation()); |
| 133 | _forward = reflect(_forward, _node->getUp(), 0); |
| 134 | _forward.normalize(); |
| 135 | _forward *= -1; |
| 136 | |
| 137 | _up = Vec3::UNIT_Y; |
| 138 | _up.transformQuat(sourceCamera->getNode()->getWorldRotation()); |
| 139 | _up = reflect(_up, _node->getUp(), 0); |
| 140 | _up.normalize(); |
| 141 | |
| 142 | Quaternion::fromViewUp(_forward, _up, &_cameraWorldRotation); |
| 143 | _cameraNode->setWorldRotation(_cameraWorldRotation); |
| 144 | _camera->update(true); |
| 145 | |
| 146 | // Transform the plane from world space to reflection camera space use the inverse transpose matrix |
| 147 | Vec4 viewSpaceProbe{ _node->getUp().x, _node->getUp().y, _node->getUp().z, -Vec3::dot(_node->getUp(), _node->getWorldPosition())}; |
| 148 | Mat4 matView = _camera->getMatView(); |
| 149 | matView.inverse(); |
| 150 | matView.transpose(); |
| 151 | matView.transformVector(&viewSpaceProbe); |
| 152 | _camera->calculateObliqueMat(viewSpaceProbe); |
| 153 | } |
| 154 | |
| 155 | Vec3 ReflectionProbe::reflect(const Vec3& point, const Vec3& normal, float offset) { |
| 156 | Vec3 n = normal; |
nothing calls this directly
no test coverage detected