Chicken, an Egg exporter for Blender 2.49 and lower

I just wanted to say I got normal maps exporting fine.
I found out that blender gives actually -1 for mtex.mtNor, so I had to replace all instances of mtex.mtNor with abs(mtex.mtNor) in the script.
Also, I found that internally chicken didn’t find an associated UV with my normal map (and I wouldn’t know how to assign that) so I just replaced the “list = texgenTextures” with “list = textures” and the first instance of “uv = None” with “uv = uvnames[0]” (be careful with the latter, there are multiple instances, only replace the first.)

Also, don’t forget to run egg-trans -tbnall after exporting. :slight_smile: HTH anyone.

pro-soft: You seem to be suffering a different set of problems, certainly, I can export normal maps from Blender fine without touching the script. What I’m talking about is that Blender uses a different tangent/bi-normal calculation algorithm to Panda, and whilst this doesn’t show normally it causes issues at boundaries far worse than you expect from typical texture seams, often resulting in some quite nasty artefacts. The simple solution is to skip using egg-trans -tbnall altogether and export the egg file with blenders tangent/bi-normals, as whilst they calculate them differently they interpolate across polygons using the same method, so this would resolve the problem completely. As a bonus it would be easier for newbies - can just make this behaviour the default.

What he is saying is to READ your post at least once before you post it. Check it for spelling,check it for understanding. Just becasue YOU understand what you wrote does not mean everyone else here will.

That sounds like a memory problem or maybe a problem with your systems video adaptor not working will with blender. I also could be you have the wrong version of blender or python.

Andreas after reading several of your post here. I suggest you read the panda 3d manual several times over. Just to get a grounding. And if you are interested in blender the blender noob to pro wiki.

Hi all,
I want to export an animation from Blender to the EGG format, but this doesn’t work for me. I can only export static meshes when I select the character’s mesh. When I select the armature the exporter warns me that that there is no mesh selected.
After reading the Chicken documentation I guess there is something wrong with the scene’s outline structure, but I am not sure what to do.
Maybe someone can try to export my animaton using the .blend file?
That would be great!

BTW: I am using Blender 2.48 and Chicken v1.0

EDIT: Sorry, I found the solution in this thread. By applying a subsurf modifier beneath the armature modifier it works!

glad you it worked out. just as small notice. its recommended to use the latest release (i think its r44), instead of v1.0

Thanks Thomas, I will use Chicken r44 from now on.

I’ve got another question, about motion extraction. In Blender I created
an animation with a SyntheticRootBone following the model’s location. I exported this with Chicken.

In the Chicken manual it says:

However I can’t find this test model and the script in the Chicken package, so I don’t know how to use motion extraction to move the charachter properly.
Anyone?

the test model is not included in the exporter. dunno where i found it last time. i suggest to check the chicken website and the sourceforge page of chicken.

I searched for the model and the motion extraction script on these websites, but still couldn’t find it. Strange…

Joost: IIRC the model mesh comes in a blend file that is inside the zip file that you download from the site.

I must be blind, because I can’t find it in either of the zip files (v1.0 and r44) and not on the SourceForge website.
Ah well, maybe I should figure it out myself to learn more about Panda :slight_smile:

Hi, the last model what i could find its this one downloads.sourceforge.net/chicke … 42.zip.zip

i tested ir and works fine…

i have a problem with normals, when i tried to export my character it look weird in the pview but if you flip the normals it works fine…it happened too with a map…what wrong whit normal?

What about the lightmaps? somebody knows how to export it with chicken?

about lightmaps. jup i know. lemme do a small screencast. it’s quite easy actually :slight_smile:
just wait a bit until i finish it.

[EDIT] here it is http://home.arcor.de/positiveelectron/files/blender-lightmap.ogm unfortunately no sound or otherwise documented. but it should give you an idea about how it works.

as a short summary:

  1. create , uvmap and texture your models.
  2. use blenders uv-lightmapping tool to create a new lightmap+UVlayer
  3. render/texturepaint that lightmap as you like
  4. save the texturemap as image (using the uv-editor-menu)
  5. set up the materials to use 2 textures:
    -base texture for color, set the mapping input to UV and enter the name of the uv-set
    -lightmap texture, set the mapping input to UV and enter the lightmap-uv-set’s name. select “multiply” as mode in the map-to tab.
  6. export your model :slight_smile:

tipp: if you are using lots of small triangles/quads you might get black borders on your faces (in the lightmap). this is caused by your hardwares texturefiltering. there are 2 ways to fix it. either increase the spacing in the lightmap AND the border margin of the render2texture settings. or you manually unwrap the parts in question so you have less “open” borders to start with. the 3rd way is more a work-around:which would be to manually extend the colors in the lightmap with an image-editor.

[edit2] i found blenders “shadow” baking tool is producing quite low-quality results compared to its “full render” option. http://home.arcor.de/positiveelectron/files/lightmap-comparison.png
if you want to bake lightmaps with the “full render” quality you have to:

  1. delete the material from your objects.
  2. texturebake with “full render”
  3. re-asign the material back to your object.
    (of course save the new lightmap)

it’s also possible to realtime texture-paint your lightmap using glsl materials. after baking the lights switch to blenders glsl material mode. and disable the glsl lights in the glsl preferences. be aware that texture-paint mode can will paint on the texture itself. so it can happen that if you paint a border , that another border somewhere is painted,too. so be careful.

Well, I previously mentioned that I was hoping to find time to add some new features to the exporter over Christmas, and I have. The new features are:

  1. The use of tangent maps now works by using Blenders tangents/bi-normals directly. The GUI allows you to disable this feature but I’ve enabled it by default as you would be mad not to use it. I’ve put together an image to demonstrate the improvement of using this exporter - normal_comp.jpg. The left image is a shot of the normal mapping inside blender, the middle image is using the panda 3d generated tangents/bi-normals whilst the right image is with blenders.

  2. I’ve integrated mweb’s single file patch, with an interface so its use is optional. Made it default to off as most people are used to multiple files and I am not in a position to give it a proper test right now. Latter on it should probably become the default as its a preferable mode for newbies, but if anyone here could test it and confirm it works that would be a help.

  3. Animation details are now saved into an object property when you hit the export button and reloaded when you next run the script. This means that you don’t have to re-enter the time ranges, fps and names for your animations each time you reopen the file.

  4. Fixed an issue with the package creation script so it works under windows.

You may get the packaged script for blender here.
My copy of the repository is here. There are a few extra test blender files plus the fix to the package creation script in there.

If anyone finds any bugs with the changes I’ve made please post them.

psiberpunk: Feel free to update the sourceforge repository with my version. Alternatively I made a git repository from the svn repository, and hence have all the changes as a sequence of commits rather than just one, or can provide diff files etc. Whatever really.

Dudes thanks, Amazing lightmap tutorial, thanks, very usefull…

The “fixed” script gives me a console error…

To export “correctly” a model i must flip the normals, why?

you dont need to flip them if the are already correct. but there are many chases where the point inside and not outside. a common error people encounter.

Master Tanker, you didn’t happen to look at the console and find out what the error was by any chance? (Under windows there should be a black console window also called Blender, under Linux you might have to run Blender from the command line to see 'em.) Also, what version of Blender are you using and what operating system? I want to know what that error is so I can fix it for obvious reasons, but I’m going to need more info to do so!

Great work, lethe!

I have some feature requests :slight_smile:

  1. In my humble opinion, the Chicken should be re-written:
    a) with more comments (this will help developing it and adding more features later),
    b) in more readable form (right now it’s very hard to understand how it works),
    c) with more accurate indentation (currently it is total mess: tabs and spaces are mixed; new code additions use 8 spaces as one indentation level, while 4 is standard, I think).

  2. Chicken exports polygons that use the same material as group. Today it names them “like this : [objname][index] where [objname] is the name of the object in question, and [index] is… well, the index.” (quote from manual). I believe it should better name them as [objname]_[materialname] or something similar. Also, it is good to have this group creation feature switchable on and off.

  3. Right now the exporter (or Blender API?) treats coordinates as floats. Here we encounter float precision problem: for example, 1.0 can become 0.999999940395 and so on (read generated egg of the default Blender cube as example). I think this can lead to errors later. It looks like it happens in Blender when applying transform on a mesh, in order to retrieve vertices’ world coordinates. Therefore, it would be awesome to retrieve vertices’ local coordinates from Blender, and apply the transform matrix in the exporter (no idea how to do it, though) to eliminate this problem.

I take it it works for you then? Its good to have confirmation it works for people other than me, seeing as my only feedback so far is master tanker saying it doesn’t work! (My testing is obviously limited however, so I can believe there are bugs there. But I need someone to tell me where they are first, preferably by sending me problematic .blend files…)

I’ld agree that the code is mostly a mess and needs some serious work, an inevitable consequence of its organic development I expect. However, seeing as Blender is changing its gui model with 2.5 doing that right now wouldn’t make much sense, at least in the GUI bits which are the most problematic. (The actual object export code isn’t so bad, if under-commented.) It does take quite a lot of reading to work out what is going on though - its certainly not new feature friendly.

As for your second suggestion, that causes problems if you have two groups with the same material name, though I can see its potential value, esp. for exporting invisible geometry for AI use etc. Keeping the number and appending the material name on the end would probably be best, as that would make it easy to search for geometry chunks by material name whilst keeping name uniqueness and the ability to search by position. You can’t switch making an object for each material off however - the egg file format requires that each object have only one material.

I’m afraid that your 3rd suggestion is unsolvable - that is an inevitable consequence of using floating point maths. Reality is that the slight error should not be visible to humans anyway, so its not really a problem. (Well, it can become an issue if tiling stuff as cracks can form momentarily, but then you should probably be stitching your tiles together for speed anyway, or if they are simple generating them in code.) You have to remember that once the egg file is loaded it goes through almost identical floating point transforms before it hits the screen anyway, so even if you did fix that problem for loading it would still re-emerge in panda.

The other thing it needs is a far deeper manual - some explicit tutorials on things like setting up normal mapping, making collision geometry, the stride bone and example code of how to use some of these features within panda would be more valuable I think than more new features.

However, right now the above is mostly academic - I have effectively forked the exporter and whilst I can keep my fork going would very much prefer to fold it back into the actual sourceforge repository. That is entirely dependent on psiberpunk really. And even if he gives me sourceforge write access my time is limited as well, though I should be able to get some of that done, but rate of progress would be slow.

I have just tried to render cubes with two materials: one cube with materials grouped separately, another with materials in the same group. Both of them were rendered correctly.

The first cube is the one exported by Chicken. I loaded it and did render.ls():

<CoordinateSystem> { Z-up }

<Comment> { "Egg laid by Chicken for Blender vR44_nf" }

<Material> Green {
  <Scalar> diffr {0.0}
  <Scalar> diffg {1.0}
  <Scalar> diffb {0.0}
  <Scalar> specr {0.25}
  <Scalar> specg {0.25}
  <Scalar> specb {0.25}
  <Scalar> shininess {12.5}
}
<Material> Red {
  <Scalar> diffr {1.0}
  <Scalar> diffg {0.0}
  <Scalar> diffb {0.0}
  <Scalar> specr {0.25}
  <Scalar> specg {0.25}
  <Scalar> specb {0.25}
  <Scalar> shininess {12.5}
}
<Group> Cube {
  <VertexPool> Cube {
    <Vertex> 0 {
      1.0 0.999999940395 -1.0
    }
    <Vertex> 1 {
      1.0 -1.0 -1.0
    }
    <Vertex> 2 {
      -1.00000011921 -0.999999821186 -1.0
    }
    <Vertex> 3 {
      -0.999999642372 1.00000035763 -1.0
    }
    <Vertex> 4 {
      1.00000047684 0.999999463558 1.0
    }
    <Vertex> 5 {
      -0.999999940395 1.0 1.0
    }
    <Vertex> 6 {
      -1.00000035763 -0.999999642372 1.0
    }
    <Vertex> 7 {
      0.999999344349 -1.00000059605 1.0
    }
    <Vertex> 8 {
      1.0 0.999999940395 -1.0
    }
    <Vertex> 9 {
      1.00000047684 0.999999463558 1.0
    }
    <Vertex> 10 {
      0.999999344349 -1.00000059605 1.0
    }
    <Vertex> 11 {
      1.0 -1.0 -1.0
    }
    <Vertex> 12 {
      1.0 -1.0 -1.0
    }
    <Vertex> 13 {
      0.999999344349 -1.00000059605 1.0
    }
    <Vertex> 14 {
      -1.00000035763 -0.999999642372 1.0
    }
    <Vertex> 15 {
      -1.00000011921 -0.999999821186 -1.0
    }
    <Vertex> 16 {
      -1.00000011921 -0.999999821186 -1.0
    }
    <Vertex> 17 {
      -1.00000035763 -0.999999642372 1.0
    }
    <Vertex> 18 {
      -0.999999940395 1.0 1.0
    }
    <Vertex> 19 {
      -0.999999642372 1.00000035763 -1.0
    }
    <Vertex> 20 {
      1.00000047684 0.999999463558 1.0
    }
    <Vertex> 21 {
      1.0 0.999999940395 -1.0
    }
    <Vertex> 22 {
      -0.999999642372 1.00000035763 -1.0
    }
    <Vertex> 23 {
      -0.999999940395 1.0 1.0
    }
  }
  <Group> Cube1 {
    <Polygon> {
      <MRef> { Red }
      <Normal> { 0.000000 -0.000000 1.000000 }
      <VertexRef> { 4 5 6 7 <Ref> { Cube } }
    }
    <Polygon> {
      <MRef> { Red }
      <Normal> { -0.000000 -1.000000 -0.000000 }
      <VertexRef> { 12 13 14 15 <Ref> { Cube } }
    }
    <Polygon> {
      <MRef> { Red }
      <Normal> { -1.000000 0.000000 -0.000000 }
      <VertexRef> { 16 17 18 19 <Ref> { Cube } }
    }
  }
  <Group> Cube2 {
    <Polygon> {
      <MRef> { Green }
      <Normal> { 0.000000 0.000000 -1.000000 }
      <VertexRef> { 0 1 2 3 <Ref> { Cube } }
    }
    <Polygon> {
      <MRef> { Green }
      <Normal> { 1.000000 -0.000000 0.000000 }
      <VertexRef> { 8 9 10 11 <Ref> { Cube } }
    }
    <Polygon> {
      <MRef> { Green }
      <Normal> { 0.000000 1.000000 0.000000 }
      <VertexRef> { 20 21 22 23 <Ref> { Cube } }
    }
  }
}

render.ls() showed following:

  ModelRoot cube1.egg S:(CullFaceAttrib ShaderAttrib TransparencyAttrib)
    PandaNode Cube
      GeomNode Cube1 (1 geoms: MaterialAttrib)
      GeomNode Cube2 (1 geoms: MaterialAttrib)

The second is edited cube where materials are not separated to different groups:

<CoordinateSystem> { Z-up }

<Comment> { "Egg laid by Chicken for Blender vR44_nf" }
<Comment> { "Edited so that both materials go in the same group" }

