I'm designing a class that holds values representing a 3D scene. This includes lights, cameras, meshes, materials, etc.
The way how I'm setting it up is that each "thing" has a name. A camera has a name, a light has a name, etc. But they also have an "interface" to access the object via pointer instead of having to name it each time something needs to be changed.
For example:
Light *light = scene.getLight("light2");
light->setBrightness(2.0f);
The problems is what Light
is. Ideally, it's "proper C++" where it's a pointer directly to the internal object. However, these classes are closely tied to how the scene class works, which makes maintainability a mess. It's seems much easier to just have private implementations that do all the dirty work and only let the user receive pointers to an interface.
What I want to do is make Light
an interface (struct with virtual functions, no data, no non-virtual functions except empty constructor) and implement the internal details as a private class inside the scene class. While this makes it more maintainable, it comes at the cost of using polymorphism where I'm not dealing with more than one implementation.
Any thoughts or ideas are helpful.
scene.SendMessageToMediator(NVPair("SetBrightness", "light2", "2.0f"));
? \$\endgroup\$ILight* newLight = lightfactory->CreateLightByType("PointLight");
\$\endgroup\$Light& light = scene.get<Light>("light2");
\$\endgroup\$