Tuesday, 22 March 2011

Project 1 Final - MicroBreath

I have decided to go with the micro-organism looking thing from my pre-3D code, with a few modifications. I really like where the 3D stuff is going but I feel like it is more suited to project 2, and could be really interesting when further developed.

I call this project MicroBreath, because it is based on the idea of a micro-organism breathing, and what we are looking at is its bizarre alien cells expanding and contracting.

There are many interactive controls to change the pattern, but the default pattern is the designed one. There are mouse controls and keyboard switches, all commented in the code.

Thursday, 17 March 2011

Generative/Addictive Photography

I find this compelling for much the same reason I find exploring and photographing Minecraft worlds compelling; no one has seen what you are seeing, nor will they. Like the sand mandalas made to demonstrate the Buddhist ideas of impermanence, it wafts into being, and wafts away again just as easily. It has not been before, nor will it be again.

MUST. STOP. TAKING. SCREENSHOTS. AND. GO. TO. BED.


 


 




Worlds, Piecemeal

It turns out that making all the fold angles the same between each shape results in something that tends towards a sphere. Who knew?

How can I sleep when my computer is churning out things like this:

Flower Power

In the interests of a diverse blog, here are some older experiments using JP's 'flower' code (that's what I call it anyway) as a starting point.











I particularly like this last one, it seems like the glowing strands of a micro-organism. Quite an ethereal, fibrous quality to it.

OpenGL Can Speed Things Up

On my five year old gaming PC, using OpenGL to render my scenes speeds things up a lot.

This is probably because it has a lot of graphics horsepower that is going to waste, and OpenGL enables hardware acceleration. Even with a purely 2D scene, I can get 6 FPS average on a program that runs at 4 FPS using the default Processing renderer. This much difference at low FPS is pretty big, another test I ran for high framerates confirms that it scales well (28 FPS vs 49 FPS with OpenGL). It obviously depends on your machine, but might be worth a shot.

To use OpenGL, add it to the size() function where you declare the size of your display window, like this:
size(600, 600, OPENGL)
EDIT: As JT kindly pointed out to me, P3D gives a much smoother look than the other renderers. This comes at a performance cost though, so might be good for screenshots. In my test I got 20, 28 and 49 FPS on P3D, Default and OpenGL renderers respectively.

Polygon Paths

Here's a peek at some of my 3D experiments so far.

I had this idea for randomly generated 'molecules' spiralling past the screen, with some kind of appropriate background, representing a bloodstream or liquid system at the microscopic level. I also was curious about 3D, and though I have learned an awful lot from creating this, there is a lot to keep track of in a 3D program. The idea of placing the coordinate system somewhere and then drawing a shape is quite strange, although it seems flexible enough.

More on this idea as it develops.




Sunday, 6 March 2011

Super Useful Screenshot Code

Don't ask me how this works, the save function isn't even on the Processing reference as far as I can tell. It must have been forged long ago by some very clever dwarves, because it even contains the power to encode in a specific image format based solely on the extension you chuck on the file name. I think Ben Jack told us about this save() function in 142, and I made my own version to create unique file names based on a timestamp. Here is the code.

Firstly, the special keyPressed() function to capture key presses (83 is 's'):
def keyPressed():
        k = keyCode
        if k == 83:
                screenshot()
Then, the screenshot function itself:
 def screenshot():
        days = str(day())
        hours = str(hour())
        mins = str(minute())
        secs = str(second())
        filename = "screen" + days + hours + mins + secs + ".png"
        save(filename)
Screenshots will show up in the same folder as the code file you are running.

V is for Vortex

There are many possibilities with this code, especially once the process of modifying wave parameters is sped up. Like I did last summer in 142, I added a bunch of global variables into the mix to control various parts of my equations, and used the mouseDragged() and keyPressed() functions to hook keyboard and mouse commands into those variables. This means I can experiment with different parameters and see results in real time, which is both efficient and remarkably entertaining.

 Anyway, pictures from the latest craziness today. I enjoy how the secondary waves come into the pattern in different ways, and how three-dimensional everything looks, especially in motion.





Friday, 4 March 2011

Parametrics - Spirals



Tips for Python Processing on Windows

Since our method of running python processing code on windows is far from ideal, I struggled through improving a few things about the experience and thought I might share them. This stuff is in addition to Richard's initial setup document.

Setup jEdit to recognise .pyp files as Python files.
This is so you will get properly highlighted code when opening your .pyp files in jEdit.
  • Go to Utilities > Global Options
  • Editing
  • Select 'python' in the first drop down box
  • It might be useful to turn on Soft Tabs while you are in here (not related)
  • Add 'pyp' to the 'File name glob:' area, so it now says '*.{py,pyp,pyw,sc,jy}'
  • Apply
  • Ok
Make a macro to run your code.
Running it by navigating through that menu is tedious for me. I made a macro that does the same console commands as the pyp.xml, so you can run them with one shortcut key. Here's how:
  • Grab my macro file (Download)
  • Put it in your .jedit\macros\ folder (see Richard's tut, this is in C:\Documents and Settings\Username\ for me on XP)
  • Open the macro in jEdit.
  • Edit the pyp variable to be the path to your processing-py
  • Save
  • The macro will now show up at the bottom of your Macros list.
To assign a keyboard shortcut to your macro:
  • Utilities > Global Options
  • Shortcuts
  • Choose Macros in the 'Edit Shortcuts:' dropdown
  • Find your macro
  • Click in the Primary Shortcut box next to it
  • Enter a shortcut
  • Ok, Apply, Ok
Now you just need to use your shortcut to run the code, much faster!

Beware that it saves the file before running it. This is because making changes to the file without saving will result in you running the old version of the code, so you really always need to save before running anyway. It's a dangerous way to work in some ways, but things are setup like this at school on TextMate anyway, so get used to it.

Hope this helped!