Simple LEvel Editor for Panda3D (WORKING!)


#21

V 1.01

DOWNLOAD LINK (ziped source):
sendspace.com/file/cjb7ud

What’s new:
-should not crash when hightmap is missing
-walk maps
Layer #0 in the texture paint mode has now a special use. It’s just another gray-scale image/mask and you can’t select a texture for it, by itself it does exactly nothing, but the image can be used to determine what parts of the map are walkable. There’s a good example on the forum on how it can be used: Limiting the terrain that an actor can walk on
It’s even a bit simpler if you use a geomipterrain the worlds X and Y map exactly to the maps X and Y coordinates.


#22

Isn’t available the possibility to load an already existent map into the editor?

UPDATE:
added these 4 lines at the end of init make the map load in case there is a name specified via command line:

		# if there are additional args then load map
		# else create a new map
		if len(sys.argv) >1:
			self.loadMap(sys.argv[1])

2nd UPDATE:
I found an annoying bug :frowning: I paint on a first layer. Then i switch to the second and paint there, switch back to 1st layer and paint. I lost all the previous modifications I did to the first layer.


#23

Do-it-yourself-fix:

def selctLayer(self, layer, notUsed=None):        
        TexturePool.releaseAllTextures()
        self.TexPlane[0].hide()
        self.textureFrames[0]['frameColor']=(1, 1, 1, 0.5)
        self.currentTexLayer=layer
        self.texPointFrame.setPos(self.winX-64,0,-128-(64*self.currentTexLayer)) 
        file=str(self.currentTexLayer)+"tex.png"
        if os.path.exists(path+self.saveName+"/"+file):    
            self.altPlane.setTexture(loader.loadTexture(path+self.saveName+"/"+file), 1)
        else:
            self.altPlane.setTexture(loader.loadTexture("full_mask.png"), 1)
                
        if layer == len(self.textureFrames)-1:
            self.textureFrames[layer]['frameTexture']=path+"textures/"+self.textures[0]
            self.textureFrames.append(DirectFrame(frameSize=(-64, 0, 0, 64),
                                    frameColor=(1, 1, 1, 1),
                                    frameTexture='plus.png',
                                    state=DGG.NORMAL,
                                    parent=pixel2d))
            self.textureFrames[layer+1].setTransparency(TransparencyAttrib.MAlpha)
            self.textureFrames[layer+1].setPos(self.winX,0,-128-(64*(layer+1)))
            self.textureFrames[layer+1].bind(DGG.B1PRESS, self.selctLayer,[layer+1]) 
            self.textureForLayer.append(0)
            self.TexPlane.append(self.texturePlane.copyTo(self.altTexRender))  
            temp_textures=Texture()
            temp_textures.read('full_mask.png')
            temp_textures.setFormat(Texture.FAlpha)
            self.TexPlane[layer].setTexture(self.TexPlane[layer].findTextureStage('Tex1'),temp_textures,1)
            self.TexPlane[layer].setTexture(self.TexPlane[layer].findTextureStage('Tex2'),loader.loadTexture(path+'textures/'+self.textures[0]),1)        
            self.TexPlane[layer].setZ(-1)
            self.TexPlane[layer].setDepthOffset(layer) 

The only change is TexturePool.releaseAllTextures() at the top of the function (line 946)

packed and fixed:
sendspace.com/file/ae0132


#24

Hi wezu, is there a way to get the brush to behave more like an airbrush than a stamp? Currently holding down the mouse button doesn’t paint continuously like expected.


#25

No, I don’t think so, at least I don’t know how to do it.


#26

Hi, wezu. Are you still developing your editor?


#27

Not at this point in time. I’m working on something else now (indiedb.com/games/scratch-the-surface), but I want to get back to the editor sometime in the future (after pyweek, at End-o-may-or-so-but-don’t-quote-me) and do a major rework.


#28

OK, I see. Anyway, it already has enough functionality for me. It even has the same concepts I had in mind when tried to make a similar editor in Dark Basic. Thank you for the tool!


#29

I have a new version. It’s still work in progress, but some parts are working ok.

Changes:
-90% of the code rewritten. I’ve split the code into 4 classes, it should be easier to edit or reuse parts of it if someone wants to roll an editor of his own.
-The heightmap is applied in a shader, so drawing it is 5-30x faster (with a 512x512 map), so the height map can be drawn with a click-hold-drag technique and not a click-wait-click technique like it was earlier.
-The camera is controlled with the mouse, and (some) brush settings are controlled from the keyboard, the default keys look like this:
[A] and [D] -scale brush
[Q] and [E] - rotate brush
[W] and [S] - scale brush strength (height/alpha)
[+] and [-] or [mouse wheel] - camera zoom
[mouse3] or [alt] - pan camera (on mouse move)
[mouse2] or [ctrl] - rotate camera (on mouse move)
[mouse1] - paint
[f1] - paint height map mode
[f2] - paint texture mode
[tab] - switch between razing and lowering the terrain in height map paint mode
-The color texture is one big texture (2048x2048) plus some crazy details - the crazy details are controlled with a widget in the bottom left corner with 3 sliders (do experiment, you’ll get it). Not sure if I’ll keep it I may revert to some sort of texture splatting in the end.
-Saving works, but more as a proof of concept, it always saves to 3 files in the save directory

