27/03/2008

Graphing SQLAlchemy Models

Here is a little function to draw a nice graph of your SQLAlchemy tables and foreign keys. Just pass it a MetaInfo instance.

import pydot

def graph_meta(meta, filename="dbgraph.jpeg"):
    d = pydot.Dot()
    nodes = {}

    for table in meta.tables.itervalues():
        n = nodes[table.name] = pydot.Node(table.name)
        d.add_node(n)

    for table in meta.tables.itervalues():
        for c in table.c:
            for fk in c.foreign_keys:
                e = pydot.Edge(nodes[table.name], nodes[fk.column.table.name])
                d.add_edge(e)

    d.write_jpeg(filename)

25/03/2008

Python vs The World

Bleh I really should post more often but Im just not "blog-minded". Ive got a new job since last time, back to php - oh no! ehehe. I even promised I wouldnt try and convert them to Python... guess what?! One and half days later theyre considering switching to Python :) Find out tomorrow morning, wish me luck ;)

What have I learnt from 2 days of php developing again? Its still just as rubbish, the language is horrible and whatever the framework page may say, its not quick, its not good, and its certainly not clever. If your still in php land get off your arse and learn something new! If you discovered php and thought, "hey this is so much easier that XXXX!", maybe you can experience that feeling again.

Anyway, enough of that.. you can find plenty of php bashing ( and if you look hard enough some python devs saying the good points about php ) on the internet.

Something about python... Its pyweek in 5 days! #python3d is going to enter its own group. http://groups.google.com/group/python3d/browse_thread/thread/9827b6b1ac2e7beb for more.

Id like to write some interesting python tidbit now but I cant think of the last interesting thing I found ...

30/11/2007

Long time coming...

Havent posted in a looong time but thats me :) Iv probably had a new job and all sorts since the last post and have had little time for fun. Im quite an expert in wsgi and related things now as well ;) Something in the works in an ajax rpg.

30/04/2007

A very simple profiler

I needed a very simple and quick profiler - this is what I came up with. Youll notice its very like a C define, oh well :)

from time import time

PROFILE_STACK = []

def BEGIN_PROFILE(thing):
    ind = "  " * len(PROFILE_STACK)
    PROFILE_STACK.append((thing, time()))
    print "%sBEGIN_PROF %s" % (ind, thing)

def END_PROFILE():
    thing, start = PROFILE_STACK.pop()
    ind = "  " * len(PROFILE_STACK)
    print "%sEND_PROF %s = %.3f" % (ind, thing, time()-start)

You simply wrap blocks of code in BEGIN_PROFILE('some string ident') and END_PROFILE() and it will print the execution time.

Im still fighting with pywracer physics unfortunatly and now Im vaguely tempted to try my hand at a golf game. There arent any free golf games! ( unless we count neverputt )

20/04/2007

Not very interesting...

Wow what fun! No - infact. Altho I have swapped in a new config backend for saving data, updated the model exporter and created a nice easy way to insert instances into levels! Here's what the level designer looks like:

Main Window:
Instance Manager:

Dont ask me why those text labels are different colors, seems to be a weird bug in blender ( couldnt possibly be me ;)

19/04/2007

Building textures

Ive created some building textures using blender! Its not very difficult you just need to use Ortho setting for the camera. I think its also possible to create normal maps this way ( see this tut ).

Here are the results:

15/04/2007

The Power of the High Pass Filter

This is a tutorial I spotted at blendernation and its great! The tutorial is from gamasutra here.

Gimp users fear not - ideasman even posted a gimp script for a high pass filter in the comments of the blendernation post. The script is here and should be placed in ~/.gimp-2.2/scripts on linux.

The results are great, lets see if I can make some nicer looking buildings now :)

14/04/2007

Pywracer in Color

Since the last post:
  • Color UV textures
  • Fading out of detail texture
  • Lots more buildings

10/04/2007

Pywracer video

Ive never done this before but this should be a YouTube video of pywracer..

09/04/2007

Let there be instances

Baked in-place instances - yay! The instances are linked from other .blend files via blenders library stuff. With my export script you can "bake" the instances ( which copies all the linked meshes to real meshes ) and with these you can bake the lighting as they are in the scene. Blimey... That screenshot was also baked with Ambient Occlusion ( which is nice ) - a nice advantage of using blender :)