02-07-2007, 12:24 AM,
|
|
thelusiv
Administrator
|
Posts: 2,346
Threads: 223
Joined: Jun 2005
|
|
PyGTK track editor idea
I've been doing some PyGTK programming lately, and I've found it's fairly easy to set up a pretty good GUI using it with Glade to design the interfaces. It is pretty fast and ports to OS X and Windows very easily. There are bindings for Python to OpenGL as well as SDL, PyOpenGL and PyGame respectively. How's that for link saturation?
So what I propose is to set up a GUI around a sort of viewport that will basically have inside it the track editor we already have. The gui would have lots of buttons to do things easily, like for instance add objects, move and edit them, set track parameters, export tracks to in-game readable format, etc.
The "viewport" code could either consist of the C++ code we have for the track editor now, converted to Python, or it could be set up as an external C++ library that is used by Python. Python has bindings for lots of languages so this shouldn't be too hard. However it might make the code a little more managable to just convert to Python.
Farther down the road we could probably even write code to generate road models based on user-input dimensions, and perhaps even import them directly into the editor. Perhaps we could get some ideas on how to do this from the Java-based open source TORCS track editor that generates roads.
So, what do you guys think about Python and GTK? To me, the biggest advantage for Python is how easy it is to develop things quickly, and for GTK it's the cross-platform interface designer (Glade).
|
|
02-07-2007, 11:05 AM,
|
|
reece146
Member
|
Posts: 187
Threads: 26
Joined: Oct 2006
|
|
I say go for it.
At this stage it is more important to have a user friendly tool prototyped and workable for users than going back to first principles and coding something from scratch in C/C++.
|
|
02-07-2007, 06:40 PM,
|
|
thelusiv
Administrator
|
Posts: 2,346
Threads: 223
Joined: Jun 2005
|
|
OK, I will see what I can whip up in terms of basic gui and Python code to go with it. Hopefully others will be able to pick up on it and add things. I thought Python would be a good language to go with since, as Joe said, we use it for Blender export scripts. Also, our build system, SCons, is all written in Python (and its SConscript files are also all Python). So, the more Python knowledge our team has, the better, I say...
Joe, when you mention using whitespace as a token, are you talking about how Python assumes code block nesting from indentation? At first this seems confusing to most people with C/C++ backgrounds but really it makes things way easier in the end. Not having to worry about the curly braces and what not is very nice. You just have to remember to be consistent. Personally, I do two spaces for indentation in Python.
I might get something set up tonight, it will be very basic though. And yeah reece146, this tool could be viewed as a prototype that could then be rewritten in C++ later, or if it works well enough, it could just be used as the finished product.
|
|
02-07-2007, 09:42 PM,
|
|
reece146
Member
|
Posts: 187
Threads: 26
Joined: Oct 2006
|
|
thelusiv Wrote:And yeah reece146, this tool could be viewed as a prototype that could then be rewritten in C++ later, or if it works well enough, it could just be used as the finished product.
Yep, these days computers have so much power it doesn't matter if the coding language underlying a tool is not C or whatever since the CPU can power through most things, particularly if it is a non-real-time type app running on a single user box.
Value add per user benefit and all that.
|
|
02-07-2007, 11:16 PM,
|
|
thelusiv
Administrator
|
Posts: 2,346
Threads: 223
Joined: Jun 2005
|
|
Heh yeah, but you know me, I am really picky about indentation and whitespace anyway, so it doesn't bother me much
I just checked something in to the vdrift-trackeditor repository.
To check it out:
Code: svn co http://svn.vdrift.net/repos/vdrift-trackeditor/branches/pygtk-trackeditor vdrift-track-editor
It doesn't actually do anything yet. It's just a mockup in glade and a framework for a program. It starts up and quits. It has a few functionless buttons. More to come...
|
|
02-08-2007, 12:21 AM,
|
|
thelusiv
Administrator
|
Posts: 2,346
Threads: 223
Joined: Jun 2005
|
|
To use what I added you'll need to install the following: python 2.4, gtk 2.8+, pygtk, libglade, libgtkglext, and pygtkglext. I haven't actually added the GL stuff yet but go ahead and get it.
Ubuntu 6.10: download the package python-gtkglext1_1.1.0-1_i386.deb from here, then
sudo apt-get install python2.4 python-gtk2 python-glade2 python-opengl libgtkglext1
sudo dpkg -i python-gtkglext1_1.1.0-1_i386.deb
On Gentoo, I'm not sure what the python GTK and Glade packages are called but you can get pygtkglext thus:
emerge pygtkglext
|
|
02-08-2007, 12:42 AM,
|
|
reece146
Member
|
Posts: 187
Threads: 26
Joined: Oct 2006
|
|
thelusiv Wrote:On Gentoo, I'm not sure what the python GTK and Glade packages are called
emerge -avt gtk+ libglade pygtkglext
|
|
02-08-2007, 05:36 AM,
|
|
thelusiv
Administrator
|
Posts: 2,346
Threads: 223
Joined: Jun 2005
|
|
Thanks for filling in that blank for me reece146
I've made a few more updates. I added some simple icons and an About dialog. The program now properly checks for all the libs it will need. Quitting was broken before, fixed now. I've started playing with Glade 3 and it's great! If you're still using Glade 2, I strongly suggest an upgrade (also, Anjuta 2 has Glade 3 built in, but I'm not sure how good the support is yet).
I've also started looking at GLChess, a simple PyGTK + OpenGL chess game. It's the best example I can find for using the Python 3D libraries.
By the way, PyGtkGLExt only provides the interface between GTK and GL, you still have to have PyOpenGL to do the actual OpenGL stuff. I didn't realize this before, Fortunately though most OpenGL calls are the same in Python as they are in C/C++, so it should be pretty easy to port our track/model load/display code to Python.
|
|
04-20-2007, 10:32 AM,
|
|
rookie1
Member
|
Posts: 231
Threads: 32
Joined: Nov 2006
|
|
Well, I can't get the display to work. I've wrapped all the necessary functions. Not sure where is the problem. Can I upload my changes to svn so others can take a look?
|
|
|