Author Topic: [Tutorial] Using Tendon's export.py [IMAGE HEAVY] [repost]  (Read 1089 times)

I am reposting this because all of the images broke.  And someone is interested in it.

Please note, Blender has had a major update since I created this script.  I am told it will not work in the latest version of blender.



LegoPepper wanted to know how to use export.py from my recent project of porting Kitchen to v21.

About export.py

export.py from kitchen is the second version of the second rewrite of a mass exporter script for exporting collision shapes from blender.
It was made specifically for this project, to get around the limitations presented by Blockland's collision system.
Because of that, it should not be considered a general purpose tool.
I highly recommend modifying it, or taking pieces from it, to serve your own purposes.

Here is a commented picture outlining the various sections of the code and what they do.


You can download export.py here: https://leopard.hosting.pecon.us/download.php?f=cxinn

Using export.py

Requires Blender 2.78 and port's dts exporter.
Create a blender project with some visual shapes, and some collision shapes.

start blender


delete beginning cube


save as


create a new folder in blockland addons


name it


name and save file


copy export.py


into our new folder


there it is


Don't forget to create the shapes folder!

create a folder


name it shapes


let make a cube


there it is


rescale to 4. (S, move mouse, 4, return)


duplicate the shape (shift+D, hold middle mouse+movemouse, 0, return)


there it is


rescaling using the object properties (on the right, click, 2, tab, tab, 2, return)


let's make this easier to see


some more rescaling (click, 5, return)


now to use a modifier, we want to take cube.001 out of cube to leave cube with a hollowed out middle


selecting boolean


selected Difference, and Cube.001


apply the changes


delete the cutting object


there she be.  now we have to do collision


hit tab to enter edit mode.  it looks like some of the faces use more than four points, which blockland can't handle
the easiest way to deal with that is to triangulate the faces



done.  now we want to separate pieces of it off to use for collision.  the pieces we select will be turned into convex shapes.
selected a chunk of it



duplicate the selected piece (shift+d, hold middle mouse+move mouse, 0, return)


see how our selection isn't connected to the rest of the shape?
now we separate by selection (P, click)



i did the same for the other four sides, note the object list on the right
now we need to make these into convex collision shapes



delete edges and faces (A, A, delete, click)


they're all gone


now we fill in some new faces with the convex hull tool (Ctrl+V, click)


der we go


now we center the object on it's geometry so that the object bounds isn't all funky when we export (Ctrl+Shift+Alt+C, click)


I select bounds center for consistency, but median center will work too


i did the same process for the other three shapes



Now we have our shapes.



Name the collision shapes beginning with "col" so that Blockland doesn't freak out every time it tries to load them.
Name the visual shapes however you want.
Do not use dashes or other special characters in your object names.  Blockland uses these names to create datablocks.
You can use periods if you want.  export.py will automatically turn those "." into "DOT" when writing the script files.



Put the collision objects in a group.  You can use Ctrl+G to create a new group.  You can also use this button here:



Name the group "Collision-1".
I believe the name must be exact.




You can add objects to an already existing group by clicking here:


i did this for the other three collision shapes



Put the visual objects into another group.
Name this group "detail32"



Change your view to "Scripting" mode.




Load export.py





Modify the last line to reflect the location of your project.




Save the modified export.py



Save your project in case something get's messed up.



Click "Run Script"



View the changes in your project folder.
our script files


our shape files



Start Blockland, and test out your automatically generated map.
ho boy, my favorite game


.....


ahoi!


new game


custom


select your map
if it's one of my maps, you can only run one at a time



addons submit!


lan mode so we don't disrupt


loading


loading


loading


there it is!


it's in the ground because it was centered on 0,0,0
we could move it up in blender and reexport



but let's at least look at the bottom part


advanced


for


translucence


there it be


ow


it's a little stuck between the invisible ground and the object, but at least it didn't go through




If you run into problems, Blender has a console you can view by going to Window > Toggle System Console, and the source code for export.py is right up there ^.  While writing this tutorial, I forgot to make a shapes folder.  So blender screamed at me there was an error, and left a DETTEMPSHAPE in the object list.  That's just how things go sometimes.
:panda: