Experimental PyPRP

Announcements and discussion regarding any projects related to Cyan Worlds' Plasma Engine including (but not limited to) CyanWorlds.com Engine, Drizzle, OfflineKI, PyPRP, and libHSPlasma.

Experimental PyPRP

Postby Sirius » Wed Apr 22, 2015 12:10 pm

Hey everyone,

I was wondering whether people would be interested in an alternative version of PyPRP for Blender 2.7.

You see, I'm playing with procedural terrain creation, and Plasma is a good engine to explore the output, but the old Blender interface and API are really getting on my nerves. So the other day I thought I would try to see how hard it would be to port PyPRP to newest versions of Blender.
Answer: it's tricky as hell. It's a mess since both the Blender API and the Python version changed in Blender 2.7, which means twice as much work to repair everything. That, and having to reinstall newest PIL and PyYaml into Blender's integrated Python module.
I was about to let go, but after meddling with it for 4 hours, I though it would be a waste (plus... you know, it's still fun to do). So I didn't give up and finished it ! (more or less).


Obviously, it will be made redundant by Korman when it comes out, but meanwhile I thought some people might like having access to the source code.

It's not perfect - animations, for instance, don't work yet. I might add that later (hopefully soon), but I've been busy lately, and didn't need it in my test Age. I'll probably fix more things when I find the time (since it's easier to access the API, I might try tweaking/adding some features to make Age building easier).
The rest of the basic stuff - multitexturing and AlcScripting, seem to work fine.

So, if you want, I can upload this version to Github or something. It's not yet ready for big Ages with a lot of content (at least, not until I fix animations), but you can at least export visual stuff, kickables, wavesets, or journals. Also, anyone looking to contribute is of course welcome.
User avatar
Sirius
 
Posts: 957
Joined: Mon Jul 26, 2010 4:46 am
Location: France

Re: Experimental PyPRP

Postby cskid13 » Wed Apr 22, 2015 12:43 pm

I would love to see this. In fact, I'd probably get back into writing if this existed.
cskid13
 
Posts: 227
Joined: Tue Feb 01, 2011 4:19 pm
Location: Eder Tsogal

Re: Experimental PyPRP

Postby Deledrius » Wed Apr 22, 2015 5:06 pm

If you're going to work on a massive re-write of PyPRP to work with the newer Blender versions, it might be worth a look at starting from PyPRP2. It was a pre-Korman attempt at doing just that, relying on libHSPlasma to do most of the heavy lifting, saving the effort of rewriting all of that import/export code and behind-the-scenes logic. It largely just needs to be hooked up to the Blender API/UI, I believe, which is what you'd be doing with a fork of PyPRP anyway.

Either way though, this would be really useful. I can't stand using Blender 2.49. :x Upload what you have as a branch on your Github fork and people can try it out! :D
User avatar
Deledrius
Gehn Shard Admin
 
Posts: 1014
Joined: Mon Oct 01, 2007 1:21 pm

Re: Experimental PyPRP

Postby Sirius » Sat May 02, 2015 3:13 am

Sorry for not replying earlier to this topic, life's been keeping me quite busy lately...

cskid13 wrote:I would love to see this. In fact, I'd probably get back into writing if this existed.
Glad to hear it ! I just wish it were the case for more people...

Deledrius wrote:If you're going to work on a massive re-write of PyPRP to work with the newer Blender versions, it might be worth a look at starting from PyPRP2.
Isn't Korman intended to be the massive rewrite for newest Blender ? :P
No, the original idea was just feeding the scripts to a Python 2x to 3x translator, and then replace any call to Blender's API by their new equivalent (even though it was a bit more work than expected). AlcScript remains the same, and only minor changes in the interface are intended: either to rebind options to new buttons in Blender, or because I didn't like some options and wanted a simpler alternative*.
Rewriting it to use HSPlasma sounds like more work, and I'm not sure I want to bother.
However, I did have a look at PyPRP2 to get an idea of how to write plugins using the newest API... This was a time saver.


*:
For instance, shadow casting is off by default, since I never use it and it's annoying to untick the button. Plus, it makes it easier to bake lightmaps**. Of course, some people might not like these modifications, which is why they are contained to this version of PyPRP (working on two versions of PyPRP and two APIs is already complicated enough, which is why I don't create a separate branch for these modifications either).

**:
Ideally, the user wouldn't have to mess with Plasma's materials anymore, they would just setup the scene to render correctly in Blender, and my lightmap baking script would take care of the rest. I'm in no rush to finish the script, though, since the topic didn't get much replies anyway.



Now, I finally uploaded the new files to GitHub. Animations still don't work, but I fixed a few more things since the last post.

Here is a small guide to installing it (hopefully I made it simple enough for anyone to follow). Note: I tested it using Blender 2.71, it might not work with previous versions. Later versions should.

