Latest Posts

Topic: Blender 2.5 Alpha2

Kiscsirke
Avatar
Joined: 2009-12-16, 13:40
Posts: 42
Ranking
Pry about Widelands
Location: Budapest, Hungary
Posted at: 2011-04-25, 23:14

Oh, and one question as well: In the old script for player colors, if an object had no materials, it was turned black, and if an object was in the Group 'PlayerColor', it was whited out. Is it OK if I consider these behaviours deprecated, and expect all objects to have a material, and that player color is represented only by material?

It seems to me that those old possibilities aren't used too much (at all?) and they are more ugly, so I would gladly deprecate them, but if they are needed, I think I can code them face-smile.png


Top Quote
chuckw
Avatar
Topic Opener
Joined: 2010-03-15, 16:23
Posts: 945
Ranking
One Elder of Players
Location: New York - USA
Posted at: 2011-04-26, 00:56

@Kiscsirke I will most happily check out your (Python 3?) script! It is very good to hear from you again. face-smile.png

To my knowledge of the existing Blender models, player color is currently invoked only via materials, so I believe it would indeed be feasible to deprecate the old behaviors in the rendering script(s). Besides, at this juncture, i.e. migration to a new version of Blender and Python, we can certainly rewrite the manual procedures for graphics development if required.

I'll try to test out your script in the next day or so.

Cheers!


I see little people.

Top Quote
SirVer

Joined: 2009-02-19, 15:18
Posts: 1445
Ranking
One Elder of Players
Location: Germany - Munich
Posted at: 2011-04-26, 11:28

I reviewed the branch you did and it seemed good to me. However, I am not at all comfortable with the blender api to be sure. I encourage further testing face-smile.png


Top Quote
Kiscsirke
Avatar
Joined: 2009-12-16, 13:40
Posts: 42
Ranking
Pry about Widelands
Location: Budapest, Hungary
Posted at: 2011-04-27, 15:52

So, here I'll reply to Chuck's post on the bugtracker, because it's gonna be pretty long, and I think it's more permanent on the forum than on the bugtracker. But first, some technical details face-smile.png (Prepare for long rant. Concrete problems will be at the end face-smile.png )

SirVer wrote: I reviewed the branch you did and it seemed good to me. However, I am not at all comfortable with the blender api to be sure. I encourage further testing