<Material> Green {
  <Scalar> diffr {0.0}
  <Scalar> diffg {1.0}
  <Scalar> diffb {0.0}
  <Scalar> specr {0.25}
  <Scalar> specg {0.25}
  <Scalar> specb {0.25}
  <Scalar> shininess {12.5}
}
<Material> Red {
  <Scalar> diffr {1.0}
  <Scalar> diffg {0.0}
  <Scalar> diffb {0.0}
  <Scalar> specr {0.25}
  <Scalar> specg {0.25}
  <Scalar> specb {0.25}
  <Scalar> shininess {12.5}
}
<Group> Cube {

  <VertexPool> Cube {
    <Vertex> 0 {
      1.0 0.999999940395 -1.0
    }
    <Vertex> 1 {
      1.0 -1.0 -1.0
    }
    <Vertex> 2 {
      -1.00000011921 -0.999999821186 -1.0
    }
    <Vertex> 3 {
      -0.999999642372 1.00000035763 -1.0
    }
    <Vertex> 4 {
      1.00000047684 0.999999463558 1.0
    }
    <Vertex> 5 {
      -0.999999940395 1.0 1.0
    }
    <Vertex> 6 {
      -1.00000035763 -0.999999642372 1.0
    }
    <Vertex> 7 {
      0.999999344349 -1.00000059605 1.0
    }
    <Vertex> 8 {
      1.0 0.999999940395 -1.0
    }
    <Vertex> 9 {
      1.00000047684 0.999999463558 1.0
    }
    <Vertex> 10 {
      0.999999344349 -1.00000059605 1.0
    }
    <Vertex> 11 {
      1.0 -1.0 -1.0
    }
    <Vertex> 12 {
      1.0 -1.0 -1.0
    }
    <Vertex> 13 {
      0.999999344349 -1.00000059605 1.0
    }
    <Vertex> 14 {
      -1.00000035763 -0.999999642372 1.0
    }
    <Vertex> 15 {
      -1.00000011921 -0.999999821186 -1.0
    }
    <Vertex> 16 {
      -1.00000011921 -0.999999821186 -1.0
    }
    <Vertex> 17 {
      -1.00000035763 -0.999999642372 1.0
    }
    <Vertex> 18 {
      -0.999999940395 1.0 1.0
    }
    <Vertex> 19 {
      -0.999999642372 1.00000035763 -1.0
    }
    <Vertex> 20 {
      1.00000047684 0.999999463558 1.0
    }
    <Vertex> 21 {
      1.0 0.999999940395 -1.0
    }
    <Vertex> 22 {
      -0.999999642372 1.00000035763 -1.0
    }
    <Vertex> 23 {
      -0.999999940395 1.0 1.0
    }
  }
  <Polygon> {
    <MRef> { Red }
    <Normal> { 0.000000 -0.000000 1.000000 }
    <VertexRef> { 4 5 6 7 <Ref> { Cube } }
  }
  <Polygon> {
    <MRef> { Red }
    <Normal> { -0.000000 -1.000000 -0.000000 }
    <VertexRef> { 12 13 14 15 <Ref> { Cube } }
  }
  <Polygon> {
    <MRef> { Red }
    <Normal> { -1.000000 0.000000 -0.000000 }
    <VertexRef> { 16 17 18 19 <Ref> { Cube } }
  }
  <Polygon> {
    <MRef> { Green }
    <Normal> { 0.000000 0.000000 -1.000000 }
    <VertexRef> { 0 1 2 3 <Ref> { Cube } }
  }
  <Polygon> {
    <MRef> { Green }
    <Normal> { 1.000000 -0.000000 0.000000 }
    <VertexRef> { 8 9 10 11 <Ref> { Cube } }
  }
  <Polygon> {
    <MRef> { Green }
    <Normal> { 0.000000 1.000000 0.000000 }
    <VertexRef> { 20 21 22 23 <Ref> { Cube } }
  }
}

render.ls() showed following:

  ModelRoot cube2.egg S:(CullFaceAttrib ShaderAttrib TransparencyAttrib)
    GeomNode Cube (2 geoms: MaterialAttrib)

In other words, separating materials is not required, separate geoms are created on the fly. The only difference is whether separate GeomNodes for each material are created or not. And if you flattenStrong() the first cube, you get exactly the second one.

PS: Sorry for posting the lengthy egg contents. I decided to put them here in text form rather then to ask you to download anything.