Yet Another Blender Egg Exporter (YABEE r13.1)

Return to Pipeline

Postby preusser » Sun Jul 22, 2012 4:14 am

I have offered to write documentation before.
preusser
 
Posts: 516
Joined: Sun Mar 27, 2011 10:07 am

Postby ninth » Mon Jul 23, 2012 2:07 pm

Thanks, but I mean this particular case )
Vodka, bears, balalaika... hmm... sorry for my English =)
ninth
 
Posts: 352
Joined: Fri Jan 23, 2009 9:06 am
Location: Russia

Postby ninth » Wed Jul 25, 2012 11:49 pm

YABEE rev 12.0

* Some bugfixes.
* Performance optimization.
* Option: Apply modifiers.
* Option: Merge meshes which have Armature modifier with the same skeleton.
* Option: Run pview after exporting.
* Collide and ObjectType recognize.

Possible issues:
I used temporary scene copy to make changes before exporting (e.g. modifiers applying),
it's can cause some issues.
- Incorrect material exporting on merged meshes.
- Incomplete scene clearing. Whenever we are deleted our temporary scene,
Blender won't to delete other objects, created with the scene, so
we should do it by hand. I recommend to save the .blend file before
exporting and reload it after.
- Names changing.

http://code.google.com/p/yabee/downloads/list
Vodka, bears, balalaika... hmm... sorry for my English =)
ninth
 
Posts: 352
Joined: Fri Jan 23, 2009 9:06 am
Location: Russia

Postby preusser » Thu Jul 26, 2012 3:41 am

Nice.
I think you should have a StringProperty to allow to specify Panda's bin directory manually. Right now the script assumes the Panda executables are added to the PATH, but some versions of Panda had issues adding the path after install.

And we can also have a configuration file to save changes to be reused on next startup.
I have some example code for parsing and writing a configuration file:
Code: Select all
# Configuration file syntax:
#
#      for each line:
#         "variableName variableValue"
import os

# defaults
animation_only = False
separate_animation_files = True
tbs_generation = False
tex_processing_mode = False
uv_as_texture = False
copy_texture_files = True
merge_actor = True
apply_modifiers = True
pview = False

def setVariable(var, value):
   varDict = {
      'animation_only': animation_only,
      'separate_animation_files': separate_animation_files,
      'tbs_generation': tbs_generation,
      'tex_processing_mode': tex_processing_mode,
      'uv_as_texture': uv_as_texture,
      'copy_texture_files': copy_texture_files,
      'merge_actor': merge_actor,
      'apply_modifiers': apply_modifiers,
      'pview': pview}
      
   varDict[var] = bool(value)

def parseConfigFile(filename='config.txt'):
   filepath = os.path.dirname(__file__)+'/'+filename
   fileobject = open(filepath, 'r')
   lists = fileobject.readlines()
   
   for i in lists:
      setVariable(i[0], i[1])
   
def writeConfigFile(filename='config.txt', settings=[]):
   """
   settings - a list of sublists with each having two members:
   the variable name and value
   """
   filepath = os.path.dirname(__file__)+'/'+filename
   fileobject = open(filepath, 'w')
   
   for i in settings:
      fileobject.write(str(i[0])+' '+str(i[1])+'\n')
   fileobject.close()

def generateConfigFile(filename='config.txt', settings=[['animation_only', False],
      ['separate_animation_files', True],
      ['tbs_generation', False],
      ['tex_processing_mode', False],
      ['uv_as_texture', False],
      ['copy_texture_files', True],
      ['merge_actor', True],
      ['apply_modifiers', True],
      ['pview', False]]):
   """
   In case file is missing (deleted), generate a default one
   """
   writeConfigFile(filename=filename, settings=settings)
   
# create config file if missing
if os.path.isfile(os.path.dirname(__file__)+'/'+'config.txt') == False:
   generateConfigFile()
preusser
 
Posts: 516
Joined: Sun Mar 27, 2011 10:07 am

Postby Nemesis#13 » Thu Jul 26, 2012 11:28 am

Or simply use ConfigParser, which comes with python.
User avatar
Nemesis#13
 
Posts: 1040
Joined: Mon Aug 04, 2008 8:09 pm
Location: Germany

Postby ninth » Thu Jul 26, 2012 2:42 pm

Ok, but why so difficult? Why not just use the *.py file with the python dictionary as a config?
Vodka, bears, balalaika... hmm... sorry for my English =)
ninth
 
Posts: 352
Joined: Fri Jan 23, 2009 9:06 am
Location: Russia

