| 93 | } |
| 94 | |
| 95 | void Light::SetDirection(const dm::double3& direction) const |
| 96 | { |
| 97 | auto node = GetNode(); |
| 98 | if (!node) |
| 99 | { |
| 100 | assert(!"Lights must be attached in order to set their direction"); |
| 101 | return; |
| 102 | } |
| 103 | |
| 104 | SceneGraphNode* parent = node->GetParent(); |
| 105 | dm::daffine3 parentToWorld = dm::daffine3::identity(); |
| 106 | if (parent) |
| 107 | parentToWorld = daffine3(parent->GetLocalToWorldTransform()); |
| 108 | |
| 109 | daffine3 worldToLocal = lookatZ(direction); |
| 110 | daffine3 localToParent = inverse(worldToLocal * parentToWorld); |
| 111 | |
| 112 | dquat rotation; |
| 113 | double3 scaling; |
| 114 | decomposeAffine<double>(localToParent, nullptr, &rotation, &scaling); |
| 115 | |
| 116 | node->SetTransform(nullptr, &rotation, &scaling); |
| 117 | } |
| 118 | |
| 119 | std::shared_ptr<SceneGraphLeaf> DirectionalLight::Clone() |
| 120 | { |
no test coverage detected