------------------------------------------------------------------------------
| 193 | |
| 194 | //------------------------------------------------------------------------------ |
| 195 | void vtkLightActor::UpdateViewProps() |
| 196 | { |
| 197 | if (this->Light == nullptr) |
| 198 | { |
| 199 | vtkDebugMacro(<< "no light."); |
| 200 | return; |
| 201 | } |
| 202 | double angle = this->Light->GetConeAngle(); |
| 203 | |
| 204 | if (this->Light->GetPositional() && angle < 90.0) |
| 205 | { |
| 206 | if (this->ConeSource == nullptr) |
| 207 | { |
| 208 | this->ConeSource = vtkConeSource::New(); |
| 209 | } |
| 210 | |
| 211 | this->ConeSource->SetResolution(24); |
| 212 | double* pos = this->Light->GetPosition(); |
| 213 | double* f = this->Light->GetFocalPoint(); |
| 214 | |
| 215 | double direction[3]; |
| 216 | int i = 0; |
| 217 | while (i < 3) |
| 218 | { |
| 219 | direction[i] = pos[i] - f[i]; |
| 220 | ++i; |
| 221 | } |
| 222 | double height = 1.0; |
| 223 | double center[3]; //=pos |
| 224 | |
| 225 | double n = vtkMath::Norm(direction); |
| 226 | |
| 227 | // cone center is the middle of its axis, not the center of the base... |
| 228 | i = 0; |
| 229 | while (i < 3) |
| 230 | { |
| 231 | center[i] = pos[i] - 0.5 * height / n * direction[i]; |
| 232 | ++i; |
| 233 | } |
| 234 | this->ConeSource->SetCenter(center); |
| 235 | this->ConeSource->SetDirection(direction); |
| 236 | this->ConeSource->SetHeight(height); |
| 237 | this->ConeSource->SetAngle(angle); |
| 238 | |
| 239 | if (this->ConeMapper == nullptr) |
| 240 | { |
| 241 | this->ConeMapper = vtkPolyDataMapper::New(); |
| 242 | this->ConeMapper->SetInputConnection(this->ConeSource->GetOutputPort()); |
| 243 | this->ConeMapper->SetScalarVisibility(0); |
| 244 | } |
| 245 | |
| 246 | if (this->ConeActor == nullptr) |
| 247 | { |
| 248 | this->ConeActor = vtkActor::New(); |
| 249 | this->ConeActor->SetMapper(this->ConeMapper); |
| 250 | } |
| 251 | |
| 252 | this->ConeActor->SetVisibility(this->Light->GetSwitch()); |
no test coverage detected