I think so far no one is comfortable with the new blender API, parts of it are still under development. (I just read up on it this weekend, I'm no expert myself either face-smile.png ) Now I want to stick with my approach, that there is only a small loader script inside the blender files, and the real script is loaded by that. This is, so if I change the script, I only need to change one file, and not all the blend files. Now, of course this didn't help, because from 2.4 to 2.5 they renamed the Blender python module from 'Blender' to 'bpy', so we need to change the inner script in all blend files, which will make a ~800 MB commit on the media bzr, but I don't think it can be helped. But the new loader script only uses that the filename is at "bpy.data.filepath", so I hope that will stay the same for some time. (Blender can try to keep track of outside files itself, but that doesn't really work when the files are moved around, for example, it thinks that I have one script at 'C:/Users/Chuck/...', that's why this loader script is needed.)

One new thing with the new version is, that if you 'Register' a script, it runs when you load the file (which puts in the menu in the Render box). This could be a security vulnerability, they say, but I don't think that's too serius, beacuse

  • You don't really understand python, so you would just run it anyways, no different than if it runs automatically.
  • For this to be a problem, they would need to change the 'menu_b25.py' file into a virus, which would need to be a pretty specific attack against the Widelands team, that I don't think likely.

Sooo I don't think this is a problem, but I thought it fair to warn you face-smile.png

One more thing, I'm almost sure I can make a script in blender/python that changes the "old" inner scripts to the new one in all the .blend files, so that wouldn't need to be done by hand.

Problems

And now for the actual problems and possible solutions, in order of importance and the chance that I'll solve them face-smile.png

  • Numbering of files: This is the most serious problem. This happens because with the new script, I don't do the animation rendering 'myself', I just call blender's 'render animation' command, and I think that makes more sense. (I also use the original blender settings for other things as well, like the extension of the images, unlike the old script which always put out PNGs.) But, the animations so far were made so that they are from frame 1 to frame X (not from frame 0), and the blender command names the files according to that. I see 3 possible solutions:
    • We already do some post processing on the files before they get into the game (resizing, for example), so they could be renamed then.
    • We move the frames back one step when we do the first re-rendering of an old file (so the animation will be from frame 0 to frame X-1), by hand.
    • I might be able to move all the animations back one frame with a script, but I haven't looked into how that could be done. If it is possible, it could be ran together with the script changing script mentioned above.
    • Probably I could program animation rendering by hand, like in the 2.4 script, but I think that's stupid.
  • 'Rotate to this orientation' button: should be easy, will do.
  • Progress indicator: As I said, if you run blender from a console, you can see the progress as images are finished. (You can toggle console's visibility from Help -> Toggle system console.) As for some kind of graphical indicator, I tried to do that, but either it's not possible yet, or it is not documented. By downloading the blender source code and digging around in there I could probably find a way, but they also said that that part of the API is still in development and not stable, so I think it's better to wait with it. I hope the current way will be okay until then.

Top Quote
chuckw
Avatar
Topic Opener
Joined: 2010-03-15, 16:23
Posts: 945
Ranking
One Elder of Players
Location: New York - USA
Posted at: 2011-04-27, 17:25

Kiscsirke wrote: I think so far no one is comfortable with the new blender API, parts of it are still under development...

I agree with SirVer and don't see value in pursuing a migration in earnest until the Blender API is finally stable. However, what we are learning through Kiscsirke's exercise is most valuable indeed and will help in the formulation of a final conversion/migration strategy.

One new thing with the new version is, that if you 'Register' a script, it runs when you load the file (which puts in the menu in the Render box). This could be a security vulnerability, they say, but I don't think that's too serius, beacuse

You don't really understand python, so you would just run it anyways, no different than if it runs automatically.

Very true. Well, I'd likely run it ONCE anyway. face-smile.png

For this to be a problem, they would need to change the 'menu_b25.py' file into a virus, which would need to be a pretty specific attack against the Widelands team, that I don't think likely.

Sooo I don't think this is a problem, but I thought it fair to warn you

Perhaps there are additional measures that can be taken to secure the scripts if this exposure is considered untenable, but this IS open source after all.

One more thing, I'm almost sure I can make a script in blender/python that changes the "old" inner scripts to the new one in all the .blend files, so that wouldn't need to be done by hand.

Bless your heart. face-smile.png

Problems

Numbering of files: This is the most serious problem... ...I see 3 possible solutions:

We already do some post processing on the files before they get into the game (resizing, for example), so they could be renamed then...

Of the options mentioned, I think I would prefer a post-processing procedure that would mitigate the need for altering anything but the python code in the models. In fact, I have done batch renames of rendered files for certain models from which I wished to use a subset of the total renderings (mostly out of ignorance of features that may be inherent within Blender itself.) There are freeware utilities we could use or if need be perhaps someone could write a stand-alone Python script. face-wink.png

'Rotate to this orientation' button: should be easy, will do.

Hurrah!!

Progress indicator:

I wouldn't want you to waste calories on this one. The console should be adequate.


I see little people.

Top Quote
SirVer

Joined: 2009-02-19, 15:18
Posts: 1445
Ranking
One Elder of Players
Location: Germany - Munich
Posted at: 2011-04-28, 07:32

Hi,

[Loader script idea]

I agree that this is the way to go. The one big commit can't be helped. Maybe we should add documentation for --lightweight checkouts for bzr which work a lot like SVN (you only load one commit and you need internet access for pretty much everything you do in the repo)

[Security concerns]

This risk is negligible for us as far as I understand. A maliciously crafted script would need to make it into our repository. The same danger is in widelands itself: every developer could try to sneak malicious code into widelands and commit it. So we shouldn't worry too much. I agree though that this is quite a strange approach from the blender people to 'registering' scripts. Will not be long before we have Blender Macro viruses in the open I guess.

Numbering of files: This is the most serious problem. This happens because with the new script, I don't do the animation rendering 'myself', I just call blender's 'render animation' command, and I think that makes more sense. (I also use the original blender settings for other things as well, like the extension of the images, unlike the old script which always put out PNGs.) But, the animations so far were made so that they are from frame 1 to frame X (not from frame 0), and the blender command names the files according to that. I see 3 possible solutions:

I support the approach of calling blenders rendering function instead of manually rendering everything.

Good work! Nice to see some progress here already face-smile.png

Holger

Edited: 2011-04-28, 07:32

Top Quote
chuckw
Avatar
Topic Opener
Joined: 2010-03-15, 16:23
Posts: 945
Ranking
One Elder of Players
Location: New York - USA
Posted at: 2011-08-21, 20:48

Once again, I apologize for dropping out of site for a while, but I'm back and I would like to hear if anyone knows the current status of the Blender 2.5x Python API.

I have just posted in another thread that I will now consider accepting work from non-2.49 Blender models.

Are we any closer to migration?


I see little people.

Top Quote
kingcreole

Joined: 2010-12-18, 12:13
Posts: 93
Ranking
Likes to be here
Location: germany
Posted at: 2011-08-22, 11:10

http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/changelog_259#Python_API: only 3 lines changed since last blender release and the warning changed from red to white saying

Note

The Blender Python API has areas which are still in development.

The following areas are subject to change.

   operator behavior, names and arguments
   mesh creation and editing functions

These parts of the API are relatively stable and are unlikely to change significantly

   data API, access to attributes of blender data such as mesh verts, material color, timeline frames and scene objects
   user interface functions for defining buttons, creation of menus, headers, panels
   render engine integration
   modules: bgl, mathutils & game engine.

live is my dancefloor as long as my lag works

Top Quote
kingcreole

Joined: 2010-12-18, 12:13
Posts: 93
Ranking
Likes to be here
Location: germany
Posted at: 2011-08-22, 11:11

heres the link: http://www.blender.org/documentation/blender_python_api_2_59_0/


live is my dancefloor as long as my lag works

Top Quote
Kiscsirke
Avatar
Joined: 2009-12-16, 13:40
Posts: 42
Ranking
Pry about Widelands
Location: Budapest, Hungary
Posted at: 2013-01-22, 03:18

Wow, I dropped out of the site for a short while too, eh? Are you still here Chuck? face-smile.png

Aaanyway, I did it! I added the rotation, made a script to change it in all the .blend files, and ran it. The results are here.

The python interface did indeed still change a bit since 2.57, but that only needed like 2-3 lines of change. This works with 2.65 now.

There were a few files I couldn't change, because they had external dependencies that weren't checked in to bzr. For example, Chuck, you didn't check in the textures like "\media\tribes\atlanteans\texture\00003.jpg" for the atlantean buildings, so most atlantean buildings are 1) missing their wood texture, 2) have the old script because I couldn't change them. Also two empire buildings missed files like "C:\home\alexiade\storage\widelands\empire_forester_1.png". But everything else worked, so for example all workers and animals and such! face-smile.png

There were also some conversion messages displayed by blender, like "?????? Texture couldn't be updated, look in Help for how to do it", but I think that can be handled if those exact files are ever needed?

So, anyway, sorry for the long absence, take a look and merge if you like. I'll try to stay present for a while here face-smile.png

PS.: Also, sadly the file sizes also increased from the version conversion, my branch is now almost 5 GB (with the bzr extra), I don't know how that could be helped face-upset.png


Top Quote