Not logged inOpenClonk Forum
Up Topic Development / Developer's Corner / Clonk Blender Exporter (for Blender >= 2.80)
- - By Randrian Date 2020-02-08 21:07 Edited 2020-02-09 12:59
Seeing again a spark of life on OpenClonk, I decided to continue my work on updating the Clonk Blender Exporter.

I got a first version going for exporting meshes and skeletons. The aim is to make it as straight forward as possible.

The current version can now be found on Github:

https://github.com/rgerum/clonk-blender-exporter

You just have to open the provided object.blend file and you can start directly!

Feedback is highly appreciated.
Reply
Parent - - By Apfelclonk Date 2020-02-08 21:15
The link doesn't work for me. It shows me 404.
And also thanks for your hard work.
Reply
Parent - By Randrian Date 2020-02-08 22:34
Sorry, I forgot to make the repository public. It should work now.
Reply
Parent - By manuelclonk Date 2020-02-08 23:21
Thanks a lot!!!
Reply
Parent - - By Randrian Date 2020-02-09 13:01
I now added a very basic export for materials.
Currently it only looks if the material has a texture assigned to it (via nodes) and then adds the texture to the .material definition.
Are there some other properties of the .material files that we need for the export?
I am not even sure which parts are currently used by OpenClonk.
Reply
Parent - By Randrian Date 2020-02-09 20:42
I now added custom material properties in the blender exporter to make it easy to set the basic values directly from Blender.
I now implemented "ambient", "specular", "diffuse", "emissive", the "receive_shadows" switch and a texture image selector.

For receive_shadows, I think almost all objects in Clonk have set it to on, so maybe we should just default it to "on".
For the others that you did mention, I don't quite know what they are exactly used for. Some are related to transparency, I think.
Maybe we should just offer a switch "Use transparency" that sets the appropriate properties. I think it would be cool if we provide the user just the essential properties he has to care about.

Does anyone know more about these properties?
Reply
Parent - - By manuelclonk Date 2020-02-09 21:46 Edited 2020-02-09 21:59
Currently getting the following errors:

  File "/home/manuel/Downloads/clonk-blender-exporter-master2/object.blend/ui.py", line 10, in <module>
ImportError: cannot import name 'Report' from 'report' (/usr/local/lib/python3.7/site-packages/report/__init__.py)


Seems like the python script can not import report. If I remove the import, the addon appears in the UI, but the export mesh button yields  another import error


Traceback (most recent call last):
  File "/home/manuel/Downloads/clonk-blender-exporter-master2/object.blend/ui.py", line 114, in execute
ModuleNotFoundError: No module named 'mesh'

location: <unknown location>:-1


Tested on Blender 2.81
Reply
Parent - By Randrian Date 2020-02-10 08:40
oh, it seems that somehow you have another python package installed that is called "report" and somehow blender tries to import that one. Strange, I would have expected that Blender gives the Scripts it has in the .blend file priority.

So you can rename the report.py file and change the import accordingly.
E.g. report.py -> my_report.py (in the Scripting window)
and in ui.py change "from report import Report" -> "from my_report import Report"

I have to investigate why Blender does not give priority over its internal scripts. Maybe I just have to prefix all scripts with "Clonk_" to avoid ambiguities.
Reply
Parent - - By Randrian [de] Date 2020-02-10 14:42
It was not a matter of priority, it seems that Blender just does not import the internal script files :-( In my setup in Linux with Blender 2.80 it worked.
I now fixed this issue. You don't have to rename anything, that would unfortunately not solve the problem.
Download the newest version from Github.
Reply
Parent - By manuelclonk Date 2020-02-13 20:55
Thanks again!
Reply
Parent - - By Apfelclonk Date 2020-02-10 12:36 Edited 2020-02-10 12:44
I get "ModuleNotFoundError: No module named 'report'" message.
I tried renaming as mentioned above and adding r'.' and r'./scripts' to sys.path.

Also File is on c:\\ and Blender on d:\\
Reply
Parent - By Randrian [de] Date 2020-02-10 14:07
Hmm strange. Somehow Blender does not find the python files included in the file. Maybe it is a problem of the Blender Version or operation system. I used Blender 2.80 on Linux.
I will give it another try on windows.
Reply
Parent - - By Randrian [de] Date 2020-02-10 14:41
It appears that the current Blender version in Windows (I don't know if it was the Blender version or Windows) does not import files that are shipped with the .blend file.
I now rewrote the imports so that they should work now.
The newest version is in the repository.
Reply
Parent - - By Apfelclonk Date 2020-02-10 18:38
Cool! I managed to export a model. Great feeling. But when adding an armature it fails for me. Even with the default cube after the following steps:
Add Armature
Select Cube, Select Armature -> Set Parent/Armature/With Automatic Weights
Export Mesh

it Shows:

Warning: 'MT_mini_report' doesn't contain '_MT_' with prefix & suffix
Warning: class CLONK_OT_add_image_texture contains a property which should be an annotation!
C:\Users\mimi\Desktop\clonk-blender-exporter-master\clonk-blender-exporter-master\object.blend\ui.py:151
    assign as a type annotation: CLONK_OT_add_image_texture.filepath
register_class(...):
Warning: 'MaterialPanel' doesn't contain '_PT_' with prefix & suffix
register_class(...):
Warning: 'ActionPanel' doesn't contain '_PT_' with prefix & suffix
register_class(...):
Warning: 'ClonkActionPanel' doesn't contain '_PT_' with prefix & suffix
register_class(...):
Warning: 'ExportPanel' doesn't contain '_PT_' with prefix & suffix
register_class(...):
Warning: 'MT_mini_report' doesn't contain '_MT_' with prefix & suffix
target_file C:\Users\mimi\Desktop\clonk-blender-exporter-master\clonk-blender-exporter-master\export\Graphics.mesh.xml
Traceback (most recent call last):
  File "C:\Users\mimi\Desktop\clonk-blender-exporter-master\clonk-blender-exporter-master\object.blend\ui.py", line 243, in execute
  File "<string>", line 56, in dot_mesh
AttributeError: 'Context' object has no attribute 'depsgraph'

location: <unknown location>:-1

location: <unknown location>:-1
Reply
Parent - - By Randrian Date 2020-02-10 18:46
It could be that it fails because you don't have defined an action yet.
But I should fix the exporter so that it can also export a skeleton without an action.
Reply
Parent - - By Apfelclonk Date 2020-02-10 19:21
I appended the clonk into the object.blend and its Actions.txt from the repo, but I still get the error. Although I successfully exported the skeleton using the default cube as mentioned above.
Reply
Parent - - By Randrian Date 2020-02-10 19:24
Well, for the clonk I will make a separate updated .blend file containing all the parts for exporting the Clonk. But it seems that currently when an object has an armature, the mesh cannot be exported (in Blender 2.80 it works, in 2.81 it is broken).
Reply
Parent - - By Apfelclonk Date 2020-02-10 19:29
Is there anything special with the clonk? I "ported" and cleaned up the the file for 2.81 yesterday.
Reply
Parent - - By Randrian Date 2020-02-10 19:33
Well, I already have a "cleaned" version lying around here I prepared fro 2.81. The main difference is basically how the layers are sorted.

And you have to "import" the new exporter in the clonk. To do that you can copy the content of "load_scripts.py" into the target blender file and execute it. It will load the scripts into the .blend file.
Reply
Parent - - By Apfelclonk Date 2020-02-10 19:46
Since the exporter is about to change, I kept any .blend file except object.blend clean and appended the item I want to export to object.blend when needed.

>The main difference is basically how the layers are sorted.


Yeah ok. That's what I mainly was doing too, putting them into named Collections and enabling their visibility.
Reply
Parent - - By Randrian Date 2020-02-10 20:01
I have uploaded you my version of the clonk: http://www.renderclonks.de/files/clonk.zip
It is equipped with the current version of the exporter.
Contrary to the old exporter you can now define an Action.txt file to load. It is not automatically searched. This should prevent blender files do accidentally load the Action.txt.
(In the Clonk.blend I already specified the Action.txt)

Also I don't know if you have seen that in the exporter you can define tools to be liked with each action. This is just a convenience for seeing an attached tool in Blender while designing the animation. Its not yet properly documented.
Reply
Parent - - By Apfelclonk Date 2020-02-10 20:25
Ok, I will use your file, since everything works as is. But (and I am sorry that I have to bring another thing up), when I
append my own Clonk Mesh, delete everything except the object and parent it to the skeleton, (but also with the technique I used before) I get this error:

<bpy_struct, Mesh("Knight_F_Cloth.003")> 1652
tri <bpy_struct, MeshLoopTriangle at 0x0000024A02417F98>
Traceback (most recent call last):
  File "C:\Users\Apfelmann\Desktop\clonk\clonk.blend\ui.py", line 243, in execute
  File "<string>", line 188, in dot_mesh
  File "<string>", line 534, in extract_vertex_color
AttributeError: 'MeshLoopColor' object has no attribute 'color1'

location: <unknown location>:-1

is possibly something wrong with my mesh? I actually changed/created/deleted topology.

PS. Thank you very much for your ongoing efforts.
Reply
Parent - - By Randrian Date 2020-02-10 22:14
Ok, it seems that the problem is that exporting of meshes with vertex colors did not work. I pushed another fix on Github.
But, well, I think slowly we are finding all the bugs that can occur.
Thank you for your beta testing.

@Clonk: I think here we should work together to produce a new "official" version of the Clonk. So keep me update on your changes to the file.
Reply
Parent - - By Apfelclonk Date 2020-02-12 13:55
I changed only the Steampunk model, for I want to use it as a base for a new one.
There are some overlapping vertices in the back that I adjusted. Also I tried to clean up some of quad flow around the lower back region.
Another main difference is, that the ears have been swapped for some reason.

It's hard to make changes on this model, for it's been designed to have a low triangle count. But is that even still a thing?
Does it make sense for me, clean up the flow of quads even more, to have a maintable mesh?
I just ask, because don't think that triangle count is notable anymore and I want to have a mesh, atleast for myself, to properly go on from.
Attachment: clonk_changed.zip (1872k)
Reply
Parent - - By Randrian [de] Date 2020-02-12 14:00
Well, go ahead and make the Clonk into a workable mesh.
And well, to have a low polycount is still not a bad thing. So its advisable to not use more vertices then the mesh needs.

Maybe we even have to import the Clonk into a new clean Blender file to adjust the Layout to the current Blender versions defaults.
Reply
Parent - By Apfelclonk Date 2020-02-13 17:16
Again, I only editted the steampunk for now.
I think the mesh is now cleaner and should still be animated as before.
There is only one loop I didn't fully close, since it would add a lot vertices without gaining any detail.

I hereby license the file clonk_changed.zip under the CC-BY license
Attachment: clonk_changed.zip (1869k)
Reply
Parent - - By Apfelclonk Date 2020-02-13 17:48 Edited 2020-02-13 18:02
I just encountered another error :S

register_class(...):
Warning: 'MT_mini_report' doesn't contain '_MT_' with prefix & suffix
<bpy_struct, Object("MyArmature")>
ActMap track: {'Name': 'Action', 'ExportName': '', 'Start': -1, 'End': -1, 'Group': ''}
Traceback (most recent call last):
  File "C:\Users\Apfelmann\Desktop\rg_clonk\mh.blend\ui.py", line 263, in execute
  File "<string>", line 33, in dot_skeleton
  File "<string>", line 582, in to_xml
AttributeError: 'NoneType' object has no attribute 'action'

The armature is just a single bone, no ActMap. I tried exporting the skeleton.

Could it be that I still use an outdated version?
EDIT: + another one

        Done at 0.15 seconds
      - Writing submeshes
        Done at 0.16 seconds
      - Created .mesh.xml at 0.17 seconds
FileNotFoundError [WinError 2] Das System kann die angegebene Datei nicht finden
C:\Users\Apfelmann\Desktop\rg_clonk\export\Scene.material

This one occurs with the mesh export. The Graphics.mesh is not generated.
Reply
Parent - - By Randrian Date 2020-02-15 11:50
could you perhaps send me the .blend file? As I don't know how to reproduce your error.
Reply
Parent - By Apfelclonk Date 2020-02-18 16:23
I reloaded all scripts, it does export now and looks fine on first glance in the editor.
Thank you
Reply
Parent - - By Randrian Date 2020-02-10 19:21
Ok, it seems that it is really a problem with Blender 2.81. A bit sad that I developed with 2.80 an it was instantly again outdated :-( I hope Blender does not keep changing its API in this pace.
Reply
Parent - By J. J. [py] Date 2020-02-11 00:56
Great job, Randrian!

I'll be testing out the exporter on windows 7 with blender 2.81.
Parent - By Randrian Date 2020-02-10 19:46
I uploaded a fix to github, it should now be possible to export a mesh with a skeleton in blender 2.81.
Reply
Parent - - By manuelclonk Date 2020-02-13 18:01 Edited 2020-02-13 20:28
Whats is the best option to export existing models that were created without Randrians .blend template with the new exporter? Copy all the python scripts to the existing project each time?
Reply
Parent - - By Randrian Date 2020-02-15 11:52 Edited 2020-02-15 12:54
Well, this is a bit the disadvantage of having the exporter included in a .blend file.

I prepared a script "load_scripts.py" that can be added to the .blend file and executed to import the other scripts.
If someone has another or a better idea, I also would be open.

We could also make the user register the Exporter as a Blender Addon. Could make it a bit harder than just having to open a .blend file which is ready made configured.
Maybe we can also use an exporter that allows both.
Reply
Parent - By manuelclonk Date 2020-02-16 17:24
This helps a lot, thanks :)
Reply
Parent - - By roboclonk Date 2022-07-16 23:43
I know the last post is over two years old, but if there is still interest in using the exporter:

Already a few months ago I tried to export the normal Clonk with the latest changes from the repo and had some problems and errors with the scripts on export as well. That is why I made a few changes to the scripts and put them inside a Blender addon, that can actually be used in any blend file directly.

Some more changes and fixes I made:
- Resolved the error with: "Warning: 'MT_mini_report' doesn't contain '_MT_' with prefix & suffix" (There was a naming error on a call to CLONK_MT_mini_report)
- Put the OgreXMLConverter.exe inside the Addon folder so it will be found directly
- Export only deform bones
- Removed some print statements that heavily slowed down the export
- some smaller changes

Other than that I worked on the Clonk blend file itself and merged the two armatures together which makes working with it a little bit easier. I adjusted the addon in that regard as well, so it will only need one armature.

I'd really much like to share the changes I made. So Randrian if you want to look these changes and then maybe allow for a pull request, that'd be appreciated :)
Reply
Parent - - By Clonkonaut Date 2022-07-18 14:16
I have no idea if Randrian still looks at this forum tbh. If you want to push your changes, the resource repository would be a good place for them: https://github.com/openclonk/openclonk-resources
There are more people having access to it, so you don't have to wait for one particular person.

It'd probably be helpful if, in addition, you could write a short post on how to animate your model (no idea if anyone will ever pick this up though).
Reply
Parent - By roboclonk Date 2022-07-18 16:58
Hey, thanks for the reply. Yeah I was hoping that at least some people might read this post. x)

That's a good point to push it to the resource repository. I think there is an old version of the scripts already, that aren't working anymore as far as I know.

Sure I can write a quick note about the model as well as uploading the model there. :)
Reply
Up Topic Development / Developer's Corner / Clonk Blender Exporter (for Blender >= 2.80)

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill