3D World Editor - Suggestions and Ideas

Started by
10 comments, last by Jman2 7 years, 6 months ago

Hello GDNet

For about 2 months now i have been actively developing an editor for my game project.
The reason i took the challenge to shift from my project and actually build an engine and an editor for my game is purely for learning purposes, and i have learned a lot.

At first i was focused on getting things done but now i'm enjoying the process of creating my own game engine architecture and tools.
I know its too early to get excited as my game engine lacks on many things, but i'm happy to see what i have accomplished so far.

Currently i have the following problems to solve:
- How to implement the Redo and Undo algorithms ?
- How to save the map, in what format and structure ?
- How to select faces, vertices, and transform them around ?

While i was developing the editor i was highly motivated by Unity, Valve Hammer Editor and Frictional Games HPL Editor.
I'm a one man studio and i like when people throw ideas and suggestions at you, it keeps me motivated.

Here is a preview at what i have accomplished so far

Capture13.png

Capture15.png

Capture16.png

Advertisement

This doesn't particularly seem like a 'beginner' topic, so I'm moving you to General Programming.

Nice, i think that you learned Opengl from here learnopengl.com.

If i may ask what widget library did you use to make the editor? and is it open-source?

How to implement the Redo and Undo algorithms ?

Think of the operations you do in terms of commands. You react to the UI by creating such commands, then dispatching them to a processor class which reacts to them. You keep a stack of all the commands you processed. Each command should encapsulate enough data to allow you to reverse it (for example, translation should store the origin, add object should store a reference to the added object, etc.).

Once you have that architecture in place, it's straighforward to implement undo and redo.

How to save the map, in what format and structure ?

Define map? And that really depends on your engine and the features you support.

I started to write an answer, but figured it's a topic on its own, so be more specific in what you want to export.

How to select faces, vertices, and transform them around ?

Hmmm.... Any particular reason you want to move faces around? That's what we have Maya for.

It's not difficult. Implement picking to detect which face/vertex was chosen, then update the corresponding vertices location in the vertex buffer.

Take a look here - http://ogldev.atspace.co.uk/www/tutorial29/tutorial29.html.

@[member='N.I.B.'], Why i want to move faces or vertices around ? What if i want to play with terrains and terrain manipulation tools.
About the map, i need to export all of the game objects in a scene to a file. I'm thinking of exporting all of the game objects and their components into a JSON file format.

@[member='Zlixine'], Indeed learnopengl.com is a wonderful resource and i learned alot from it.
I'm using WinForms with C# and OpenTK because why not ? I'm very comfortable with WinForms and C# anyway

and its not like my editor is going to be the next Unity competitor. I'm planning on keeping it small and tied to my game project.

I'm thinking of exporting all of the game objects and their components into a JSON file format.

JSON is one way to go. In fact, it's exactly what we are using at work for our research framework.

We chose JSON because it is human readable. We don't store actual models there - just model filenames with relevant data (position/rotation/scaling). We also store light source information, camera definitions and some other parameters.

The main drawback is that parsing text files is slow. If you plan to store actual model data there (i.e. vertices), I would advise you to come up with a binary format. It will make a huge difference in loading time when loading a scene with large amount of vertices.

In my experience, undo/redo needs to be designed in from the very beginning. It is a nightmare to retrofit to an existing project so I'd focus on it as soon as you can.

Then general idea is as explained above. The only way you should be able to modify your state is via Command objects, which store enough information to be able to undo and redo themselves.

I use the C++ const system to enforce my undo/redo system at the code level. I have a WorldState object that just contains bare read-write data for the world state. This is then wrapped in a World object which provides const-only access (read) to the world state. Eveything like views, toolbars etc uses the World interface to read the state.

The World also has beginCommand(Command*) and endCommand(Command*) methods that take classes deriving from Command. When one is passed to beginCommand() it is given a pointer to the WorldState so it can directly modify the values, but must take responsibility to undo itself and redo itself. When endCommand() is called, if the command is valid, it is pushed onto an UndoStack in the World object.

So the only way to modify the WorldState is via Command objects. It is not possible via any other mechanism so you can't accidentally fall outside the system.

It can feel a bit weird at first that every time you want to modify something, you have to create a Command to do it, but for me it is really the only way to ensure the system is comprehensive and you soon get used to it.

Hope this helps.

What if i want to play with terrains and terrain manipulation tools

Terrain editing tools are generally _highly_ specialized and don't work like normal model editors. Terrain often isn't even a mesh per se, but it's own data structure (which generates meshes on the fly). You have relatively little reason to want to select faces, but as mentioned above it's pretty easy to do.

I'd suggest - as always - to spend some time with competing tools before building your own. Take a look at what the terrain editors in other engines do and why. Some time on Youtube looking at terrain editor videos at the very least might be very informative. For instance here's an open source Game Maker terrain editor video that illustrates the basic concepts pretty decently.

Then you'll be far more prepared to implement your own terrain brush system.

Sean Middleditch – Game Systems Engineer – Join my team!

Currently i have the following problems to solve:
- How to implement the Redo and Undo algorithms ?

The best resource I've found on this is Robert Nystrom's (aka @MunificentBob) Game Programming Patterns, available as a dead-tree book, a downloadable PDF and a (FREE) website. Chapter 2 deals with the Command pattern, talks you through some Theory and shows you an implementation of Undo & Redo.

http://gameprogrammingpatterns.com/command.html

It's well worth your time giving him a read.

In my experience, undo/redo needs to be designed in from the very beginning. It is a nightmare to retrofit to an existing project so I'd focus on it as soon as you can.

Yes exactly, i realize now after reading the article from the link @[member='Eulagrief'], dropped, so thank you guys !

@[member='SeanMiddleditch'], Maybe i don't have to implement terrains at all since my game will be more closed indoors fps and even if i need some outdoors areas i can use static meshes.

This topic is closed to new replies.

Advertisement