I'm studying physics at the University of Vienna and trying to get into OpenGL/GLSL programming lately. I began to mod Freelancer some years ago and lastly I joined the Universe Modding Crew that focuses on modding Sci-Fi games. Our current project is "Stargate: Revenge of the Fallen", a Stargate mod for Battlefield 2142. Besides, I try to develop a Spacesim-Engine that can simulate (special) relativistic effects in a realtime application. (Check out my YouTube channel: Copycap) Hopefully I will update progress on both on my Blog. :) If you have questions, feel free to contact me via Email or Jabber (I actually don't like ICQ/MSN ;)

RSS My Blogs

Xen and WinXP

Bl00drav3n Blog

So after over one day of investigating, configuring and trial&error I finally got Xen to create a virtual windows machine. Our root server is running on Debian Lenny and I tried out the BF2142 Linux dedicated server on it, but because I could not get it to run our Mod, we decided that we'll need a Windows machine. So we uploaded an image of a Windows XP Pro Service Pack 2 onto the hostmachine and I tried to configure the domain. At the moment it looks like that:

#
#  Kernel + memory size
#
kernel      = '/usr/lib/xen-x.x-x/boot/hvmloader'
builder     = 'hvm'
memory      = '2048'
vcpus       = 2
device_model= '/usr/lib/xen-x.x-x/bin/qemu-dm'

shadow_memory = 8
acpi = 1
stdvga = 0
serial = 'pty'


#
#  Disk device(s).
#
disk        = [
                'phy:/dev/vg-xen/win-disk,hda,w',
                'phy:/dev/vg-xen/win-data,hdb,w',
                'file:/etc/xen/winxp/winxp.iso,ioemu:hdc:cdrom,r'
              ]

boot='c'

#
#  Hostname
#
name        = 'host'

#
#  Networking
#
vif         = [ 'type=ioemu, ip=x.x.x.x, bridge=x' ]

#
#  Behaviour
#
vnc=1
vncviewer=1
sdl=0

The most difficult part to figure out was the vif part, because of some restrictions of our server provider. The virtual machine gets its own local IP adress space and a friend told me how to tell iptables to map incoming IP requests on adress x.x.x.x to the local network space of the virtual machine (and vice versa). The connection between the local network and the internet is set up with a bridge that acts as the gateway for the windows machine. I had to manually create a bridge, but that was an easy part with Debian's brctl tool.

So after that worked, I could log in with a VNC Client and I was happy since the first thing I saw was the Windows Setup Screen. After the setup was complete, I just turned on Windows' remote control tool and deactivated VNC access. This was the first time I used Windows Remote and I'm pretty happy with it - it integrates well into the local system and is much MUCH more handy than a VNC Client.

Now came the time to install the BF2142 v1.5 Server files. The first thing that I noticed was, that EA/Dice was lazy AGAIN, because the msvcp71.dll and msvcr71.dll were not shipped with the installer. On the Microsoft homepage is said, that one MUST ship these files, because they need to be compiled by the developers and are not part of any framework. That made me pretty mad, because I searched for about an hour for a nice solution to this: I installed visual c++ runtime libs, tried out .net framework v2.0 and v4.0 but the files were not there. At the end I just decided to download the dlls from dll-files.com. So once again, THANK YOU EA/DICE! :P
Well, after that, I started the server, but I could not connect to it: Connection lost, everytime. I do not have a clue what was wrong, but after I was mad about the thing AGAIN, I just decided to restart the machine et voila: suddenly I could connect to it...

Okay, after this problem was out of the way, another one arised. The server performance was way too low. After inspecting the virtual machine, I realized, that ping.exe returned some crazy negative numbers when pinging other hosts, but I had no clue what was wrong. First I thought that the Windows performance is so low because of Xen. But after some google search, I stumbled on a thread regarding dual core machines and WinXP. First I just thought, that this would not help me with the problem, but then I read something interesting on the Microsoft Support Page:

KB938448 wrote: When you use the ping command to send Internet Control Message Protocol (ICMP) packets to a remote computer, the reply may show negative response times.

