Its not so much can’t be done as not sensible to be done - for instance animation data is in a different location to the associated mesh, potentially in a different file; textures and materials are at the start of the file, and due to the differences between blender and panda you often need multiple variants of a what is a single material in Blender, as Panda pushes more rendering information into the material, so you actually have to go through and analyse all the objects before you can generate the materials/textures at the start of the file and the animation data at the end of the file, or in a separate file completely. When building the hierarchy and doing instancing you often need to reference other meshes, which might not be created when your creating the current mesh, so that has to be done in a separate pass. From a gui point of view its quite useful as you can reuse the code that analyses the mesh to check that it can be exported and provide the user with the relevant options. Its also quite helpful as it separates the steps - analysing the data and working out what you have versus writing the data. There is probably other stuff that I have forgotten - at the end of the day such an approach is more flexible, so when you find yourself implementing something you didn’t initially plan for its not as painful.
The current Chicken is a total mess, but only at the code level and in its abuse of globals etc due to the many hacks that have been used, but structurally is not unreasonable, except for that fact it has 90% of the code in a single file, which is several thousand lines long - if I was reorganising it I would give each class a file, as well as a file for each of the interfaces (command line and gui.). But as a general rule of thumb I would have an object for each entity that exists in the egg file and then the code would first map Blender onto that structure before doing the export via a hierarchy of method calls. Chicken goes a bit further than that, as it copies everything from blenders data structure into its custom data structures - whilst more convenient I wouldn’t go that far as python is not very efficient at packing data into memory, and the Chicken exporter is very slow and memory heavy as a result - I would be more inclined to have ‘VertexSet’ objects rather than individual ‘Vertex’ objects, that wrap the relevant blender object without copying it, but allow the storing of additional info as required.
It seems like you didnt check properly if the object was a mesh or armature somewhere. In the B2.4 API you could check that by object.getType() or I guess type(object.getData()).
Added basic skeletal animation export.
Animation is written in the same file as the model.
Parameters are set in the constants: FPS, START_FRAME, END_FRAME
@@ -192,8 +192,7 @@
def collect_vtx_normal(self, vidx, attributes):
if vidx in self.smooth_vtx_list:
- no = self.obj_ref.data.vertices[vidx].normal * self.obj_ref.matrix_world.rotation_part()
- no = map(str, no)
+ no = self.obj_ref.data.vertices[vidx].normal * self.obj_ref.matrix_world
attributes.append('<Normal> { %.6f %.6f %.6f }' % (no[0], no[1], no[2]))
return attributes
worked for me after applying this.
keep in mind that map is a class in python 3 and it returns a map object, unlinke the python2 function map() which returned a list.
For me, the script will create a file, but the file won’t load in Panda. I could be doing something wrong. It tells me something about the (a tag?) and then says, “all matching files on model path invalid (the model path is currently: “/c/Panda3D-1.7.2/test folder;/c/Panda3D-1.7.2/etc/…;/c/Panda3D-1.7.2/etc/…/models”).” I don’t know what that means.
You open a file through loader.loadModel(‘file’) or through pview?
likely texture path is wrong.
Can you open the egg file with text editor and and copy here the header of the file with part?
You were right. There was something weird going on with my texture. I fixed it and got Panda to read the egg file, but what showed up was definitely not my model! It looked like a white plane! I know why it was white, but I don’t know why it was a plane.
For the record, the script did export a cube earlier. It’s just animated models/actors I’m having trouble with.
I kinda don’t want anyone to know about my project yet.
I did get the egg to animate this time, but it was still a plane object of some sort instead of my model. I’m using Blender 2.57b.
I’m sorry I’m being difficult. Can I just ask it there are things you have to turn off in Blender for the script work (i.e., parenting, modifiers, etc.)? If that doesn’t work, I guess I’ll give up and try to put up the files.
Bamboo_Pandamonium, there is a suspicion: script can work only with the simple mesh object yet. Any modifiers, e.g. multires, subdivide, etc., except Armature, should be “applied” before you running the script.
Manou, thanks ). Script trying to export all selected objects, but keep in mind, that only meshes are supported. Hierarchy conversion for the selected objects -> img709.imageshack.us/i/hierarchym.png/
Okay, I just tested something. It is exporting the model, but when I tried to do the animation for it, it doesn’t work. The model showed up correctly when I did this:
So is this syntax wrong? Do you have to do something else for a single-file situation?
EDIT: Never mind. I see what my mistake was in the code. But now the animation won’t play. How do you play an animation from a single file? Also, I wanted to attach objects to the Armature joints. I know how to do it, but he doesn’t seem to have joints anymore. What do I do?
Animation is written in the same file as the model.
Parameters are set in the constant ANIMATIONS in dictionary form:
{ ‘animation_name’ : (start_frame, end_frame, frame_rate), }
Added export through Blender’s “Game logic” -> “properties”
Some bugfixes.