Blender Import/Export Script?

Discuss the future of Warzone 2100 with us.
User avatar
kage
Regular
Regular
Posts: 751
Joined: 05 Dec 2006, 21:45

Re: Blender Import/Export Script?

Post by kage »

can you give me the maximum precision for floating point values in PIE5's?
User avatar
kage
Regular
Regular
Posts: 751
Joined: 05 Dec 2006, 21:45

Re: Blender Import/Export Script?

Post by kage »

minor rev 0.2.1 for pie_import.py is complete. only change is that it no longer uses glob.

known (and as of yet unfixed) issues are:
  • it does not handle filenames safely (tabs and other whitespace in a filename are not handled correctly, though the likelyhood of this problem arising are low)
  • it can parse extremely incorrect pie files (points not defined within a level, for example) when perhaps it should just fail gracefully
since, to the best of my knowledge, i don't have svn access, i'm attaching the revised version to this post. it'd help if someone could test this out on windows.
Attachments

[The extension has been deactivated and can no longer be displayed.]

User avatar
DevUrandom
Regular
Regular
Posts: 1690
Joined: 31 Jul 2006, 23:14

Re: Blender Import/Export Script?

Post by DevUrandom »

http://en.wikipedia.org/wiki/IEEE754

The german page says explicitly that 6-7 digits are ok. This should be slightly more for numbers between 0.0 and 1.0.
Generally I don't think you imo need to truncate the numbers when reading or writing.

Tell me when I shall (or am allowed to ;) ) commit the file.
User avatar
kage
Regular
Regular
Posts: 751
Joined: 05 Dec 2006, 21:45

Re: Blender Import/Export Script?

Post by kage »

every time i attach a file, it's suitable for a commit of its own. also, i've got a local git repository, so if there are any problems, it's no issue for me to seek around and branch as necessary.

yeah. a quick test shows that 1.0/3.0 produces up to 7 fractional digits with single precision floats (when converted to decimal), and up to 16 fractional digits for a double precision float.

otoh, pie's are a textual format, so the question is: do we standardized based on what scanf might do, or do something like standardized the maximum number of digits that may appear to the right of the dot, regardless of how many digits are on the left?

btw, python looks like it standardizes their floats somewhere between a float and a double (so we would have to truncate to fit into a single-precision float, but not a double), though with the right modules, arbitrary precision numbers can be used in python, not that we'd find use for that here.
User avatar
DevUrandom
Regular
Regular
Posts: 1690
Joined: 31 Jul 2006, 23:14

Re: Blender Import/Export Script?

Post by DevUrandom »

structs/blpowlab.pie fails to import with following message:
PIE version  2
basename: page-10-laboratories
ext: .png
options: ['/home/sevendays/Warzone/Gna/trunk/data/texpages/page-10-laboratories.png']
UVs [[0.695312, 0.515625](vector), [0.687500, 0.523438](vector), [0.695312, 0.515625](vector)]
UVs [[0.687500, 0.523438](vector), [0.691406, 0.515625](vector), [0.691406, 0.515625](vector), [0.687500, 0.523438](vector)]
UVs [[0.847656, 0.515625](vector), [0.843750, 0.515625](vector), [0.843750, 0.523438](vector)]
UVs [[0.074219, 0.429688](vector), [0.074219, 0.472656](vector), [0.097656, 0.414062](vector)]
UVs [[0.074219, 0.332031](vector), [0.136719, 0.328125](vector), [0.074219, 0.472656](vector)]
UVs [[0.070312, 0.472656](vector), [0.007812, 0.335938](vector), [0.070312, 0.335938](vector)]
UVs [[0.101562, 0.335938](vector), [0.074219, 0.332031](vector), [0.074219, 0.390625](vector), [0.101562, 0.394531](vector)]
UVs [[0.070312, 0.335938](vector), [0.058594, 0.335938](vector), [0.058594, 0.390625](vector), [0.070312, 0.390625](vector)]
UVs [[0.074219, 0.335938](vector), [0.101562, 0.335938](vector), [0.101562, 0.390625](vector), [0.074219, 0.390625](vector)]
UVs [[0.757812, 0.589844](vector), [0.917969, 0.589844](vector), [0.917969, 0.566406](vector), [0.757812, 0.566406](vector)]
UVs [[0.843750, 0.523438](vector), [0.843750, 0.523438](vector), [0.843750, 0.523438](vector), [0.839844, 0.523438](vector)]
Traceback (most recent call last):
  File "", line 149, in load_pie
IndexError: array index out of range
Tip: Output the name of the failed file to the console, if possible.

For other files it worked well, so I commited it. (r1541)
User avatar
kage
Regular
Regular
Posts: 751
Joined: 05 Dec 2006, 21:45

Re: Blender Import/Export Script?

Post by kage »

DevUrandom wrote: Tip: Output the name of the failed file to the console, if possible.
i haven't even looked through half the code yet, but i'll see what i can do.

EDIT: blpowlab.pie has a bsp stack, which may be the cause of the problem.
Last edited by kage on 20 Jun 2007, 01:07, edited 1 time in total.
User avatar
Terminator
Regular
Regular
Posts: 1077
Joined: 05 Aug 2006, 13:46
Location: Ukraine
Contact:

Re: Blender Import/Export Script?

Post by Terminator »

what about export ?
Death is the only way out... sh*t Happens !

Russian-speaking Social network Group http://vk.com/warzone2100
User avatar
kage
Regular
Regular
Posts: 751
Joined: 05 Dec 2006, 21:45

Re: Blender Import/Export Script?

Post by kage »

EDIT: i looked at pie_export.py and found no division ops without a float as one of the first operands, which theoretically leaves the __future__.division feature unused. only change to that file is that the __future__ import line is commented out. it should operate exactly as before for anyone who didn't have problems with it, and should now work for windows users. lmk if there are any problems.

i haven't had time to test this, and i have to go for a while, so i thought it'd be thoughtful to post the revision earlier rather than later.
Attachments

[The extension has been deactivated and can no longer be displayed.]

Last edited by kage on 20 Jun 2007, 04:08, edited 1 time in total.
User avatar
Terminator
Regular
Regular
Posts: 1077
Joined: 05 Aug 2006, 13:46
Location: Ukraine
Contact:

Re: Blender Import/Export Script?

Post by Terminator »

I dont know may be I'm noob or doing something wrong but again no exports & no imports. not that not that dont want t work :-[

first is import last consle log is export.

Code: Select all

Compiled with Python version 2.5.
Checking for installed Python... got it!
PIE version  2
basename: page-12-player buildings
ext: .pcx
options: []
Traceback (most recent call last):
  File "<string>", line 107, in load_pie
IndexError: list index out of range
PIE version  2
basename: page-8-player buildings-bases
ext: .png
options: []
Traceback (most recent call last):
  File "<string>", line 107, in load_pie
IndexError: list index out of range
PIE version  2
basename: page-8-player buildings-bases
ext: .png
options: []
Traceback (most recent call last):
  File "<string>", line 107, in load_pie
IndexError: list index out of range
PIE version  2
basename: page-14-droid hubs
ext: .png
options: []
Traceback (most recent call last):
  File "<string>", line 107, in load_ie
IndexError: list index out of range
Traceback (most recent call last):
  File "<string>", line 53, in fs_callback
ValueError: face has no texture values
//Edit (Giel): swap picture for text block
Last edited by Giel on 20 Jun 2007, 14:00, edited 1 time in total.
Death is the only way out... sh*t Happens !

Russian-speaking Social network Group http://vk.com/warzone2100
User avatar
DevUrandom
Regular
Regular
Posts: 1690
Joined: 31 Jul 2006, 23:14

Re: Blender Import/Export Script?

Post by DevUrandom »

kage wrote: EDIT: i looked at pie_export.py and found no division ops without a float as one of the first operands, which theoretically leaves the __future__.division feature unused. only change to that file is that the __future__ import line is commented out. it should operate exactly as before for anyone who didn't have problems with it, and should now work for windows users. lmk if there are any problems.
Modified script commited.
User avatar
kage
Regular
Regular
Posts: 751
Joined: 05 Dec 2006, 21:45

Re: Blender Import/Export Script?

Post by kage »

version 0.3 of the import script is half way done... it allows for gui selection of the texpage, and will accept pie5's. the snag i hit is the way that blender handles gui stuff in a seperate thread -- any attempts to block the main script thread also block the gui thread, and there doesn't appear to be any "block until gui exits" option for the non-floating gui stuff, which means i need to rewrite very large sections of the import script.

the good news is that pie_export.py v0.2 is done. as requested, it now provides a gui for setting the pie version -- you do this indirectly by setting the floating point precision (precision of 0 will create a "PIE 2", while anything else will create a "PIE 5"). note that only points will be given any extra precision at the moment, since i'm not sure how you want to handle texture coords. precision defaults to 0 (old pie format) since, afaik, pie 5 support in the engine is still lacking.

EDIT: afaict, pie_import should already support loading of arbitrary-precision points, so it's at least compatible with the latest version of pie_export.py
Attachments

[The extension has been deactivated and can no longer be displayed.]

Last edited by kage on 29 Jun 2007, 06:55, edited 1 time in total.
User avatar
DevUrandom
Regular
Regular
Posts: 1690
Joined: 31 Jul 2006, 23:14

Re: Blender Import/Export Script?

Post by DevUrandom »

Commited in r1631.
User avatar
kage
Regular
Regular
Posts: 751
Joined: 05 Dec 2006, 21:45

Re: Blender Import/Export Script?

Post by kage »

because of the way i need to go about the gui stuff for pie_import.py, it was easier to just write a general-use serial parser for pies from scratch. works kind of like sax does for xml, but isn't constrained by requiring callbacks. it can be imported as a module or run directly with a filename argument for an example of its capabilities.

only known bug is that it assumes that the convention of one statement per line is a requirement, though afaict, wz itself only cares about "whitespace". breaking this convention in a pie makes it difficult to comprehend, though, so i don't consider it much of a bug.

EDIT: i did find some bugs in pie.py related to the handling of incorrect pies, and the fixes will alter the order of output a bit, so if anyone is actually messing around with this yet, know that it's broken and will change.
Attachments

[The extension has been deactivated and can no longer be displayed.]

Last edited by kage on 06 Jul 2007, 22:02, edited 1 time in total.
User avatar
kage
Regular
Regular
Posts: 751
Joined: 05 Dec 2006, 21:45

Re: Blender Import/Export Script?

Post by kage »

fixed the problems i found with pie.py -- error handling is much better, now has optional bsp support for the hell of, and output is fundamentally different from the previous version (hence the change from 0.1 to 1.0).
Attachments

[The extension has been deactivated and can no longer be displayed.]

User avatar
DevUrandom
Regular
Regular
Posts: 1690
Joined: 31 Jul 2006, 23:14

Re: Blender Import/Export Script?

Post by DevUrandom »

The pie.py is not an import/export plugin, but a "library" to be used in future versions?
Post Reply