How does a real time Game Editor actually work?

4af1b16998e305b64ec076eb432054bd
0
SICGames2012 101 Aug 22, 2012 at 22:01

Hey everyone! I’m Paul , my first post! I am also on GameDev.net and spotted this site on Google whilst looking up Real Time Game Editor. Is the Game Engine main functions created using Dynamic Libraries then migrated in Managed C++ or C#. I saw a video of Unreal Engine 4 where as you can run around the world as if you are the player. Additionally, the changes take place in real-time now just after compiling the scene over and over again. Is it possible the engine checks to see if there’s anything changed then compile it then place it back in editor?

I’m confused on how I can implemend a real time editor because I do feel it would create more productivity! Thanks in regards to this post! Everyone have a great day! Peace!

-Paul

7 Replies

Please log in or register to post a reply.

B20d81438814b6ba7da7ff8eb502d039
0
Vilem_Otte 117 Aug 23, 2012 at 02:50

Building editors and generally tools is quite a bit of work, you might find out that it took you twice the work to build the actual game or game technology. Basically doing really simple game editor needs some kind of GUI (to allow user change settings, load stuff, add stuff to scene, etc.) and some kind of Picking (often with ability to use dragging to move objects around and rotate).

Adding this to your game while allowing user to switch to “edit mode” is basically working.

Although F.e. we’ve got our own set of tools (our own texture compressor, model editor/compressor (you can edit mesh materials there), shader editor (with debugging thats work-in-progress, though we extended GLSL a bit to support includes for example), and work-in-progress world editor) … and I won’t lie, they took us so much time that we don’t have the game yet.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Aug 23, 2012 at 04:53

A real-time editor *does* create more productivity…once it’s done. :) As Vilem says though, it takes a LOT of engineer-time to build even what you would consider a basic editor…with just such basic things as some menus or buttons, click-and-drag, undo, loading and saving game data in the editor format (as opposed to the fully compiled, shipping game format), and so on.
@SICGames2012

Is the Game Engine main functions created using Dynamic Libraries then migrated in Managed C++ or C#

That’s a possible way to organize your code, but equally possible is to keep everything in one big executable rather than splitting it into DLLs. And many people use straight C/C++, no managed languages to build games, although many others use C# as well. (Not that this really has anything to do with the real-time editor, though.)
@SICGames2012

Is it possible the engine checks to see if there’s anything changed then compile it then place it back in editor?

Perhaps for certain kinds of operations it needs to do this, such as changing the script on an object, where it must go out to the script compiler (even if it’s an “interpreted” language, it probably gets compiled to bytecode). But mostly, a real-time editor should work by directly modifying data structures in memory. Compiling in the background can easily introduce some lag, which is undesirable. One thing to consider is that the scene may be in an unoptimized but still usable form in the editor, and then gets compiled into an optimized form. For example, in the editor you might just have a big list of objects to render so that you can easily move things around, but in the compiled form you would build an octree so you can do frustum culling and such. (That’s not the best example because it’s actually not hard to update an octree in real-time…but you get the idea. :))

6837d514b487de395be51432d9cdd078
0
TheNut 179 Aug 23, 2012 at 18:12

@SICGames2012

I saw a video of Unreal Engine 4

You should try out UDK to see how it works first hand. On that note, you should also try out the Hammer editor, the Unity editor, and any editors from games you own. Take notes and see how everything fits together. There are many ways to design an editor and it pays to have experience in software design and various technologies to get the job done correctly. If you’re not familiar with software design patterns, building modular components, and designing large scale software then I would suggest you develop an editor using what’s known as rapid prototyping. This way you’ll encounter common pitfalls and mistakes quicker so that you can build a better designed engine later.

One thing to remember is that an editor is just a frontend to your engine. An editor should not dictate what the engine should do, but rather the engine should dictate what the editor can do. There’s generally two fundamental parts to a game engine. There is the framework/s layer that consists of common logic and then there is the game specific layer that consists of configurable components for use in your game. Maths, I/O, rendering, sockets all fall under the common layer, but shooting a projectile at 1000m/s using texture XYZ facing the camera at all angles is a game layer component. The more of these components you externalized from compiled code (ie: use of scripts), the more dynamically configurable your game. If you take a look at Supreme Commander, most of their game runs off lua scripts. One community member managed to rewrite the entire AI. That should give you an idea how powerful scripting can be.

As for designing and integrating the editor with your engine, this is a rather complex topic. Take a look into MVC, MVVM, and MEF style frameworks. Specifically investigate MEF. It’s primarily designed for .NET, but you can write a similar framework in C++ if you have to. The core concept is that your interface is as close as possible to an empty shell. Modules are dynamically loaded into the editor, which control the features available to the user. It’s a very clean architecture for developing dynamic user interfaces that plug into your engine.

8676d29610e6c98d6dd2d9c38528cd9c
0
alphadog 101 Aug 23, 2012 at 19:03

@SICGames2012

Additionally, the changes take place in real-time now just after compiling the scene over and over again. Is it possible the engine checks to see if there’s anything changed then compile it then place it back in editor?

Are you talking about “hot-swapping” game world data or actual code? The latter is much more difficult. The former is simply a change to data in memory; there’s no compilation. I’m confused by your post. Maybe a tangible example of what you’d like to be able to do would help?

With the right structures, you can smartly change some or any data on the fly.

For “changing” code on the fly, depends on how far you want to go and what you are using/wanting to achieve. One technique that allows less coupled code in OOP is called Inversion Of Control. You are not actually changing compiled code so much as you are dynamically choosing at runtime what to instantiate. You can suddenly add compiled code, though.

Another technique is Reflection, which in some languages allows you to alter objects at run-time. C# is pretty advanced for this; look to the ExpandoObject for a starting point.

There’s monkey patching in Python and Ruby.

And, good ol’COM/ActiveX is a way to swap in new code. The old code never goes away, just “shifted”.

Very few languages allow for truly swappable code while running. Most that do are functional languages. Erlang, for example, allows hot-swapping code pretty easily as the code is running.

8676d29610e6c98d6dd2d9c38528cd9c
0
alphadog 101 Aug 23, 2012 at 19:07

Humph. A colleague just pointed me to this:

http://runtimecompiledcplusplus.blogspot.co.uk/2011/06/source-code-now-live.html

340bf64ac6abda6e40f7e860279823cb
0
_oisyn 101 Aug 23, 2012 at 21:57

MSVC++ has supported “edit and continue” for decades, even when running code remotely (such as on the Xbox 360). Although certain compiler options and code modifications can disable it.

92b820913825a97ebbcd7fcf9ccf416f
0
dougbinks 101 Mar 20, 2013 at 19:14

@.oisyn

MSVC++ has supported “edit and continue” for decades, even when running code remotely (such as on the Xbox 360). Although certain compiler options and code modifications can disable it.

I’m one of the authors of Runtime Compiled C++. Edit and Continue has a lot of limitations, and in practice I’ve found it rarely works in game development circumstances (see here for more info on the limitations). For example you can’t make changes to optimized code, making gameplay changes tough to make since many games need optimization to run at interactive rates.

With RCC++ you can make any change, with the limitations being on the interface between code needed to support runtime swapping. An added benefit is the technique is cross platform, currently supporting Windows Visual Studio, Linux GCC, and OS X with LLVM (or GCC with a small change). Further platforms, providing they support shared library loading at runtime, can be added fairly easily though embedded or mobile platforms which don’t have a compiler on the target would require extra work to host the runtime compiler on the dev platform and communicate between the process on the target and the host (via tcp/ip for example).