Lesson 7: Exporting to PlaneShift Time has come to test the model in PlaneShift. Start Blender and open the banana model. Let's just export it and see how it looks. If you've installed Blender2Crystal properly in the first lesson, you'll have a "CrystalSpace" option in File-Export menu. Click it and wait for the exporter window to open. Select the library option, as we're creating an item and not a level. Choose suitable export directory and push Export. I get a p
ython script error and the exporter disappears.
*edit*
If you do not get an error and the export runs through fine, you should congratulate yourself; you're either lucky or know what you're doing. You should still change the object type to genmesh from the overlay gui, but you don't have to mess with the renderloop. Then export the object again, as library, and jump to 7.1.
If we take a look at the console program, we see a long list of traceback. The last item is the most interesting:
"...line 273, in get_material_shaders steps = b2cs.prop.global_keys["renderloops"][rloop].getSteps() KeyError: 'standard'"
I'm no coder, but it seems to point that something is amiss in the renderloop 'standard'. We need to change that. First open the overlay interface of the blender2crystal. You can do this from View-Space Handler Scripts-Event:blender2crystal.py. Finally click on your 3D view to open the exporter on that window. A large grey box appears to fill your view. That's the export, jammed due to the error. Double click on it to close. Now you should see the normal overlay gui. Change the object type to genmesh:
Onward to change the renderloop then. Select the square painting from the top row, there we can change sector settings. We also see a renderloop option there. It's currently "not set". Click the value to change it and choose "ambient" from the popup menu. (This doesn't affect anything really, since we're only exporting a single object library.)
Continue by clicking the gear icon on the top row. This brings up the exporter main screen. Click the "create library" button and the export should run through.
7.1 Tweaking by handIf you check the export dir, there is a world.zip packed file. Open it and you'll see it has tree files in it:
- banana01a.tga (texture)
- library (so called worldfile)
- genbanana (banana model file)
Ok, let's get the model in PS then. Open your PS install directory. Go into /art/things dir and copy all the export files there. First let's get rid of the worldfile, since libraries don't need them. Open the "library" on a text editor. It's not very long. Mine is like this:
<?xml version='1.0' encoding='UTF-8'?>
<library>
<plugins>
<plugin name='genmeshfact'>crystalspace.mesh.loader.factory.genmesh</plugin>
</plugins>
<shaders/>
<textures>
<texture name='banana01a.tga'>
<file>textures/banana01a.tga</file>
</texture>
</textures>
<materials>
<material name='ma_bananabanana01a.tga'>
<texture>banana01a.tga</texture>
</material>
</materials>
<sounds/>
<library>factories/genbanana</library>
</library>
There are two things of interest there:
<plugin name='genmeshfact'>crystalspace.mesh.loader.factory.genmesh</plugin>
Which links a plugin named 'genmeshfact' to a certain crystalspace mesh loader. And
<material name='ma_bananabanana01a.tga'>
<texture>banana01a.tga</texture>
</material>
Which links a material named "ma_bananabanana01a.tga" to a texture named "banana01a.tga".
Next open "genbanana" in text editor. It's a bit longer file, but most of it is coordinate data, which we don't have to go into. The first few lines are of interest here.
<library>
<meshfact name='genbanana'>
<plugin>genmeshfact</plugin>
<zuse/>
<params>
<material>ma_bananabanana01a.tga</material>
The first tag "library" defines that this is a library. The meshfact-tag defines name for this object factory. Next we have a plugin tag that specifies what type of mesh this is. Next is zuse-tag which is the Z-Buffer render mode for this object. Then there is params tag, and inside, material tag, which defines the texture. Let's replace the plugin and texture with the ones found in the earlier file:
Replace
<plugin>genmeshfact</plugin>
with
<plugin>crystalspace.mesh.loader.factory.genmesh</plugin>
and replace
<material>ma_bananabanana01a.tga</material>
with
<material>banana01a.tga</material>
Then let's delete the line
<zuse/>
alltogether and just let CS use the default.
Last but not least, change the meshfact name
<meshfact name='genbanana'>
to
<meshfact name='banana'>
The model file is starting to look good. Might be a good time to save your changes. You can also delete the file named "library", we don't need it anymore. Next step is to replace an existing PS item model with our custom one. I have selected shortsword as the item to replace, because I know I my character has that item in his inventory. If I open the shortsword01a.spr from PS/art/things/weapons.zip in a text editor, it looks like this:
<meshfact name="weapons#shortsword01a">
<plugin>crystalspace.mesh.loader.factory.sprite.3d</plugin>
<params>
<material>/planeshift/weapons/shortsword01a.dds</material>
<frame name="stand0">
...
We see certain differences with our "genbanana" file. Most importantly:
<meshfact name="weapons#shortsword01a">
and
<material>/planeshift/weapons/shortsword01a.dds</material>
Let's add those changes to the genbanana. The banana file should now look like this:
<library>
<meshfact name="weapons#shortsword01a">
<plugin>crystalspace.mesh.loader.factory.genmesh</plugin>
<params>
<material>/planeshift/weapons/banana01a.tga</material>
...
Note that I left the material to point to the banana texture. Finally save the genbanana file and close the text editor. Rename "genbanana" to "shortsword01a.spr".
Take a backup copy of the original PS shortsword01a.spr! Then copy the both custom files, banana01a.tga and shortsword01a.spr, into PS/art/things/weapons.zip. Run Planeshift normally and find yourself a shotsword.
Well it is exported, although the fruit is over 9,5 meters long and poorly aligned. More about fine tuning the results later. This is the end of the exporting lesson.
End of Lesson 7: Exporting to PlaneShift