Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // camera view matrix
- void Library::Camera::CalculateVeiw()
- {
- DirectX::XMVECTOR R = DirectX::XMLoadFloat3(&m_right);
- DirectX::XMVECTOR U = DirectX::XMLoadFloat3(&m_up);
- DirectX::XMVECTOR L = DirectX::XMLoadFloat3(&m_look);
- DirectX::XMVECTOR P = DirectX::XMLoadFloat3(&m_position);
- // Keep camera's axes orthogonal to each other and of unit length.
- L = DirectX::XMVector3Normalize(L);
- U = DirectX::XMVector3Normalize(DirectX::XMVector3Cross(L, R));
- // U, L already ortho-normal, so no need to normalize cross product.
- R = DirectX::XMVector3Cross(U, L);
- DirectX::XMMATRIX V = DirectX::XMMatrixLookToRH(P, L, U);
- DirectX::XMStoreFloat4x4(&m_view, V);
- DirectX::XMStoreFloat3(&m_position, P);
- DirectX::XMStoreFloat3(&m_up, U);
- DirectX::XMStoreFloat3(&m_look, L);
- DirectX::XMStoreFloat3(&m_right, R);
- }
- // light view matrix
- void ShadowMap::SetLightSource(const LightSource * light)
- {
- for (unsigned int i = 0; i < MAX_LIGHT_SOURCES; i++)
- {
- if (!light[i].Type)
- continue;
- m_lightSource[i] = light[i];
- DirectX::XMVECTOR pos;
- DirectX::XMVECTOR dir = DirectX::XMVector4Normalize((DirectX::XMLoadFloat4(&(m_lightSource[i].LightDir))));
- pos = DirectX::XMLoadFloat4(&(m_lightSource[i].LightPos));
- DirectX::XMMATRIX V = DirectX::XMMatrixLookToRH(pos, dir, DirectX::XMVectorSet(0.0f, 1.0f, 0.0f, 0.f));
- DirectX::XMStoreFloat4x4(&(m_lightView[i]), V);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement