Irrlicht binding for Perl, Python, Ruby etc.

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
sirshane

Irrlicht binding for Perl, Python, Ruby etc.

Post by sirshane »

For the past few days i've been working on a high level binding to Irrlicht called 'Venom' that should allow one to write games, etc. without having to touch C/C++ code. You can find more information at http://venom.sf.net. Below is an example showing how one would initialize the engine, load/texture a mesh and accept input using python:

----------------------------------------

import venom

class Game:
def __init__( self ):
venom.Initialize( 640, 480, 16, 0 )

mesh = venom.GetMesh( "mesh.md2" )
node = venom.CreateAnimatedMeshSceneNode( mesh )
texture = venom.GetTexture( "texture.jpg" )
venom.SetNodeTexture( node, texture )

venom.AddFPSCamera( )

venom.BindInputEvent( "key escape", self.exit )
venom.Run( )

def exit( self ):
venom.Shutdown( )

mygame = Game( )

----------------------------------------

It's a pretty simple example. Because Venom is based on an event system, you can just let Irrlicht handle everything and only call to the slower Python code when needed. This keeps performance optimal. Venom is not a direct binding to Irrlicht. There will be other features as well, such as audio and network support.

The idea here is to get rid of the 'C' factor of game development to use more productive high-level languages. I think this will make it a lot easier to write games, especially as the size of your code base increases.

If you're interested in writing a serious multiplayer online game with Irrlicht, you could look into combining Venom with Twisted, a very powerful internet framework for Python. Because Venom is an extension of Python and other languages, you can use the libraries that are native to that language for increased flexibility.

I've already made quite a bit of progress, and with some luck an official release will be out soon enough. I just thought I would let you all know what i'm working on in case you were interested. :D

-Shane
hearsedriver
Posts: 81
Joined: Fri Aug 22, 2003 12:06 pm
Location: Germany
Contact:

Post by hearsedriver »

It's very nice indeed, but there's one issue that has been discussed before: what sense does it make as long as Irrlicht is still under heavy development (< 1.0)? You will have to change a lot with the next release. Anyway, good work.

Cheers.
matthias gall, lead programmer at sechsta sinn - email matthias@sechsta-sinn.de
sirshane

Post by sirshane »

Just because it's under heavy development doesn't mean one shouldn't use it. What about all the other people using Irrlicht? Should they avoid it as well? It doesn't bother me to make changes as Irrlicht evolves, this is just what happens with open source software. Things change. A good early start is better than no start at all.
joorce
Posts: 15
Joined: Tue Oct 14, 2003 9:48 am

Post by joorce »

That's simple great.

I've wanting to use python for games from ..., well since I've found python. I'm looking forwar to see in action, but I'm at work!!!!

And I think that if you keep in sync with irrlicht releases this would very good for the engine.
Orporick

Post by Orporick »

Great

are you thinking about using SWIG to generate the wrappers interfaces? I'm using it for my job project, using a mix of C++ and Ruby code and it works great .. I've done some test with Irrlicht and Ruby using SWIG last week, and it is really nice to have access to the 3D engine from a scripting language .. now it seems that your project is doing exactly what I was doing, so I'll stop and I'll take a look at your venom .. thanks for providing it :)

Riccardo
sirshane
Posts: 31
Joined: Tue Oct 14, 2003 5:02 am
Contact:

Post by sirshane »

Right now i'm using SWIG to generate the wrapper. This might change, since SWIG doesn't allow me to use all of the language's built in features. For example, I can't use Python Tuples for vectors of coordinates, which makes things a little easier. SWIG will also make it extremely easy to add it to other languages, like Ruby. Writing wrappers by hand can be a real pain.
-Shane
joorce
Posts: 15
Joined: Tue Oct 14, 2003 9:48 am

Post by joorce »

Hi

I downloaded de cvs snapshot but I couldn't make it work. Files have text from cvs commands and extensions are messed up.

I also tried to access cvs directly but it was not possible somthing about file lock.

I would like to try this, but ...
sirshane
Posts: 31
Joined: Tue Oct 14, 2003 5:02 am
Contact:

Post by sirshane »

Sorry.. There aren't any code releases, and CVS isn't working yet. I'll get a downloadable version ready, as well as public CVS running, as soon as possible. Venom just isn't mature enough yet, and does not have a proper build system or anything. It's getting there, though.

Edit: Okay, I decided to make an official first release. The souce code is provided, but the binary has only been compiled for Linux. Also, there's no Visual Studio project files. I'll get a good build system going as soon as I can... Just visit http://venom.sf.net for the download.
-Shane
joorce
Posts: 15
Joined: Tue Oct 14, 2003 9:48 am

Post by joorce »

Hi

Any progress about this ?.

I would like to use it under Windows and tried to compiled myself but without luck.
sirshane
Posts: 31
Joined: Tue Oct 14, 2003 5:02 am
Contact:

Post by sirshane »

I haven't had much time recently to work on it. College sucks. :P

What kinds of problems did you have compiling it on Windows? I might be able to help you out, but I have very little experience developing on the Windows environment.
-Shane
joorce
Posts: 15
Joined: Tue Oct 14, 2003 9:48 am

Post by joorce »

Hi I've been messing up with venom now and then and I got some results.

I managed to compile it under windows using Msys and Mingw. If someone is interested the makeile is bellow, note that you must use swig 1.1, and you will have to adjust paths.

I have a question to sirshane, I was trying to translate tutorial 4 (Movement) to venom. How do you transalte the part about customizing your own event receiver?

Also do you plan to move to swig 1.3?

thanks in advance

--> Start of Makefile.win

AUTHOR=Shane
NAME=Test

OBJ=o

CFLAGS=-I. -I/d/Python23/include -I/d/irrlicht-0.4/include -fPIC -O3 -DHAVE_CONFIG_H
LDFLAGS=-L. -shared -L/d/Python23/libs -lpython23 -L/d/irrlicht-0.4/lib/DevCpp -lIrrlicht -lz -ljpeg
LIBS=-lm
SMC=

CROSS=

CC=$(CROSS)g++
ASM=$(CROSS)as
INSTALLDIR=/usr/bin

O=obj
BIN=bin

WHICH=python

SWIG="D:\msys\1.0\local\bin"

OBJS= \
$(O)/main.o \
$(O)/interface.o \
$(O)/gamecallbacks.o

all: interface $(BIN)/game

interface:
swig -c++ -$(WHICH) -o interface.cpp swig.i

install:
@echo Installing to $(INSTALLDIR)...
cp bin/game $(INSTALLDIR)/os

clean:
rm -f *~ *.flc
rm -f $(O)/*.o

$(BIN)/game: $(OBJS)
$(CC) $(CFLAGS) $(OBJS) \
-o $(BIN)/venom.pyd $(LDFLAGS) $(LIBS)

$(O)/%.o: %.cpp
$(CC) $(CFLAGS) -c $< -o $@

<-- End of Makefile.win
coffeefrombrazil
Posts: 4
Joined: Wed Nov 19, 2003 7:10 pm

Post by coffeefrombrazil »

Sounds sweet. Are the bindings only for Python or could one imagine maybe some Java bindings too? :)
sirshane
Posts: 31
Joined: Tue Oct 14, 2003 5:02 am
Contact:

Post by sirshane »

Java bindings will come eventually. So far I have Python, Ruby and now TCL supported. The version of Venom available for download at venom.sourceforge.net is extremely outdated. I've made so many updates and changes... You can try the newer version for download at venom.feralfox.net, which contains a working ( I hope ) build environment for Windows. I'm actually waiting for the 0.4.2 release of Irrlicht before I make an official stable release of Venom... So, hopefully it'll come out soon. :)

The new version does not use SWIG. Instead, it uses it's own code generators written in Python. I think this works a bit better.

In Venom, you don't need to write event handlers as you do in C. Venom will handle that for you.. for example, to have the game exit when the user presses the escape key, you would do something like the following in python:

venom.SetInputCallback( "keydown", "escape", sys.exit, 0 )

In Ruby, you would do about the same thing:

venom.SetInputCallback( "keydown", "escape", proc { exit } )

For GUI event handling, it's just as easy:

venom.SetGUIEventCallback( "clicked", ELEMENT_ID, sys.exit )

This way Venom can handle all the input related stuff, so you can worry about the actual game code.[/url]
-Shane
wornaki
Posts: 54
Joined: Sat Aug 23, 2003 1:18 am
Location: Argentina, South America

Post by wornaki »

Nice, but wouldn't it be better to release venom under the wxwindows license?
You can see this license at www.opensource.org. It is similar to a lgpl license with an exception that allows the distribution of works based on the library under the terms of whatever the author wants. However it is still compatible with the lgpl and the gpl. It would be a great things to use venom to make commercial apps and free software too, because it it were for me I would do both...
Just an idea. Think about it.
sirshane
Posts: 31
Joined: Tue Oct 14, 2003 5:02 am
Contact:

Post by sirshane »

Unless i'm mistaken, the LGPL should allow you to create commercial software as well. Just don't link with it statically. This shouldn't be a problem, since normally one would link dynamically with Venom anyway through the dynamic language they choose.
-Shane
Post Reply