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 ;)

Report RSS Battlefield Map Explorer Development

Posted by on

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.

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: