I was hoping to get some ideas on how people connect independent objects together. By independent objects I mean separate classes that represent different things on a technical basis, but visually, or at least how the program executes, they appear to be whole. For instance, in a game one might have two separate classes that comprise an entity. One class might contain various values to be used for logic, and another that represents the entity's rendered appearance. This assumes that the render class cannot be stored with the logic class. Due to the large number of entities a game might process, it may make sense to keep the render classes as limited in number as possible. Essentially only keeping graphical information on hand for the entities within the player's line of sight or immediate area.
Back to the original question, how would anybody else link the two classes together? I imagine that letting the render class store a pointer to its "master" logic class would be ideal. This would allow it to access information like position or size quickly, which would be required for fast drawing.
I just want to know if there are any other ways one might do this that I have (probably) overlooked.
I'd have one class representing the entity. If the rendering information is huge and you're running out of memory, load that information when you're nearing the point of having to draw it and dump it again afterwards. If you have these optional render classes, that's basically what you're doing anyway; you're just making it unnecessarily complicated.
I'm always so hellbent on keeping everything separate and contained that I completely missed that. I don't know why but for some reason I feel a compelling need to keep graphics away from everything else.
I've made a half-finished engine not long ago.
Its structure looked like this:
Engine
-> Model
-> Vector of Model Instances
-> Pointer to Texture
-> Pointer to Shader
-> Texture
-> Shader
Each Model has the actual graphical and collision model, and the Instance has the positional information, taken from the Physics engine, plus some graphical properties.
When it's time to draw a Model Instance, the Model Instance sets up its own 3D matrices with the updated positional infos then draws the Model. Poof, done.