Postby preusser » Fri Jul 27, 2012 2:22 am

So we can reuse it after restarting Blender?
preusser
 
Posts: 516
Joined: Sun Mar 27, 2011 10:07 am

Postby Nemesis#13 » Fri Jul 27, 2012 2:31 pm

I think ninth meant to store a config file in python syntax along the export script.

ConfigParser is full featured, very simple to use, bundled with python, commonly used (thus having good documentation) and the file format is simple to edit by end users and error tolerant.
It supports sections, substitution and reminds a lot of the good old windows ini files. Example:
Code: Select all
[paths]
panda_path = /opt/panda3d
bin_path = %(panda_path)/bin
# comment 1
; another comment
[animation]
animations_separate : true # yes, ":" can be used too!


With a python file you can basically do anything from crashing the program (one commata too much and you get a syntax error) to starting arbitary applications.
User avatar
Nemesis#13
 
Posts: 1040
Joined: Mon Aug 04, 2008 8:09 pm
Location: Germany

Postby adamr » Fri Jul 27, 2012 9:00 pm

Sorry if this is a dumb question, but is it possible to export the whole scene so I can use Blender as a level editor? I can only ever seem to export an individual model.

Thanks,

Adam

Edit: Oh sorry, it is as simple as selecting all of the objects to export. For some reason I thought I'd tried this already but I'm just starting to learn Blender so had probably done something wrong.
adamr
 
Posts: 2
Joined: Fri Jul 13, 2012 11:43 pm

Collision tags?

Postby sam.szuflita » Sun Jul 29, 2012 7:21 pm

Hi I'm new to Panda3D and blender. How can I add collision tags in blender 2.63a? I cannot find any information on this. Any tutorials freely available?
sam.szuflita
 
Posts: 2
Joined: Sun Jul 29, 2012 7:18 pm

Postby ninth » Sun Jul 29, 2012 11:33 pm

adamr, it should be keep in mind that the script does not really able to export the whole scene (sound, light, camera e.t.c.), because the possibility of the YABEE / EGG file in this regard are limited.

sam.szuflita, You should select "Blender game" as render, then select "Game Logic" and add game property. If you enter "Collide" or "ObjectType" as the name of the property, then script process option as Collide/ObjectType respectively, otherwise the option will be exported as the "Tag".

Tag, Collide, ObjectType

Screen
Vodka, bears, balalaika... hmm... sorry for my English =)
ninth
 
Posts: 352
Joined: Fri Jan 23, 2009 9:06 am
Location: Russia

Postby ambyra » Mon Jul 30, 2012 8:04 am

Great job on the exporter! Is there any way to put it permanently in a window? An export button would be nice, instead of always having to go through menus. Or even a shortcut key that goes to the current export menu.

Also, would it be possible to set tags through the 'custom properties' section of the object tab, instead of having to switch to the game render? I feel that this makes more sense anyway, since the property has nothing to do with the BGE.

Image
ambyra
 
Posts: 130
Joined: Sat Sep 20, 2008 5:47 pm

Postby ninth » Mon Jul 30, 2012 11:45 pm

An export button would be nice, instead of always having to go through menus. Or even a shortcut key that goes to the current export menu.

I think it's possible.


Also, would it be possible to set tags through the 'custom properties' section of the object tab, instead of having to switch to the game render?

I was planning to use it when I was writing an export for the Tags, but I couldn't find the way to get this options :(
Vodka, bears, balalaika... hmm... sorry for my English =)
ninth
 
Posts: 352
Joined: Fri Jan 23, 2009 9:06 am
Location: Russia

Postby lethe » Tue Jul 31, 2012 6:42 am

To get the options from a custom property of an object you just treat the object like a dictionary, i.e. context.active_object['Collide']. It basically works exactly like a dictionary for the custom properties - its kinda hard to find in the documentation due to it not being in the list of methods. Note that it does some kind of type detection depending on what the user types in, so you would be well advised to type cast it as needed, e.g. str(context.active_object['Collide']).
lethe
 
Posts: 524
Joined: Wed Jul 18, 2007 3:55 pm
Location: London, England

Postby ninth » Tue Jul 31, 2012 1:39 pm

Ok. Thank You very much. Now I think I can add this ability in the next update.
Vodka, bears, balalaika... hmm... sorry for my English =)
ninth
 
Posts: 352
Joined: Fri Jan 23, 2009 9:06 am
Location: Russia

Postby ambyra » Thu Aug 02, 2012 9:44 am

Thanks!!! You guys are great.
ambyra
 
Posts: 130
Joined: Sat Sep 20, 2008 5:47 pm

Postby redpanda » Thu Aug 02, 2012 10:53 am

OK, I tested today YABEE with one of my level blend files. The blends were originally made in Blender 2.4.

Firstly, good job on making the script faster, ninth. It took about as long as the old Chicken exporter to export my level.

Now for suggestions and issues:

1) I've mentioned this before, just putting with the rest: texture relative paths are ignored. Full path is written. In Blender a relative path starts with "//", scan the file paths for those before export.

2) By comparing the old egg by Chicken and new by YABEE inside Panda3d, I notice the new map has almost no specularity.
It's either the specularity or shininess/hardness that YABEE writes differently.

3) Seems you made an option to start Pview like Chicken. Cool. You should add check buttons for "egg2bam" and "pzip" too.
Note that then the file path you supply to Pview will be different, a bam file or pz file, not the original egg file path.
Same form these two. If both checkbuttons will be True, the bam file should be pzipped, not the original egg.

I haven't tested any animated characters with the script yet.

Good job so far, ninth!
redpanda
 
Posts: 380
Joined: Wed Aug 03, 2011 6:34 am

Postby JamesR » Sun Aug 05, 2012 6:10 am

Why would I get an empty egg file? Blender is giving me this

Image

Ideally I'd convert files from bryce, but then it gets more complicated with the obj files and the textures. There are some nice textures in there to use.
JamesR
 
Posts: 22
Joined: Sat Jul 28, 2012 12:10 pm

Postby ThomasEgi » Tue Aug 07, 2012 4:37 am

my guess would be that your blender+yabee version don't match up.

a suggestion for yabee here: check the blender version and warn the user if yabee and blender version mismatch.
User avatar
ThomasEgi
 
Posts: 2147
Joined: Fri Jul 28, 2006 10:43 am
Location: Germany,Koblenz

Postby JamesR » Tue Aug 07, 2012 4:44 pm

Well, I used version 12. I thought that was right. Maybe I need to check.

In some regard we need installation instructions to install the correct software in the right place for Panda, python and blender.

Using Panda isn't that inspiring when you can't get models and textures across. Presumably with Yabee you can bake or use UV maps. I quite like a load of textures in Bryce, but I guess that's a complication.

I can use obj2egg to get basic models into Panda, although its uninspiring as animations are quite helpful.

Hmm. But thanks for the pointer.
JamesR
 
Posts: 22
Joined: Sat Jul 28, 2012 12:10 pm

Postby preusser » Wed Aug 08, 2012 3:17 am

You are likely using YABEE version below 12 on Blender version 2.63.
Maybe you didn't overwrite the old script files properly?

In 2.63 BMesh was added which adds ngons support to Blender, but breaks some old code.
Mesh.faces is now Mesh.polygons. Or if you don't want to modify your script too much there's Mesh.tessfaces which is there just for backward campatibility. With the latter you only need slight code modifications to make your old scripts work in 2.63.
Code: Select all
mesh.update(calc_tessface = True) # so Blender will generate a triangulated copy you can access instead
mesh.faces -> mesh.tessfaces
mesh.vertex_colors -> mesh.tessface_vertex_colors
mesh.uv_textures -> mesh.tessface_uv_textures


I had a Blender script I needed to work on both 2.63 and older versions. Having two separate scripts was too much work as each time I updated one I had to modify the other one too, so I chose to check the version of Blender and access the above data types differently depending on the Blender version.
Maybe YABEE should do that too, it complicates the code a bit but makes it campatible with older Blender versions.

Code: Select all
if bpy.app.version[0] == 2 and bpy.app.version[1] >= 63: # for Blender 2.63 API
    mesh.update(calc_tessface = True)
    mesh.tessfaces
    mesh.tessface_vertex_colors
    mesh.tessface_uv_textures

else:
    mesh.faces
    mesh.vertex_colors
    mesh.uv_textures
preusser
 
Posts: 516
Joined: Sun Mar 27, 2011 10:07 am

Postby JamesR » Wed Aug 08, 2012 2:08 pm

Thanks. I've got a basic white model of it now. No material colour, but I don't know whether it works like obj2egg and it can produce the basic material colour or not.

Btw ashamebly it was the revision 11 not 12. I had d/l 12 but obviously hadn't done things properly. A simple copy and paste of the ioscene folder fixed it up nicely.
JamesR
 
Posts: 22
Joined: Sat Jul 28, 2012 12:10 pm

