Code Organization

hi all,
i know that is not an Opengl related answer but i want to organize my resources like shaders, meshes, textures, materials… and so on, how can i organize a class in cpp in order to make order in my code and start doing things seriously?
i thought to something like:


ResourceManager
    -Mesh
         -Material
               -Texture

    -Shader

    -Camera

    -Light

how can i obtain a well ordered code (it is not bad for now but i want to do things well)?

I organize my resources like this:

[ol]
[li]Mesh (VBOs) [/li][li]Shader [/li][li]Texture [/li][li]Material[/li][LIST=1]
[li]N * Texture [/li][li]N * Shader [/li][/ol]

[li]Model[/li][ol]
[li]Mesh [/li][li]Material [/li][/ol]

[/LIST]

In the above scheme some resources “own” other type of resources.

The cameras and lights are part of another hierarchy, the scene graph.

thanks, i think code organization is very important to build good applications.
i was watching your engine, good job, how much time did you spend on this?

EDIT:
ok now that i have a clean ResourceManager header so what about the Scene Graph? what is the hierarchy?
thanks advance.

[QUOTE=Ruggero Visitnin;1261601]thanks, i think code organization is very important to build good applications.
i was watching your engine, good job, how much time did you spend on this?

EDIT:
ok now that i have a clean ResourceManager header so what about the Scene Graph? what is the hierarchy?
thanks advance.[/QUOTE]

Thanks. I am working on it whenever I have free time for the last ~7 years.

About the scene graph. Scene graph is one of the most weird things to get right. After re-writing it a found a design that I am mostly happy with. That design is “component based” and the bases of this design are the “scene nodes” and the “components”.

The scene node, roughly, is an object hierarchy that connects it with other nodes. It also contains a list of components.

The components define the properties of the scene node. Example components are the MoveComponent, FrustumComponent (essentially defines an object that has a frustum), RenderComponent and others. For example, a movable model is a scene node with MoveComponent and RenderComponent. A static model is a scene node with a RenderComponent. A camera is a node with FrustumComponent and MoveComponent. A light with shadow is a node with FrustumComponent, LightComponent and MoveComponent.

Every component has a specific job in the pipeline. For example, on visibility tests I iterate the scene nodes that have a RenderableComponent or a LightComponent and I determine the visible ones. The list of visibles will be used by the renderer later on.

Hope that helps

thanks you are helping me a lot, i got the point but i did not implemented this elements in my engine yet, for now i will keep my Scene Graph as it is: basic light and camera components.

last thing i swear (i don’t wont to waste your time)
if in my engine i have classes like PickManager or ObjParser and so on, to what kind of hierarchy they belong?

It’s OK.

Maybe PickManager is a helper of the SceneGraph since it interacts with it closely.

The ObjParser is a helper class used by the Mesh. In my case that job is done by the MeshLoader.

ok thanks a lot i have a lot of work to do