• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
imagenesis

What is the correct way to seperate (react) view from state?

2 posts in this topic

I would like to know the correct implementation to declare game logic and view logic:

I see 3 ways of implementing this:


1. Storing (eg writing preprocessing to store the change to a property) property changes to data entities that are dispatched to listener(s) of the data entity. The main listener being the view, where the view contains the declared rendering logic (ie changing the entities animation based on a property change, changing the entities render object position).

> State Model (x,y,z,state) -> View (listens to change in
> x,y,z,state)->Scene graph object (x,y,z,animation, gets set by the View)

The issue with this is that it becomes evident that game engines are executing a lot of `char[]` switch statements (eg the names of properties) in the View.

2. Declaring the view as updating to the entirety of the model. Eg, instead of saving the changes as specified in 1) the view updates the render objects on every tick by inspecting the entire model, as opposed to the provided changes of 1). The tradeoff between 1 and 2 is the necessity of the additional execution of storing the property changes on the state tick.

3. Declaring animation logic in the state logic. Eg, instantiated member render objects are dummy objects when rendering is not performed.

***The questions:***


1. As specified in the title, what is the correct implementation to reacting to the game state  in the sense of where should one declare display/rendering/animation (view) logic that reacts to the game state?

2. What is the implementation used in most game engines that facilitate large projects? (if possible, please specify for specific engines: SupremeCommander/clones, SC2, Unreal, ID, Frostbite, Anvil)

3. Which implementation do studios implement to architect projects using said engines? It's apparent that it is possible to not seperate model from view in the above engines. Eg, if you implement an entity, you would presumably want it to be viable in multiplayer, coop, and single player.

So, on tick we update the game data simulation. For example:

> The state of a unit's weapon is updated to firing. However, updating
> the view of the weapon to firing (by for example, setting the animation of the weapon and animating the hand) is not necessary in all
> instances of the simulation.

0

Share this post


Link to post
Share on other sites

Things should be updated when they need to be! Especially the rendering sub-system is a counter-example w.r.t. implementing a listener concept. Remember that rendering happens as last action in the game loop. At that point all of the before running sub-systems have passed, and they for sure should have left the game in a renderable state. In other words, the rendering sub-system simply works on what exists and how it exists when it is next.

 

Another example is input processing. The effect of input (I mean PC controlling input) need not take place immediately. It gets prepared when the input sub-system runs at the beginning of the game loop, but its effect take place when later the animation sub-system runs.

 

The above concept avoids invoking listeners at all, which is preferable, of course.

 

An additional strategy (on the lower level) is to use dirty marking, useful in cases where elements are updated only sparsely before another step requires dependents of them. For example, let us assume that just 10 placements of the overall 1000 entities are touched in a simulation step. Then you can write the new value to the property and set a "dependents are dirty" flag to true. When a dependent needs to be run, it checks whether the properties it depends on are marked, and updates self only if so.

 

What to do best depends on the use case and the engine's architecture. However, display / rendering (assuming that rendering does not include mesh generation like e.g. skinning here) should never react to the state at all. It just draws the current state. This is often done by having separate layers in the rendering sub-systems.The top layer iterates the scene, performs visibility culling, and passes rendering jobs for visible entities to the lower level. The lower level is then responsible for driving the graphics rendering API (D3D, OpenGL, …) accordingly.

0

Share this post


Link to post
Share on other sites

I am not refering to the render pass.

 

I am refering to the following abstractions:

 

1. State simulation (eg, position, attack results, necessary to be functionaly isolated in the instance of deterministic lockstep)

2. Manipulation of the scene graph objects in response to the deterministic simulation as specified in #1 or #2 or declared as directly manipulated in the state simulation as specified in #3.

 

3. The rendering of the scene graph objects is the render pass for which you specified an answer, which as you specified is done as a traversal of the tree.

 

As specified, #2 is sort of a "View" render pass. In the sense that it takes the entity state and manipulates (not creates! vertices) the scene graph to the correct state. The problem with claiming that this is a correct implementation, because it is seemingly similar to the render pass as a complete traversal of the tree, is incorrect because the render pass needs to actually create the culled, subset of applicable vertices to the GPU from the entirety of the scene graph, and they almost certainly have changed for every frame. The View, implements the higher level declaration with regards to animation and the objects of the scene graph as specified in the example.

 

It's not like the View pass as contempated in #2 is going to recreate scene graph objects on every tick. So, logically it is not a pass but a programmed mutation to the view based on state.

Edited by dlots
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0