Blender Level Editor

Hello everyone!
I am proud to release my first Blender Script, that is written in bpy. This is a Level Editor extension I have written with help from my brother!
It is designed for a Sidescroll Game.

The Level Editor can be found on the left side in the Tools Panel.

Current Features:

  • asset library for quickly selecting certain assets
  • add and remove assets to your library
  • paint and erase function for rapidly painting assets into your 3D scene(use the “Pace/Remove Assets” Button, for erasing press “alt” and paint over the objects to erase them)
  • variable grid resolution
  • repeat last operation

This LevelEditor is designed for fast game level editing. I hope some of you may enjoy it. I will publish an installable addon in the next few days.
So this is version 0.1

Unfortunately the editor gets slow when many objects are in the scene. This has to do with blender. Blender adds objects slower the more objects get into the scene.
Maybe anyone knows how this can be handled more efficiently. For adding objects I use bpy.ops.object.add_named(linked=True, name=“Cube”)

So have fun! :slight_smile:
Greetings Andreas

Attachments

BlenderLevelEditor.blend (420 KB)

As it run in blender (that’s the right place for a level editor btw) You can use some extra trick - like merge close by objects using the same material in to one - with some custom property magic You can save the original object so the editor can split them in to separate linked objects again.

If You merge object in a sane way the level will run faster in the game too!

This is a great initiative, thanks!

@LaH
yeah… I already thought about merging objects.
Lets say I have about 2000 seperate blocks. Adding new blocks is already really slow. By merging those 2000 blocks together the editor works very fast again. My problem is to seperate those again and keep its Material, Properties and other custom settings…

Why is blender getting so slow? Is it just because there is a superlong list where all objects are assigned? This is really a bottleneck at the moment.

The optimal merge is that You merge X close objects so when You play the game You have only a few of merged objects in camera view - while still most of the level is outside camera view and culled. That give fast game play.

For splitting - if the editor works with linked objects (it’s a sane thing to do) You only have to store the original, the position and the orientation. Then You remove the merged object and recreate all linked objects - then You can move and replace each object again - and they should get right material from the original.

You want to be able to exclude objects from merging (objects that should have some kind of dynamic behavior). The merging can be more or less manual to (select X object - press merge, select a merged object - press split).

For splitting - if the editor works with linked objects (it’s a sane thing to do) You only have to store the original, the position and the orientation. Then You remove the merged object and recreate all linked objects - then You can move and replace each object again - and they should get right material from the original.

This sounds like a good idea! What I can already do is this. Via a button I can merge any count of objects. All names and positions get stored into my final object.
Lets see what I can do with that data… :slight_smile:

Ok…
I got my merge and seperate Script working! What it does is, it merges selected objects. Saves the name of the linked asset and position in the final merged object. when seperating it iterates through all names and craetes a linked object on the saved location.
All properties get restored from the asset itself. I have to look if I can restore custom properties too, so you don’t have recreate them to.

But this feature should be a nice workaround for the bottleneck I mentioned above. When painting objects gets laggy, just select a bunch of objects. Merge them together. If you want to edit them later, just unmerge them and everything works fine!

Thank you very much for your contribution!

So here is a video of the actual state of the editor! Take a look :slight_smile:

Great, just great!

At the moment I work on a function that removes me all walls between the cubes when merging the objects(faces that are on the same position). This is also very nice for decreasing polygons. It works already, but unfortunately it is veeeery slow for lots of objects!
My brother is going to help me optimizing the lookup for double faces, we came up with an idea already. Lets see how this is going to work.

I was about to suggest that - but figured it could wait for later. Connecting faces that’s side by side on ‘outher’ surfaces is another one (then we can set smooth rendering on merged meshes).

Stuff I wold like:

  • paint horizontally.

  • paint with some random offsets between objects and some random rotation and scaling.

  • paint with a set of objects randomly chosen.

  • paint aligned to a surface (a canvas object) With options to:

    • orient object to surface normals.

    • orient objects to canvas center.

    • update: And of course to global Z axis.

  • Select objects latest painted.

Anyway - if this editor goes open source I will play with it and maybe even contribute some…

Great Job, looking for more updates!

Blender is definitely the best level editor out there, making a script to make it behave properly for your own needs is the right idea.

  • orient object to surface normals.

This idea has a lot of potential, if someone has a large landscape / terrain mesh, then to able to just click and place trees would be great. You could also add some ‘jitter’ options, where scale and rotation and randomised.

Nice idea, would be very useful for those making 2D games as it essentially recreates a tile-based editor in Blender.

Though a lot of people (like me), don’t use a tile-based paradigm in the BGE and often use it for 3D games, so it would be nice if there was a suite of snapping, placement, and alignment tools that can work with complex 2D and 3D level geometry that do not use a tile system. :slight_smile:

It looks great nice one ndee!

Amazing!!!

Thanks for this script, it’s very useful. :wink:

@ LaH
a few of this features I definately want to tackle! And yes, the final editor will be released and can be edited.

@BlendingBGE
thanks :slight_smile:

@andrew
yeah… this feature would be nice, I don’t know if I have the skills to achieve it! The thing is, I am a graphics artist with a few programming skills. But I hope my skills will grow over time :slight_smile:

@ Ace Dragon
yeah… at the moment the editor works only for some special cases…

@leonnn
thank you very much :slight_smile:

@flopoloco
the editor that can be downloaded at the top is not the current version. I have added a few features already!


generelly I think a proper level editor is where blender lacks a lot! If you want to create a bunch of levels you need tools that let you work efficiently. of course you can do everything in blender as it is. But on a bigger scale the tools just lack speed. Thats the reason why I try to develop this editor. Of course this is adapted to my needs and not a generel editor.

But I think a proper editor CAN be done in python. This doesn’t need to be done via c. I think the python api gives us all tools that are needed. We just need a talented coder to realize it! At the end it just can be released as an addon. And we will see this feature much faster in blender as when someone is going to code it i c.

Thank you all for your kind words!

Edit
I also think that a particle system can be realised via bpy. Of course it won’t have the performance as if it is hardcoded. But it can be done much more userfriendly as setting up a particle system now.
Maybe be a hint for solarlune. His x-emitter is great already, maybe this can be hooked up with bpy and realised in the ui! :slight_smile:

Ace Dragon: The ‘canvas object’ was meant for more ‘free’ building. But it’s probably best if this add-on remains grid based (but a horizontal grid option for top down game would probably fit). The nice thing with add-ons is that we can have plenty - and two who do there respective work great is better than one that do both work poorly.

Hi ndee,

I found your script very interesting. Currently, I look Blender as 3D map editor for my project and I have tested your script with some changes to fit with my needs.


In this exemple the map use some 3D tiles to create a labyrinth :wink:

But before I really use it and mainly modify it for my project, I would know what is its license ?

If you don’t want give an open source license to your final addon, may I have the permission to use this script (in version 0.1) in my addon with an open source license as GPL, MIT, Zlib or an other OSS license ?

PS : Ndee, this post was sent before my private message for you but it has been moderate. so it has been posted in forum after your answer :wink:

Hello why I haven’t the asset library window