Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

3 Dimensional Chat / DirectX Exporter for Blender 2.49/2.5

Author
Message
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 10th Jul 2010 00:14 Edited at: 10th Jul 2010 00:16
Thanks!

I have some great news, and that is that my exporter has been accepted into the official release of Blender!!

I uploaded it to the Blender Extensions Upload Tracker last night, and sent Meta-Androcto (who manages the scripts repository) a message. This morning, I had a response thanking me and explaining that the team is freezing the wave of incoming scripts for the upcoming Blender release, but that he got the okay to sneak it in last minute.

You can now download a recent build from graphicall.org and it'll have my script in it!

Anyway, I thought I'd just update all of you on the script's progress and share the good news!

DonWON
15
Years of Service
User Offline
Joined: 4th May 2009
Location:
Posted: 10th Jul 2010 02:01
Congrats man!!

I am having lots of fun testing your exporter out and have yet to have one problem. Now I can say "I know that guy"...lol


Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 11th Jul 2010 05:11
Hahaha, yes, I suppose you could.

Let's hope no problems come up.

My script has already been brought up to standards by the other devs. I've updated the OP so that you can download the version of the script that came straight from the Blender Extensions svn. It has been made Pep8 compliant, and someone fixed some of the add-on info. None of the functionality has been changed though.

BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 17th Jul 2010 06:39
That's great! I'm glad you've brought the script all this way, and I'm off to get the latest version of Blender .

Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 17th Jul 2010 11:18
Thanks!

On Wednesday I revised the armature export. It's now actually correct. I used to borrow the functionality of the old Blender 2.4x exporter when it came to armatures, which exports the mesh already deformed at frame 1, along with the skeleton in rest position, and then applies further deformations on top of that. Now the undeformed mesh is exported, along with the posed skeleton in frame 1, so the skeleton can accurately deform the mesh. I haven't updated the 2.49 exporter, but that's not a very high priority anymore. I will if I have free time (which is not very often anymore).

I'm working on Full Animation right now to more accurately represent FCurves. Since Blender uses Bezier curves to interpolate between keys, the Full Animation option will export the Position/Rotation/Size of objects and bones at every frame, taking the job of interpolation between keys away from the engine. It's going alright, but I'm having issues with axis flipping on rotations past 180*. It creates only a tiny blip, but it's noticeable.

Also, I have a bit of bad news, and that is that it appears Microsoft has officially dropped support for the .x format. It's been a long time coming, but now it's here. Ah well. At least I'll still have an audience with you folks. Maybe now I'll get around to that .fbx exporter

GrumpyOne
16
Years of Service
User Offline
Joined: 27th Nov 2007
Location: London, UK
Posted: 19th Jul 2010 19:24
Hi Kira,

I've run into an error message in the Blender console window:

line 184
ImageFiles = [os.path.basename(Texture.image.filename) for Texture etc
AttributeError: 'Image' object has no attribute 'filename'

I'm using Blender 2.5 r30109. It says it is version 1.2 of your exporter.

Best,
Mr Grumpy

GrumpyOne - the natural state of the programmer
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 19th Jul 2010 19:58 Edited at: 19th Jul 2010 20:10
Hi there,

Thanks for pointing that out. I guess I missed one. A while ago, the API changed so that all "filename" attributes were renamed "filepath". If you want to change it yourself, that should be the only problem with it, but otherwise, I've updated the Blender Extensions svn, but I guess I'll post it here too.

Actually, how about I just post a link to the script in the svn? That saves me the trouble of constantly repackaging the script for this thread. Just follow the link and then save the page.

Edit: And by that I mean that I updated the OP.

GrumpyOne
16
Years of Service
User Offline
Joined: 27th Nov 2007
Location: London, UK
Posted: 20th Jul 2010 15:02
Hi Kira,

Thanks for the speedy response.

Yes, the exporter now exports an X file. I've been experimenting. The mesh export works great....the animation export writes data but the X file format is illegal (or rather it won't load in DBPro or in the Milkshape importer). I've got some experience with X file formats (I wrote a parser to analyse meshes in DBPro) so I've been comparing the file format between the Blender file and a working Milkshape JT exporter.

