Create a 3d Map editor

Started by
9 comments, last by Sasuko 19 years, 2 months ago
I would create my own 3d game editor. All i need to do is load mesh files (.x) and translate/rotate/scale at the last set some proprety as Bounding box. In this way i can define a new world. How can i starting? How could i save it so to use in my game?
Advertisement
Quote:How can i starting?

If you're "rolling your own" then you've probably got a lot of work to do. Some sort of windowed-mode interface (so you can get windows dialog boxes for loading/saving for example) might work out easiest.

Loading of .X files and moving them around will probably have to be done using "ray picking" and/or "ray projecting", so that you can convert the 2D mouse coordinates into 3D data that you can translate/rotate from. You might also want to look into "Arc Ball Camera" for that familiar 3D editor navigation feel.

Quote:How could i save it so to use in my game?

However you want [smile]. Maybe some heirachical XML format will suit you nicely - there are loads of libraries for XML (creating and parsing). Alternatively, any binary format that makes sense to the context of your game is best.

In creating my own file formats, I find it helps to write down all the information I might need when I load it again (so as to restore the exact same state when it was saved). Once you have this list you can group things together and define how they should be related to each other in a file. Then work on the actual coding of the file format...

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

I am working on a level editor for a university project myself
and I can tell you it's not that easy. But it's also not impossible and it may be neccessary if you are developing a game.
But remember if your game is a hobby project, maybe you can use an already existing map editor!
If you are sure you want to spend a lot of time developing an editor then here are some thoughts I came up with for my project:
(I assume you are developing for Windows)

- The editor should run the engine of the game in it's work space, so
all features of the game (like Normal-Mapping etc.) run in the editor as well.

- I would recommend C# for developing the editor (windows, controls etc.) because it is perfect for that, but your game engine may be unmanaged C++ (as in my case) so you would have to call unamanged code from your managed editor.
It is possible but I guess it's not very easy AND things in the engine woun't work automatically in your editor (you would have to write a wrapper for the unmanaged code first)

- So you are left with writing you editor in unmanged C++ - normal Win32 API programming. I used the WTL because it gives me a little bit of object orientation. But I think it's hard work to get a editor running with the Win32 API if you don't have much experience in that field.

- The level files are saved in xml format because ther are parsing libraries on the web I can use and our files are not so big that xml becomes a speed problem.

Here is a screenshot of an early version of my editor so you see that I know what I am talking about :)

-- Constantin

I think you would do best to have some sort of graphical interface like C#. I prefer C++ Builder just because I've always used it. To interface, you can create a list of the most important functions to your game engine and export the engine to a dll. It makes interfacing a lot easier in my opinion.
Chris ByersMicrosoft DirectX MVP - 2005
I know C# i could create the editor with this lanaguage and .NET framework, but to handle:
"ray picking" and/or "ray projecting", so that you can convert the 2D mouse coordinates into 3D data that you can translate/rotate from. You might also want to look into "Arc Ball Camera" for that familiar 3D editor navigation feel.
can someone suggestme about?
Quote:Original post by Supernat02
I think you would do best to have some sort of graphical interface like C#.

C# only works out well if you plan to write our games in a managed language, too.
.NET has very poor interop abilities with C++ (e.g. only works through COM or MC++ wrappers → lots of unnecessary work).
I'm fine with MFC, though any UI framework like wxWindows or GTK works well, too.

Sasuko:

First of all you will want to create some kind of game engine, e.g. a code base that is shared between game(s) and editor. This includes resource handling (loading meshes, materials and possibly scripts) and basic rendering services.
It's best to create a static library or a dll for this code. This way you can be sure that editor and game(s) are in sync and share equal functionality.

The basic steps are
1) create a detailed list of features you need (put in as much detail as you can - helps you to stay focused)
2) assign priorities to the items you've got from the list in 1)
3) implement a basic UI framework that has a preview window for rendering and a menu
4) implement the top priority items first (e.g. load a mesh, position/scale/rotate it and save to file).
5) test the functions by loading the created output into a simple viewer that shares the engine code
6) remove completed items from the list
7) goto step 4) until list is empty [smile]

how can i implement the toutch controll?
How can enstable when/whether i've cliccked on a vertex or a face of a mesh?
Quote:Original post by Link
how can i implement the toutch controll?
How can enstable when/whether i've cliccked on a vertex or a face of a mesh?

Do you really want/need to edit meshes physically? It can get quite complicated if you want to do that...
i don't want edit mesh but just can rotate/translate/scale.
How can i intercept the mesh, how by click select it, or its vertex or face?
Link i've your same interests.
You need to look up the topic "picking". The basic concept is to take the coordinate for the mouse (which is 2D) and using the various projection/view/viewport/world matricies back-transform it to a ray in 3D space.

Once you have this ray (often just a vector starting on the near plane/camera) you need to trace it through your world geometry. This can be achieved using bounding box or sphere tests to quickly accept/reject objects, but you will probably need to work down to the triangle/face level. The maths can get a bit hairy here.

I think there are some D3DX utility functions in the SDK that you can quite easily use provided you also have ID3DXMesh objects containing your main geometry.

This reply to another thread may well be of interest to you.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

This topic is closed to new replies.

Advertisement