3D World Editor

Blitz3D Forums/Blitz3D Beginners Area/3D World Editor

QuickSilva(Posted 2004) [#1]
Ok, I`m going to take a stab at my first ever 3D world editor for my game. My question is where should I start? I want to keep things as simple as possible but 3D is tons different from the 2D editors I`m used to making. Any tips apart from buying TerraED or similar? I would really like to learn to make my own but am a little unsure on how its done. Any good links? I had a serach but couldn`t find much.

Jason.


Perturbatio(Posted 2004) [#2]
decide how your world format will look before ever touching the IDE.
Write it out (either virtually or on a piece of paper).
List all the features you need (in both the format and the editor).
Then list all the features you would like to have.
Decide what is necessary to make it functional and aim for that, then if you achieve that, add the rest.


QuickSilva(Posted 2004) [#3]
Ok I probably didn`t explain it that well. The main problem I have is placing 3D objects with the mouse in the 3D enviroment. The rest, loading and saving objects to a file etc... is going to be pretty much like my 2D editors so the 3D placement is my main concern. Any tips on this?

Jason.


Agamer(Posted 2004) [#4]
I would also be interested in how this is done as I am doing the same thing for my game


Jellon(Posted 2004) [#5]
Just about ANY 3D editor I've found comes with a walk through/tutorial. If it doesn't come with the program, it's probably on the website you got it from. How you use a 3D editor is based on what the program is designed. I started my 3D editing with anim8. www.anim8or.com It is a free 3D eidtor. The problem I found with it is you can't do any animating that can be used with blitz! But if you ever got board one day you could still make animation and scenes and stuff with it. Besides, it can export as .3DS which can be used as a mesh in blitz.


jfk EO-11110(Posted 2004) [#6]
Personally I came to the conclusion that a "walkthru and place things" Editor is the most efficient thing. Many people prefere 4-view editors like CShop, 3D Studio Max etc. But I found it much more userfriendly when you can walk or fly trough your world and simply drop things. All you need is a fileselector. So when you want to position some furniture or something, simply open the file-requester and select the wanted mesh. It would then load and position at the cameras position. So your Camera / player position is the cursor in this editor. Now you can adjust xyz, scale,rotation and a lot of further things. Write down a list of the properties you want to be able to edit for every entity. You can try to completely "wrap" the entity by implementing every possible Parameter, just parse the docs and write a list (FX, Alpha, Shininess, Tex Flags etc. etc. etc) Take some time for that list since it this will be the basement of the flexibility of your editor in the end.

Of course, when you load and adjust an entity, all parameters, including mesh-filepath, are stored in some arrays or types.

Now to save a level you only need to store all informations of the said arrays or types. I suggest to use strings for everything, write every parameter on a new line, this makes things easy and doesn't make the file too big. If you have once written your save function, simply clone it and edit this to be a load function, this is an easy step.

As for the placement etc. you have to decide yourself what method you want to use, but I'd suggest something that is really fast, eg. use mousex/y to position X/Z axis and use the mouseY with eg. the Shiftkey to adjust the Y Axis. Do the same with rotation and scaling with other keys, but still implement an option to enter values by number.

Additionaly I suggest to add a copy/paste function. This will clone an entity and position it right at the cursors position. Very useful.

After some time you can also try to implement a collapse function that will collapse all mesh-entities (or the selected ones only) to a single mesh and let you export this. This may be handy for the level design (lightmapping..) and it will also reduce the number of surfaces when you use some meshes multiple times in the level. Collapsing those entities may be a bit tricky, you need to undo all positionentity, scaleentity and rotateentity Commands and redo the same using PositionMesh, ROtatemesh and ScaleMesh Commands only, (and do this in the right order) then AddMesh everything to one mesh and save it using eg. the SaveB3D code form the archives.

Once you have your static level assembled, you can also use a placement tool for dynamic content, eg. items to pick up etc. Personally I use a special string field in the Entity Properties list. This string will allow me to use triggering words like "Bonus" or "key" or "door". The game engine then has to handle this string. This makes the editor very flexible. I don't have to edit the editor everytime I want to implement a new Feature, but instead the engine has to handle this string as some kind of script.

You can also implement 3D Sounds this way, it's about the same. I even use the same entity structure for both, with a flag to signal if it's a sound or a mesh (for the loader).

If you have your save and load functions working, you can use the load function as a basement for the game engine.


jhocking(Posted 2004) [#7]
Here's a function I wrote to position an object in 3D space based on 2D mouse coordinates:

;-----------------------------------------------------------------------------
; Positions an entity in 3D from given 2D coordinates
Function PositionEntityFrom2D(usecam,entity,x2d#,y2d#,height#=0,camZoom#=1)
gw=GraphicsWidth()
gh=GraphicsHeight()
x#=-((gw/2)-x2d)
y#=(gh/2)-y2d
parent=GetParent(entity)
EntityParent entity,usecam
z#=Abs(EntityZ(entity))
div#=(gw/(2/camzoom))/z
x=x/div
y=y/div

;z distance determined by a straight line from camera, through xyz coordinates, to height
TFormPoint x,y,z,usecam,0
y3d#=height
x3d#=TFormedX()
z3d#=TFormedZ()
EntityParent entity,parent
PositionEntity entity,x3d,y3d,z3d
End Function
;-----------------------------------------------------------------------------


Note that it moves the object around on a plane parallel to the ground; you can adjust where the plane is with the optional height parameter. This is a standard approach for a lot of editors: move objects around on a plane, and move the plane up/down to adjust what height objects are placed at.

Another standard approach is moving objects around on a plane parallel to the camera. The code above is actually modified from a sample in the code archives that moves objects in 3D on a plane parallel to the camera.

Another standard approach is to move objects around along the cardinal axes. This is usually done with special handles for people to click on. For example, if people click and drag on the arrow pointed along the X axis, the object will move restricted to the X axis. This is generally combined with the above approach. Specifically, if people click on special handles they will move the object according to this approach; if people do not click on the special handles and instead click just somewhere on an object they will move the object according to the second approach.