The major difference between the two files is the absence of the XSkinMeshHeader{} and SkinWeights{} structures in the mesh definitions. As far as I've been able to figure out these define the "link" between armatures/bones/joints and the mesh and allow for a single vertex to be influenced by more than one armature. I believe these structures go directly after the Material{} structure within the mesh definition hierarchy. Your exporter defines each object as a separate mesh whilst the JT-exporter combines each separate object into the same mesh. As a result I'm not entirely sure whether XSkinMeshHeader{} and SkinWeights{} are required for each mesh...but I am guessing they are. Thankfully the format of these structures is simple and they can be populated with default values for simple models....when you get around to applying modifiers I guess the weights will need to be set. Anyway here is the format of the structures:


I've got very little experience with animation key formats but I've also noticed the format in the blender file is very different from that in the JT file. This may not be a problem since I have notices that animated X files produced by JT often exhibit strange mesh deformations. Blender file is:


The JT file is:


Anyway, sorry to fire a lot at you. I have very little experience with python (like yesterday was my first look at a python code!) but I may try and rewrite your exporter to generate default XSkinMeshHeader{} and SkinWeights{} structures and see if that works. Although I will probably be defeated by the frame transform matrix in the SkinWeights.

Best,
Mr Grumpy

GrumpyOne - the natural state of the programmer
GrumpyOne
16
Years of Service
User Offline
Joined: 27th Nov 2007
Location: London, UK
Posted: 20th Jul 2010 18:42
Ah...I see you've already got functions in the python script to write SkinWeights and XSkinMeshHeader. Will have to investigate further why they aren't being written to the x file.

GrumpyOne - the natural state of the programmer
GrumpyOne
16
Years of Service
User Offline
Joined: 27th Nov 2007
Location: London, UK
Posted: 20th Jul 2010 19:18
Right by adding print statements to your lovely code I've worked out the code execution goes into WriteMeshSkinWeights() but that ArmatureList is returned as zero by the line:

ArmatureList = [Modifier for Modifier in Object.modifiers if Modifier.type == "ARMATURE"]

So the SkinWeights and Header are not written.

My model definitely has armatures that have child meshes, do I need to apply a modifier to them to get them to export? I'm rather new at animating with blender.

Best,
Mr Grumpy

GrumpyOne - the natural state of the programmer
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 20th Jul 2010 20:22 Edited at: 20th Jul 2010 20:44
Yes, a parent/child relationship is not enough (or even necessary) for armature export. The only thing that affects it is the presence of an Armature modifier. The Armature modifier tells Blender which armature object to use for deformations.

Wait a minute....... it just occurred to me that without the armature modifier, you armatures wouldn't even be working in Blender. But then I realized that you could just parent the two objects and choose Armature instead of Object in the object settings. I suppose that's what you did. My script doesn't support that kind of definition right now. Maybe I'll add it in later.

Right now though, an Armature modifier is required. Hope that helps.

Edit: Oh, and the difference in the AnimationSet between the files is that mine uses individual components of a transformation to define animation, and JT's tries to do it all in one fell swoop with a complete transform matrix. Both are perfectly valid, but since matrices combine all transformation data, there's often no way to determine the difference between different transforms, like a rotation of 180* looks like a complete scale flip. I felt that such inaccuracies were unacceptable and so I excluded them from my exporter. The ancient 2.4x exporter by Arben Omari used matrices as well. Ew.

Edit 2: Also, every time the script encounters an error while exporting, the file becomes invalid. You might be able to open it in text editors, but no 3D app seems to be able to read it. The only solution I've found is to close Blender. After that, the file can be read again. I dunno if it's just my computer, but who knows.

GrumpyOne
16
Years of Service
User Offline
Joined: 27th Nov 2007
Location: London, UK
Posted: 20th Jul 2010 20:52
Ah, so, it is my lack of ability with Blender!

I "skin" my model by selecting the mesh object in pose mode, CTRL-P, the set parent to bone. This seems to attach the mesh object to the armature...at least...it moves when I move the bone. How does one create an armature modifier?!? I apologise, with any other application I'd simply look for the button....but I know from experience that finding the button in Blender is impossible.

You know, one of the problems with Blender is the lack of up to date documentation on simply how to use the thing. I end up learning most of my techniques from some 12 year old on youtube. If only the developers spent 5% of their time on writing a how to it would be so much easier.

GrumpyOne - the natural state of the programmer
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 20th Jul 2010 22:32 Edited at: 20th Jul 2010 22:34
Well in this case, there actually is a button (more or less). It's in the Properties window, under the Modifiers tab. Just select Armature from the list.

That should add an Armature modifier to the object, but then you need to specify the armature object to use for deformations. These settings have always worked for me.

Of course, this will only work if you have already defined vertex weight groups for each bone. If you haven't, you can set the object's parent with Blender's nifty Automatic Weights option. It automatically creates a weight group for each bone and it works pretty well for simple rigs. Anything complicated should probably be done, or at least edited, by hand.

Keep in mind that your mesh object does not need to be a child of the armature to deform. The armature modifier is what determines that.

Quote: "You know, one of the problems with Blender is the lack of up to date documentation on simply how to use the thing"

I agree, but also keep in mind that Blender 2.5 is under heavy development all the time. When a stable release comes out, I'm sure we'll see more documentation.

Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 21st Jul 2010 05:03
Update!

Okay, so I've added support for Full Animation for objects only. I haven't gotten to armature bones yet, but I will.

Also, I've taken time and updated the page on Blender's wiki for this script. I've moved a lot of info from the OP to that page to avoid having to update many places every time I come up with something new. There's a link to the wiki (for 2.5) and a link to a tiny page I threw together really fast (for 2.49) in the OP now.

@GrumpyOne: Lemme know if that did it for you. I hope I can help.

Aralox
17
Years of Service
User Offline
Joined: 16th Jan 2007
Location: Melbourne
Posted: 31st Jul 2010 12:30 Edited at: 31st Jul 2010 12:35
Hey Kira, thank you so much for the exporter. Ive been using it for a while now, just to export static models, and i figured i would see how animation went before i made my judgement. It works beautifully.
You are a credit to this society, keep up the good work .

Heres some hints id give to someone trying to get (bone) animation working:
- Keyframe all your bones at frame 1

- export the bones and it's object (the one with the armature modifier) together, and select armatures and animations on export.

- If you have strange glitches in DBP, make sure that your vertices are assigned to specific bones. Now i may be missing something, and I dont claim to be an expert, but i find that even though a bone may be affecting some vertices, sometimes you dont see that vertex group in the drop down menu. Just create a vertex group with the exact bone name, and assign the vertices you want for that bone to it. This sorted out alot of my problems.

- If you export two objects together, say the body and the head, and you want to manipulate just the head in dbp, you have to manipulate the bone that object is joined to, not the object itself. Say in dbp the blender 'head' object is limb 9, and the 'headBone' is limb 4. You have to manipulate limb 4 to move the head.

Thanks again
Aralox



http://www.freewebs.com/aralox/
Omen
18
Years of Service
User Offline
Joined: 7th Nov 2006
Location: Maple Grove, MN US
Posted: 3rd Aug 2010 02:20 Edited at: 3rd Aug 2010 02:27
Can't wait for you to get bone animation working. I hope that also means vertex weighting is coming too?

If you can get bone animation and vertex weighting all working (4 bones per vertex would be ideal) I could switch over completely to Blender. The shrinkwrap function alone saves me hundreds of hours of work -- that's how I make my low-poly meshes from high-poly meshes without all the vertex position distortion that comes from just doing decimation

Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 3rd Aug 2010 02:31 Edited at: 3rd Aug 2010 02:35
@Aralox: Thanks for the kind words! Y'know, it really is posts like this that motivate me to work on this. I'm glad it has been helpful!

@Omen: Bone animation should be working, but just keyed animation. In other words, the exporter will write animation data for every key you set in Blender, which seems to be the way most exporters go. I'm working on exporting data on every frame of the animation, so that the entire F-Curve is exported. That would add support for weird custom interpolation between keys and F-Curve modifiers.

As for vertex weighting, I'm not sure what you mean. The exporter already exports vertex weights for each bone, and the deformations depend on that data. Am I missing something?

Edit: However, Full Animation has already been implemented for objects. With objects you can choose to export just the full animation, or just the keys.