Exactly my problem! And we've got an Intel Core i7 and no Win2003 Server... I don't know if the CPU is causing that issue, or if it is Xen, but the problem was, that the cores were not synchronized. So the solution to it was to append the following switch to the Windows boot.ini: /usepmtimer

After a quick reboot now the astonishing result: it worked! Server is running at good performance and my ping is lower than 40 ms. Now the last thing I got to do was to let our Mod Leader Lantian configure the server and upload the mod files. Everything's working good now, so we may not have to rent another gameserver just for the mod in future. Well, and after that's done, my work with the server is close to be finished. We now got three virtual machines running on the Debian-Xen dom0, one acting as mod repository for developing, one as the webserver and one as the gameserver. The webserver is hosting the Board, a Developer Blog, an official Jabber-Server/Chat and an MTA, for which I have to get receving Emails done. But now that everything's working fine, I can finally move back to work on the RotF Mod. I really want to make all the icons appear ingame, because some weapons still haven't got any, and I think some animations already need to get done.

See you next time!

Python and HUD Builder Project

Bl00drav3n Blog

So I started to get into python by reading some basic tutorial to learn the syntax. I'm not an python expert now, but I can get things working, and that's all that I want for the moment. In near future it will definitly be a good idea to be able to connect python and C++, 'cause Battlefield's .tweak and .con files are all written in python-like manner.

Some days ago, I started to alter the F302's HUD for testing purposes and I found it annoying to edit all nodes and variables by hand with a text editor (though vim is a big improvement from blank notepad). So I decided to write a GUI Tool in Python, that will let us develop new HUDs easily. I'm using wxPython for my GUI. The reason why I'm using python is just the same fact as stated above: the hudfiles are mostly simple python-scripts. There you have something like the following code:

hudBuilder.createSplitNode		VehicleHuds F302Hud_Base
hudBuilder.setNodeLogicShowVariable 	EQUAL GuiIndex 700

hudBuilder.createSplitNode		F302Hud_Base F302Hud
hudBuilder.setNodeLogicShowVariable 	EQUAL GuiIndex 700
hudBuilder.addNodeBlendEffect		7 2

hudBuilder.createPictureNode		F302Hud F302LeftFrame 147 105 136 390
hudBuilder.setPictureNodeTexture 	Ingame\Vehicles\Icons\Hud\Air\Attack\gunship\EU\leftFrame.tga
hudBuilder.setNodeColor		 	1 0.706 0 1

This is just a code snippet from the current F302Pilot-HUD. As I understand that, the script uses a hudBuilder-class (probably a wrapper class), where you can attach several different nodes with specific variables. With that hudBuilder you build up a tree containing all the nodes. So what I'm doing now is just the same: I used a wx.TreeCtrl object and added a rootnode, than the user can do a right-click onto the node and choose from several options, for example "Add Node". A list shows up and the user can select which node to be added to the selected node. The nodes will later be linked with other GUI-Objects, that will be displayed in the actual Program-Window, that represents the player's screen. For example the PictureNode will be coupled with an object that holds that picture and can be moved to a specific position (by mouse or keys, or just autoset). I did not think about the actual implementation now, it may get a bit tricky, but I hope I can get it to work as I want.

What I'm working on at the moment is some kind of "properties-window\" that shows the node's logical and other variables. This should hopefully not be such a big problem. The thing where it will get a bit nasty is file i/o. It should be possible for the user to at least save the whole tree in the .con format that the hudBuilder class can understand and interpret right. At the moment I have no idea how I will implement that, I did not look up python's I/O routines yet, just got a little idea of it. After I completed the "saving" part, it may be easy to implement an actual "loading" routine, so that existing trees can also be loaded back into the program. Would be stupid if the program would not offer that task.

I have much more things going through my mind and I got a pretty good idea of what the program should look like at the end, so hopefully I will be able to get this done quick so I can return back to the MapExplorer Project - there are also the first animations to be done for the mod, so got a bunch of work to do. See you next time!

Battlefield Map Explorer Development

Bl00drav3n Blog