Installing PyPRP:
First, grab the ZIP file from the GitHub repository, and uncompress it. Inside it, copy the PyPRP folder. Navigate to your Blender "addon" directory (C:/Program Files/Blender Foundation/Blender/2.71/scripts/addons), paste the PyPRP folder there.

Installing PyYaml and Pillow (previously PIL):
Alright, I don't know the "proper" way to do this, but this one worked for me. (if anyone has a better idea, I'm all ears.)
The issue is that PyYaml and Pillow will only install on a "valid" Python install, meaning it probably won't like Blender.

Find the Python version used by Blender (change one of the views to "Python interactive console", the version is on the first line. Mine is 3.4.0, since it's Blender 2.71).
Download and install the Python installer for your version (don't forget: download the correct version if your version of Blender is 64bits). Install it anywhere you want.
Download PyYaml and Pillow (make sure they match the Python version used):
http://pyyaml.org/
https://pypi.python.org/pypi/Pillow/
Install these two.

Go to Python's installation directory (probably something like C:/Python 34). Open the "Lib" directory.
Copy the two folders: "PIL" and "yaml"
Now, go to your Blender install directory (something like C:/Program Files/Blender Foundation/Blender), browse to <Blender's root folder>/<Blender's version>/python/lib/,
and paste the two folders there.


Activating PyPRP in Blender:
This is done the same way as it was done in PyPRP2. Change one of the views to "User preferences". Go into "Addons > Import-export", and find the one named "PyPRP exporter".
Tick the checkbox next to it, wait until it is loaded. Switch back to the 3d view, and hit Ctrl-U to save your preferences (otherwise it will be disabled once you restart Blender).
You should have a new export option, as well as two new menus in the Add menu.
(if not, click Window > Toggle System Console, there is probably an error message written in the window that pops-up)



Short guide to using it:

Since a lot of Blender's interface changed, I had to find workarounds for some of the buttons that disappeared.
Also, I modified some of the default options. It was all done to fit my tastes, but you're welcome to suggest any change, of course.

Short list, from what I remember:
- ACTOR button (used to force the object to use a Coordinate Interface):
now bound to Object > Display > Axis. Animated objects should now automatically get a CoordinateInterface, to avoid unfriendly crash logs in-game.
- Object properties (type=region, etc):
now as custom properties in the Object panel
- Shadow casting is entirely disabled. People never understood they had to disable it, or always forgot to turn it off.
This can bring even the most recent computer to its knees. Since only kickables may have a reason to cast shadows,
the only way to enable them now is via AlcScript.
- Specularity:
now it's always disabled for shadeless objects, since it's quite heavy. To tell the truth I don't even know if it has a
performance impact when the object receives no light, but you know, "just in case".
- Lightmaps:
you must check either the "Ambient" or "Emit" button in the texture panel to enable them (I wasn't sure which was the most appropriate,
it was "ambient" before, but "emit" might look better in the 3D view...)
- Physics:
now in the physics panels (obviously). Making something collidable requires pressing the "Rigid body" button
(no, despite its name, it's not the "collision" button - it's tempting to use it, but it does not offer enough options such as friction).
Beware: by default, Blender's setup and how it's hooked to PyPRP makes the object a kickable. The object can be made static by
setting the type to Passive (or simply disable the "Dynamic" checkbox, that's 1 less click).
Don't forget to change the collisions type to "Mesh" for exact collisions.
- mesh faces:
no real change in the interface here. However, it's worth noting you can use polygons of any number of vertices now - it's no longer limited to tris and quads. UVs and colors will be handled correctly.
(this was a pain to code, the API modified a LOT of things around faces and UVs.)
- sum files:
these are now empty. Reason: I often modify my Ages after they are exported, and don't want to update them.
- not working yet:
animations will cause an error on export. Ladder regions might work, but AutoLadders will end up anywhere in the Age. Some other logic options might not work either.



Last note: in one of the Ages I exported with this version of the plugin, I crash whenever I switch to 3rd person with dynamic shadows enabled :shock: To be able to use third person, I have to disable shadows in the F4 menu. The other Age is fine, though.
Does anyone know why ?
User avatar
Sirius
 
Posts: 957
Joined: Mon Jul 26, 2010 4:46 am
Location: France

Re: Experimental PyPRP

Postby Rabbit » Sat May 02, 2015 9:20 am

This may be a stupid question, but will this enable Ages to be imported into Blender?
Rabbit
 
Posts: 89
Joined: Fri Jul 25, 2008 11:25 am

Re: Experimental PyPRP

Postby Sirius » Sat May 02, 2015 9:56 am

Rabbit wrote:This may be a stupid question, but will this enable Ages to be imported into Blender?
That's a clever question, actually. I forgot to mention it, but no, it won't allow you to import Ages. Once again, that would require a lot of work to adapt it to Blender's newest API (also, this version of PyPRP is based on the exporter one, not the importer, which means it would also require merging the two).

I felt it was less important, since even newest versions of Blender can open files from the 2.49 version. The other way around (building in 2.7 to export with 2.49) is not possible, which is why I was focusing on it.


Oh, and before I forget: currently, this version of PyPRP only allows you to export "All as full Age". I didn't bring back the other options yet (such as All as PRP, or Per-Page Textures), although it should be relatively simple to do.
User avatar
Sirius
 
Posts: 957
Joined: Mon Jul 26, 2010 4:46 am
Location: France

Re: Experimental PyPRP

Postby cskid13 » Tue May 12, 2015 12:14 pm

Do you think this will be a short or longer-term project? I'm trying to decide whether to wait for its release before beginning writing again, or whether to start in 2.49 and transition to 2.7.
cskid13
 
Posts: 227
Joined: Tue Feb 01, 2011 4:19 pm
Location: Eder Tsogal

Re: Experimental PyPRP

Postby Sirius » Tue May 12, 2015 1:28 pm

Important note, unrelated to Cskid's question: in case you already downloaded this version of PyPRP, you MUST redownload the latest version again (however, since nobody had the issue, I take it that nobody experimented with it yet).
The previous version had a TexCache reading bug, meaning some textures would randomly fail to be included in Uru, causing a crash upon linking to the Age. (I didn't notice it before because it doesn't always happen). The current version should be fine.

Now, back to Cskid's question...
cskid13 wrote:Do you think this will be a short or longer-term project? I'm trying to decide whether to wait for its release before beginning writing again, or whether to start in 2.49 and transition to 2.7.
Honestly ? I don't know. I don't think it will be a really long-term project (since Korman would eventually replace it), but on the other hand there are still some things left to fix - animations, for instance. I work on it when I feel like it, or when I need it to build something specific, and I'm fixing bugs as I go. But otherwise I can't tell when it will be fully functional as the "old" PyPRP will.

You can still download it from the GitHub link I provided above, and install it if you want - installation might be a bit tricky, but you can ask here for help.
Some features are still missing, so right now some AlcScript might not work, and animations will prevent the Age from exporting. If you're mainly focusing on visuals, it should be fine.
If you want some of the currently non-working features, you can still start with old Blender 2.49, then transition to 2.7 at a later time. Blender 2.7 opens older 2.49 files just fine, so only minor modifications will be needed before exporting with the new version (such as re-enabling physics for collidable object, since the button is not the same in both versions).


Anyway, got this to export using this plugin the other day.
Show Spoiler

This is one of my three test Ages, and also the smallest. I like it, though: it's hard to see in the picture, but lights are automatically baked thanks to my lightmapping script (I fixed a lot of things in it recently), and wavesets look pretty cool now. I got them to look exactly like I wanted at first export - I've been studying how wavesets work recently, and learned a lot. The picture cannot show it, but there are some very nice "long-length" waves, along with the smallest disturbance on the water's surface.
User avatar
Sirius
 
Posts: 957
Joined: Mon Jul 26, 2010 4:46 am
Location: France

Re: Experimental PyPRP

Postby Sirius » Wed May 13, 2015 6:58 am

Double post ! :D

Animations now working !
I found enough time today to fix all animation-related code ! Things you can now animate:
  • object location, which is probably the most important
  • light color
  • light energy (this wasn't present on version for Bl249, but was easy to add)
  • material color
  • material opacity
  • texture offset
  • texture scale

To use the latest version, just re-download the scripts from Github, and put them into Blender's addon folder. Nothing else required.
Setting up animations is done just the same way as it used to be in Blender 2.49, so no big surprise there.


Things that still need to be fixed, or may not work:
- "Generated" texture mapping might not work (I don't remember if it did in the 2.49 version). Always use UV mapping and unwrap your meshes.
- non-mesh collision types might not work (sphere and box should, but I've experienced issues with ConvexHull on kickables).
- AvatarWalkable flag is on by default for most physical objects, which may not be required - I don't know what will happen if it's set for non-walkable objects.
- auto ladders still don't work. Normal ladders should, theoretically.
- using AlcScript to create puzzles is still untested, as I don't have any scene of such complexity.

If you're using it and experiencing crashes or weird behaviors, feel free to report the issue ! I'll do what I can to fix it :D
User avatar
Sirius
 
Posts: 957
Joined: Mon Jul 26, 2010 4:46 am
Location: France

Re: Experimental PyPRP

Postby cskid13 » Wed May 13, 2015 10:19 am

In that case, I will start with 2.7. I can test the AlcScript, too.
cskid13
 
Posts: 227
Joined: Tue Feb 01, 2011 4:19 pm
Location: Eder Tsogal

Next

Return to Plasma Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron