Crystal Space
Welcome, Guest. Please login or register.
April 20, 2014, 01:57:18 am

Login with username, password and session length
Search:     Advanced search
8990 Posts in 2037 Topics by 7597 Members
Latest Member: Drukareczka1989
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Game Content Creation
| | |-+  Patch for blender2cal3d_2.py to export submeshes as separatemeshes.
« previous next »
Pages: [1] Print
Author Topic: Patch for blender2cal3d_2.py to export submeshes as separatemeshes.  (Read 2371 times)
zaz
Newbie
*
Posts: 16


View Profile
« on: August 01, 2005, 06:22:05 pm »

The file below can be applied via patch to fix a bug in blender2cal3d_2.py and add an enhancement or for those unable to apply patches, I've also included my version of blender2cal3d_2.py.  I've supplied this same patch to the cal3d project at SF also, but figured I'd make it available here too so it might be more visible to those who need it.

The bug fixed has to do with exporting mutiple times per run of this script.  Since this script has a GUI, its possible to invoke it, then export from it several times before finally terminating it.  However, the CVS and released versions of this script don't properly clear the BONES dictionary making exports beyond the first export empty skeletons.  This was easily fixed by calling BONES.clear() in the export function.

The enhancement added was a new option for exporting, the SSM toggle button.  The blender2cal3d_2.py script makes a separate submesh for each texture used in the blender model.  Normally the exporter exports one cal3d mesh per blender mesh.  If the blender mesh includes multiple textures, all the submeshes are exported into that one cal3d mesh.

With the new SSM toggle button enabled, the cal3d submeshes are exported as their own meshes, i.e. into their own .[xc]mf file, allowing one to apply separate materials per submesh easily in a CS world or .cal3d Sprcal3d file. Maybe there's another way to do this in CS, however answers didn't seem forth coming and this solution was easily attainable.

For example, lets say we have a model called Freddy in blender.  This model has 4 textures applied to it.  Exporting with the original script or in the new script with the SSM toggle button disabled will export one cal3d mesh to a file called Freddy.[xc]mf that contains 4 submeshes.  It is not possible as far as I know at the time to apply the 4 separate textures to Freddy in CS.

Exporting with the new script and enabling the SSM toggle button, will cause 4 meshes to get exported: Freddy1.[xc]mf, Freddy2.[xc]mf, Freddy3.[xc]mf and Freddy4.[xc]mf.  Each of these meshes will contain one submesh, the submeshes originally exported in the Freddy.[xc]mf file.  You can then easily apply separate textures/meaterials to these meshes in your CS world or Sprcal3d .cal3d file.

I've attached two files.  The first, blender2cal3d_2.diff-u.txt, is a patch file.  You can apply the patch by cd'ing to the directory containing your current blender2cal3d_2.py file and typing:
Code:
patch < /path/to/the/file/blender2cal3d_2.diff-u.txt

The second file, blender2cal3d_2.py.txt, is my current working version.  If you've made no changes to your blender2cal3d_2.py file, applying the patch to your copy or downloading this should give you the same result so there is no need to download more than one of these files.  Because of restrictions in uploaded file types, you will need to rename this file to blender2cal3d_2.py, i.e. drop the .txt extension when you download or rename after.

Whichever file you get, you should then make sure the final result is avilable to blender so you can find the script in your blender menus.  Under most unix variants, this means putting the file into ~/.blender/scripts .  Under windows ?  I don't know, however there are docs describing this as well as other solutions.  In any event, once you've got the possibly updated script in place, you should restart blender to allow it to find and/or reload the new script.

If you've successfully installed the script, you should be able to find it via: File->Export->Cal3D Exporter 2 V1.0

* blender2cal3d_2.diff-u.txt (5.73 KB - downloaded 250 times.)
* blender2cal3d_2.py.txt (59.87 KB - downloaded 269 times.)
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 4.266 seconds with 14 queries.