Basics of engine

Started by
13 comments, last by GraphicsBas 18 years, 8 months ago
But i guess if you wanted to port your drawing code into a new project, that would require you removing all your game specific stuff from it?

Mark Ingramhttp://www.mark-ingram.com
Advertisement
If you have an entity class (and entity manager) is it best to have all objects (that will be drawn on screen) as entities, even the 2D stuff, like custom panels, dialogs etc.

Or is it better to have 2 entity lists, one for 2d, one for 3d? So that you only have to switch projection once?

Or should stuff like GUI be drawn by its own GUI manager after all entities have been drawn? The only down side i can see with that is that if you wanted to put a GUI panel onto a computer monitor in game, or on a wall, or floor or something - because then it would have to be an entity?



Im just trying to work out what should control the drawing, and how i should list all the objects within the engine.

Any input greatly received.
Mark Ingramhttp://www.mark-ingram.com
The most elegant solutions are found by look at reality I believe. I stand corrected but look at what everything is.. it's an object.. so everything has something that relates to another..


Quote:
If you have an entity class (and entity manager) is it best to have all objects (that will be drawn on screen) as entities, even the 2D stuff, like custom panels, dialogs etc.

Or is it better to have 2 entity lists, one for 2d, one for 3d? So that you only have to switch projection once?

Or should stuff like GUI be drawn by its own GUI manager after all entities have been drawn? The only down side i can see with that is that if you wanted to put a GUI panel onto a computer monitor in game, or on a wall, or floor or something - because then it would have to be an entity?


Essentially you can look at this in many aspects. I don't have all the best answers but what I would do is have an entity list, this entity list gets sent to a RenderEntities()/or similar method within your renderer or whatever graphics class/structure you have in place.

UpdateEntities()/or similar will be a method outside of this class since it has nothing to do with rendering.

so as a simple structure I think it should look like this

[source lang = c#]public void Update(){     foreach(Entity e in entityList)     {         e.Update();     }}public void Render(){     foreach(Entity e in entityList)     {         e.Render();     }     //or you could do something like     renderer.RenderEntities(entityList);}


I might work for small games but I believe that it should do fine for small engines.
Someone else might have some better input.
cheers thanks - but what about separating 2d and 3d? or would you have them in the same list?

particularily with the GUI, you'd want that drawn last, over all the other objects.
Mark Ingramhttp://www.mark-ingram.com
What I did; I seperated the storing of 2D and 3D. 3D object, with me called entity's, are stored by nodes, wich store the position and orientation. Nodes are stored by the SceneManager. (I'm working with Managers too, helps me get rid of a lot of pain in the ass. As it is "Easy managing").

2D elements are storing as GUIElements, wich are ofcourse stored by the GUIManager. You can't really create 2D games with this design but you get the point. (Create a 2D SceneManager or whatever)

A GUIManager can be attached to a scene. When a scene has finished rendering, the scenemanager will, call the GUIManager rendering function, wich will then render it's components over the allready rendered scene.

This works for me, but I'm not saying it works for everyone..

GBS
GBS

This topic is closed to new replies.

Advertisement