Event-base architecture and separation of subsystems

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

    • Event-base architecture and separation of subsystems

      Hey All,
      I purchased Game Coding Complete about 3/4 months back and I was very happy with the content going over it roughly a first time, I've recently renewed my interest in game engine development now I have a couple of people to work on it with me so I took up the book again and theres something that none of us can understand.

      At this stage we have a number of segregated game objects done such as terrain mapping with textures into a quad-tree like uniform grid, large structure loading, etc&

      We finally got the point where were looking for a higher level design to integrate components into so we can start on other areas such as NPC management, entity collision against the terrain and structures (e.g. a castle) and we hit a wall. After agreeing upon the event system presented in in GCC were stuck on how some of the concepts involved.

      The biggest problem is the renderer, I have heard many time that its good to keep a level of separation between the renderer and the other subsystems, for entities I can see how the works; You could store the model/textures and any vertex data in the renderer and associate with something like a bounding volume in the game logic then link them together with a unique ID, the event handler would then take any events such as ID 123456 moved to x y z to which the renderer would react.

      With after this I am left with two gaping question I cant seem to figure out based on the book:

      1. With our terrain we plan to use the individual vertices to with a technique like ellipsoids in conjunction with Uniform Grid BVH to perform ground collision, so the question is (finally) how does one achieve the separation of graphical elements such as vertices from renderer without restricting the game logic and vice versa? The renderer would need direct access to vertices in order to draw them, and at the same time the game logic would need direct access to be able to perform any terrain based calculation. The same question also applies to structures.
      2. The second question is, on events such as player moved would the renderer be responsible for smoothly translating the object or would it be the job of game logic to send an event every update cycle to move the object slightly more forward in case something inhibits it mid translation?
      Sorry for the essay long question I hope I was able to convey it well enough, I would greatly appreciate any help with this,

      Thanks!
      Istinra
    • RE: Event-base architecture and separation of subsystems

      A most excellent question.

      The purpose of the separation of the visuals from the game logic I think you get very well, or you wouldn't be able to form the question.

      But, as you observe, sometimes the visuals and the logic are very tightly bound together. This leads you to wonder whether you should break the rules of separation, or create two parallel systems to keep that separation.

      My suggestion is that you go ahead and break the rules - but do so knowingly, so that you can deal with issues that come up. One thing that you should always do is when data like terrain verts is shared by both game logic systems (like physics) and visual systems (like the renderer) it is perfectly fine for the data to be shared between two code systems that process the data for their separate purposes.

      For the translation question, the answer really is "it depends". Some games decide to have the game logic (or physics) drive the smooth translation of characters, and the animation system reads that translation to determine how best to animate the character to look right. Other games have the movement data in the animation drive the movement of a physics capsule around the character, and feed collisions back in to the animation system when the character hits a wall or other object that will cause the character to stop or change course.

      The choice to go either direction is hotly debated - as different people tend to enjoy the benefits of one over the other, and can tolerate the drawbacks. Mostly the drawbacks tend to be visual fidelity in animation, foot sliding, and how artists create and tune animations.

      As animation fidelity increases, and dynamic physics interactions with characters are more realistically produced, games are beginning to see more procedural animations being blended with hand crafted animations. The hand crafted animations give the character, well, character, :) and the procedural animations allow the myriad animations that could never be hand crafted.

      But...I seem to have digressed.

      Short answer - share data everywhere you can, and share code too - keep the separation between game logic and game view whereever you can and whereever it makes sense.
      Mr.Mike
      Author, Programmer, Brewer, Patriot
    • RE: Event-base architecture and separation of subsystems

      Thanks Mike : )

      We're still slowly working on this, we have each object being translated based on the values our physics system defines while managing to keep a fairly decent level separation. I don't like how we shelved the animation for later but with only two people its a fair bit to face up front.

      I have to say though the biggest stump has been the physics system, even getting the sort of base collision you seen in games like Zelda OOT depends on so much. Originally we were just going with the idea "split the static world into an octree and we can do smaller tests based on that" but to actually design a small world in an editor and partition it into an octree comes with a mass of problems on its own, even when you refine it to a small set of objects getting them to all draw correctly and react properly to sphere/box collisions and basic stuff like standing on the ground, running an jumping proves to be a considerable challenge.

      Any tips for world structure for a world that's fairly open and allows for easy testing against the static elements would be greatly appreciated :D

      Thanks,
      Istinra
    • RE: Event-base architecture and separation of subsystems

      Instead of octtrees there is something much easier - with your editor define zones which you can turn on or off based on triggers. These zones can be used for knowing what you need to render or simulate in a physics system.

      Octtrees tend to be messy, since they tend to divide things arbitrarilly and not based on what makes sense from a level design perspective.

      If you are making an outdoor, streaming world style game perhaps octtrees is the way to go - but I wouldn't build that kind of game if you only have two people! If you start with an interior, level based, game design you'll get the chance to explore a lot of game design and technology issues without running into a brick wall.

      Good luck!
      Mr.Mike
      Author, Programmer, Brewer, Patriot