For about 6 months now I'm a member of the Universe Modding Crew, a small modding team that has a big interest in science fiction. At the moment we are developping the Battlefield 2142 Stargate-Mod Revenge of the Fallen, and I'm acting there as programmer and scripter, but I'll also do some of the needed animations later on. Though my main interest lies in programming, and I found it a good idea to start to put some effort into a future tool with the great name Battlefield Map Explorer. With this tool I want to make it possible to edit minor subjects like Flags-Position, or spawnpoints without the need of starting the unhandy and overloaded BF2 Editor. I want the tool to provide the user a window where the terrain geometry is shown in 3D using OpenGL (I really like that API!), and a simple GUI that makes it easy to read out objects-positions or other varialbes from object templates on the map. Maybe I'll work with a python C++ implementation later on, to get the thing really dynamic, but I don't know if I've got time to do so.

For the moment, I just got one module I call the Heightmap Viewer to work. What it does is simply letting you specify a heightmap and some additional data like map-size or stepping (it's basically used to determine how many pixels cover one polygon, the lower the stepping, the higher the accuracy is, but the performance suffers from it). I also implemented the I think in BF not so common 8Bit heightmaps, to achieve some kind of generality when it comes to heightmaps. After my first implementation I got an average framerate of about 70 FPS with 16-stepping on the Suez Canal map (using ATI HD Radeon 4870), but the algorithm to create the geometry was very slow. Because this was just the basic terrain geometry and I want to implement a GUI and maybe other objects on the map, this was not acceptable. I then wanted to try out (for the first time) the concept of OpenGLs display lists, so I created two lists on program start, one defined as wire-grid-mode and one as solid-quads. And I was overwhelmed by the performance win: I got about 600 FPS when in solid-mode and about 400 FPS in wire-mode! So after I partied for about 3 minutes, I started to search for a cool GUI API. Because I knew that there were problems implementing OpenGL windows into wxWidgets and GTK from my previous "projects", I searched for something new. And I found the NUI3 API Libnui.net that provides a fully hardware accelerated crossplattform GUI with "easy" OpenGL window implementation. This GUI offers a Interface that is called the nuiGLUTBridge, that let's you connect the GUI to a (free)glut application. I decided to switch from the Code::Blocks IDE to Microsoft's Visual Studio 2008 (which I find is not as bad as it was some years ago when I first tried it out... it still gets on my nerves eventually) because there are VS2008 projectfiles that are fully configured to download from the libnui website.

So I finally got the thing to work after some initial MS-specific... issues... And I could start to test out the tutorials. I really like the API, it's easy to understand if you just want to make simple GUIs. Then I tried out this glutBridge with my Heightmap Viewer, but the result everytime was just a black screen. And now the drawback of the API comes into play: I could not find a good documentation for it. There is this nice doxygen-tool that provides an API documentation, but that does not help me understanding the connections between all of the modules. So I just posted onto the forums and happily the creator of the API answered to my post. I'm still working on this issue on Windows, but as I have no Windows for about a week, I ported the project to my netbook that runs on Arch Linux (nice little distro, KISS principle). And today after some hours of programming effort I got it to work. Now I have the Heightmap Viewer in the background and a nice GUI overlay with five buttons (they are just decoration for now though). Now the last issue that remains is the problem, that I don't now how to connect callbacks to the button's signals when they get pressed. I do not know how the API eventloop is implemented in the glut-environment or if it is implemented there at all... I just posted a quick question on this onto the nui-forums and I hope I get a request on that soon.

So a quick list of what works for the moment:

  • Specifying a Heightmap and some parameters related with it to view it in the Heightmap Viewer
  • Displaying the Heightmap in hardware accelerated 3D together with the nui-API
  • Zooming in/out (further camera movements are the next on my todo list)
  • Switching betweend grid and solid mode
  • Change the stepping without to reload the heightmap (the display lists get recompiled though

For the camera movements I plan something similar to the BF2 Editor, namely the Soldier mode where the camera snaps to the ground and the free-flight mode. Hopefully I get the GUI working soon, so that we can use the tool in our current mod project to speed up the development.