Additions to track exporter

Additions to track exporter

Postby asciimonster » 03 Jun 2010, 23:10

I've been busy adding support for writing the materials.xml file in the track exporter. I think I have it more or less working now.

To install:
* Unzip files
* Replace the files in the blender scripts directory (don't forget to back-up!)
* Run blender

To use:
* Open IDProperty browser in Blender
* In the top left, change the pull-down list furthest to the right from "Scene"to "Image"
* In the pull-down list left of it, select the desired texture
* Press the "STK" button (if not visible: the updated scripts are in the incorrect directory)
* Marvel at the menu you see! :cool:
* Select the items you want.
* Change the default values of the items you just created.
* Run track exporter.
* Check materials.xml file for correctness.

P.S. N.B. Although I thoroughly test these scripts, bugs can happen. Please make backups of the files before trying!
P.S.2. My additions in the code are marked by my "FHR"(my initials). So you can easily see what I changed.
P.S.3. STK button also works when "Scene"is selected!!! :cool: :D :cool:

Have fun.
Attachments
Blender_scripts.7z
Changes to track exporter and IDProperty browser
(17.21 KiB) Downloaded 296 times
asciimonster
 
Posts: 375
Joined: 03 Dec 2009, 18:24

Re: Additions to track exporter

Postby Auria » 04 Jun 2010, 00:49

Hi,

thanks for the contribution :) Joerg, our blender script "expert", is currently on leave so he won't be able to look at them right away; but don't worry, it's not forgotten :)
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: Additions to track exporter

Postby hiker » 08 Jun 2010, 06:31

Hi,

sounds great - I am currently flooded with stuff, but I'll have a look later.

Cheers,
Joerg
hiker
 
Posts: 1435
Joined: 07 Dec 2009, 12:15
Location: Melbourne, Australia

Re: Additions to track exporter

Postby asciimonster » 08 Jun 2010, 08:55

Welcome back, Hiker.
asciimonster
 
Posts: 375
Joined: 03 Dec 2009, 18:24

Re: Additions to track exporter

Postby asciimonster » 03 Oct 2010, 17:29

I see my changes to the track exporter didn't make it to the SVN repository. Was there something wrong with it?
asciimonster
 
Posts: 375
Joined: 03 Dec 2009, 18:24

Re: Additions to track exporter

Postby Auria » 03 Oct 2010, 18:33

I think he forgot to come back to it :) I send him a email, so he should not forget it this time

Thanks for your patience ;)
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: Additions to track exporter

Postby hiker » 05 Oct 2010, 07:15

Hi Asciimonster,

sorry for the delay - I was aware that this is still on my todo list, but never actually managed to get to it.I'll have a look soon (sorry, b ut I am currently sick so it will be a few days before I can get back to STK).

Thanks for the patience!
Joerg
hiker
 
Posts: 1435
Joined: 07 Dec 2009, 12:15
Location: Melbourne, Australia

Re: Additions to track exporter

Postby hiker » 12 Oct 2010, 06:11

Hi Asciimonster,

Sorry that it took me so long to get back to this - a great patch, thanks a lot!

I've applied the section for the track exporter to our current stk_track.py exporter in the svn repository (and I also fixed a few issues, esp. using relative filenames) - though admittedly it is kind of useless without the id property browser atm. Re the ID-property browser: I am not sure if replacing blender's id property browser completely as you have suggested is the best way. People might not want to replace a system supplied library (not to mention compatibility problems with different blender versions).

What do you think of the idea of modifying this code a bit more and turn it into a stk-track-property browser or so ... basically just remove the id properties that are not used by the track exporter, leaving only scene and images. The word 'scene' could be replaced with 'Track-wide settings' or so. That might be as simple as (untested):

{l Code}: {l Select All Code}
IDTypeModules = [[Scene, 0, "Scenes"], [Image, 0, "Images"]]


Cheers,
Joerg
hiker
 
Posts: 1435
Joined: 07 Dec 2009, 12:15
Location: Melbourne, Australia

Re: Additions to track exporter

Postby asciimonster » 12 Oct 2010, 21:38

hiker {l Wrote}:What do you think of the idea of modifying this code a bit more and turn it into a stk-track-property browser or so ...

I think that is a good idea. That way we can tune it even more to our liking and decrease the threshold for new STK designers. :)

I added a small proof-of-concept.
Attachments
STKPropBrowser.7z
(4.53 KiB) Downloaded 274 times
asciimonster
 
Posts: 375
Joined: 03 Dec 2009, 18:24

Re: Additions to track exporter

Postby hiker » 13 Oct 2010, 00:06

asciimonster {l Wrote}:
hiker {l Wrote}:What do you think of the idea of modifying this code a bit more and turn it into a stk-track-property browser or so ...

I think that is a good idea. That way we can tune it even more to our liking and decrease the threshold for new STK designers. :)

I added a small proof-of-concept.

