yin / yngine

Automatically exported from code.google.com/p/yngine
0 stars 0 forks source link

Refactor Scene-graph into separate subsystems #21

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Right now Yngine Scene-graph implements nodes with loose attributes. Attributes 
represent node states, like transformation, render geometry, etc. This has a 
big disadvantage: An engine subsystem has to query for attributes of known 
type, e.g. renderer queries for TransformationAttribute and GeometryAttribute 
to draw the primitives. As a result, all data in Scene-graph structure merge 
together and become hard to distinguish.

This should be changed. Scene-graph will define structure of the world and keep 
a list of active world-subsystems. Every subsystem will register specific 
attributes for each node. At Scene-graph traversal, each subsystem receives the 
corresponding attributes automatically at invocation time.

Example:
The world will activate OpenGL renderer, custom world logic (currently 
implemented as GLRenderers "Strategy" classes) and JBullet physics sub-systems. 
We add a camera, lights and a few objects into the Scene-graph as abstract 
nodes.

For OpenGL renderer we register a CameraAttribute for the camera node, 
LightAttribute for the lights and GeometryAttributes for the world objects. For 
JBullet subsystem we register only RigidBodyAttributes for the world objects 
and connect MotionState to the OpenGLRenderer's TransformAttributes.

The custom world logic subsystem will get a "StrategyAttribute" registered for 
every logic-controlled world object. These strategies will get applied based on 
a given conditions, e.g.: Time-based invocation.

This example shows, how complex this refactoring can become. Attributes become 
assigned to specific parts of the engine, while comunicating together. They 
start having inputs and outputs. The update/render pipeline has to invoke every 
subsystem for specific nodes, or for the whole Scene-graph at a correct time 
durring the main loop. Physics subsystem has to dispatch events, like 
touch-event, so the whole world can react.

End of example.

This is just the basic idea. Think about the best way of doing such separation 
and describe the best solution in this issue before implementation.

Original issue reported on code.google.com by yinotaurus on 28 Mar 2011 at 2:02