I am engaged on a C++ sport engine for my very own initiatives. It is divided into two components: one which handles primary performance like logging, cross-platform abstractions, filesystem utilities, and many others., 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
essential
operate that creates an occasion of this sport (which from this level on behaves like a singleton) after which namerun
on it - Override the
init
operate 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
technique - Create a
bwCamera
(a kind ofbwActor
), spawn it on the stage, then set it as the present digicam 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 might come from degree knowledge and be mechanically spawned upon coming into the stage)
- Create a
- Set the sport state to a
bwGameState
-type object, which handles logic for various components of the sport
A whole lot of that is topic to vary, however that is the overall 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 foundation 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 can 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 facet, nonetheless, bwStage
s preserve a listing of bwActor
s, which do not need dad and mom and youngsters as a result of that kind of construction is not obligatory for many sport logic.
The primary 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 knowledge buildings into the bwStage
and bwActor
s, like having some actors lengthen a Drawable
class or interface and having them present their very own drawing info 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
. It is a very troublesome query for me to reply contemplating the design of my venture, so I would like some assist figuring it out given my circumstances.