Great that you like the idea. The code looks fine so far. Two minor things: do we actually need a 'new' button? All STK related values can be selected from the stk menu anyway. And one letter of 'graphical-effec(t)' is not displayed in the menu (even though there is space for it) - though that's rather minor :)

Cheers,
Joerg
hiker
 
Posts: 1435
Joined: 07 Dec 2009, 12:15
Location: Melbourne, Australia

Re: Additions to track exporter

Postby hiker » 14 Oct 2010, 00:59

Hi Asciimonster,

a suggestion from Arthur on IRC: would it be possible to read an existing materials.xml file? This would help in getting all settings imported.

Cheers,
Joerg
hiker
 
Posts: 1435
Joined: 07 Dec 2009, 12:15
Location: Melbourne, Australia

Re: Additions to track exporter

Postby asciimonster » 14 Oct 2010, 19:56

That is not as easy as it looks, but not impossible.

In blender, textures are defined as "Image" type objects, which holds the Filename attribute. The object name and the filename do not have to be equal. So for every file mentioned in the materials.xml file the import script needs to go through all Image objects to find the filename that matches...
I'll have to run some tests.
asciimonster
 
Posts: 375
Joined: 03 Dec 2009, 18:24

Re: Additions to track exporter

Postby asciimonster » 14 Oct 2010, 22:20

Ok. The attached python code can only be regarded as a full-on hard-core hack. I just seen it work, but still no guarantees....
(It's only for converting existing tracks anyway)

Step 1: First you need to compress the materials.xml file into a flat file, since interpreting XML with python without the appropriate libraries is HARD :shock: . Every line starts with the filename, then the attributes. All are space-separated, attribute names and its values are separated by =.
Like so:
{l Code}: {l Select All Code}
water2.png reset=Y transparency=Y
track_guiderail.png transparency=Y
Walltexture4a.png transparency=Y
Walltexture4b.png transparency=Y
Walltexture4c.png transparency=Y
Walltexture4d.png transparency=Y
Walltexture5a.png transparency=Y
Walltexture5b.png transparency=Y
Walltexture5c.png transparency=Y
Walltexture5d.png transparency=Y

No blank lines or comments!

Step 2: Throw the attached plug-in in the blender script folder
Step 3: Make copy of your blender file (Important! ;) )
Step 4: Open blender file, run "STK PB Import" from Help menu.
Step 5: Select above-mentioned flattened materials file, and PRAY! :D
Step 6: Check result with Property browser

I hope this will help Arthur...
Attachments
STKPropBrowserImport.py
Import materials into blender property browser
(2.55 KiB) Downloaded 285 times
asciimonster
 
Posts: 375
Joined: 03 Dec 2009, 18:24

Re: Additions to track exporter

Postby hiker » 15 Oct 2010, 07:16

Hi,

sounds great, exactly what we need to help us converting all tracks!

Cheers,
Joerg
hiker
 
Posts: 1435
Joined: 07 Dec 2009, 12:15
Location: Melbourne, Australia

Re: Additions to track exporter

Postby asciimonster » 17 Oct 2010, 18:51

Just a question: What is the type of the STK variables? This I can use to validate the fields...

My guess would be:
{l Code}: {l Select All Code}
Track wide:
String: name, version, groups, designer, music, screenshot, arena, sky-type, sky-texture, fog-color, fog-density, fog-start, fog-end
Float/Decimal: sky-horizontal, sky-vertical, sky-texture-percent, sky-sphere-percent, ambient-color
Integer: fog (?)

Textures:
String: clamp, transparency, alpha, light, sphere, anisotropic, ignore, zipper, reset, graphical-effect,
Float/Decimal: max-speed
Integer: slowdown


Are these correct? :|

I'm working on making pick-lists for some items, e.g. alpha=yes/no... see the work-in-progress below...

