[Feature request] Export to .kvx
Use case: creation of voxel models for GZDoom mods
Yeah, actually it shouldn't bee too complicated, since I already have the code to import kvx files.
Anybody has the complete specification of the kvx format? I cannot find any documentation on that.
It is in package with SLAB6 and it’s source on Ken Silverman page (author) and on some external site with Build engine resources(they mention KVX file format description). Ken’s page: http://advsys.net/ken/download.htm Build engine resources page: http://www.dukertcm.com/knowledge-base/downloads-rtcm/general-tools-voxel/
Have a good day
Please someone do this, there's not a voxel editor with KVX exporting that can run on linux
Hello! It's been a long time since this feature was discussed. With recent revival of Build engine games, IMO it is relevant more than ever. I will try to prove my point.
In few months Ion Maiden is coming out. This is completely new 3DRealms game based on much enhanced Build engine (EDuke32). It uses voxels for pickups and some of level props. This game will be VERY modders friendly & has very enthusiastic following by Build-games fans & mappers scene.
Blood (1997) will be officially remastered and re-released. Goodbye DosBox.
There is alive and kicking scene of modders & mappers of Duke3D, Blood & Shadow Warrior. Every month brings improvements to projects like Eduke32, NBlood or GDXBlood. There is constant flow of new content created by Build engine fans, voxel enthusiast too. Outdated & terrible SLAB6 is only option for exporting KVX models.
Imagine, to save in KVX format I have to save model as .QB in Goxel, load it in Voxelshop, save it as KV6, open it in SLAB6 on other Windows machine, save it as KVX, load it into the game on my MacOS machine...and cross fingers that I have not ******** something in the beginning.
Please reconsider adding KVX export to Goxel, thanks!
OK, this workflow is not optimal for sure. I will try to see if I can do it. I'll need to find some KVX loader I can run on linux though, or it will be tedious for me to test it out.
Fantastic! In regard to documentation of KVX format, there is this description of loading KVX in SLAB6 readme file. Here it is: slab6.txt
SLAB6 has it source code attached to its package on Ken Silverman homepage. SLAB6+SRC In file slab6.c I've found KVX relevant code with commented-out descriptions of various functions. I'm not programmer, I hope it suffices.
Voxelshop export module for KV6 written in Java: https://github.com/simlu/voxelshop/blob/develop/src/main/java/com/vitco/app/export/Kv6Exporter.java Since KV6 is KVX predecessor, it might be useful (?).
By the way, have you tried the kvx import of goxel? Does it work? I wrote it a long time ago and basically never tested it.
Nevermind :P

