-
-
Notifications
You must be signed in to change notification settings - Fork 48
Application Design Notes
The application should simulate any number of different machines. Therefore it should be built out of small, modular blocks that can be joined to form larger behaviors. Research suggests that an Entity Component System would be ideal, as it has been used quite successfully in many games and engine systems to achieve similar results.
It should have clear separation between the Model (serialized data), the Controllers (the systems which change the model) and the View (representations of the data to the user). This is a Model-View-Controller pattern.
It should be scriptable from within the application. Something like a node-based system like Donatello.
The Model an EntityManager that contains a tree of Entities. On it's own it is a static thing.
Components are properties. An Entity might have a PositionComponent or a ColorComponent.
The Model must be serializable so that the state can be saved and reused for testing. Therefore all Entities and Components must be serializable. There should be a serialization unit test for every Component.
Systems are Controllers that update the Entities and Components. An example would be a physics engine that updates the position of an entity based on the entity's Components for Mass and Intertia.
Systems can stack components together - When the OpenGLRenderPanel sees A Box Component with an adjacent MaterialComponent then the Box will be drawn according to the material properties.
Systems can stack components between Entities - A parent with Gravity might affect the momentum of a child Entity with Mass.
The view is the entire UX. Robot Overlord is written in Java Swing for the GUI and Jogamp OpenGL for the 3D view.
There are several components to the GUI.
The GUI has a EntityTreePanel that displays the contents of the EntityManager in a JTree.
The GUI also has a ComponentManagerPanel displays a list of the Components common to all the currently selected Entities. ComponentManagerPanel then gives each System a ViewPanelFactory to generate the Swing GUI equivalent of each Component.
ViewPanelFactory ensures that the JComponents have a consistent look and feel. All GUIs for reading/changing a number look the same. All dialogs for file selection look the same. All of them work with Undo/Redo.
The OpenGLRenderPanel is the class responsible for generating the 3D view. It uses OpenGL 3 with vertex and fragment shaders.
There is a pattern equivalence:
- the OpenGLRenderPanel uses GL3 to Decorate the GLJPanel with colored triangles;
- the Systems use ViewPanelFactory to Decorate a JPanel with JComponents like JComboBox, JSlider, JTextField, JRadioButton, etc.