Author Topic: BATTLE OF BLENDER/Python: more AH friendly .ac export script  (Read 663 times)

Offline Xjazz

  • Gold Member
  • *****
  • Posts: 2653
BATTLE OF BLENDER/Python: more AH friendly .ac export script
« on: April 30, 2006, 03:35:18 PM »
Hi

I finally get tired with Blender's original AC3D_export.py Python script and I started hacking it to meet better my needs. Because  I don't know chitte about the programming etc so,I started the Python language and Blender API studding...

 Anyhow, I could cut down the text editing phase pretty much due cleaner export.
 
* Changes so far:
Decreased the vertex coordinate accuracy to 10E-2 to avoid the vertex 'shifting'.
Decrease the UV / texture mapping coordinate accuracy  to 10E-6.
Add the 256 material definition lines automatically.
Fixed 'Crease 45' value, no matter what values Blender has (default is 35).
Removed the '//' front of the texture name.
Automatically gives a 'MaxDist=20000' values for all groups.
Add the user defined mat number to the object surfaces (one mat number per object).
Removed the 'texrep' line.
 
* Know issues
No real support for object properties.
The complex hierarchy trees (HT) order will get messed during the export. The simplest trees are OK.
If duplicated group/object names or object properties values, then Blender will give a index number: tex01, text01.001, tex01.002, MaxDist=2000,MaxDist=2000.001 mat 19, mat 19.001 etc.


A-HEM! Any Python gurus here?
 I have a idea to use the external or Blender's internal text file as a HT work list and object properties data source. With one script version I succeeded to use external text file for proper HT export but the method is not too user friendly. I must write down the whole HT in certain format to the single line string.

I would need a  tutor how to write a pyhton script, which could read a from following text lines a needed parts.

Text file Format:
[object or group name]: [object property1, object property2, object property3, etc] #[ignored text comment filed]

sample:
(beginning of the text file)
# This is just a comment field which is ignored during the export
model: maxdist=40000 # it's possible to add comments end of the these lines
objects: maxDist=40000
vod0: maxdist=40000
bar1:maxdist=40000, NoCollide=0, StencilAlpha=1
(end of the file)


Hierarchy tree string
The script will read the names (except the tabs / spaces) from the beginning of the line until it find a end mark ' : '. The rest of the lines are ignored  now.

At the end the script will compile names to the following format:
[[OBJECT model], [OBJECT objects], [OBJECT vod0], [OBJECT bar1]]


Object properties
When main export script is about to write, lets say bar1, object to the file, the script will note the name and look up the same name from our list and then look up the data.

The script read the rest of the line after the ' : ' start mark to the end, count a mount of the marks(excluding the spaces and commas),and give this value for data-variable.

Write to the file
data 40 (value)
maxdist=40000
NoCollide=0
StencilAlpha=1

The main script continue from here and start writing the vertex&surface data. so on and so on.


Any help?

Thanks

Offline Xjazz

  • Gold Member
  • *****
  • Posts: 2653
BATTLE OF BLENDER/Python: more AH friendly .ac export script
« Reply #1 on: May 04, 2006, 04:08:17 PM »
Hi

Looks like people are even more Python newbies than me :)

 I spend some intensive evenings with coding while searching and reading internet tutorials about the python list & string managing, Blender API's and etc. I never ever saw so many error messages in my life...

First I get basics working in Python's IDLE and finally I succeeded to squeeze needed code lines in to the Blender export script... The very first script with full support for object properties data and proper hierarchy tree export is ready.

There are few issues still to check but almost there :D

On the picture you can see object with all lod’s and dead shapes on top left , hierarchy tree in middle and ready hierarchy tree order & object properties data text file on top right.

http://warezhouse.1g.fi/here/aceshigh/te_stuff/Blender3D/AHv2_export.jpg

Offline Bogie603rd

  • Silver Member
  • ****
  • Posts: 1563
      • http://603sqdrn.collectivelyspaced.com
BATTLE OF BLENDER/Python: more AH friendly .ac export script
« Reply #2 on: May 04, 2006, 06:13:38 PM »
INCREDIBLE! I'm still trying to make a darn object! can't find any good tuts on how to make it work.
No. 603 Squadron... Visit us on the web, if you dare:
http://603sqdrn.collectivelyspaced.com
Join our TeamSpeak server, Click Here.

New forum ID: Denholm

Offline Xjazz

  • Gold Member
  • *****
  • Posts: 2653
BATTLE OF BLENDER/Python: more AH friendly .ac export script
« Reply #3 on: May 05, 2006, 04:38:04 PM »
Hi

Here is the script
http://warezhouse.1g.fi/here/aceshigh/te_stuff/Blender3D/AH2v1_export.zip

Zip file contains the AH2v1_export.py script, onames.txt temp file for script and ah_opd.txt. Unzip these to the Blender's script folder

This script is meant to the OE ready object export only. It will export ALL current scene objects, except those ones, which name starts with ! or with #.

 
The format of the ah_opd.txt file

(beginning of the ah_opd.txt file)
[object or group name], [properties1] [properties2][enter]
[object or group name], [prperties1] [properties2] [properties3][enter]

