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 »

DevUrandom wrote: The pie.py is not an import/export plugin, but a "library" to be used in future versions?
exactly. it solves the problem i'm having with blender's gui thread quirkyness. atm, there's not much reason to commit in, but as soon as i finish my updated version of pie_import.py, pie.py will have to be somewhere in python's library path for it to work.

i'm also taking requests for either the import or export script. after i finish the next version of pie_import.py, i plan on adding the option of each LEVEL end up in a seperate blender "group" as opposed to just being a seperate mesh, which is useful for frame-based animations, but not useful for ani-based animations (hence the user selectable option).
User avatar
kage
Regular
Regular
Posts: 751
Joined: 05 Dec 2006, 21:45

Re: Blender Import/Export Script?

Post by kage »

the gui additions (among other things) to pie_import.py are almost complete... i'm just having to work out some texturing issues on some models.

EDIT:

fixed the texturing issues... just a few more things to do.

also, i found out the problem with blpowlab.pie... not all of its polys are valid -- starting at line 104 of that file, several polys reference the same point twice -- as in a triangle with two unique points isn't really a triangle anymore... my guess is blpowlab is not actually used in warzone. suffice it to say, the import script will check for this and ignore such polygons.
Last edited by kage on 10 Jul 2007, 09:00, 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 »

i'm getting very close to release, and am just dealing with teamcolors/connector issues -- right now polygons that reference the same point twice will have one of those references replaced by a newly generated point, so it'll look messed up when you load it, but at least it'll load as much info as possible. once you get me that info about how it should work, i'll try to make a fix to do it the warzone way.

in the specific case of blpowlab.pie, it's obvious that was done in something like 3dsmax quickly before deciding that it wouldn't be used in the game and was subsequently abandoned -- i can say this because those polygons that are normal aren't stitched together quite right, and the model as a whole could be a lot simpler and look better at the same time
User avatar
Terminator
Regular
Regular
Posts: 1077
Joined: 05 Aug 2006, 13:46
Location: Ukraine
Contact:

Re: Blender Import/Export Script?

Post by Terminator »

btw. Yesterday I installed Maya8.5 at first time :) so there was something connected with python . May  .py plugins work there ?
Because MAya a little better than blender ( as for me).
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 »

given the gui additions, and theoretical pie 5 support, i'm calling this version 1.0. too much changed for me to remember, and still outstanding is the issue that the teamcolor code assumes 8 frames: fixing that will be my next priority, and i have at least one definite fallback approach for that, if i can't find a cleaner and more flexible method.

EDIT -- partial changelog:
  • each level now has a more fitting name -- the mesh of level 2 will now be named PIE_LEVEL_2. eventually that may be shorted to just LEVEL_2, but in either case, export levels is probably not supported atm (will be soon, though).
  • likewise, connectors are named "CONNECTOR_1", "CONNECTOR_2", etc. i don't recall if this is a new addition, but i did remove the import constraint on the number of connectors (used to discard all but the first 3 connectors) since things might be different now with watermelon's multi-turret support, and/or may change in the future to support more than 3 connectors.
  • will automatically find all close texpage matches based on the filename, and will always allow you to choose between alternatives or add new alternatives before import
  • any PIE errors (malformed points, for example) will be reported at the end of import and an option will be given to save the import log to a file. pie.py was designed to be an error-resistant parser, and pie_import.py will do its best to import pies as cleanly as possible, even very broken ones, but will never violate some structural constraints (for example, while parsing polygons, if a non polygon is encountered before it is expected, it will discard any further polygons until the next valid LEVEL -> (POINTS, POLYGONS) block is encountered). eventually, i plan to add support for loading that discarded data into a seperate mesh, so that you have a "clean and trusted" mesh and a "clean data + best guess data" mesh for every level.
  • pie 5 support: should load floating point points in all cases, and if PIE 5 is encountered, texture coords will be expected to be in the [0.0-1.0] range.
  • should handle pie 2 coords like warzone does, regardless of actual texture size, though this is fairly untested.
  • teamcolor code was changed to work in a way i can understand: don't know how you did it before, but my hat goes off to whoever created that teamcolors import hack in 0.2 or earlier of pie_import.py.
export script also doesn't export pie 5 texture coords, so that will need to get fixed. have tested it moderately on linux, but haven't done full tests after each change. could use some mac and windows (and other unix variant) testers.

one other note: pie_import.py will need pie.py accessible somewhere in the python path, and will need the attached version of pie.py (not the older one from a previous post). putting both pie_import.py and pie.py in blender's scripts/ dir (within your home directory or if need be in the install path) should be enough to satisfy this requirement.

oh, and devurandom: blpowlab.pie will load now, though i'm don't know how warzone is supposed to interperet polygons that reference the same point more than once, if indeed that is valid, so for now, it just generates fresh points as needed in such instances.
Terminator wrote: btw. Yesterday I installed Maya8.5 at first time :) so there was something connected with python . May  .py plugins work there ?
Because MAya a little better than blender ( as for me).
that's cool. it's almost certain that these scripts won't work with maya, since they're specifically designed for blender, but they could probably be ported to maya's interface -- especially the earlier versions of the import/export scripts (before gui additions).  pie.py would probably speed up development of a from-scratch version if porting would be too difficult.
Attachments

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

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

Last edited by kage on 14 Jul 2007, 12:18, 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 »

More PIE5 specs as worked out with Grim. (More or changes will probably follow.)
- 768 vertices
- 512 polygons
- 6 vertices/polygon

A note on the last one: Older versions of the engine (2.0.7 at least, don't know whether this ever was changed) support up to 10 vertices/polygon. This was cut since apparently no model in current WZ uses this and Grim said it would lead to bad design, too. Grim even said 4 should suffice fully and for the model part it seems to work, just the terrain renderer bails, so it may be that this will be further cut to 4 when the issues are fixed.

The files are commited in r2085.
User avatar
kage
Regular
Regular
Posts: 751
Joined: 05 Dec 2006, 21:45

Re: Blender Import/Export Script?

Post by kage »

okay. i think even 4 vertices would be a sensible maximum, and as a rule, modellers should use triangles whenever the quad doesn't fit within a single plane. splitting polygons is something i don't want to do in a script, so i'll just leave it to the modeller to do that.

one suggestion for the pie 5 spec: since, afaik, there does not yet exist a pie 5 model that's being used, or close to being used, and we're already having texture coords fit within the [0.0-1.0] range, why not have pie 5 texture coords start from the bottom left instead of the top left, to be fully compatible with opengl? to this end, i could easily make a converter script that'd change pie2 coords to bottom-left pie 5 coords and back again, for pie slicer users.
User avatar
Terminator
Regular
Regular
Posts: 1077
Joined: 05 Aug 2006, 13:46
Location: Ukraine
Contact:

Re: Blender Import/Export Script?

Post by Terminator »

At last this release is working fine in winBlender2.44 . but didnt test with textures. Anyway this will be like a buffer program for 3DMax.

& what about export plugin ?
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 »

cool. good to know it's working well in windows (if it doesn't give any script errors, it's probably working with full functionality). at the moment, the export script will handle PIE 2's (set "precision" to 0 when you export), but it may still need tweaking in pie slicer for things like connectors, and definitely tweaking for teamcolors or animations with more or less than 8 frames. since my next release of pie_import.py will fundamentally change a few things around, i'll wait until i'm done with that before i update pie_export.py. hopefully, my next release of both shouldn't take nearly as long as this last one.

regardless of which future version of the scripts you use, the important thing to remember when using blender as a proxy for another 3d editor like 3ds max or maya is that the export script will ignore objects and groups not named correctly, so starting with the next pie_export.py version, it will search for any groups named "PIE_*", and will choose a default export name based on that, so when you export to pie, and if you have two groups named "PIE_DRLBOD01" and "PIE_PRLLTRK1", it'll try to export two pie files at once: "drlbod01.pie" and "prlltrk1.pie", respectively. within each group, it will only look for objects named "LAYER_*" (like "LAYER_1", "LAYER_5", etc) and "CONNECTOR_*" ("CONNECTOR_1", "CONNECTOR_2", etc), so if the editor you want to use doesn't support a method of object/group naming, or even a method of storing objects/groups that is compatible with blender's 3ds, maya, or any other import script, then you'll have to do such tweaking in blender. naming objects and groups is not difficult once you learn the most basic subset of the interface -- if anyone needs help, i can give direction for this sort of thing.

also, addition to the changelog for pie_import.py v1.0:
  • each LEVEL in warzone will have its own visible layer in blender -- all LEVELs will be visible on layer 1, while also having their own layer in the range of 2-19 (LEVEL_1 will be in visible layers 1 and 2, LEVEL_5 will be in layers 1 and 6, etc). LEVEL_19 and later, if they exist, will only show up in layer 1.  layer 20 will be reserved for the "best guess/broken" meshes i plan to support in future versions. note that layers in blender aren't used or otherwise significant in pie_export.py or any other script i'm planning on adding -- it's just layered like that for your convenience.
User avatar
DevUrandom
Regular
Regular
Posts: 1690
Joined: 31 Jul 2006, 23:14

Re: Blender Import/Export Script?

Post by DevUrandom »

kage wrote: one suggestion for the pie 5 spec: since, afaik, there does not yet exist a pie 5 model that's being used, or close to being used, and we're already having texture coords fit within the [0.0-1.0] range, why not have pie 5 texture coords start from the bottom left instead of the top left, to be fully compatible with opengl?
Now I know why my float patch looks so funny...
Yes definitely, fully GL compatible texcoords please. :)
User avatar
kage
Regular
Regular
Posts: 751
Joined: 05 Dec 2006, 21:45

Re: Blender Import/Export Script?

Post by kage »

sweet.