GrumpyOne
16
Years of Service
User Offline
Joined: 27th Nov 2007
Location: London, UK
Posted: 10th Aug 2010 13:45
Hi Kira,

I am getting on very well with your exporter, no problems so far. However, I've just installed the Blender 2.53 beta and was surprised to see your exporter was not included in the installation package. In fact the directory structure seems to have changed drastically so there is no scripts\addons directory. Do you know how to install the exporter on the new beta?

Best,
Mr Grumpy

GrumpyOne - the natural state of the programmer
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 12th Aug 2010 00:19
Hi there,

Hmm, I'm not sure how that is possible. The new directory structure puts the scripts\addons directory inside the directory named "2.53". You should check to see if the script exists from inside Blender. Just go to the User Preferences window, under the Add-Ons tab, and it should be listed there. If it's not there, just drop a new copy of the script inside the 2.53\scripts\addons folder.

Hope that helps, but lemme know if it doesn't.

Maximilian++
14
Years of Service
User Offline
Joined: 13th Aug 2010
Location:
Posted: 13th Aug 2010 15:46
Hi all,
I downloaded and installed the latest version of the exporter.
I enabled the exporter in the user preferences of blender 2.53 beta but when I try to export my object I can't select the exporter cause it's grayed.
In the Fie->Export menu I see "export.directx" but can't select it.
My OS is ubuntu 10.04.

Thanks,
Max
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 14th Aug 2010 04:17
Hi,

My best guess is that the version of Blender that you're using is incompatible with the current state of the script. I'd investigate further, but I'm not at my dev computer right now (I'm on vacation). The script is updated all the time by other Blender devs to reflect the crucial changes made to the Blender Python API, so chances are that if the script no longer works, the problem is that the script has been updated to work with the latest Blender version. You should go to [href]graphicall.org[/href] and look for the latest Blender build for linux.

Sorry I couldn't be of more help. I'll get to updating when I get back home to my triple booted machine (Ubuntu 10.04 included ) to do further tests if it's still a problem. Good luck!

Clonkex
Forum Vice President
14
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 14th Aug 2010 12:09
I wanna thank you again for this script.....it's really great! All blender functions work with it and they all load fine into DBPro. Now I have a favour.....could you also make an importer?

Clonkex

Making games is easy.....finishing them is a different matter.

Intel Core 2 Duo 2.8Ghz, Nvidia GeForce 9400 GT 512mb, 1gb ram.
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 22nd Aug 2010 08:53 Edited at: 22nd Aug 2010 08:54
@Clonkex: Sorry it took so long to respond. I'm on vacation at the moment

However, I had a bit of down time, and so I did some work on the exporter. Update!

Full Animation should now be fully functional for all objects and armature bones! About friggen time.

Anyhoo, now I'm wondering where to go from here. Perhaps I'll add support for binary .x files, or write Clonkex an importer. Is there any interest in binary .x files?

BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 22nd Aug 2010 17:00
I'd be more interested in an importer than a binary exporter, normal .X files are just fine for DBP.

Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 25th Aug 2010 17:26
Interesting. Thanks for the feedback. I'm back in town now, so perhaps I shall start on an importer.

Clonkex
Forum Vice President
14
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 30th Aug 2010 10:20
That would be really great! Thanks.

Clonkex

Making games is easy.....finishing them is a different matter.

Intel Core 2 Duo 2.8Ghz, Nvidia GeForce 9400 GT 512mb, 1gb ram.
gForge
14
Years of Service
User Offline
Joined: 30th Aug 2010
Location: Seattle, WA USA
Posted: 31st Aug 2010 01:13 Edited at: 31st Aug 2010 22:26
Very nice.
Has this been tested with an advanced rig such as the blanderManRig?

I know BlanderMan is for 2.49 but the tutorial was basically do-able in 2.53 with a little button hunting. Currently I get the armature heirarchy ( although I was hoping that it only exported deform bones and not constraints), the mesh object (file size is a little big, but I understand your solution to dupli-verts/uv), the skin weights(per deform bone of coarse)

I chose export selected only(armature and deform mesh) but still got my bone constraint widgets in the exported x file. No vertex information btw, but the 'Frames' were written toward the end, just before the AnimationSet.

Animation information is there but I was expecting to see the keys in matrix form. Long story short, DirectX Viewer shows the mesh in the pose that happened to be where the frame marker was when the export was invoked. Hand editing showed some promise but no movement yet.

Still...Best script ever no joke. Thanks mucho.
If you wanted the test .blend I'd be happy to hand it over.

Edit: hand editing started most of the animation sequences in DirectXViewer. Seems that there were some negative value key times which when shifted to positive all was good. Animation renames to deform bones instead of constraint bones worked for straight copy constraints were good but there isn't a rename for IK or poll targets just because of the nature of the constraint.
gForge
14
Years of Service
User Offline
Joined: 30th Aug 2010
Location: Seattle, WA USA
Posted: 1st Sep 2010 06:01
I have to add though,
take away the advanced rigging and this script works flawlessly.
Thank you very much.
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 1st Sep 2010 20:21 Edited at: 1st Sep 2010 20:23
@gForge: I'm glad you like the script!
Quote: "but still got my bone constraint widgets in the exported x file"
Hm, the script will automatically export the children of selected objects when the Selected Only option is picked.

Quote: "Animation information is there but I was expecting to see the keys in matrix form"
Matrix form for animation keys is just a bad idea. I don't think they preserve enough information to properly describe a complete transform. Take, for example, a rotation of 180 degrees. In matrix form, that looks like a complete scale flip and as the DXViewer just interpolates transform matrices between frames, that's the way it would be interpreted. The exporter that shipped with 2.49 did this, but it's much better to separately provide each part of the transformation.

Quote: "If you wanted the test .blend I'd be happy to hand it over"
I'd be interested in taking a look if you'd like to upload it.

Quote: "Seems that there were some negative value key times which when shifted to positive all was good."
Really? Weird. I encountered that problem while developing, but I was pretty sure I fixed it. Could you post all of the settings you used? Also, I haven't tested it yet, but I think it should be possible to capture movements of individual bones that are part of IK chains using the Full Animation setting.

Edit: It occurred to me to ask which version of the script you are using, as many issues that were in the version released with Blender that can be downloaded from blender.org have been fixed. All of the new ones can be found on graphicall.org

gForge
14
Years of Service
User Offline
Joined: 30th Aug 2010
Location: Seattle, WA USA
Posted: 3rd Sep 2010 23:45
yes, the current build in r31692 showed improvement for sure.

Test Blend attached.
or linked at

http://www.goliathforge.com/content/news/npc_news/nanoSoldier_testBlend.rar

notes in the files.

Again, thanks...The current state is working fine in my art pipeline.

Mark
Goliath Forge Online

Attachments

Login to view attachments
nastasache
14
Years of Service
User Offline
Joined: 8th Jun 2010
Location:
Posted: 15th Sep 2010 00:36
Hi Kira,

I tested and found your script as an amazing (and maybe only one) way to export the mesh&texture&animation from Blender 2.49 to FPSC.

My question is: it is there a reverse way? I found no way to import an animation (I mean entity with animation .x file) from FPSC to the Blender keeping mesh&texture&animation. The only mesh I have as result into Blender.

Thanks.
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 15th Sep 2010 08:01
Hi,

I'm glad the script is working for you!

I don't know of an alternate method of importing a .x file. I haven't played around with it, but I hear that the .x importer script that comes with 2.49 is pretty bad. Who knows, but I've been toying with the idea of writing a .x importer for Blender 2.5x.

Sorry I can't be of much help, but I haven't heard of another importer. Perhaps you could try converting the .x file into another format that can be read by Blender? I don't really have any conversion software that I could recommend though.

entomophobiac
22
Years of Service
User Offline
Joined: 1st Nov 2002
Location: United States
Posted: 6th Oct 2010 09:12
Saw that this isn't included in the 2.54 version, anymore. They seem to have changed around with the Python API a bit.

Any chances we'll see an upgrade?
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 6th Oct 2010 09:44 Edited at: 6th Oct 2010 09:58
What? That doesn't make sense. The script is still in the extensions svn, and was in the first version of 2.54 I got. I'm downloading a newer version now to see. Is it possible the builder just didn't include any scripts with the build? Which version are you using?

Edit: Just downloaded r32239 for 64-bit Windows and the script is still there.

entomophobiac
22
Years of Service
User Offline
Joined: 1st Nov 2002
Location: United States
Posted: 7th Oct 2010 09:02
I downloaded the 2.54 that is on the frontpage of the website. Didn't have the DX exporter packaged with it. It would still work, then?
Clonkex
Forum Vice President
14
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 12th Oct 2010 08:30
Hey guys,

@Kira

I was wondering if you could make the exporter export multiple textures for this particular model (the attached one). I exported it from Sauerbraten (a FPS game that can be used as a level modeler). I import it into Blender, export it using your script, and it doesn't export all textures. But if I use the Poly Reducer script (ships with Blender, go edit mode the Mesh menu and scripts up the top), it exports all the textures fine. The only thing is, the poly reducer sort of craps on the model.

Thanks,
Clonkex

Making games is easy.....finishing them is a different matter.

Intel Core 2 Duo 2.8Ghz, Nvidia GeForce 9400 GT 512mb, 1gb ram.

Attachments

Login to view attachments
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 13th Oct 2010 09:46
Sorry guys, I've been rather busy with classes as of late. I hope I can devote more time to this soon.

@entomophobiac: I don't understand. Which version did you download? I downloaded the 64-bit Windows version and it had everything with it. The current state of the script probably won't work with that version, but there should be a copy with it.

@Clonkex: I looked at your model, but it seems that you didn't upload the .mtl file that should've been created with the .obj file, and none of the textures were there either. Also, I've never heard of this poly reducer script. Which version of Blender are you using?

entomophobiac
22
Years of Service
User Offline
Joined: 1st Nov 2002
Location: United States
Posted: 14th Oct 2010 09:22
Seems they've done some serious renaming in the new version of the API. Suppose it's safer to just wait until they lock it down, and stick with 2.49 for a while.

A little bit annoying, but I guess it's all for the better, in the end. Hopefully, 2.6 isn't TOO far away.
Clonkex
Forum Vice President
14
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 17th Oct 2010 10:17
I'm using 2.49b and I think you poly reducer may have been left over from the last version I had (2.47). It doesn't matter anyway because I found the import obj script has the option to split the object into many objects depending on it's material (so an object with 2 mats would split into 2 objects, one for each mat).

Clonkex

P.S. When I meant you should make an importer I meant you should make one that will import most (or better, all) the FPSC models. The stock importer is pretty useless.

Making games is easy.....finishing them is a different matter.

Intel Core 2 Duo 2.8Ghz, Nvidia GeForce 9400 GT 512mb, 1gb ram.
hookkshot
17
Years of Service
User Offline
Joined: 12th Apr 2007
Location: Adelaide, Aus
Posted: 22nd Oct 2010 18:50 Edited at: 23rd Oct 2010 08:30
i am getting an error saying "none type"

attached is the .blend file. I'm using blender 2.49b

2.0Gh AM2 Processor, 9800GT, 2Gb Ram

Attachments

Login to view attachments
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 25th Oct 2010 09:30 Edited at: 25th Oct 2010 09:32
Ah, did you used to have bones in the armature that you deleted? The script was trying to write animation data for bones that didn't exist. Anyhoo, I've added a check for that now. I've posted an update for the 2.49 version.

Also, for 2.5, I've fixed Full Animation with armatures, as I know some people were having issues with them. I recommend finding the latest Blender build you can for it, as there have been a couple recent changes to the API. Dunno what would break the script on previous versions though.

Edit: Weird, my last 2.49 update was five months ago to the day.

hookkshot
17
Years of Service
User Offline
Joined: 12th Apr 2007
Location: Adelaide, Aus
Posted: 25th Oct 2010 18:06
Yeah i delete the pole targets and ik bones. didnt know it would effect it so much

2.0Gh AM2 Processor, 9800GT, 2Gb Ram
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 25th Oct 2010 20:21
Well it won't anymore!

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 26th Oct 2010 01:53
@Kira Vakaan