DOWNLOAD LINK (source in zip):
sendspace.com/file/g34rze

This is not a final version.
Questions?


#30

How does one download this file from Sendspace? I can’t find a download link at the site. I have the same problem with the other files to which you’ve linked at that site. :question:


#31

Hmm, I was able to download it ok. It should have a link ‘Click here to start download from sendspace’.

I’ve downloaded it and put it into my dropbox if it still doesn’t work for you:
dl.dropboxusercontent.com/u/19917470/sleep2.zip

Maybe github would be a nice place for it if Wezu continues to develop it…


#32

I’ll admit that I’m not a fan of Sendspace’s seeming tendency to half-cover the download page with other links, some of which can easily appear to be the download link. I fear that it can be easy to miss the actual download link, or mistakenly click on one of the other links. :confused:

More on-topic, this is looking good–well done, I do believe. :slight_smile:


#33

Sendspace used to be good, but now it has all them false links and signup/pay/buy/whatnot… I call it the imageshack syndrome.
I’ll try to put up a project page on github or sourceforge in a day or two.


#34

I’ve set up a page on Github:

github.com/wezu/koparka

To be honest it’s my first git repo, so if something is wrong with it let me know.


#35

A bit of an update:
-proper saving and loading menu (but don’t bug me for a file browser)
-grass painting

The grass painting uses hardware instancing and I’m not sure I’ve got the shader right. My driver (ati) will eat almost any GLSL shader, so I can’t be sure it’s 100% correct. Wouldn’t mind if someone would test it :wink:


#36

Hmm, yeah the grass instancing isn’t working for me on nvidia. Errors relating to casting ints / floats:

:display:gsg:glgsg(error): An error occurred while compiling shader shaders/grass_v.glsl
0(4) : warning C7572: OpenGL requires extension names to begin with 'GL_'
0(20) : error C7011: implicit cast from "int" to "float"
0(30) : error C7011: implicit cast from "int" to "float"
0(30) : error C7011: implicit cast from "int" to "float"
0(35) : error C7011: implicit cast from "int" to "float"

Had a brief look and fixed those, but then got to problem with anim_data not being sent to the shader.


#37
0(4) : warning C7572: OpenGL requires extension names to begin with 'GL_'

That I don’t understand.

Line #4 is:

#extension GL_EXT_draw_instanced : enable

…but then again my driver says:

 WARNING: 0:4: warning(#62) enable/warn/disable extension isn't found, extension
 'GL_EXT_draw_instanced' is not supported

It’s a warning, so it should work anyway, right?
The ‘implicit cast from “int” to “float”’ a presume where I wrote 0 and should have 0.0.

I got rid of the anim_data input. You can see now where the grass tiles are, but it should work.

I just made a commit to the git, if You’d give it a second go, that would be great.


#38

Yeah - it still works for me with the warning.

Still wasn’t working, missed out on a few casts. I fixed them in your grass and terrain shaders. Heres a pull request : github.com/wezu/koparka/pull/1

Hopefully it doesn’t break ATI, but the grass and terrain now works really well :slight_smile:


#39

Works great on (my) ATI, merged it, thanks.

I think I’ll keep the terrain texture painting as it is. The 80 texture samples are much more then I could have with any sort of texture splatting, and there’s nothing standing in the way of adding 80 more if I need to. The size of the grass that I made is such that a map should be ~50m not 5km, so I think I’ll change the size of the details and leave it at that. One other thing I may add is that the scale of the texture used for painting will stay the same (more or less I hope) even if the size of the brush is changed (the texture gets blurred now) - it won’t be pixel perfect, not with rotating the brushes but I think it will be better then it is now.

I also think I’ll get rid of the shader I used for painting the hight map and always display the level textured and ‘grassed’ that should make things easier… or add a button somewhere to switch it on and off if someone wants to use the editor only for editing heightmaps, not as a level editor.

…but probably not today :mrgreen:

Oh, and if someone is wondering how the grass looks, but didn’t download the files (yet), here’s a screenshot:
s17.postimg.org/r5kqkb4a7/grass_fxaa.png


#40

I’ve added the option to drop objects into the map, and also a ability to pick them up later (for this to work the models need to have collision geometry under a node/group named ‘collision’ ).

The models/objects dropped are organized into a quad tree, that should help with collisions, but it also should make things simpler to flatten.

The editor can also generate a collision mesh that is just like the visible geometry (more or less) and also organized into a quad tree. This is more accurate then checking the heightmap.

Screen:
s30.postimg.org/n4g6qggkv/koparka1.png

Source:
github.com/wezu/koparka

EDIT:
Saving and loading objects works.