EDIT:
another suggestion for PIE5: since there is already some form of support for multiple turrets, but as far as i know there is no support for orienting and limiting the range of movement for specific turrets, we should at least add support for such things and ignore such data until we're ready for it; i propose that pie CONNECTOR directives should be given 3 extra fields for 3 degrees of rotation, specified in radians. this would determine the "at rest" direction of the turret -- specifically it would affect how warzone draws turrets, and should either be supported with duplicate data in one of the data txt files, or warzone could pull such "really affects gameplay" from these connectors.

the suggest connector might look like:

Code: Select all

0.0 2.0 1.0 0.0 0.0 1.5707
  x   y   z   l   v   o
with l, v, and o representing "Lateral" (rotating around x), "Vertical" (around y), and "lOngitudinal" (around z) axes, respectively. values for the last 3 values should be in the range of [0-2Pi) (not including 2Pi). additionally, it'd be very nice if pi could be used as a suffix, so instead of the above, you could use:

Code: Select all

0.0 2.0 1.0 0.0 0.0 1.0pi
whose rotation components would yield similar results to having the second connector at those same coordinates for a PIE2 model (vtol rendering).

eventually this could be coupled with min/max rotational info in a data txt file to accurately simulate turreted warfare.
Last edited by kage on 15 Jul 2007, 06:00, edited 1 time in total.
User avatar
Watermelon
Code contributor
Code contributor
Posts: 551
Joined: 08 Oct 2006, 09:37

Re: Blender Import/Export Script?

Post by Watermelon »

kage wrote: sweet.

EDIT:
another suggestion for PIE5: since there is already some form of support for multiple turrets, but as far as i know there is no support for orienting and limiting the range of movement for specific turrets, we should at least add support for such things and ignore such data until we're ready for it; i propose that pie CONNECTOR directives should be given 3 extra fields for 3 degrees of rotation, specified in radians. this would determine the "at rest" direction of the turret -- specifically it would affect how warzone draws turrets, and should either be supported with duplicate data in one of the data txt files, or warzone could pull such "really affects gameplay" from these connectors.

the suggest connector might look like:

Code: Select all

0.0 2.0 1.0 0.0 0.0 1.5707
  x   y   z   l   v   o
with l, v, and o representing "Lateral" (rotating around x), "Vertical" (around y), and "lOngitudinal" (around z) axes, respectively. values for the last 3 values should be in the range of [0-2Pi) (not including 2Pi). additionally, it'd be very nice if pi could be used as a suffix, so instead of the above, you could use:

Code: Select all

0.0 2.0 1.0 0.0 0.0 1.0pi
whose rotation components would yield similar results to having the second connector at those same coordinates for a PIE2 model (vtol rendering).

eventually this could be coupled with min/max rotational info in a data txt file to accurately simulate turreted warfare.
That is exactly what I am doing right,to give a connector x,y,z rotation,to get rid of the VTOL invert hack and making another interesting stuff possible.

Another problem I want to address is the connector type,currently there is no way to tell what a connector is for,the current idea:

CONNECTOR x y z rotationx rotationY rotationZ TYPE
CONNECTOR 0.0 0.0 0.0 0 180 0 CT_WEAP_S
rotationX,Y,Z are in int because they dont need the precision of float,CT_WEAP_S means weapon connector for small weapon.

great minds think alike  :o
tasks postponed until the trunk is relatively stable again.
User avatar
kage
Regular
Regular
Posts: 751
Joined: 05 Dec 2006, 21:45

Re: Blender Import/Export Script?

Post by kage »

okay, so this is something you already started work on?

i'll submit to rotation specified in degrees for now, though if we ever do make projectiles work in even a semi-physics-simulated way, then we really will need that floating point precision, as otherwise the projectiles will always miss when they have a long enough range (such as in the case of artillery) because of rounding issues. to put it simply: the extra precision can't possibly hurt, and it's easier to change the source code to handle model data, then to change all the models to meet changing conditions. if pie5 can be seen as a progressive update to the format, we might as well go overboard in terms of precision, imo.

what exactly are you suggesting in terms of "TYPE"? hardpoint size to be used with design-window selection, or something like "ground"/"vtol"? if it's the former, then i think that it should be in bodies.txt, but if it is used for connector grouping, such as specifying that points 1 and 2 are for ground weapons, and 3, 4, and 5 are for vtol weapons, then i agree that it should be in the pie.
Watermelon wrote:

Code: Select all

CONNECTOR 0.0 0.0 0.0 0 180 0 CT_WEAP_S
don't you mean this?

Code: Select all

CONNECTORS 1
   0.0 0.0 0.0 0 180 0 CT_WEAP_S
and just making sure, in your own example, vtols should have the 180 as the zrot value instead of the yrot value (yrot would just have it pointing backwards).
User avatar
DevUrandom
Regular
Regular
Posts: 1690
Joined: 31 Jul 2006, 23:14

Re: Blender Import/Export Script?

Post by DevUrandom »

There was also this idea to provide a maximum size for a connector... No idea what the final conclusion about this was. But I think Grim et al said that it is not a bad idea.
Post Reply