How to visualize the structure of the engine?

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • How to visualize the structure of the engine?

      I am trying to visualize the structure of the engine. I mean which objects go inside what other objects and what they do from a high level.

      I have heard of UML diagrams and things that can help with this.

      What do you guys think is the best way I can visualize large code bases like this, including yours?
    • What I did,

      - Went to Home Depot
      - Got a HUGE piece of marker board
      - stuck it to my wall

      I love using my whiteboard, it really helps me visualize complicated connections between systems and also plan out any future work, and for under 10$ you can't go wrong

      I do my diagrams very simply, just draw a bubble with a system in it, with any major components connected to it to show me what it can do, and then connect other systems with lines. Just makes sure you have alot of colours, believe me it helps
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • For me, it's all about being able to visualize the big picture of whatever I'm working on. I use UML diagrams extensively for this sort of thing. I have a whiteboard hung up near my desk at home and three at work, which I scribble formulas, UML, or anything else that's needed. When I get something reasonably solid that I need to remember, I build a diagram in xmind for it and check it into SVN.

      As for where to start, just think about the high-level systems and how they talk to each other. Here's the overview document I created for my personal game engine, though it's a bit out of date now.

      -Rez
      Files
    • Nice to meet you Rez the book is excellent!

      Ya thats what I'm talking about. It would be a huge help to have one of those for GameCode4's engine. Could you make one? I'll try to make one myself but I don't understand the code or xmind yet, probably won't get far.

      The post was edited 1 time, last by pwnstar23 ().

    • Thanks! It's good to meet you too. :)

      There kind of is one. If you look on 27, there's a very high-level overview showing you the Application / Game Logic / View layers. These layers are described in more detail in the pages that follow, complete with more diagrams that drill in a bit deeper. For example, on page 29 it shows the major components of the Game Application Layer, being the operating system, the game lifetime, and hardware interfaces. That chapter is full of these types of diagrams.

      If you're looking for actual class diagrams and sequencing diagrams, none of those currently exist. It would take quite a while to go back and try to document every single class and interaction in UML so it's not something I could whip up in an hour. I'd be happy to point you in a particular direction if you're just trying to understand some aspect of the engine.

      As far as your other question about what we do to understand large code-bases, the answer is that we don't. The Sims Medieval was several million lines of code. There was no single person at EA that understood the entire thing, so we had specialists. The project I'm on now is the same way. We have five leads, each who are responsible for a particular set of systems and are considered experts those areas. I'm the lead AI programmer, so everything having to do with NPC behavior and NPC management is my domain. Collectively, the five of us have a complete understanding of the gameplay code.

      This is fairly typical at most companies. Some companies are less hierarchical than others, but the principle of "we all collectively know it" is the same.

      -Rez
    • UML Reverse engineering model

      Hi there,

      Although i agree with the board solution, Some time ago i managed to reverse-engineering some code (maybe from the second or the third edition, cant recall now) using the free BOUML tool (google for it, last time i saw several problems with the downloads), although its not perfect, i managed to reverse several classes, and also build some class diagrams to get a rough overview of the model. Its not complete but it helped me somehow...


      Regards

      @B^)>
      Files
      • umlrough.gif

        (35.54 kB, downloaded 1,212 times, last: )

      The post was edited 1 time, last by kidchaos2k9 ().

    • If anyone here is lucky enough to have their company buy them a copy of Visual Studio 2012 Ultimate edition (has to be ultimate). Then you'll get a new feature called Architecture, which automagically builds class diagrams and relationships, and allows you to drill into your code from an object model perspective.

      I've seen it work on a large C++ project, and it was really slick.
    • You mean Visual Studio 2011 Beta? Thats the one I have right now but it's only in Beta

      *Edit*
      Nevermind, I guess it's called Visual Studio 2011 but it is 2012
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz

      The post was edited 1 time, last by mholley519 ().

    • Originally posted by mholley519
      You mean Visual Studio 2011 Beta? Thats the one I have right now but it's only in Beta

      *Edit*
      Nevermind, I guess it's called Visual Studio 2011 but it is 2012


      Yep, It's version 11 of visual studio, but now that the RC is out they have re-badged it as 2012.
    • Been studying the code for some time now think I got a general idea of it. Have a question though. In the code I see that the base class where every thing starts is GameCodeApp class and that TeapotWarsApp derives from it. Within the engine code it has a global pointer to a GameCodeApp, which I believe was instantiated as a TeapotWarsApp, and the base class pointer in the engine code is set to point to the TeapotWarsApp instance? Is this how it works and where does this happen?

      EDIT:

      I think I got this. So the global TeapotWarsApp in the teapot wars project creates a TeapotWarsApp class instance and the base constructor sets the global GameCodeApp pointer to this. And the object is initialized in the GameCode4() function.

      The post was edited 4 times, last by pwnstar23 ().

    • Originally posted by pwnstar23
      I think I got this. So the global TeapotWarsApp in the teapot wars project creates a TeapotWarsApp class instance and the base constructor sets the global GameCodeApp pointer to this. And the object is initialized in the GameCode4() function.

      Correct.

      -Rez
    • Hello Guys!

      I'm new here, and my question is related to this thread, so I didn't want to create a new one.

      First of all, I read a part of the third edition of your book, and recently bought the fourth edition and it's amazing! It's full of useful information, so thank you MrMike and Rez! :)

      And here's my question:
      I'm a little confused with the game architecture described in the second chapter. You said, that the display, audio and input parts of the code belong to the Human GameView. But I don't need render things and interpret input only at the gameplay. For example I need display the main menu, and interpret mouse input, too. Where are those codes? Or is a Human View present through the entire game (not only at gameplay) or what?

      At the beginning I had a renderer (for game objects, map etc.) in the Human View, and a common renderer (for menu and buttons) in tha GameApp base class. Now I have renderer and input manager codes in the base class only, what calls the proper render functions depends on the game state (MainMenu, GamePlay, GamePause etc.).
      How do you manage these things in your architecture?

      I hope you understand my problem, and sorry for my bad english..
    • The HumanView is present the entire time - take a look through the GameCode4 source code and you'll find a MainMenuUI class - which is attached as a member of MainMenuView, which inherits from HumanView.

      The HumanView manages the drawing surface, the audio system, and the input hardware like keyboards, a mouse, or controllers.

      The renderer implemenation can go intro the base class as you describe, since it depends largely on what is supported by the OS or hardware of the device running the game. The HumanView would make calls into the renderer to draw the screen.

      I'm not entirely sure I answered your question - if I didn't give me another chance by restating your question!
      Mr.Mike
      Author, Programmer, Brewer, Patriot