Hello,
Your direct x work is impressive! I have a request, of sorts, specifically aimed at blender versions 2.45 to 2.49. This isn't directly related to Directx but, it is somewhat related.

I want to be able to extract a list of bones and the vertices and weights assigned to each bone. I also want to be able to extract the key timing for animation in direct x format for bones but I want the transformations (animation keys) to use the animation key types 0,1,and 2 not 4 (matrix transformation). I've done blender direct x export work before, but not for bone animation.

Can you point me in the right direction perhaps? I want to be sure to maintain the hierarchy of the bones. The goal is to use the information to build a custom animation routine.

Enjoy your day.
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 26th Oct 2010 03:30
@Latch:
Thanks!
Hmm, I don't know how different 2.45 is from to 2.49 (I got into Blender with the advent of 2.48), but sure I could help you with the 2.49 API.

Within my 2.49 exporter, I think the following functions might be of interest:
- WriteArmatureBones()
- WriteMeshSkinWeights()
- WriteAnimationSet()

More specifically, each Armature object should have a method called getData() that will return the armature used by that object.
Armatures have a dictionary-like structure called a BonesDict (the instance is called "bones") that contains all of the bones in the armature. Each bone has a member list called "children" which contains.. well.. all of that bone's children. Each bone also has a member called "parent" which... yeah. Using those two you can easily recreate the hierarchy.

It should be noted that each Armature object (not armature, but the objects that use them) has another method called getPose(). This returns a Pose object, which has a PoseBonesDict called bones, that is full of PoseBones. The difference between these bones and the previous ones is that these contain the posed positions of the bones, and so these are the one's you'll want for animation. However, it appears that they don't have a "children" member like the others, so the others are necessary.

For the animations, you'll really want to take a look at the second half of my WriteAnimationSet function. That's where I write animation data for armature bones. You need to retrieve an Action object from the Armature object, and from there obtain the IPOs for the bones. I write my animation keys using key types 0, 1, and 2, as using 4 produces inaccurate transformations (a rotation of 180* looks like a scale flip, etc).

I hope I've been of some help and if you have any other questions, feel free to ask.

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 26th Oct 2010 12:41
Thanks for the info! I've been going through the code and trying stuff out.

Quote: "I hope I've been of some help and if you have any other questions, feel free to ask"

You've definitely helped.

A couple of questions regarding the exporter:

1. Why does the 'Make Real' modifier have to be set? What is it doing? What is it applying to? It seems that it makes the initial pose of the mesh as influenced by the armature committed, so to speak. Am I correct in that assumption? Also, once I click that, the mesh no longer can be posed by the bones.

2. I made a cube model and extruded it a few times. I added an armature. I linked the the cube as a child to the parent armature. In pose mode, I can animate the mesh and store the ipos and play back the animation. On exporting the object, everything is in the X file except for the skin weights for the vertices.

I read earlier in this thread that an armature modifier has to be added. Why is this? Why isn't the parented and animated armature enough? If your export is picking up the IPOs of the posed bones, why isn't it picking up the related vertex groups in this scenario?

In the case of parenting an armature to an object, doesn't the object becomes a child in the armature hierarchy? Contained in a relationship to the object's mesh, are the vertex groups. Would it not be possible to add this as a check in the export?

Enjoy your day.
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 26th Oct 2010 18:57
Let's see if I can give some answers

1. After clicking the "Make Real" button, Blender should turn the "virtual" modifier into a real one. It's strange you should say that the mesh can no longer be posed by the bones though.. I've never experienced that. The only possible explanation I have is that you may have accidentally clicked the "Apply" button on an already "real" armature modifier (the Make Real button doesn't exist on real armature modifiers, but the Apply button is in about the same place).

2. Yes, that is by design. The logic behind the current behavior of the exporter is the result of the struggle over how to determine whether or not an object is using an armature for deformation. Basically, there is no good way to determine whether or not an object is simply parented to another object (only parented and not using the armature), or using an armature to deform, when there is not an explicit armature modifier on the object (which actually makes the relationship between the objects irrelevant, as parenting is not necessary when using the modifier).
To address your idea regarding vertex groups, the groups are not necessarily indicative of an object/armature relationship. An example of which can be observed by deleting the virtual modifier off of an object that was recently parented to an armature using automatic weights. The object is still a child of the armature object, still contains intact vertex groups, and yet does not use the armature for deformation.

For these reasons the exporter requires the explicit use of an armature modifier (which can be easily created using the Make Real button on the virtual modifier).

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 27th Oct 2010 01:04
@Kira Vakaan

Thank you!

Yes, I was clicking apply after clicking make real. My fault

I noticed that there may be a small error in the export in regards to the frame transform matrices:



There is only a double ; after the first transform matrix. The others don't have this. This may be causing some errors I'm experiencing in the animation I'm testing. It happens when the Export Armatures toggle is set.

Also, I believe the final animation lines need 3 ;;; and the divider group in between frames at the end should be ;;,

This



Should be




Quote: "To address your idea regarding vertex groups, the groups are not necessarily indicative of an object/armature relationship. An example of which can be observed by deleting the virtual modifier off of an object that was recently parented to an armature using automatic weights. The object is still a child of the armature object, still contains intact vertex groups, and yet does not use the armature for deformation.

For these reasons the exporter requires the explicit use of an armature modifier (which can be easily created using the Make Real button on the virtual modifier)."


I see. I suppose it's based on the modeler's intention. In the case of parenting the armature, it is not necessary to add a modifier, in the case of adding a modifier, it is not necessary to parent the armature. Parenting doesn't necessarily indicate deformation, whereas adding a modifier most likely does. Is that about right?

So, if I wanted to go the route of parenting, deliberately designing the model and the armature this way, is it possible to export the bone animations and the vertex groups and indicate that they are related (which is the main goal of the information I want to extract out of blender)?

Enjoy your day.
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 28th Oct 2010 07:38
Wow, thanks for pointing those things out. The first is a simple typo on my part. It should indeed end in ";;" and not ",".

As for the others, I've just been doing some reading on the use of commas and semicolons from the MSDN library, and you are indeed correct. I never thought to read these documents before, as in the beginning, I studied the behavior of the old exporter along with other .x files I had. Little did I know that these other source are actually incorrect. However, I've never had any issues with the export... I tested against the DirectX X Viewer all through development as kind of a "definitive" authority on the .x format. I never had any problems.

Anyhoo, thanks for pointing that out. I shall set about updating my scripts to be technically correct.

As for your other questions, yes, that is correct. And yes, it is possible to export vertex group data from a Mesh object for the bones of an armature without an armature modifier. My exporter only needs the armature modifier to specify which Armature object is to be used for the Mesh object. The modifier doesn't contain any other useful information for the exporter. So, instead of getting the Mesh/Armature object pair in that way, you could write an exporter that simply assumes any Mesh object child of an Armature object uses that armature for deformation. Blender determines which vertex groups go with which bones only by matching their names. You should take a look at WriteMeshSkinWeights() for how to go about getting the vertex influences. That function uses a mesh's method called getVertexInfluences(VertexIndex) to return a list of lists in the format [BoneName, Weight] for that vertex. Be warned however, that data for bones that no longer exist are still returned in that list, so WriteMeshSkinWeights() does some extra checking for that.

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 28th Oct 2010 16:53 Edited at: 28th Oct 2010 16:57
Quote: "That function uses a mesh's method called getVertexInfluences(VertexIndex) to return a list of lists in the format [BoneName, Weight] for that vertex. Be warned however, that data for bones that no longer exist are still returned in that list, so WriteMeshSkinWeights() does some extra checking for that."

Thanks for the help. Looking through your script is very informative.

Quote: "However, I've never had any issues with the export... I tested against the DirectX X Viewer all through development as kind of a "definitive" authority on the .x format. I never had any problems."

I would guess that the SDK app is a bit forgiving. But if you write any custom viewers or use an already written custom viewer that adheres to the strict comma, semi-colon syntax, you might run into problems. Also, running any conversion scripts/programs (like Ascii to Binary or X to 3ds etc.) might hiccup if the delimiters aren't exact.

Thanks again, I have a few ideas that I'll have to roll around in the old coconut!

Enjoy your day.

Login to post a reply

Server time is: 2024-11-23 11:23:11
Your offset time is: 2024-11-23 11:23:11