Blender 3D Exporter

Modders can post their questions on scripting and more.

Moderators: Slitherine Core, BA Moderators

Lillarpy
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 121
Joined: Tue Apr 12, 2011 2:52 pm

Post by Lillarpy » Fri Jun 10, 2011 2:29 pm

Merr wrote:Nomet,

Hold the phone ! .... standby .... I'll explain ... First of all, thanks for your help! ... I'm such a noob.

Ok ... Come to find out, the correct Python wasn't installed ... well, v2.6.x wasn't ... I was running 2.5.x. :oops:
Ok ... Fixed. I've got python 2.6.6 installed. :)

Now ... I've got Blender, v2.4.9b installed ... so, cross your fingers .... :roll:

Ahhh ... now I'm back in business ... :D

Now ... I still get an error but it's my fault now (I think) :D ... see screenshot below.
This error can be fixed by me since the script assumed I knew what I was doing :wink:

Image

I'll assume this is a normal error?
I just wanted to see if the basic default CUBE would work with no other action taken ... apparently not ! :wink:
When I had v2.5.x of Python installed (and no Python installed) it errored out as described earlier ... obviously.
Hi Merr, glad to see your using our script and Blender :) I am the Teach Art Nomet was talking about, I am not the author behind the Script but I been spending some time using it and also know my way around python.

Just give me a minute to download your version of Blender and I am sure we can get you going again!

Lillarpy
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 121
Joined: Tue Apr 12, 2011 2:52 pm

Post by Lillarpy » Fri Jun 10, 2011 3:03 pm

There is an bug with the naming of Armatures unfortunately.

I will tell Tony, the hero behind the script first thing Monday :)



And here is how you fix it right now. All you need is a named armature in the background.

1) Press Space, Add, Armature

2) Select your object(RightCLick on the cube), then hold down shift and right click on the newly placed Armature.

3) Press CTRL + P having both object selected

4) Pick "Armature"

5) Then "Name Groups"

Now you have actually made a small rig 8)

Now you will be able to export it with no problem. I apologize for any inconvenience this creates for you.

//Lillarpy

Merr
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 903
Joined: Mon Aug 16, 2010 2:00 pm

Post by Merr » Fri Jun 10, 2011 5:26 pm

Lillarpy wrote:There is an bug with the naming of Armatures unfortunately.

I will tell Tony, the hero behind the script first thing Monday :)

Now you will be able to export it with no problem. I apologize for any inconvenience this creates for you.

//Lillarpy
Lillarpy,

No need to apologize ... It was my lack of experience with Blender causing the trouble!
The CTRL-P was my error :oops:

I couldn't figure out why it didn't export the keyframes ... but I solved this ... I forgot to create an action!

Please, don't bother Tony ... again, it's my lack of Blender experience.

Thank you very much for your demo and for providing an exporter for BA!

Good news ... I can use v2.5.7 to build the mesh, then open the .blend with v2.4.9b and use v2.4.9b for the animation part.
So, there is no need to have Tony build a python script for v2.5.7 ... it would be nice, but not necessary.
If Tony made a script for v2.5.7 then it would be outdated the moment you post it, and Tony would be spending his entire career making python scripts and that doesn't seem to be very fun!

If I run into more problems I will post here ... I am back on my feet now with your help!

Rob

nomet
Administrative Corporal - SdKfz 232 8Rad
Administrative Corporal - SdKfz 232 8Rad
Posts: 168
Joined: Wed Sep 29, 2010 12:32 pm

Post by nomet » Fri Jun 10, 2011 5:43 pm

Great we are happy to help :)

Merr
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 903
Joined: Mon Aug 16, 2010 2:00 pm

Post by Merr » Tue Jun 14, 2011 1:45 pm

Nomet, Lillarpy ...

I spent a few days trying to resolve another issue but I'm stuck again ... I need Lillarpy's knowledge in Blender to help.

