I am engaged on a C++ sport engine for my very own initiatives. It is divided into two components: one which handles fundamental performance like logging, cross-platform abstractions, filesystem utilities, and so forth., and one other which is used particularly as a sport growth library. The sport growth (“core”) library is designed for use like this:
- Create a category which extends
bwGame
- Create a
primary
perform that creates an occasion of this sport (which from this level on behaves like a singleton) after which namerun
on it - Override the
init
perform of the sport class- Create a
bwStage
or an occasion of a category which extendsbwStage
then set it as the sport’s present stage utilizing theenterStage
methodology - Create a
bwCamera
(a sort ofbwActor
), spawn it on the stage, then set it as the present digital camera by means of thebwRenderer
pointer saved within the sport singleton - Create the entire wanted actors, set their properties, then spawn them on the
bwStage
(a few of these actors could come from degree information and be robotically spawned upon getting into the stage)
- Create a
- Set the sport state to a
bwGameState
-type object, which handles logic for various components of the sport
Loads of that is topic to vary, however that is the final thought.
Internally, bwGame
-type objects are singletons, which preserve tips to the render supervisor (bwRenderer
), the present sport state (bwGameState
), and the present stage bwStage
. The bwRenderer
incorporates the basis node of a bwSceneGraph
(which is itself inherits from bwGraphNode
), a easy graph-like construction that does not assist reparenting logic, discovering particular youngsters/ancestors/descendants, or something like that, because the expectation is that the scene graph shall be constructed as soon as and by no means modified till it’s deleted and a brand new one is constructed. On the sport logic aspect, nonetheless, bwStage
s preserve an inventory of bwActor
s, which don’t have mother and father and youngsters as a result of that sort of construction is not crucial for many sport logic.
The principle query right here, although, is whether or not or not I ought to preserve a separate scene graph particularly for rendering, or I ought to simply combine graphics-related metadata and information buildings into the bwStage
and bwActor
s, like having some actors prolong a Drawable
class or interface and having them present their very own drawing data like meshes and supplies, possibly even having a Drawable
object separate from the actor however referenced by it, and having totally featured parenting and scene tree assist in bwStage
. This can be a very troublesome query for me to reply contemplating the design of my mission, so I want some assist figuring it out given my circumstances.