1 // Copyright 2021 Intel Corporation 2 // SPDX-License-Identifier: Apache-2.0 3 4 #pragma once 5 6 #include "sg/Node.h" 7 #include "sg/scene/World.h" 8 #include "sg/renderer/Renderer.h" 9 10 namespace ospray { 11 namespace sg { 12 13 /** 14 * LightsManager node - manages lights in the world 15 * 16 * This node maintains a list of all lights in the world. It holds a list of 17 * Light nodes which is passed to the world on commit. This list lets us 18 * add/remove lights without adding unrelated functionality to the World 19 * node 20 */ 21 struct OSPSG_INTERFACE LightsManager 22 : public OSPNode<cpp::Light, NodeType::LIGHTS> 23 { 24 LightsManager(); 25 ~LightsManager() override = default; 26 NodeType type() const override; 27 bool lightExists(std::string name); 28 bool addLight(std::string name, std::string lightType); 29 bool addLight(NodePtr light); 30 void addLights(std::vector<NodePtr> &lights); 31 bool removeLight(std::string name); 32 void clear(); 33 hasDefaultLightLightsManager34 inline bool hasDefaultLight() 35 { 36 return hasChild("default-ambient"); 37 } 38 39 void updateWorld(World &world); 40 bool rmDefaultLight{true}; 41 42 protected: 43 std::vector<std::string> lightNames; 44 std::vector<cpp::Light> cppLightObjects; 45 46 virtual void preCommit() override; 47 virtual void postCommit() override; 48 49 private: 50 }; 51 52 } // namespace sg 53 } // namespace ospray 54