The problem is that I can't get the model (cube) to properly position (scale) into the BA world.
I'll start from where we left off at making the Armature the parent and the object the child (CTRL-P) ...

1. In OBJECT mode, I've selected the Armature and the Cube.
2. Inserted a keyframe ( "I", LocRotScale) at frame 1. My start frame = 1, Endframe = 1. One frame is needed for a static object to be placed in the BA world.
3. In the Action Editor, I created a new action at frame 1. This was required because the script needs an action to export the frame.
4. Ran the export.

Now, all this worked, but the Cube is tiny and buried half way into the ground (viewing it in BA).
This is where I need help with Blender, to export the frame correctly, to fit into the BA world.

The code below is from the text file (at frame 1) that was exported ...

Code: Select all

[Cube__FRM1]
trx (matrix3 [1.000000,0.000000,0.000000] [0.000000,1.000000,0.000000] [0.000000,0.000000,1.000000] [0.000000,0.000000,0.000000])

v [1.000000,1.000000,-1.000000]
v [1.000000,-1.000000,-1.000000]
v [-1.000000,-1.000000,-1.000000]
v [-1.000000,1.000000,-1.000000]
v [1.000000,0.999999,1.000000]
v [0.999999,-1.000001,1.000000]
v [-1.000000,-1.000000,1.000000]
v [-1.000000,1.000000,1.000000]
n 0.577349 0.577349 -0.577349
n 0.577349 -0.577349 -0.577349
n -0.577349 -0.577349 -0.577349
n -0.577349 0.577349 -0.577349
n 0.577349 0.577349 0.577349
n -0.577349 0.577349 0.577349
n -0.577349 -0.577349 0.577349
n 0.577349 -0.577349 0.577349
n 0.577349 0.577349 -0.577349
n 0.577349 0.577349 0.577349
n 0.577349 -0.577349 0.577349
n 0.577349 -0.577349 -0.577349
n 0.577349 -0.577349 -0.577349
n 0.577349 -0.577349 0.577349
n -0.577349 -0.577349 0.577349
n -0.577349 -0.577349 -0.577349
n -0.577349 -0.577349 -0.577349
n -0.577349 -0.577349 0.577349
n -0.577349 0.577349 0.577349
n -0.577349 0.577349 -0.577349
n 0.577349 0.577349 0.577349
n 0.577349 0.577349 -0.577349
n -0.577349 0.577349 -0.577349
n -0.577349 0.577349 0.577349
In comparison, this is the frame 1 of the Crates.s3f (same idea, a cube that works in the BA world) ...

Code: Select all

[crates__FRM1]
trx (matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0])

v [-7.38563,-6.92403,-0.100863] 
v [7.38563,-6.92403,-0.100863] 
v [-7.38563,6.92403,-0.100863] 
v [7.38563,6.92403,-0.100863] 
v [-7.38563,-6.92403,5.43836] 
v [7.38563,-6.92403,5.43836] 
v [-7.38563,6.92403,5.43836] 
v [7.38563,6.92403,5.43836] n 0.0 2.75468e-007 1.0
n 0.0 2.75468e-007 1.0
n 0.0 2.75468e-007 1.0
n 0.0 2.75468e-007 1.0
n 0.0 2.75468e-007 1.0
n 0.0 2.75468e-007 1.0
n 0.0 -1.0 0.0
n 0.0 -1.0 0.0
n 0.0 -1.0 0.0
n 0.0 -1.0 0.0
n 0.0 -1.0 0.0
n 0.0 -1.0 0.0
n 1.0 0.0 0.0
n 1.0 0.0 0.0
n 1.0 0.0 0.0
n 1.0 0.0 0.0
n 1.0 0.0 0.0
n 1.0 0.0 0.0
n 0.0 1.0 0.0
n 0.0 1.0 0.0
n 0.0 1.0 0.0
n 0.0 1.0 0.0
n 0.0 1.0 0.0
n 0.0 1.0 0.0
n -1.0 0.0 0.0
n -1.0 0.0 0.0
n -1.0 0.0 0.0
n -1.0 0.0 0.0
n -1.0 0.0 0.0
n -1.0 0.0 0.0

Lillarpy
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 121
Joined: Tue Apr 12, 2011 2:52 pm

Post by Lillarpy » Tue Jun 14, 2011 2:51 pm

Merr wrote:Nomet, Lillarpy ...

I spent a few days trying to resolve another issue but I'm stuck again ... I need Lillarpy's knowledge in Blender to help.

The problem is that I can't get the model (cube) to properly position (scale) into the BA world.
I'll start from where we left off at making the Armature the parent and the object the child (CTRL-P) ...

1. In OBJECT mode, I've selected the Armature and the Cube.
2. Inserted a keyframe ( "I", LocRotScale) at frame 1. My start frame = 1, Endframe = 1. One frame is needed for a static object to be placed in the BA world.
3. In the Action Editor, I created a new action at frame 1. This was required because the script needs an action to export the frame.
4. Ran the export.

Now, all this worked, but the Cube is tiny and buried half way into the ground (viewing it in BA).
This is where I need help with Blender, to export the frame correctly, to fit into the BA world.
The reason the cube is buried half way into the ground in BA is because in blender your Pivot point is in the middle of the cube. So when it spawns in BA, BA finds the Pivot point in the cube and place it on the ground in BA, and therefore everything under the pivot point(Half the cube) is below the ground.

I don't know if your familiar with Pivot Points ? I could elaborate if you need :) It is quite exiting.

Go into Blender, Select your Cube in Object Mode, press TAB to change to Edit mode, now lift the cube and you will see a purple dot in the middle of it. This is the pivot and you want it at the bottom of the mesh.

In Object Mode the Pivot is always relative to the cube, so if you move the Cube X units to the right you also move the Pivot X units to the right, but in Edit Mode if you move the Cube X units the Pivot does not follow.

I don't see the problem with the seize ? If it is small in BA you could just increase it in Seize in Blender to solve this ? Unfortunately there is no scale standards and this is a great cause of pain in my daily work. What we normally do is make a scale-mesh which we use to scale future things in the game and make sure everyone is on the same settings. I recommend you to do the same thing, find a mesh in a nice seize and use it as a scale tool in the future.

I would recommend you to be very careful when it comes to scaling bones. It is the birth of many bugs. That rule apply to all 3D programs.

Also do not scale in Object mode, scale in Edit mode.

If your rig the cube to the bone you do not have to key-frame both the cube and the bone. Key-framing the bone shall be enough.


See if you can solve it with this in mind :)! I had some early problems with getting everything to work too in the beginning but when I managed to throw in one of our tanks from Team Assault into BA and blast some tanks with it it was totally worth it :wink:

//Lillarpy

Merr
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 903
Joined: Mon Aug 16, 2010 2:00 pm

Post by Merr » Tue Jun 14, 2011 9:11 pm

Lillarpy,

Thank you very much! You allowed me to kill two birds with one stone!

My scaling problem was .... I didn't have the "deformation distance" (armature) set far enough to include the vertex!

So ... now my cube fits in the BA world, thanks to you!
This is going to be my reference ( I think it's around 30 BU's ).
Image

My next step .... adding in more objects and armatures ... learning heiarchy! :?
Fortunately, I can follow the churchill.3DS heiarchy as an example ... but at the moment I'm having trouble with it.
I get a script error about "index" ... so I hope I can resolve that.

I might have to ask for more of your Blender knowledge if I can't figure it out.

Thank you!
Last edited by Merr on Wed Jun 15, 2011 5:27 am, edited 1 time in total.

pipfromslitherine
Site Admin
Site Admin
Posts: 8952
Joined: Wed Mar 23, 2005 10:35 pm

Post by pipfromslitherine » Tue Jun 14, 2011 9:29 pm

Borg mod incoming! ;)

You guys let me know if you need anything from me.

Cheers

Pip

Merr
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 903
Joined: Mon Aug 16, 2010 2:00 pm

Post by Merr » Tue Jun 14, 2011 10:07 pm

pipfromslitherine wrote:Borg mod incoming! ;)
:lol: :lol: :lol:

Actually, once I get the heiarchy correct .... I'm going to replace the p47_thunderbolt_attack animation with the borg_cube_attack animation :wink:
Thanks for the idea! ... I'm glad you "accidently" included the p47_thunderbolt_attack.s3f, I'm going to use that as my reference to add the correct emitters.
Also, I can use the s3f to get an approximate start/end point for the animation!

Of course, my goal isn't making a Star Trek mod ... but, these basic reference models will help me ensure my models are complete!

Thank you gentlemen ... your support is outstanding!

Merr
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 903
Joined: Mon Aug 16, 2010 2:00 pm

Post by Merr » Thu Jun 16, 2011 10:29 am

Lillarpy,

Well, I've spent days trying to get the armature parent/child relations correct ... I'm stuck. :x
I keep getting this error ...

IndexError : list index out of range

When you have the time, could you build (from scratch) a basic tank model, rigged properly, and upload the .blend file?
If I could look at the OutLine I can figure out where I went wrong.

A basic tank model ... like the one I'm testing now ;
Image

Thank you very much!

Lillarpy
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 121
Joined: Tue Apr 12, 2011 2:52 pm

Post by Lillarpy » Thu Jun 16, 2011 4:40 pm

As I don't have BA on my computer right now nor have been playing with it for a couple of months it will take me some time to both install it again and familiarize me with it again and there for I can't really prioritize it. Not Sure when I can help you as we have quite a lot work to do right now.

If you uploaded your blend file somewhere though I could take a look at it and most likely figure out what is wrong. I would very much prefer this as I have a rather big work-load the coming weeks and tasks like this one are unfortunately easy to forget as no one in the office are yelling at me to do it.

Some things you could test for yourself:

The Dummy-Squares I see that you will use for the particles, are they all rigged (CTRL+P) to the base-armature ? Are they all named correctly ? I don't remember exactly but remember BA uses a naming system to find the Squares to put the effects on them. Also I would recommend using Empty's instead (Space ---> Empty) .

//Lillarpy

Merr
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 903
Joined: Mon Aug 16, 2010 2:00 pm

Post by Merr » Thu Jun 16, 2011 5:26 pm

Lillarpy wrote: Some things you could test for yourself:

The Dummy-Squares I see that you will use for the particles, are they all rigged (CTRL+P) to the base-armature ? Are they all named correctly ? I don't remember exactly but remember BA uses a naming system to find the Squares to put the effects on them. Also I would recommend using Empty's instead (Space ---> Empty) .
Yes to all your questions.
I'll try empties.

I tried different rig setups but I'm getting lost to quickly. :cry:

Also, I will try to use a BONE for each particle. Then, I'll assign each BONE to each particle.
I'll keep plugging away ... This could be a basic rigging problem ... I wish I knew exactly what the error means.

Thank you for your time! I know you are busy and I feel aweful asking for help :oops: .

Heiarchy sure is a pain in the backside, eh? :)

pipfromslitherine
Site Admin
Site Admin
Posts: 8952
Joined: Wed Mar 23, 2005 10:35 pm

Post by pipfromslitherine » Thu Jun 16, 2011 9:33 pm

I'm no expert in blender scripting, but could you tweak the script to output the object it is exporting so you could tell where the error occurs?

Cheers

Pip

Merr
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 903
Joined: Mon Aug 16, 2010 2:00 pm

Post by Merr » Fri Jun 17, 2011 10:12 pm

pipfromslitherine wrote:I'm no expert in blender scripting, but could you tweak the script to output the object it is exporting so you could tell where the error occurs?

Cheers
Pip
Ouch .... tweaking Python would really be ugly! :wink:
The script works ... but the script needs to have my ducks in a row to behave properly!
Getting my little ducks in a row is my problem :?

Pip ... Can you ask Two-Eyes a question when he has a moment please ...
Relates to Vehicle heiarchy ...
1. The emitter mesh (#!00,#!01, etc) ... Do they need bones or armatures?

Right now, I'm going back to baby steps to figure out when, why, and how the error occurs.

Thanks again (Zeal and Slitherine) for all your support!

pipfromslitherine
Site Admin
Site Admin
Posts: 8952
Joined: Wed Mar 23, 2005 10:35 pm

Post by pipfromslitherine » Fri Jun 17, 2011 10:25 pm

We don't actually require bones at all - they are just used to move the other objects in the heirarchy around, or to deform any mesh animations.

wrt outputting the current object, I meant adding a debug logging string of some kind - assuming there is support for that? Or even an annoying popup for every object, just to track it down.

Cheers

Pip

Merr
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 903
Joined: Mon Aug 16, 2010 2:00 pm

Post by Merr » Fri Jun 17, 2011 11:43 pm

pipfromslitherine wrote:We don't actually require bones at all - they are just used to move the other objects in the heirarchy around, or to deform any mesh animations.
Hmmm ... I'll have to see if I can export without an armature. You see, the script is looking for that armature(Lillarpy mentioned that "bug"), however, there is code in the script that looks at parent objects so I'll see if I can export the mesh (by itself). Now, I've done this, but the object doesn't get "deformed" (without an armature) and it's either huge, or tiny. So, the armature deforms the mesh correctly so it fits into the BA world.
wrt outputting the current object, I meant adding a debug logging string of some kind - assuming there is support for that? Or even an annoying popup for every object, just to track it down.
Oh yes ... I see what you mean. That's the "console" ... the DOS window looking thing, from my first error post. It acts like a debug.
Now, the IndexError does reference a few lines of code .... I'll post the whole error, but I want to first generate the error and explain to Lillarpy what I was doing when the error occured. The reference to the lines of code are consistant ... something like line 101 and 309 ... But I'll post that when I figure out an explaination.

Thank you Pip!
Just by chatting about it helps get the wheels turning in the right direction.

Merr
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 903
Joined: Mon Aug 16, 2010 2:00 pm

Post by Merr » Sat Jun 18, 2011 1:09 am

Lillarpy,

Ok .... This problem I have goes back to the initial bug, where the script needs an armature.
However, you said you were able to get one of your tanks to play in BA after some changes in Blender.

Here is where I'm at .... screenshot has no armature, but the heiarchy is correct.
Here is the link to my blend file, zipped up .... http://www.gamefront.com/files/20451836/merr_tank.zip

How can I get this monster to export correctly?
No worries about making it "fit" into the BA world .... I just need it to export without an error (with 1 keyframe).

Thank you for taking a moment of your time to help!

Image

Merr
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 903
Joined: Mon Aug 16, 2010 2:00 pm

Post by Merr » Tue Jun 21, 2011 4:42 am

Lillarpy and Pip,

Well gentlemen ... I figured it out (finally!). Blender isn't very pretty imo.
I probably didn't need to do all these steps, but it works none-the-less.

1. Exported my model to a .3ds.
2. Imported it back into blender ... adjusted sized and faced it correctly.

Both these steps above may not have be needed, but it did "clean" things up a bit.

3. Added 10 armatures ... One for each mesh.
4. Parent/Child the armature/mesh.
5. Parent/Child everything back into the correct hierachy.
6. UV mapped really quick.
7. Inserted a key at frame 1 and 201 ... it filled in the rest, then I added an action.

Now ... I commented out some lines in the py script, and I'll explain why.
First of all, the script likes to cut-off the last "letter" or "number" in the objects name. Usually the 2nd and subsequent objects.
This isn't a problem with names like "_0Body" but it kills the emitter names ... like #!01, it will write out #!0, not good.
To fix this, I added an extra "_" ... so it reads #!01_.

OK ... here is what I commented out of the script and the reason ...
Line 25 #EXPORT_ANIM = True
Line 103 #if EXPORT_ANIM:
Line 104 # file.write('MESHANIM\n')

I've never seen MESHANIM in any of the s3f's ... Plus, when the STUB engine builds the s4f, the file size is HUGE.

Since we're in the vicinity of line 104 ... look at the lines from 106-114 ...

Code: Select all

		#write parent
		if obj.parent != None and BPyMesh.getMeshFromObject(obj.parent) != None:
			file.write('parent %s\n' % obj.parent.name)
		else:
			#armature = BPyArmature.getBakedPoseData(
			print obj.parent.name
			print len(obj.parent.modifiers)
			for mod in obj.parent.modifiers:
				print mod, mod.nam
This appears to try to parent/child mesh ... but, since the parent/child relationship is armature/mesh or mesh/armature, it never writes out "parent (meshname)".
So, I had to manually add the "parent (meshname)" in the s3f. Now, I could have saved a lot of steps earlier by not setting up a parent/child relationship since it appears it doesn't work anyway. I'll have to experiment with that.

And finally, the last line that I changed ...
change ... Line 214 #if EXPORT_ANIM or i == 0:
to read ... if i == 0:

This change above prevents it from writing "v" and "n" for every keyframe past 1 ... reduces file size.
Now, I may need to change Line 236 ... if EXPORT_ANIM or frame == 1:

Anyway ... Just my 2 cents worth ... I don't know Python but after spending time reading "Pip Scripts" I can sort out some logic :wink:
Any tips on your end would be helpful, thank you.

Here's my Mini-Merr tank in BA .... (ignore the funny railroad tracks, that's another experiment altogether!)
Image

pipfromslitherine
Site Admin
Site Admin
Posts: 8952
Joined: Wed Mar 23, 2005 10:35 pm

Post by pipfromslitherine » Tue Jun 21, 2011 3:03 pm

Glad you are making progress! The mesh animations wouldn't be needed for a tank for sure - they are used for things like infantry. That's why the Max script asks you to tell it which meshes to use mesh animation on (I tried getting it to work out which ones didn't need it, but there are always small numeric inconsistencies which could fool it into false positives).

Cheers

Pip

Merr
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 903
Joined: Mon Aug 16, 2010 2:00 pm

Post by Merr » Wed Jun 22, 2011 1:20 am

pipfromslitherine wrote:Glad you are making progress! The mesh animations wouldn't be needed for a tank for sure - they are used for things like infantry. That's why the Max script asks you to tell it which meshes to use mesh animation on (I tried getting it to work out which ones didn't need it, but there are always small numeric inconsistencies which could fool it into false positives).

Cheers

Pip
Ok ... I can see why MESHANIM is needed for infantry ... If it wasn't there the mesh would move, but it wouldn't deform properly and look ugly.
I can see why the soldiers are so basic looking ... Just like the Zeal tutorial mentioned when they added their soldier into BA, re: size of output file.

Since I removed the declaration of EXPORT_ANIM, I suppose it would be better if the script had a pop-up window allowing you to control the true/false.
I would have to study Python to add this into my changes, but it's not really important because I could just run the original script instead of my ammended script!

To update my progress ... I was able to use only 3 Armatures (body, turret, gun) instead of 10. It works but I still need to fiddle with the emitters.

wrt IndexError ... I checked the Blender forums but there's no explaination, bascially it's just telling me it broke! Where it broke was easy to figure out, I just looked at the text file it spit out and see where it stopped in writing the file. Most of the time it didn't say IndexError (in the console).

Anyway ... I've jumped through that hoop and the only hurdles remaining are with Blender, not the script.

Thank you and ZEAL for providing the script ... it's the springboard required to get model's into the game!

Post Reply

Return to “Battle Academy : Modders Corner ”