P.S. I need to find a way to format the new SFX tag in materials.xml (didn't see it before now... :?). I'm thinking of adding the variables right in the property list of the Image object; after that, changes need to be made to the track exporter... :think: Flattening nested XML structures into a flat structure is frankly a pain. :(
Attachments
STKPropBrowser.py
(17.38 KiB) Downloaded 298 times
asciimonster
 
Posts: 375
Joined: 03 Dec 2009, 18:24

Re: Additions to track exporter

Postby Auria » 17 Oct 2010, 22:06

transparency, alpha, light, anisotropic, ignore, reset can only be "Y" or "N", so they could even appear as checkboxes

You can find more types here : http://supertuxkart.sourceforge.net/Tra ... properties

@Joerg: I just realized we're ridiculous, "arena" can be "yes" or "no"; fog can be "0" or "non-0"; and we use "Y"/"N" everywhere else :?
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: Additions to track exporter

Postby hiker » 17 Oct 2010, 22:59

Auria {l Wrote}:@Joerg: I just realized we're ridiculous, "arena" can be "yes" or "no"; fog can be "0" or "non-0"; and we use "Y"/"N" everywhere else :?

Well, the track exporter just exports what the user has specified, and stk checks:
{l Code}: {l Select All Code}
s==""     || s[0]=='T' || s[0]=='t' || s[0]=='Y' || s[0]=='y' ||
s=="#t"   || s   =="#T";

Asciimonster actually added a function (which doesn't support all of the above), perhaps it would make sense to use this everywhere.

Cheers,
Joerg
hiker
 
Posts: 1435
Joined: 07 Dec 2009, 12:15
Location: Melbourne, Australia

Re: Additions to track exporter

Postby asciimonster » 18 Oct 2010, 15:04

Auria {l Wrote}:transparency, alpha, light, anisotropic, ignore, reset can only be "Y" or "N", so they could even appear as checkboxes
You can find more types here : http://supertuxkart.sourceforge.net/Tra ... properties

Thank you. Still I have some trouble interpreting the descriptions (must be my blue personality), for instance:
{l Code}: {l Select All Code}
"How much of the sphere is drawn. Value should be between 0 and 2, where 1 is an exact half-sphere and 2 is a full sphere (sky-dome only)."

Does that mean: "allowed values are 0,1, and 2" OR "allowed values range from 0.0 to 2.0"
asciimonster
 
Posts: 375
Joined: 03 Dec 2009, 18:24

Re: Additions to track exporter

Postby Auria » 18 Oct 2010, 17:45

"How much of the sphere is drawn. Value should be between 0 and 2, where 1 is an exact half-sphere and 2 is a full sphere (sky-dome only)."


Can be 0.1, 0.2, 0.3, ..., 1.0, ... 2.0 (i.e. any float in [0.0, 2.0] range)
:)
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: Additions to track exporter

Postby asciimonster » 18 Oct 2010, 22:21

Auria {l Wrote}:transparency, alpha, light, anisotropic, ignore, reset can only be "Y" or "N", so they could even appear as checkboxes

I just wanted to note that the Blender API doesn't have radiobuttons, so I'll have to be inventive...
asciimonster
 
Posts: 375
Joined: 03 Dec 2009, 18:24

Re: Additions to track exporter

Postby hiker » 19 Oct 2010, 04:36

asciimonster {l Wrote}:I just wanted to note that the Blender API doesn't have radiobuttons, so I'll have to be inventive...

Looking at http://www.blender.org/documentation/24 ... tml#Toggle shows there is a toggle button, which should be good enough - but admittedly I don't know a thing about blender's python GUI.

Cheers,
Joerg
hiker
 
Posts: 1435
Joined: 07 Dec 2009, 12:15
Location: Melbourne, Australia

Re: Additions to track exporter

Postby asciimonster » 19 Oct 2010, 17:00

Yes, but unfortunately togglebuttons aren't situationally aware, i.e. they don't "declick" themselves when another one of the group is clicked...
asciimonster
 
Posts: 375
Joined: 03 Dec 2009, 18:24

Re: Additions to track exporter

Postby Auria » 20 Oct 2010, 00:04

asciimonster {l Wrote}:Yes, but unfortunately togglebuttons aren't situationally aware, i.e. they don't "declick" themselves when another one of the group is clicked...


I don't see how that is a problem, the properties we were discussing were either enabled or disabled

Anyway, not too important! :)
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: Additions to track exporter

Postby asciimonster » 26 Oct 2010, 22:49

Update... Added all the recent changes in the wiki. Added a nice radiobutton feature (I rule!) :D

To-do: Change track exporter to allow for changes in the materials.xml format. (The nested sfx tag is not trivial!)

Two things:
- Would you add the STK property browser to the svn?
- How can I make sure I use the right svn version of the track exporter?
Attachments
stkpropbrowser.py
(28.98 KiB) Downloaded 283 times
asciimonster
 
Posts: 375
Joined: 03 Dec 2009, 18:24

Re: Additions to track exporter

Postby hiker » 27 Oct 2010, 05:47

asciimonster {l Wrote}:Update... Added all the recent changes in the wiki. Added a nice radiobutton feature (I rule!) :D

Haven't had a time to run, but I am looking forward to ;)

To-do: Change track exporter to allow for changes in the materials.xml format. (The nested sfx tag is not trivial!)

Two things:
- Would you add the STK property browser to the svn?
- How can I make sure I use the right svn version of the track exporter?

Yes, we will certainly add this to our svn repository (I'll do this as hopefully tomorrow). You want to check that the right version of the track exporter is installed on the system? I admit I have no idea. There might be some features in blender that allow us to store some application specific values (I seem to remember that the old track exporter did something like that), but I don't remember anything about this. What we could do: the property browser could but some version information in a property that's not shown to the user. The track exporter would then make sure that it is at least of that version. That wouldn't help with older version of the exporter, but it would be good enough in the near future.

Cheers,
Joerg
hiker
 
Posts: 1435
Joined: 07 Dec 2009, 12:15
Location: Melbourne, Australia

Who is online

Users browsing this forum: No registered users and 1 guest