Postby preusser » Sat Aug 11, 2012 7:57 am

I can't get animations out.
Do we need to do something more than create an object, armature, parent the object to armature (with auto weights), move some bones, press I->LocRotScale, then move to another frame and do the same, before export?
preusser
 
Posts: 516
Joined: Sun Mar 27, 2011 10:07 am

Postby ambyra » Sat Aug 11, 2012 9:12 am

Make sure you click + and add the animations in the export panel. Also, you can apply the armature as a modifier so you know its there.
ambyra
 
Posts: 130
Joined: Sat Sep 20, 2008 5:47 pm

Postby RylandAlmanza » Sat Aug 11, 2012 2:05 pm

Hi, I'm having a bit of trouble getting this to work. I load up and run __init__.py, and then try to export it. When I do, I get this:
Code: Select all
Traceback (most recent call last):
  File "/__init__.py", line 331, in execute
ValueError: Attempted relative import in non-package

location:<unknown location>:-1

This is the line from __init__.py line 331:
Code: Select all
from .yabee_libs import egg_writer

I'm assuming blender is looking in a certain directory for modules, but I'm not sure where that is. I tried putting the yabee_libs folder in ~/.blender/scripts and in ~/.blender/scripts/modules. Anyone know what I did wrong? Thanks!
RylandAlmanza
 
Posts: 1
Joined: Sat Aug 11, 2012 1:59 pm

Postby Rabbit » Sun Aug 12, 2012 5:40 am

I've been fooling around with trying to get this to work for about 6 hours now and it just isn't happening. No matter what paths I use, or where I put my textures, this is always the output when trying to load the .egg model:

Code: Select all
Error in ../mypath/mymodel.egg at ...
<Texture> My Model Texture 512 {
parse error


I'm out of ideas; hopefully someone else will know what's up. <strike that>

Ok, I don't know why I didn't think of this before but the problem lies with spaces in any names used by Blender. I had to rename the material, uv map and texture to remove any spaces in their names. Panda was then able to correctly load the models.
Rabbit
 
Posts: 2
Joined: Sun Aug 12, 2012 5:34 am

Postby ninth » Sun Aug 12, 2012 11:26 pm

RylandAlmanza, You should place io_scene_egg in the scripts/addons dir, then run Blender and activate YABEE in the Blender user preferences menu (Ctrl + Alt + U) -> Addons -> Import-Export -> Import-Export: Panda3D EGG format.

Rabbit, it's strange, I thought I made ​​the processing of names with spaces. I'll check it.
Vodka, bears, balalaika... hmm... sorry for my English =)
ninth
 
Posts: 352
Joined: Fri Jan 23, 2009 9:06 am
Location: Russia

Postby preusser » Thu Aug 16, 2012 7:06 am

1. Addon fails to copy texture images if they are packed in the blend file.

2. I see these in the egg file
Code: Select all
<Scalar> alpha-file { "./tex\mytexture.png" }

Is that right? I don't use separate files for alpha textures.
Also it should be "./tex / mytexture.png".

3. If copy textures is disabled, relative paths are ignored.

4. can only see textures in Pview if I click on the "UV as textures". But my model has a material with texture on it.

egg: http://www.pasteall.org/34514
blend to export to egg: http://www.pasteall.org/blend/15932

5. Also I can't get an animated egg to export. I mean i can if I use the UI, but if I generate and assign Armatures by code then no Dart group is exported.
Code: Select all
object.parent = armObject
object.parent_type = 'ARMATURE'

I couldn't reproduce the problem with the UI, but since the Armature acts just fine in Blender, maybe the exporter has the problem.
I'll try to make an example blend.
preusser
 
Posts: 516
Joined: Sun Mar 27, 2011 10:07 am

How awesome

Postby supus71 » Mon Aug 20, 2012 1:49 pm

This is absolute a great add. I think adding the tagging to the object custom properties will be nice too. Smooth the work flow. This really* adds a lot of functionality w/o having to futz around by hand with egg files. Thank you thank you thank you!
If it wasn't for my horse, I wouldn't have gone to college.
User avatar
supus71
 
Posts: 22
Joined: Tue Nov 08, 2011 7:35 pm

Postby robsullivan » Wed Aug 22, 2012 7:38 pm

ahh thank you this is so cool
User avatar
robsullivan
 
Posts: 24
Joined: Mon May 21, 2012 6:06 pm
Location: Dublin,Ireland

PreviousNext

Return to Pipeline

Who is online

Users browsing this forum: No registered users and 0 guests