| 53 | */ |
| 54 | |
| 55 | void Light::AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix) const |
| 56 | { |
| 57 | static Matrix4f biasMatrix(0.5f, 0.f, 0.f, 0.f, |
| 58 | 0.f, 0.5f, 0.f, 0.f, |
| 59 | 0.f, 0.f, 0.5f, 0.f, |
| 60 | 0.5f, 0.5f, 0.5f, 1.f); |
| 61 | |
| 62 | switch (m_type) |
| 63 | { |
| 64 | case LightType_Directional: |
| 65 | { |
| 66 | AbstractRenderQueue::DirectionalLight light; |
| 67 | light.ambientFactor = m_ambientFactor; |
| 68 | light.color = m_color; |
| 69 | light.diffuseFactor = m_diffuseFactor; |
| 70 | light.direction = transformMatrix.Transform(Vector3f::Forward(), 0.f); |
| 71 | light.shadowMap = m_shadowMap.Get(); |
| 72 | light.transformMatrix = Matrix4f::ViewMatrix(transformMatrix.GetRotation() * Vector3f::Forward() * 100.f, transformMatrix.GetRotation()) * Matrix4f::Ortho(0.f, 100.f, 100.f, 0.f, 1.f, 100.f) * biasMatrix; |
| 73 | |
| 74 | renderQueue->AddDirectionalLight(light); |
| 75 | break; |
| 76 | } |
| 77 | |
| 78 | case LightType_Point: |
| 79 | { |
| 80 | AbstractRenderQueue::PointLight light; |
| 81 | light.ambientFactor = m_ambientFactor; |
| 82 | light.attenuation = m_attenuation; |
| 83 | light.color = m_color; |
| 84 | light.diffuseFactor = m_diffuseFactor; |
| 85 | light.invRadius = m_invRadius; |
| 86 | light.position = transformMatrix.GetTranslation(); |
| 87 | light.radius = m_radius; |
| 88 | light.shadowMap = m_shadowMap.Get(); |
| 89 | |
| 90 | renderQueue->AddPointLight(light); |
| 91 | break; |
| 92 | } |
| 93 | |
| 94 | case LightType_Spot: |
| 95 | { |
| 96 | AbstractRenderQueue::SpotLight light; |
| 97 | light.ambientFactor = m_ambientFactor; |
| 98 | light.attenuation = m_attenuation; |
| 99 | light.color = m_color; |
| 100 | light.diffuseFactor = m_diffuseFactor; |
| 101 | light.direction = transformMatrix.Transform(Vector3f::Forward(), 0.f); |
| 102 | light.innerAngleCosine = m_innerAngleCosine; |
| 103 | light.invRadius = m_invRadius; |
| 104 | light.outerAngleCosine = m_outerAngleCosine; |
| 105 | light.outerAngleTangent = m_outerAngleTangent; |
| 106 | light.position = transformMatrix.GetTranslation(); |
| 107 | light.radius = m_radius; |
| 108 | light.shadowMap = m_shadowMap.Get(); |
| 109 | light.transformMatrix = Matrix4f::ViewMatrix(transformMatrix.GetTranslation(), transformMatrix.GetRotation()) * Matrix4f::Perspective(m_outerAngle*2.f, 1.f, 0.1f, m_radius) * biasMatrix; |
| 110 | |
| 111 | renderQueue->AddSpotLight(light); |
| 112 | break; |
nothing calls this directly
no test coverage detected