You beat me to it! ;) Yes, all KVX models that I've opened in Goxel appear to be fine in terms of form, color & orientation.
In regard to KVX, there is also Ken Silvemans Poly2Vox. It is CLI utility that converts mesh models to voxels. It can export to few voxel formats, KVX too. Source code is attached to package: http://advsys.net/ken/poly2vox.zip
I have just found description of palette.dat. It is palette file necessary to set right colors in KVX. It is different for each Build engine game. Otherwise colors are going to be messed up. Here is description file: PALETTE.TXT Tomorrow I'll extract palette files from Duke3D, Blood, Shadow Warrior in case You need them. Maybe it would be possible to load custom palette.dat file on KVX export? That way any possible palette/game would be supported. Just a humble suggestion.
Yes I think I will try to generate the best palette during export, the same way I do for the magica voxel export.
You are probably right. I mentioned it, because I had a problem with appearance of KVX files taken straight out of SLAB6. In SLAB6 model looked fine, but colours were completely off in EDuke32. I found out that before export in SLAB6, I have to use function 'Replace palette and Convert colors', choose palette.dat extracted from Duke3D game files, and after that export. Only then KVX looked properly in game.
In case You need it, here are palette.dat files from Duke Nukem 3D, Shadow Warrior, Blood & Redneck Rampage. I also attached two KVX samples for each game, that I taken from community voxel packs created for corresponding games. No samples for RR, since this game has no voxel content yet. Ion Storm has no palette.dat in its game files.
I'm surprised that all of those KVX samples load in Goxel with proper colours, without being fed with appropriate palette.dat files. I probably have wrong idea about how it works on technical side.
I an not sure either. I guess slab6 uses different format for editing and export. The KVX format seems to be to be optimized for fast rendering (it's actually pretty clever), but not for modelling. I haven't read the source of slab much, but my guess is that the models can be saved either as 'rendering ready' (what i am trying to implement now), or as 'modelling friendly'.
OK I wrote a first draft of export.
It's probably quite buggy, and the axis are inverted, but I could export the cup model as KVX and reopen it with goxel.

Blazing fast, as usual :)
Thanks for time and effort You put into this feature!
Regarding what You said before about KVX 'rendering ready' and 'modelling friendly', maybe it is the 'Mips' setting (I could remember name wrong) that can be set to ether 1 or 5 value. 5 is appropriate for Build games according to Ken Silverman documentation.
I'll try to compile latest Goxel and will come back with results.
Unfortunately it fails to compile. Here is txt file with pasted compilation error: goxel_compile_errors.zip
Yeah the usual problem, that occurs because I mostly work on linux and don't update the osx build each time. Should be fixed now. Let me know if you can get it to work. Tomorrow I'll try to fix the orientation bug.
It compiled successfully! :) What I observed, Goxel seem to save KVX properly - obviously with orientation flip - only when I draw new model from scratch. Those files seem to always save properly without crash. If try I to import some file(s) and export as KVX, Goxel succeeds only sometimes. I couldn't find deciding factor, like size.
@guillaumechereau
I'll need to find some KVX loader I can run on linux though, or it will be tedious for me to test it out.
GZDoom ? EDuke32 ?
I couldn't figure out how to make GZDoom work with voxel support. Anyway, I fixed a few bugs in the KVX import/export. It seems to work at least with the example files from slab6: I can import them, export them and re-import them in goxel.

Great, I will check it out and get back with results. Thanks!
I made few tests, this is what I found out.
KVX files generated by Goxel open in SLAB6 with proper orientation and appearance of colours.
However on attempt to use use any of such files in Build engine map editor Mapster32, they hang editor on startup. EDuke32 starts with those assets, but their in-game appearance of colours is completely messed up.
Here is screenshot of KVX file generated by Goxel right after loading to SLAB6:

I have tried to save such file in SLAB6 and use it (5 mips on export). Same as before, hang of editor & wrong in-game colours.
So I used 'Replace palette & convert colours' with PALETTE.DAT from Duke3D.
Please notice how palette changed:

Such file was (obviously:)) working perfectly.
Here KVX files for comparison: 0961_exit_GOXEL.KVX - file straight out of Goxel 0961_exit_SLAB6.KVX - SLAB6 export (5 mips) 0961_exit_SLAB6_COLORCONV.KVX - SLAB6 export (5 mips) with color conversion applied EXIT_VOX.zip
OK. Does it mean that Duke3D ignore the KVX file palette and always use its own palette? If that is the case what I could do is ask before export if we should use force the Duke3D palette I guess.
Yesterday I've read somewhere in Build files formats documentation by K. Silverman, that KVX files store palette inside of them. If that palette differs from palette set arbitrarily by Build game with its palette.dat file, it is displayed incorrectly (not a bug, feature). What do You think about option of setting custom palette (via various games palette.dat's or some other more common palette format like .pal)? Maybe adding variants of KVX to export formats list? Forcing Duke3D palette is probably easiest solution. That limits all KVX functionality to Duke3D modding, but this is still waaaay better than that conversion process that I explained You in the beginning.
I see. I can probably add support for other palette formats, maybe even the .dat used by build engine to make it easier.
If that palette differs from palette set arbitrarily by Build game with its palette.dat file, it is displayed incorrectly (not a bug, feature).
This is why each Build game has different PALETTE.DAT file. They all use different palettes. All sprites and voxel models for each given game have to use same palette.
EDIT: I posted before seeing Your post. Thats great!
Quick question: do you have some .dat palettes I can use to test it?