(end of the ah_opd.txt file

* Use only one space between the words.
* No extra spaces end of the lines.
* After the last line you must hit the enter ones.

 Hierarchy tree
This script co-operate with the Blender hierarchy tree, called 'Out Liner', where the script takes the parent-kids information.

Anyhow, you can over-ride the Blender hierarchy tree order with in following limits. The group and object places in ah_opd.txt hierarchy tree can change as long as kids number (number of the sub groups or objects) match with Blender hierarchy tree.

The object and group names are case sensitive and they must match with blender group and object names.

 
Object Properties Data
* Not case sensitive text if not announced so by HTC.
* Don't use spaces with in property: Wrong dead = 1, right dead=1.
* You must separate each property with one space.

 The ah_opd.txt file must be save to the  Blender's script folder.

Offline Xjazz

  • Gold Member
  • *****
  • Posts: 2653
BATTLE OF BLENDER/Python: more AH friendly .ac export script
« Reply #4 on: May 16, 2006, 11:52:57 PM »
Hi

New script version 1.1  is here.

changes:
- Blender indexing problem fixed
- added complete AH material definition list.
- script function can find now from the 'Help' dropdown meny.

NOTE! Save your ah_opd.txt file same with your object Blender file!

You can see in this picture a hierarchy tree order and name index manipulation.

I R coad, eh? j/k

Offline Xjazz

  • Gold Member
  • *****
  • Posts: 2653
BATTLE OF BLENDER/Python: more AH friendly .ac export script
« Reply #5 on: May 17, 2006, 02:59:22 AM »
I just notest one issues with this script.

If you first open the Blender program itself and then open or 'Reopen the last' your-object.blend file, the script propably will give a following error message to the console screen:

"Traceback (most recent call last):
  File "", line 68, in ?
IOError: [Errno 2] No such file or directory: 'ah_opd.txt'"


The script seems to working ok only if you are starting the Blender via your-object.blend file.

Offline Bogie603rd

  • Silver Member
  • ****
  • Posts: 1563
      • http://603sqdrn.collectivelyspaced.com
BATTLE OF BLENDER/Python: more AH friendly .ac export script
« Reply #6 on: May 17, 2006, 09:36:33 AM »
I installed the "AH2v1_export" so far. Gonna work with this propably tommorow. See what I figure out. Just, like I said. Need to learn how to work with the objects and figuring out how to create and shape my own. Cause I thought it was a simple process of making a .bmp image. Then in the editor taking the 2-D images and placing them together to make the 3-D object.
No. 603 Squadron... Visit us on the web, if you dare:
http://603sqdrn.collectivelyspaced.com
Join our TeamSpeak server, Click Here.

New forum ID: Denholm

Offline Xjazz

  • Gold Member
  • *****
  • Posts: 2653
BATTLE OF BLENDER/Python: more AH friendly .ac export script
« Reply #7 on: May 18, 2006, 11:07:13 AM »
Hi

#NEW SCRIPT ver 1.2
#
# Changes:
# - you can write topic texts to the ah_opd.txt file.
# - also notes after the groups and objects are supported.
# - it's possible to use an eye-candy hierarchy tree format.
# - some code cleaning etc.
#
# NOTE!
# The Blender Outliner hierarchy tree is still a necessary.
# Data lines MUST start with '+ ' (+ with one space).
# Group/object notes MUST start with ' #' (one space with #).
#
# Current ah_opd.txt file method is a global. Use a 'Save As...'
# to save your object or object version specific ah_opd.txt files.  

+ model, MaxDist=20000
+ objects, MaxDist=20000
      + ground, MaxDist=20000
         + ba1, MaxDist=20000 PolyID=20005 ZBias=1 # A ground cover object
      + BRR0, MaxDist=20000 # This is a Barrier group
         + pbh1, MaxDist=10000 NoCollide=0 # LOD 1
         + pbhl2, MinDist=10000 MaxDist=20000 # LOD 2

You can get new script from here

Blender screenshot


User feedback would be nice :)

Offline Easyscor

  • Plutonium Member
  • *******
  • Posts: 10891
BATTLE OF BLENDER/Python: more AH friendly .ac export script
« Reply #8 on: May 18, 2006, 02:10:05 PM »
I'm afraid you're out there on the bleeding edge right now Xjazz.  Once there's enough information posted for people to start climbing the learning curve then hopefully others will join in and share what they learn.  You can see it happening with both the TE and OE right now but look how long it took for people to feel like there was enough information to attempt things, and most don't post.

Personally I have my hands full and don't own PS.
Easy in-game again.
Since Tour 19 - 2001

Offline Xjazz

  • Gold Member
  • *****
  • Posts: 2653
BATTLE OF BLENDER/Python: more AH friendly .ac export script
« Reply #9 on: May 19, 2006, 04:06:37 AM »
NOTE!

Topic & note writing form.

Do not use exact same group and object name form if you're mention these in topic or in notes.
Example: if ah_opd.txt object name is cra1, then use Cra1 or CRA1 name form.

This prevents the script to get confused, when parsing the data from ah_opd.txt file.




Easycor

Jep, it could be like you said.

Anyhow, I hope the script will make Blender little bit easier to approach for any level AH-TE user.
At least now you make a OE ready objects without text editing.