Categories

Navigation

MVP

Microsoft MVP (since 2006) in the XNA/DirectX category

Tag cloud

Ajax (8) All (206) Arena Wars (21) Boo (4) BroodWar (8) Conferences (1) Development (44) Game Development (142) IronPython (3) Lost Squadron (17) Lua (6) meinSport.de (4) Other (150) Polynapping (12) Programming (156) Racing Game (7) Reviews (76) Rocket Commander (49) Silverlight (10) SQL (1) StudiHelp.de (2) XNA (40)

On this page

All XNA Games converted to XNA 2.0 from Rocket Commander to the Racing Game.
Converting XNA 1.0 Projects to XNA 2.0
My XNA book is out and XnaProjects.Net launches
GDC 2007 - Dungeon Quest - Day 1
Skeletal Bone Animation and Skinning with Collada Models in XNA
XNA Shooter Game
Your Christmas Present: Rocket Commander XNA
German developer price: Deutscher Entwicklerpreis 2006 - Pics
XNA Game Studio 1.0 released
Canyon Commander Mod for Rocket Commander released!
That leaked XNA Racer Video on YouTube
Seattle Day 1 and XNA Video and Canyon Commander
Long time, no see
Quick Tips for XNA Beta 1 (aka My Own XNA FAQ)
Windows XP x64 Experiences
New Pizza Commander finished and Quicksand entertainment goes online
And another Mod: Virus Commander, this time made by a player
Pizza Commander goes commercial
Fussball Commander released
Article in german dot.net magazine
Gamestar/dev 2006-03 Title Story
Zombie Quest - A new free 2D Adventure
Links for the Webcasts
Doxygen rulez!
Reminder: Rocket Commander webcasts next week.
Pizza Commander released!
New Rocket Commander Mod: Fruit Commander and other cool Tools
English Rocket Commander Tutorials are finally up on Coding4Fun
DirectX SDK April 2006 and Quo Vadis conference pics
Quo Vadis April 6.-8. 2006
All kinds of XBox News
New Rocket Commander Site finished
Flower Commander V1.1 available and Coop Commander Preview Video
Rocket Commander V1.1 avialable now and www.RocketCommander.com launched
Coding4Fun.de Launch with the Rocket Commander and www.RocketCommander.com coming soon
CeBIT 2006 in Hannover
Coop Commander, New Arena Wars boards and Polynapping Update
Coop Commander - More screenshots
Coop Commander - First sneak preview
More Commanders
Merry Christmas and a Rocket Commander Video
Moving to Managed DirectX for .NET 2.0
Rocket Commander Beta 2
Rocket Commander Beta-Test
German developer price: Deutscher Entwicklerpreis 2005
Rocket Commander: Week 3
Rocket Commander: Week 2
Rocket Commander: Week 1
New Project: Rocket Commander

Archive

Popular

NormalMapCompressor v1...
CR_Commenter v1.7 Upda...
Reminder: Rocket Comma...
Your Christmas Present...
CR_Commenter Update v1...
The year 2005 - Review...
Seattle Day 3 - XNA Pr...
NormalMapCompressor - ...
Zombie Quest - A new f...
Cool tools
My Bookmarks
CeBIT 2006 Pictures

Blogroll

Projects

Arena Wars (2004)

Rocket Commander (2006)

Pizza Commander (2006)

Rocket Racer (2006)

Coop Commander (2006)

Flower Commander (2006)

Fruit Commander (2006)

Euro Vernichter (2003)

Lost Squadron (2005)

Zombie Quest (very simple 2D Adventure, 2006)

Freifunk Hannover project (GoogleMaps support)

Older projects (2000 and earlier)

MeinSport.de - German Sport Community Site

About

About me: Contact

Send mail to the author(s) Email:

Total Posts: 213
This Year: 0
This Month: 0
This Week: 0
Comments: 434
Made with

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

RSS 2.0 | Atom 1.0 | CDF

My brothers

netfreak.de

mirkman.de

Sign In

 Monday, February 11, 2008
Monday, February 11, 2008 11:48:36 PM UTC (  |  |  |  |  |  |  |  |  )
Even when I did not post much last week I was very busy converting all the old XNA 1.0 games to XNA 2.0. I did not only convert all projects (8 games in total, see below), but I also tested them extensively on Windows XP, Vista (32 and 64 bit) and the Xbox 360. Additionally a lot of usability improvements have been implemented in the games, for example the XNA Shooter is now much easier (was almost impossible to even reach 50% of the level) and a lot more fun due better balancing. The XNA Racing Game has now a better physic engine and will not longer let the car fly out of the track or leave ground in loopings. Due the better input control and fixed physics the cars drive now much faster and it is more challenging to complete the tracks in shorter time frames.

Games in this article:
Please read my previous post about Converting XNA 1.0 games to XNA 2.0 for all technical tips. All the games can also be found on http://XnaProjects.net, but I will also make them easier accessible on this blog soon, which has an update overdue (need to clean up the left and right sides) ^^

Thanks to the great VS2005 support of XNA 2.0 all games have now just one single solution file, which works on Windows and the Xbox 360. The projects can be opened in XNA Game Studio 2.0 and Visual Studio 2005 without having to convert the files over and over again like in the past. The Icons for all games were also improved. Lets take a look at the Icons (.ico files) on Windows:


For the Xbox 360 game icons the .png files (usually named GameThumbnail.png) are used:


Ok, let's take a look at the games and what has changed for them. Most games are pretty much the same as for XNA 1.0, but a lot of smaller bugs were fixed and they have been tested more.

  • Chapter1Game: This application is not really a game, but a test project to check out if XNA 2.0 is properly working on both Windows and the Xbox 360. It is from the first chapter of my book "Professional XNA Game Programming". BTW: The second edition of the book is coming out soon, there are 3 more chapters about Multiplayer game programming and a cool new role playing game.

  • Xna Pong: Xna Pong is a simple clone of the favorite pong game from 1978. It is just a few hunderd lines of code and should be very easy to understand.

    This game is from the book "Professional XNA Game Programming" by Benjamin Nitschke. For more information read chapter 2. (2008-02-10: Now updated to XNA 2.0)

  • Xna Breakout: XNA Breakout is a simple Breakout/Arcanoid game based on the XNA Pong game from the previous chapter.

    It is fully described and covered in Chapter 3 of my book "Professional XNA Game Programming". The code is quite short and should be easy to understand. (2008-02-10: Now updated to XNA 2.0)

  • Xna Tetris: This is a simple, but highly addictive Tetris game. You can control the blocks with your cursor keys, aswd or a game pad and the game works both on Windows and the Xbox 360. Reaching levels above 5 is really hard. My highest level was 9, try to reach more :) (2008-02-10: Now updated to XNA 2.0)

    This game introduces the helper classes (chapter 4 of my book) and makes more use of unit testing and game components in XNA.

  • Rocket Commander Xna: XNA port of the famous Rocket Commander game. The game principle stayed the same, but the controls were a little bit simplified to make it more fun on the Xbox 360.

    If you want to learn more about the Rocket Commander game, check out its official website www.RocketCommander.com and check out the Video Tutorials on Coding4Fun by MSDN. (2008-02-10: Now updated to XNA 2.0, also supports very big resolutions now and runs faster on the Xbox 360)

  • Xna Shooter: Shoot'n'up game specifically created for my book "Professional XNA Game Programming". It features full HDTV support, runs on Windows and the Xbox 360, 5 weapon types, 5 enemy types, a powerful ship and some power ups. It is quite fun to play and it gets harder and harder the longer you play. Based partly on the Rocket Commander XNA engine, but also features lots of new effects and shaders. (2008-02-10: Now updated to XNA 2.0, also much easier and balanced)

    This game and the racing game are the most improved. The game works now much better in high resolutions and on the Xbox 360. But most importantly the game is now much easier, balanced and more fun. Additionally a level percentage is now visible on the bottom and more EMP bombs can be picked up to make it easier at the end of the level.
  • Xna Racing Game: XNA Racing Game Starter Kit I wrote for http://creators.xna.com. More information and more downloads can be found on http://XnaRacingGame.com. It runs best on the Xbox 360 in HDTV (1920x1200), but it also runs fine on the PC. (2008-02-10: Now updated to XNA 2.0, driving also improved a lot, better tested on Xbox 360 and fixed some issues).

    Following things were improved: Shadow mapping on very big resolutions works now (crashed before), more options for lower quality settings, fixed physics, car now always stays on the road, fixed loopings, cars are much faster now, winning conditions work better now, and fixed several other bugs.
  • Dungeon Quest GDC: And finally the Dungeon Quest XNA Game, which was developed in just 4 days on the GDC 2007 at the XNA Contest. Dungeon Quest GDC is a relatively complex 3D role playing game (at least for just 4 days of work). An early version even supported coop multiplayer on the Xbox 360 via splitscreen. The game was developed by Benjamin Nitschke (abi.exDream.com) and Christoph Rienaecker (WAII). (2008-02-10: Now updated to XNA 2.0). This is NOT the full Dungeon Quest game (see www.DungeonQuestGame.com for that), this is just the GDC version.

    Please note that the level was reduced to allow loading on the Xbox 360 (which otherwise crashes with an OutOfMemoryException), the game is not fully playable, only the first part is implemented. You can also press F2 to toggle the Options menu and some minor bugs were fixed. But this game is no longer supported, I will not improve it anymore! Please check out the new Dungeon Quest game from www.DungeonQuestGame.com, which is coming in a month or so.
Have fun with all the games :)
 Friday, February 01, 2008
Friday, February 01, 2008 12:32:32 AM UTC (  |  |  |  |  |  |  |  |  )

When I wrote this (a little bit each day while working on converting the old XNA projects) I was very aware about the disappointment of my blog readers about the fact that I did not blog much in the last couple of months, especially on XNA. I not only got a lot of emails about that, but also quite a lot of questions, especially since XNA 2.0 was released. I made yet another promise to myself to change that and finally blog more, maybe not only when something very interesting pops up, but instead about the everyday issues I run into.

Some Notes about XNA 2.0: More solid, lots of little new features, networking, while it may not be a very complete solution, at least it is now possible on the Xbox 360 and overall I have the feeling even more people are interested in XNA than a year ago. Plus the guys at the XNA Team doing a great job and are constantly improving the XNA Creators Club website for us game programmers and artists :)


Several people had problems using the old XNA 1.0 code of my games and make them work with XNA 2.0, so here is a little help in case you want to convert XNA 1.0 projects to XNA 2.0. You will also notice this if you go to any XNA community site as most samples will still be in XNA 1.0 and not work out of the box in XNA 2.0, and many of those will probably never be changed since they are not longer actively being developed.

For most games almost all of the code can stay unchanged, you just have to poke at a few things that have changed in the framework or were improved. More information about converting projects can be found here (read this first, this article is based on the stuff there). You can also use the Cross-Platform Game Project Converter from XNA 2.0 to add a Xbox 360 project to your existing Windows XNA project without having to create a separate project (it is helpful, but I used pretty much the same trick for all of my XNA 1.0 games anyway).

Let's go through the steps:

  1. Either use the XNA project conversion utility (can be found on the XNA Creators Club website) or just create a new XNA 2.0 project in VS 2005.

  2. If you created a new project, drag all source code files into the project and seperate the content files out and put them all in the existing Content directory (only there the content pipeline is activated). If you just converted a project and the content files did not move, move them yourself to the content directory. Gladly all my projects with more than 5 content files had a special content directory anyway, so no need to change anything content-wise for them. If you don't want some of the files to be compiled to .xnb files, you have to change the build action from "compile" to "content" (and then use the "copy to output directory" switch) or to "none" if you want them to be ignored like for .wav files, which are automatically processed by the .xct (XACT) file for you.

  3. Find the line content = new ContentManager(Services); and replace it with Content.RootDirectory = "Content";. If you do that, get rid of the content manager in your game class since you can now use the build-in Content property to access the underlying Game content manager. In case you don't want to do that or if you need an extra variable, replace the above line with content = new ContentManager(Services, "Content");. Both ways will make sure all the content is now loaded from the content directory instead from the main directory of the application. In more complex XNA games you can also change the BaseGameDirectory to the content directory, but then you would also have to move all other resource files to this directory (config files, save games, levels, etc.). It is usually a good idea to separate the compiled (.xnb) content from the content the user can change (config, levels, etc.), so I suggest just redirecting the content directory of the content manager.

  4. Replace the LoadGraphicsContent(bool) method with LoadContent, remove all the if (loadAllContent) commands (was never false anyway, just let the content of the if loop stay) and also remove the call to base.LoadGraphicsContent(bool) (does not do anything like all the Load or Unload methods in the XNA Game class, they are just empty virtual methods). You can also ignore this and the next step since it will only generate depreciated warnings, but I suggest cleaning up your source code whenever an opportunity like this presents itself. I also added some missing region blocks to the code and some comments here and there were they were missing.

  5. Finally delete the UnloadGraphicsContent method unless it did anything beside base.Unload and base.UnloadGraphicsContent. In my XNA games the UnloadGraphicsContent usually looked like this and can be safely removed now (at least if nothing else is in there):
  6. /// <summary>
    /// Unload graphic content if the device gets lost.
    /// </summary>
    /// <param name="unloadAllContent">Unload everything?</param>
    protected override void UnloadGraphicsContent(bool unloadAllContent)
    {
      if (unloadAllContent == true)
        content.Unload();

      base.UnloadGraphicsContent(unloadAllContent);
    } // UnloadGraphicsContent(loadAllContent)


  7. In case you load sound and music via the AudioEngine, you have to change the directory to the content directory too, which will not be done automatically for you since you load the .xct file directly in the AudioEngine constructor. Basically just exchange the following code:

    audioEngine = new AudioEngine("YourSound.xgs");
    waveBank = new WaveBank(audioEngine, "Wave Bank.xwb");
    soundBank = new SoundBank(audioEngine, "Sound Bank.xsb");

    with:

    audioEngine = new AudioEngine("Content\\YourSound.xgs");
    waveBank = new WaveBank(audioEngine, "Content\\Wave Bank.xwb");
    soundBank = new SoundBank(audioEngine, "Content\\Sound Bank.xsb");

       
  8. In case you have used the StorageDevice and specifically the ShowStorageDeviceGuide helper method, it is gone now in XNA 2.0. I had it in some helper classes, but never actually used it. In case you want to show a save game dialog (or some network game select dialog for example), please follow the XNA 2.0 help instructions to do this asynchronously now.

  9. In case you use any ResourceUsage enum, replace it with TextureUsage instead or remove it if the issue is not texture related. You can also safely remove any ResourceManagementMode.Automatic parameters, which are not longer supported. Everything is now automatic anyway. Just if you have been using ResourceUsage.RenderTarget you will need to change the Texture2D class to a ResolveTexture2D class in order to archive the same behaviour as before. Some calls to the device (e.g. ResolveBackBuffer) have also changed and require a ResolveTexture2D now. You may also want to check if you have any manual texture management or disposing, which you can remove or simplify.

  10. For simpler games (2D) games you should be done now. More complex games using render targets and other features that have changed in XNA 2.0 will require some more changes, but after you have done them once (or know where to change what) this is also a quick process.

The following only applies to the RocketCommanderXna, XnaShooter and XnaRacingGame engines, but you might find similarities with other XNA games and the converting process:

  1. First of all make sure the old XNA 1.1 code gets compileable by going though the changes mentioned above (e.g. replacing ResourceUsage with TextureUsage or BufferUsage) and removing everything that does not exist anymore (like ResourceManagementMode.Automatic). If a method is non-existent in XNA 2.0 like ResolveRenderTarget, comment it out and remember where it happened.

  2. You might go through other issues, but you have to come back to the RenderTarget issue. This took the most time in the converting process for me (probably half of all my issues come by something related to changes with RenderTargets in XNA 2.0). For that reason always make sure that rendering to textures still works while you make changing. I always used the TestCreateRenderToTexture unit test inside the RenderToTexture class to figure things out.

  3. Additionally to making some changes in the BaseGame class (loading content via LoadContent, using the base.Content instead of creating a new content manager, etc.) I also removed all the RenderTarget helper methods and fields from the BaseGame class (SetRenderTarget, ResetRenderTarget, etc.) and moved them into the RenderToTexture class. While this makes the code more clean and restructured by making a few more fields private, if you do not call the new InitializeDepthBufferFormatAndMultisampling of the RenderToTexture class the calls to SetRenderTarget and ResetRenderTarget will not work correctly and will not restore the default depth buffer (which has to be remembered first). If you get the following exception it means the DepthBuffer Device.DepthStencilBuffer was set to null, but is obviously still used. In order to fix that make sure the remDepthBuffer variable is set to a correct value in the InitializeDepthBufferFormatAndMultisampling method!

  4. An error has occurred during the Clear operation while trying to clear the depth or stencil buffer, no DepthStencilBuffer surface exists.
    System.InvalidOperationException: An error has occurred during the Clear operation while trying to clear the depth or stencil buffer, no DepthStencilBuffer surface exists.
    at Microsoft.Xna.Framework.Graphics.GraphicsDevice.Clear(ClearOptions options, Color color, Single depth, Int32 stencil, Rectangle[] regions)
    at Microsoft.Xna.Framework.Graphics.GraphicsDevice.Clear(Color color)

       
  5. 4. Even if you have now done everything, the app may still crash when you are trying to clear a render target (which usually happens at the start of each pre or post screen shader). The reason for the following error is the multi sampling format, which might be set to the background buffer, but not to the render targets:


    The active render target and depth stencil surface must have the same pixel size and multisampling type.
    System.InvalidOperationException: The active render target and depth stencil surface must have the same pixel size and multisampling type.
    at Microsoft.Xna.Framework.Graphics.GraphicsDevice.VerifyDepthRenderTargetCompat()
    at Microsoft.Xna.Framework.Graphics.GraphicsDevice.Clear(ClearOptions options, Color color, Single depth, Int32 stencil, Rectangle[] regions)

       
    In order to get rid of this error without changing the RenderToTexture class a lot, you can just comment out the line where multi sampling is activated in BaseGame:

    //this.graphics.PreferMultiSampling = true;

There are probably even more things that I forgot while converting the projects (converted 8 games and about 15 projects in total now), but the above list should be helpful. Especially for me because I always forget some of those little things and having this checklist is very helpful.

Tomorrow I will probably test all the XNA 2.0 games on my Xbox 360 and make some final adjustments and then post them all on http://XnaProjects.net (and here).

 Friday, May 04, 2007
Friday, May 04, 2007 1:29:43 PM UTC (  |  |  |  |  |  |  |  |  )
Yes. My XNA book is finally out and some people even got an early version last week. There is also some discussion going on in the XNA Forums and on the official Wrox forum for the book.

The coolest thing yesterday that my book was on Rank #16 for Computer/Technical books on Amazon.com and on Rank 500 something for all books. Quite impressive if you ask me, hopefully it will continue to stay high and make me filthy rich .. just kidding.

Yesterday I wanted to put all the samples from the book on my blog, but it is already way to overloaded here with screenshots and games, adding another 10 games will not make anything better. Instead I had a crazy idea to create a XNA Community site in one day. It is called XnaProjects.Net. The idea is for everyone to submit their games and links. News are grabbed with Google Blog Search and more features will come in July 2007 when I got more than 5 minutes time in a row.

Anyway, check out this great new website, submit your games and links and check out whats already submitted by me (10 Games so far, yes, thats a lot of XNA games I did in the past few months):

  • XNA Pong
  • XNA Breakout
  • XNA Tetris
  • Rocket Commander XNA
  • XNA Shooter
  • XNA Racing Game
  • SimpleRacingGame
  • SpeedyRacer
  • Dungeon Quest
  • Skinning with Collada Models in XNA
You can find source code and game installers for all of these games, including some nice screenshots and a YouTube video for each of them on the XnaProjects.Net website. Check it out:
 Tuesday, March 06, 2007
Tuesday, March 06, 2007 11:14:02 PM UTC (  |  |  |  |  |  |  )
Sorry for not blogging yesterday. We were working all day on our game here on the GDC 2007 and it was very noisy and distracting here. If you want to watch us work: We are in the Moscone North Lobby and shouldn't be hard to find. Anyway, I will probably just blog at the morning of the next day for each day here.

Our game is called Dungeon Quest and we are absolutely insane because we want to create a Multiplayer Role Playing Game in just 4 days and we haven't even thought of all the distractions here. I will try to give you a screen per day and tell you want we have done so far.

Yesterday we worked purely on the environment, the level and the general game idea and some smaller details. As I said before we started with nothing, I just created a new project and Christoph did just open up 3DS Max and started working, there are no textures or models we have already done. And we both have never worked on a role playing game before.

In the morning we still had a lot of problems getting our computers up and running (3DS Max wasn't starting, I needed lots of plugins and tools, stuff like that). It usually takes a day or more to set up a development machine in our opinion. Probably a week until you got all the important tools installed you forgot in the first day. Anyway, we finally started to build the cave, create new custom collada exporter for that and placed lights. While Christoph was working on the 3D cave I was getting the engine up and running and noticed that there are many things that have to be done:

  • Like just rendering some text on the screen,
  • Finding a good font for that,
  • Creating a bitmap font,
  • Also making other UI elements (selected monster, health, level up, etc.)
  • Rendering shaders and playing around with point lights
  • Working on many other smaller issues like effects, billboards, vertex formats, etc.
  • Most unit tests require a good camera and testing the cave level itself was very hard, so I already created the ThridPersonCamera class we going to use for this game.
I started with most classes that are required for that and I also could drop in some Texture/Font code from Rocket Commander XNA, but most of the shader and collada import classes had to be created from scratch. Then we spend all evening and even this morning tweaking the shaders, getting all the lights working, adding fog, figuring out how to do 6 complex light passes in one shader, and so on.

Today we will focus on building the main character, getting some collision detection working and some basic game logic (keys, doors, monster state machines, player behaviour and animations). Hopefully I can provide you with a nicer screenshot tomorrow, just an empty level is pretty boring.

And here are some pictures from yesterday for your enjoyment.

This is the lobby of the Moscone North building at the GDC. The GDC Expo hall is below us and on Monday the Serious Games Summit was here, but we hadn't had any time to even check out who is speaking at the actual GDC. At wednesday I will be at some Collada round table speaking about Collada and issues we had with it so far ^^


There are many art galleries here in San Francisco and the Asian population is also huge. It was not hard to find an Asian Art Gallery.


Here you can see an ad for Microsoft's Vista Operating System directly in front of the big Mac building here (seems a lot of people got one here). There is nothing interesting about a Mac for a game developer IMO.


Alcatraz at day time. I already showed you a picture at night earlier.


A view from my desk at the Hotel over San Francisco. Its still impressive every day you wake up ^^


And some picture of a place I don't know the name of. Usually I would look it up, but I have to go back to work. Cya tomorrow!

 Sunday, February 25, 2007
Sunday, February 25, 2007 9:39:45 PM UTC (  |  |  |  |  |  |  )
Don't ask me how I managed to not post anything this week. My plan was certainly different, but I didn't want to post my problem with this little project too early. To make up with the lack of blog posts this year until now this is going to be a very long and hopefully very useful article :-)

Content


Video, Screenshot and Downloads

First of all, here is a video for the project I'm talking about here:

Screenshot of the same scene (better quality since youtube videos just suck quality wise):

Before you start reading this article I suggest you download the executable and source code first in case you want to try it out directly while reading. The whole project is based on the RocketCommanderXNA engine and just adds the ColladaModel.cs class, which does all the amazing stuff you see in the video ;-) The video above shows shadowing from the XNA Shooter engine, which is not yet released and their fore not included in the downloads. The rest of the code is the same, just the shadow map rendering was removed. More details about shadow mapping in XNA can also be found in my book (plug plug plug ^^).

  • The source code is about 2.6 MB and contains projects for XNA Game Studio Windows and the Xbox platform, as well as a project for Visual Studio 2005. It was tested on Windows XP and Vista 32 and 64 bit as well as on the Xbox 360.
    SkinningWithColladaModelsInXnaSourceCode.zip (2.6 MB)
  • The executable contains the output (32 bit Windows, but runs on 64 bit and Vista too) from the project in case you just want to try it out or do not have XNA Game Studio Express installed yet. You still need the XNA Framework for this program, download it here, if you do not have it installed yet! You also need a Shader Model 2.0 capable graphic card.
    SkinningWithColladaModelsInXnaExecuteable.zip (2.5 MB)

    Update 2007-02-26: Fixed time steps, in release mode with more than 200-300 fps the animation was getting too slow. Now works flawless :)
Please note that the 3D Goblin Model was created by my friend Christoph Rienaecker (WAII) and if you want to use it, please credit him (see Readme.txt). The source code and collada loading class can be used freely too, but I want some credits too (at least in the source code ^^).


Introduction and why Collada?

OK, let's get started. I talked a lot about the XNA Content Pipeline and its problems on my blog, and in several recent interviews and also in my upcoming XNA book. For projects like Rocket Commander or even the Racing Game it was sometimes a little bit annoying, but I could do everything I needed by loading X files and adding some features to it to fix the tangents, load the correct shader techniques, etc.
However XNA does not support loading animation data or gives you a way to display them. You have to do all that work by yourself. This includes static mesh animations (like it was used in Rocket Commander, I just left it out in Rocket Commander XNA), but also skeletal animation with bones and skinned meshes.

There is a nice project on CodePlex called XNA Animation Component Library, but it only support FBX and ASCII X files (and recently BVH, ASF and AMC formats) and I could not get any of my test models to work with this library. The main thing missing here is good shader support and it also has a lot of problems with complex animated models. Other than that exporting 3D Models as X files is really a pain in the ass, no matter which exporter you use (Panda Exporter for 3dsMax was good a year ago, I still use it, now kiloWatt X file Exporter for 3dsMax is better, and the Microsoft X File Exporter for Max always sucked). Simple models might work, but the more complex 3D models get and the more meshes and animation data is stored in a scene, the more problems you will have. Sometimes it is not possible to reconstruct everything correctly on your importer side.

Anyway, at the very beginning of the Racing Game development there was no content pipeline in XNA (it was Beta 1) and I implemented loading 3D Models with help of the collada file format, which is basically just XML and very easy to read. For that reason it was relatively simple to get some 3D data loaded and displayed in the early XNA versions with help of vertex buffers. There were some problems with shader settings and I had to try many different exporters and ended up with the one from Feeling Software. Back then it had still some problems loading shaders and using the correct techniques, but the recent version (3.0.2) is much better and works like a charm.

After Microsoft had implemented the content pipeline and made it possible to load X and FBX files indirectly by going over the content pipeline I had to remove most of my collada code and re implement the model loading with the new framework. Loading and displaying 3D models was much simpler this way and especially some early unit tests were really simple, but as soon I tried shaders and loading tangents there were a bunch of problems. I reported many bugs back then and it has gotten a lot better, but I still had to fix several issues in the Racing Game and Rocket Commander XNA myself like finding out the correct shader technique and fixing tangent data with help of a custom model processor.

Some things like the level loading in the Racing Game just do not work with X or FBX files because they use splines, which are not exported at all in these formats. Collada came as the rescue again because it is really no big problem for this format. Later versions of the Racing Game removed the collada level loading and introduced a binary format for the levels, but the importer still accepts collada files.

Recently I wanted to test a couple of animated models and use skinning since it can often be more useful than static animations and it usually looks much better, especially for organic 3D models. As I said above I could not get anything working with the XNA Animation Component Library and I especially do not like the way they still use the content pipeline and the project is too complicated for me anyway (I just do not need 6 different file formats, I just want one and it should work perfectly with all the features I need).

After some searching I saw some guy called remi from the collada forum was working on importing collada models too and I posted some thoughts there too (maybe this was a mistake, I got many emails asking me about tips ^^). Here is the thread about that in the collada forum. He has provided a test project with some models and it works nice for static meshes without shader information, but that was not really what I was searching for.

This was a month ago and I had not much time working on any of these issues, but after restarting my blog earlier this week I thought this would be a nice topic to talk about. I'm still pretty busy with Arena Wars Reloaded, but I worked a couple of hours every day on this little test program for the past few days. The rest of this article explains the project and into which problems I ran.

Class Overview

Before we go into the details here is a little class overview of the project. As I said before the Rocket Commander XNA engine was used to get up and running with the project without having to re implement the basics. Most of the classes were already in place and had not to be changed. ColladaModel and SkinnedTangentVertex are the 2 new classes and to help us out with the XML loading of the collada files the XmlHelper class was also brought into the project.

I wrote the ColladaModel file from scratch, but I could reuse some of the static mesh loading code I had done last year. All of the bone and animation loading code was just try and error and I only used the collada specifications as a source of help, but most stuff had to be tested with the unit tests at the end of the class many many times.

The main program just calls the unit tests TestGoblinColladaModelScene or TestShowBones, there is no real game here, its just a test program. The unit test then calls several Standard Engine classes for doing all the post screen processing, rendering the ground plane, etc. More importantly the ColladaModel class itself basically just provides a constructor and a Render method, everything else is private and will be handled automatically for you. Most people might ignore this, but this is always the most important thing about my classes, the use should be as simple as possible and when I look at the projects mentioned above I really ask myself why people sometimes think so complicated.

The internal Bone class inside ColladaModel is used to store all the bones in a flat list, but each entry has a parent and a list old children bones. This way the list can be used both in a simple for loop, but you can also go through it recursively (which is obviously slower and often more complicated). We will talk about the loading process in a minute.

All the mesh data is stored in vertices, which is just a list of SkinnedTangentVertex structs. The SkinnedTangentVertex struct is very much like the standard TangentVertex struct used in Rocket Commander XNA, but it has 2 new members: blendIndices and blendWeights. Both are in the form of Vector3 and their fore can hold 3 values allowing us to interpolate up to 3 bone influences for each vertex in the shader. More is often not required and we have to re normalize all bone weights anyway, so skipping the least important bone weights is not a big deal. My test models use mostly max. 2-3 influences. Please also note that the vertex shader has now a lot more work to do with all that skinning and you should really optimize it as much as possible. Both the number of vertices we have to process is important (we will talk about optimizing that in the optimizing part of this article) and also the number of instructions the vertex shader has, both numbers should be as low as possible. The GPU is really fast processing this data, but if you do not have animated geometry with bones, there is no reason to let it process all that data (which can make the vertex shader 2-3 times longer and slower). The ground of our test scene does not use a skinning shader as an example.

And finally there are some additions to the ShaderEffect class. First of all we got a new shader called "SkinnedNormalMapping", which does the same thing as the normal mapping (or parallax mapping) shader, but it has an array of 80 bone matrices we can use for skinning. These matrices are set with help of the SetBoneMatrices method in the Set Parameter region of ShaderEffect.cs.


Loading collada files

Before we go into the details of the loading process, lets make sure we read the summary of the class first because it clearly states what we can do and can't do with this class. This is just a test project and I wanted to make things as simple as possible for both you as the reader and for my requirements.

   /// <summary>
   /// Collada model. Supports bones and animation for collada (.dae) exported
   /// 3D Models from 3D Studio Max (8 or 9).
   /// This class is just for testing and it will only display one single mesh
   /// with bone and skinning support, the mesh also can only have one single
   /// material. Bones can be either in matrix mode or stored with transform
   /// and rotation values. SkinnedTangentVertex is used to store the vertices.
   /// </summary>
   class ColladaModel : IDisposable

OK, with that said let's go directly into the loading code, which is located in the constructor of this class. All variables used in these class are just for internal use, all you need to know are the vertices and bone lists, which I have already mentioned, and the vertex and index buffers, which are used for rendering. All the rest of the variables are just there to help us loading the collada file (don't worry, there are not many variables anyway and most methods are short too).

    #region Constructor
    /// <summary>
    /// Create a model from a collada file
    /// </summary>
    /// <param name="setName">Set name</param>
    public ColladaModel(string setName)
    {
        // Set name to identify this model and build the filename
        name = setName;
        string filename = Path.Combine(ColladaDirectory,
            StringHelper.ExtractFilename(name, true) + "." +
            ColladaExtension);

        // Load file
        Stream file = File.OpenRead(filename);
        string colladaXml = new StreamReader(file).ReadToEnd();
        XmlNode colladaFile = XmlHelper.LoadXmlFromText(colladaXml);

        // Load material (we only support one)
        LoadMaterial(colladaFile);
        
        // Load bones
        LoadBones(colladaFile);

        // Load mesh (vertices data, combine with bone weights)
        LoadMesh(colladaFile);

        // And finally load bone animation data
        LoadAnimation(colladaFile);

        // Close file, we are done.
        file.Close();
    } // ColladaModel(setFilename)
    #endregion

As you can see first of all the filename is constructed and we just load the file as a text file and throw it to the XmlHelper.LoadXmlFromText helper method (which just uses the existing XmlDocument functionality to load xml from a string). We now get the main collada node, which contains all the children nodes we need for loading the materials, bones, meshes, etc.

Next all the materials are loaded, but we are only going to use the first one we find because we only support one single mesh anyway. The LoadMaterial method goes through all used textures and shader effects from the collada file and constructs the material at the end of the method with help of a new constructor in the Material class itself. While this is cool and a lot easier than loading material data from x files, it is not very exciting code, so let's move along.

Even through the bones are located at the end of the collada file, we have to load them first because all our other loading methods, specifically LoadMesh and LoadAnimation need the bone tree structure and the overall bone list to work. All bones are loaded in sequential order because we want to make sure that we can use the animation matrices later in an easy way without having to check the parent order all the time. Only this way we can be sure that going through our flat bones list we still respect the internal tree structure and always initialize the parents first because the children bones matrices are always multiplied with the parent bones.

    foreach (XmlNode boneNode in boneNodes)
        if (boneNode.Name == "node" &&
            (XmlHelper.GetXmlAttribute(boneNode, "id").Contains("Bone") ||
            XmlHelper.GetXmlAttribute(boneNode, "type").Contains("JOINT")))
        {
            // [...] get matrix
            matrix = LoadColladaMatrix(...);

            // Create this node, use the current number of bones as number.
            Bone newBone = new Bone(matrix, parentBone, bones.Count,
                XmlHelper.GetXmlAttribute(boneNode, "sid"));

            // Add to our global bones list
            bones.Add(newBone);
            // And to our parent, this way we have a tree and a flat list in
            // the bones list :)
            if (parentBone != null)
                parentBone.children.Add(newBone);

            // Create all children (will do nothing if there are no sub bones)
            FillBoneNodes(newBone, boneNode);
        } // foreach if (boneNode.Name)

As you can see the code uses the XmlHelper class extensively because otherwise the code would look much uglier and complex. Next we have to load the mesh itself, this is probably the longest method and not easy to figure out if you work with collada for the first time. Good thing I had already done that in the past and I only had to add the code for getting the blend weights and indices. The following code does load all the weights, which we will use later to fill the blendWeights and blendIndices members of the SkinnedTangentVertex struct vertices list. The code for that is actually a little bit more complicated because we have to find out which weights are the top 3 weights for each vertex in case more than 3 are given.


    #region Load weights
    float[] weights = null;
    foreach (XmlNode sourceNode in skinNode)
    {
        // Get all inv bone skin matrices
        if (sourceNode.Name == "source" &&
            XmlHelper.GetXmlAttribute(sourceNode, "id").Contains("bind_poses"))
        {
            // Get inner float array
            float[] mat = StringHelper.ConvertStringToFloatArray(
                XmlHelper.GetChildNode(sourceNode, "float_array").InnerText);
            for (int boneNum = 0; boneNum < bones.Count; boneNum++)
                if (mat.Length / 16 > boneNum)
                {
                    bones[boneArrayOrder[boneNum]].invBoneSkinMatrix =
                        LoadColladaMatrix(mat, boneNum * 16);
                } // for if
        } // if

        // Get all weights
        if (sourceNode.Name == "source" &&
            XmlHelper.GetXmlAttribute(sourceNode, "id").Contains("skin-weights"))
        {
            // Get inner float array
            weights = StringHelper.ConvertStringToFloatArray(
                XmlHelper.GetChildNode(sourceNode, "float_array").InnerText);
        } // if
    } // foreach

    if (weights == null)
        throw new InvalidOperationException(
            "No weights were found in our skin, unable to continue!");
    #endregion

For more information about the mesh loading please check out the last region in the LoadMesh method, it should explain all the important steps in case you want to add something there or just look how it works.

Problems with the animation data

Getting the animation data was not so easy. First of all I never had done this before because my collada files for the Racing Game were all just static meshes and I really did not need any animation there. Everything that is actually animated in the Racing Game was done directly in XNA, not in 3D Studio.

The first problem is the many formats that animation data can be in. You can have rotations around any axis or translations and even scalings, but most of your bones will only use one or two of these if they are animated at all. Alternatively all the animation data can be computed directly by the exporter plugin in 3D Studio Max and this way you can make sure that all the animation data is in the correct format. It makes testing certainly a lot harder and if you don't even know the format the matrices are in or how to apply them to each other in which order, you are in a world of trouble.

This is exactly what happened to me, I had most of my test models with rotation animation data only, but the Goblin above from my friend Christoph was done with another technique and the exporter could only export the matrices, so I had to support that too. After some try and error I managed to get the basic animations for my test models working. They are all in the project, feel free to load and test them. To test the bone animations I used the following unit test:

    #region Unit Testing
    // Note: Allow calling all this even in release mode (see Program.cs)
    #region TestShowBones
    /// <summary>
    /// TestShowBones
    /// </summary>
    public static void TestShowBones()
    {
        ColladaModel model = null;
        PlaneRenderer groundPlane = null;
        // Bone colors for displaying bone lines.
        Color[] BoneColors = new Color[]
            { Color.Blue, Color.Red, Color.Yellow, Color.White, Color.Teal,
            Color.RosyBrown, Color.Orange, Color.Olive, Color.Maroon, Color.Lime,
            Color.LightBlue, Color.LightGreen, Color.Lavender, Color.Green,
            Color.Firebrick, Color.DarkKhaki, Color.BlueViolet, Color.Beige };

        TestGame.Start("TestLoadColladaModel",
            delegate
            {
                // Load our goblin here, you can also load one of my test models!
                model = new ColladaModel(
                    //"Goblin");
                    //"test_bones_simple_baked");
                    //"test_bones_advanced_baked");
                    "test_man_baked");

                // And load ground plane
                groundPlane = new PlaneRenderer(
                    new Vector3(0, 0, -0.001f),
                    new Plane(new Vector3(0, 0, 1), 0),
                    new Material(
                        "GroundStone", "GroundStoneNormal", "GroundStoneHeight"),
                    50);
            },
            delegate
            {
                // Show ground
                groundPlane.Render(ShaderEffect.parallaxMapping, "DiffuseSpecular20");

                // Show bones without rendering the model itself
                if (model.bones.Count == 0)
                    return;

                // Update bone animation.
                model.UpdateAnimation(Matrix.Identity);

                // Show bones (all endpoints)
                foreach (Bone bone in model.bones)
                {
                    foreach (Bone childBone in bone.children)
                        BaseGame.DrawLine(
                            bone.finalMatrix.Translation,
                            childBone.finalMatrix.Translation,
                            BoneColors[bone.num % BoneColors.Length]);
                } // foreach (bone)
            });
    } // TestShowBones()
    #endregion

The most important call here is the call to UpdateAnimations, which goes through the list of bones and updates the so called finalMatrix from the Bone class for each of the bones. In earlier versions this code was horribly complicated and still had a lot of problems, but as soon as I removed all the rotation, translation, scaling, etc. animation support and just allow loading the correctly baked matrices from the collada files, the code has become much simpler (the actual code does have some optimizations in it, but it is basically the same as the posted code here):

    #region Update animation
    /// <summary>
    /// Update animation.
    /// </summary>
    private void UpdateAnimation(Matrix renderMatrix)
    {
        int aniMatrixNum = (int)(BaseGame.TotalTime * frameRate)) % numOfAnimations;

        foreach (Bone bone in bones)
        {
            // Just assign the final matrix from the animation matrices.
            bone.finalMatrix = bone.animationMatrices[aniMatrixNum];

            // Also use parent matrix if we got one
            // This will always work because all the bones are in order.
            if (bone.parent != null)
                bone.finalMatrix *=
                    bone.parent.finalMatrix;
        } // foreach
    } // UpdateAnimation()
    #endregion

For the loading itself we just have to make sure that the animationMatrices are the correct ones. Collada saves them in a absolute mode. Earlier code from me constructed relative matrices (relative to the initial bone matrix), it was easier to construct relative matrices from the rotation, translation, etc. animation data, but much harder to use these matrices later for the animation. Having these absolute matrices makes the UpdateAnimation code so much easier, so make sure you always use them this way.

However, when rendering the vertices later we can't use the absolute matrices because the vertices have to transformed first to get into a relative space to the bones, rotations should not be around the origin, but around the bone positions. Luckily for us (and you should have seen my face when I finally found out that these matrices already exist in collada and I did not have to create them myself in my own over complicated way ^^) collada stores the so called invBoneSkin matrices for each bone. By applying these matrices we can easily get the bone matrices we need for rendering, these are directly passed to our shader (as compressed 4x3 matrices BTW to save shader constants, the code for that is a little bit more complex, please check out ShaderEffect.cs and the SkinnedNormalMapping.fx shader itself for details).


    #region GetBoneMatrices
    /// <summary>
    /// Get bone matrices for the shader. We have to apply the invBoneSkinMatrix
    /// to each final matrix, which is the recursively created matrix from
    /// all the animation data (see UpdateAnimation).
    /// </summary>
    /// <returns></returns>
    private Matrix[] GetBoneMatrices(Matrix renderMatrix)
    {
        // Update the animation data in case it is not up to date anymore.
        UpdateAnimation(renderMatrix);

        // And get all bone matrices, we support max. 80 (see shader).
        Matrix[] matrices = new Matrix[Math.Min(80, bones.Count)];
        for (int num = 0; num < matrices.Length; num++)
            // The matrices are constructed from the invBoneSkinMatrix and
            // the finalMatrix, which holds the recursively added animation matrices
            // and finally we add the render matrix too here.
            matrices[num] =
                bones[num].invBoneSkinMatrix * bones[num].finalMatrix * renderMatrix;

        return matrices;
    } // GetBoneMatrices()
    #endregion

And this is what you finally get after executing the TestShowBones unit test. I had not implemented mesh loading or the shader itself at this point. I just was loading and testing the bones itself.

 

Optimizing the vertices

One major problem with the loaded mesh is the high vertices count, I had two test models with 30k and 60k vertices and as you can imagine this will slow down the vertex shader quite a lot and it is really not necessary to process all these vertices because many of them are exactly the same. The reason we end up with an unoptimized vertices list anyway is because collada stores seperate lists for each component we have to put together at the end of the LoadMesh method. By doing so we have to duplicate the data many times and we just can't know how often each part is reused and how often the overall vertex changes. If just the texture coordinate or normal differs, we have a completely different vertex, which will produce different results in the vertex shader, so just merging everything together is not that simple.

The rendering uses an index buffer anway, but for the data constructed in LoadMesh it would just be sequential (0, 1, 2 form the first polygon, 3, 4, 5 the next, etc.). Instead of having one index for each vertex, we can often reuse the same vertex 3 or 4 times and reducing the number of vertices drastically. This has also the advantage that we can store much more vertices and complexer meshes even if we still use ushort (16 bit) for our indices (which is half the size of ints and their fore faster). For example if you have 150,000 vertices, but you can reduce them to 40-50,000 optimized vertices, they all can be indexed with ushorts :-)

The easy solution is just to optimize all the vertices after all of them have been loaded, if you have a binary format and do not use collada directly, this solution is absolutely great, but it still will take a lot of time processing the collada models if they just have many vertices because we have to check each vertex against each other one and that can be a lot of compares if you have 60 or 70 thousand vertices in a mesh. It actually takes up to a whole minute just to compute that and I have no slow computer ^^ Here is the method that does all that for us:

    #region OptimizeVertexBufferSlow
    /// <summary>
    /// Optimize vertex buffer. Note: The vertices list array will be changed
    /// and shorted quite a lot here. We are also going to create the indices
    /// for the index buffer here (we don't have them yet, they are just
    /// sequential from the loading process above).
    ///
    /// Note: Slow version because we have to check each vertex against
    /// each other vertex, which makes this method exponentially slower
    /// the more vertices we have. Takes 10 seconds for 30k vertices,
    /// and over 40 seconds for 60k vertices. It is much easier to understand,
    /// but it produces the same output as the fast OptimizeVertexBuffer
    /// method and you should always use that one (it only requires a couple
    /// of miliseconds instead of the many seconds this method will spend).
    /// </summary>
    /// <returns>ushort array for the optimized indices</returns>
    private ushort[] OptimizeVertexBufferSlow()
    {
        List<SkinnedTangentVertex> newVertices =
            new List<SkinnedTangentVertex>();
        List<ushort> newIndices = new List<ushort>();

        // Go over all vertices (indices are currently 1:1 with the vertices)
        for (int num = 0; num < vertices.Count; num++)
        {
            // Try to find already existing vertex in newVertices list that
            // matches the vertex of the current index.
            SkinnedTangentVertex currentVertex = vertices[FlipIndexOrder(num)];
            bool reusedExistingVertex = false;
            for (int checkNum = 0; checkNum < newVertices.Count; checkNum++)
            {
                if (SkinnedTangentVertex.NearlyEquals(
                    currentVertex, newVertices[checkNum]))
                {
                    // Reuse the existing vertex, don't add it again, just
                    // add another index for it!
                    newIndices.Add((ushort)checkNum);
                    reusedExistingVertex = true;
                    break;
                } // if (TangentVertex.NearlyEquals)
            } // for (checkNum)

            if (reusedExistingVertex == false)
            {
                // Add the currentVertex and set it as the current index
                newIndices.Add((ushort)newVertices.Count);
                newVertices.Add(currentVertex);
            } // if (reusedExistingVertex)
        } // for (num)

        // Reassign the vertices, we might have deleted some duplicates!
        vertices = newVertices;

        // And return index list for the caller
        return newIndices.ToArray();
    } // OptimizeVertexBufferSlow()
    #endregion

 

Optimizing the Optimization

While this is all nice and dandy and we just optimized the rendering code by 20-30% (I tested with 9 goblins and using 3 passes for them, 2 for shadowing and 1 for the rendering), but the loading now takes painfully long. The main idea here is to not compare every single vertex against every other possible vertex because it does not make much sense, most of the vertices (>99,9%) will always be different. We only need to check the ones that share at least the same position.

I started with comparing neighboring vertices, but since the vertices are stored in index order, they are totally messed up, vertex 1 and 4383 can be equal, but if we just check -10 to +10 we are going to miss it. Instead we have to know which vertices come from the same position data, which we know since collada saves unique positions. All we have to do is to keep a list of all vertices that share the same position and then we can optimize the comparsions later on. Usually only up to 4 to 6 vertices share the same position, this way the whole comparison process just needs 60,000 * 6 comparisons, not 60,000*60,000 anymore.

    // Initialize reuseVertexPositions and reverseReuseVertexPositions
    // to make it easier to use them below
    reuseVertexPositions = new int[trianglecount * 3];
    reverseReuseVertexPositions = new List<int>[positions.Count / 3];
    for (int i = 0; i < reverseReuseVertexPositions.Length; i++)
        reverseReuseVertexPositions[i] = new List<int>();

    // We have to use int indices here because we often have models
    // with more than 64k triangles (even if that gets optimized later).
    for (int i = 0; i < trianglecount * 3; i++)
    {
        // [...] vertex construction

        // Remember pos for optimizing the vertices later more easily.
        reuseVertexPositions[i] = pos / 3;
        reverseReuseVertexPositions[pos / 3].Add(i);
    } // for (ushort)

And then finally the fast vesion of OptimizeVertexBuffer, which uses that data:

    #region OptimizeVertexBuffer
    /// <summary>
    /// Optimize vertex buffer. Note: The vertices list array will be changed
    /// and shorted quite a lot here. We are also going to create the indices
    /// for the index buffer here (we don't have them yet, they are just
    /// sequential from the loading process above).
    ///
    /// Note: This method is highly optimized for speed, it performs
    /// hundred of times faster than OptimizeVertexBufferSlow, see below!
    /// </summary>
    /// <returns>ushort array for the optimized indices</returns>
    private ushort[] OptimizeVertexBuffer()
    {
        List<SkinnedTangentVertex> newVertices =
            new List<SkinnedTangentVertex>();
        List<ushort> newIndices = new List<ushort>();

        // Helper to only search already added newVertices and for checking the
        // old position indices by transforming them into newVertices indices.
        List<int> newVerticesPositions = new List<int>();

        // Go over all vertices (indices are currently 1:1 with the vertices)
        for (int num = 0; num < vertices.Count; num++)
        {
            // Get current vertex
            SkinnedTangentVertex currentVertex = vertices[num];
            bool reusedExistingVertex = false;

            // Find out which position index was used, then we can compare
            // all other vertices that share this position. They will not
            // all be equal, but some of them can be merged.
            int sharedPos = reuseVertexPositions[num];
            foreach (int otherVertexIndex in reverseReuseVertexPositions[sharedPos])
            {
                // Only check the indices that have already been added!
                if (otherVertexIndex != num &&
                    // Make sure we already are that far in our new index list
                    otherVertexIndex < newIndices.Count &&
                    // And make sure this index has been added to newVertices yet!
                    newIndices[otherVertexIndex] < newVertices.Count &&
                    // Then finally compare vertices (this call is slow, but thanks to
                    // all the other optimizations we don't have to call it that often)
                    SkinnedTangentVertex.NearlyEquals(
                    currentVertex, newVertices[newIndices[otherVertexIndex]]))
                {
                    // Reuse the existing vertex, don't add it again, just
                    // add another index for it!
                    newIndices.Add((ushort)newIndices[otherVertexIndex]);
                    reusedExistingVertex = true;
                    break;
                } // if (TangentVertex.NearlyEquals)
            } // foreach (otherVertexIndex)

            if (reusedExistingVertex == false)
            {
                // Add the currentVertex and set it as the current index
                newIndices.Add((ushort)newVertices.Count);
                newVertices.Add(currentVertex);
            } // if (reusedExistingVertex)
        } // for (num)

        // Finally flip order of all triangles to allow us rendering
        // with CullCounterClockwiseFace (default for XNA) because all the data
        // is in CullClockwiseFace format right now!
        for (int num = 0; num < newIndices.Count / 3; num++)
        {
            ushort swap = newIndices[num * 3 + 1];
            newIndices[num * 3 + 1] = newIndices[num * 3 + 2];
            newIndices[num * 3 + 2] = swap;
        } // for

        // Reassign the vertices, we might have deleted some duplicates!
        vertices = newVertices;

        // And return index list for the caller
        return newIndices.ToArray();
    } // OptimizeVertexBuffer()
    #endregion

With this optimization loading is now pretty fast and rendering performs also nicely thanks to the quick shaders we will discuss below. When running ANTS Profiler over the new project the slowest line of code becomes the actual text parsing, actually the conversion of the long strings for all vertices data into the actual vertices float data, especially the positions array. But we can't do anything about that without loading the data binary and not parsing them ourselfs. It takes maybe half a second for a 50k vertices model to load, not great, but ok for our little test app.

Adjusting the shaders for skinned meshes

Now we got a bunch of vertices we can render, but as you know we need a shader to do anything in XNA, there is no fixed function pipeline. There are also no animation helper classes like in DirectX, but they won't help you anyway if you want to render with shaders. Transforming the vertices on the CPU may sometimes be a choice if you do not have many vertices and not many skinned models overall or if they all have to be updated the same way. But generally it is a much better idea to transform all the vertices on the GPU, which costs a little bit more instructions in the vertex shader, but the rest of the rendering stays the same. Most graphic apps are pixel shader bound anyway and I use fairly complex pixel shaders too. Additionally on Shader Model 4.0 cards like the GeForce 8800 with up to 128 parallel unified shader units you can do very complex vertex shaders and use simpler pixel shaders and it will just use more units for the vertex shaders automatically :)

We already have defined the bones matrix array for skinning above and we limited it to 80 bones per mesh, which is quite a lot. Even if you would spend 3 bones per finger and 20-30 bones for the body you would still have plenty of bones left for complex animations. Sure modelers will now say "thats not enough sometimes" ... well, you can always split up the mesh into several meshes with up to 80 bones each if you really need more. My graphic artists are happy with 80 bones ^^

If we want full Shader Model 2.0 support we can only be sure that we got at least 256 shader constants. NVidia has usually more (1024), but you still want your game to run on ATI cards too, especially older ones. Each constant can hold a float4 and we need 4 constants for each 4x4 matrix. This means we can only have up to 64 matrices with this limit and we still need some constants for the world, view, and projection matrices, the light and material values and anything else we want to do in our shader. You should reserve 10-20 constants for that and now we are down to less than 60 matrices, which might sometimes be too little.

Instead of splitting the mesh or providing a different code path in case the GPU can do more constants (I couldn't get that do work in XNA for some reason, not sure if there is some limit or if I made a mistake, my GPU should be able to do at least 1024 constants, and even 2048 for the 8800), there is a trick to save only a 3x4 matrix. The last colum is always 0, 0, 0, 1 if we have correctly applied the invBoneMatrix and the animation matrix (see GetBoneMatrices in ColladaModel for details and the order of the matrices). But saving 4 float3 values still needs 4 shader constants per matrix so we have to save it as 4x3 matrices instead.

My first idea was to grab the .w values and reconstruct the translation part of the matrix this way. This worked, but the resulting shader had 80 instructions (from abount 20 without skinning), which is not good for the resulting performance when rendering many skinned 3D models.

float4x4 RebuildSkinMatrix(float index)
{
    return float4x4(
        float4(skinnedMatricesVS20[index*3+0].xyz, 0),
        float4(skinnedMatricesVS20[index*3+1].xyz, 0),
        float4(skinnedMatricesVS20[index*3+2].xyz, 0),
        float4(
            skinnedMatricesVS20[index*3+0].w,
            skinnedMatricesVS20[index*3+1].w,
            skinnedMatricesVS20[index*3+2].w, 1));
} // RebuildSkinMatrix(.)

A better idea is to use the 4x3 matrix as a 3x4 matrix by just reversing the order we call mul. This involves some changes to the vertex shader code and looks a little bit confusing sometimes, but if you make sure you transform the world matrix the same way and use it in this reversed mul order too, everything works just fine. Another thing that can be optimized is to pre-multiply the indices of blendIndices for each vertex at the loading time. These indices never change and they don't really care if they are 0, 1, 2 or 0, 3, 6, etc. We save one instruction per matrix we are going to reconstruct (the rest is optimized out by the compiler). This is the much easier version of RebuildSkinMatrix, for more details take a look at the SkinnedNormalMapping.fx file:

// Note: This returns a transposed matrix, use it in reversed order.
// First tests used a 3x3 matrix +3 w values for the transpose values, but
// reconstructing this in the shader costs 20+ extra instructions and after
// some testing I found out this is finally the best way to use 4x3 matrices
// for skinning :)
float4x4 RebuildSkinMatrix(float index)
{
    return float4x4(
        skinnedMatricesVS20[index+0],
        skinnedMatricesVS20[index+1],
        skinnedMatricesVS20[index+2],
        float4(0, 0, 0, 1));
} // RebuildSkinMatrix(.)

This results in a vertex shader that has almost half as many instructions as before and their fore is twice as fast :) Good work. Performance tests showed that I could increase the framerate from 220 fps to 270 fps just by doing that (test scene with 9 goblins). The following code is actually more or less the only part you have to replace in an existing shader if you want to make it skinnable (plus providing the helper method and the skinned matrices too of course).


    // First transform position with bones that affect this vertex
    // Use the 3 indices and blend weights we have precalculated.
    float4x4 skinMatrix =
        RebuildSkinMatrix(In.blendIndices.x) * In.blendWeights.x +
        RebuildSkinMatrix(In.blendIndices.y) * In.blendWeights.y +
        RebuildSkinMatrix(In.blendIndices.z) * In.blendWeights.z;
    
    // Calculate local world matrix with help of the skinning matrix
    float4x4 localWorld = mul(world, skinMatrix);
    
    // Now calculate final screen position with world and viewProj matrices.
    float4 worldPos = mul(localWorld, float4(In.pos, 1));
    Out.pos = mul(worldPos, viewProj);

 

Post screen shaders for the final result

All the skinning code and bone transformations are nice once you get them done, but without a cool model and some post screen shaders to make the scene look more cool, it is only half the fun. Good think I got the Goblin 3D Model, thanks to Christoph (WAII) again. I also had a couple of other test models and another more complex 3D Model (big evil monster ^^) which was good for some stress testing, but the material just did not look that cool.

As you can see on the following image 6 render targets are used to accomplish the final image. Most shader passes do several things at once and the list of operations (see right side of the image) is longer than the list of used passes. Most of this was just trying to get the best looking values together quickly. If you are an experienced artist you can probably do much better than me, I'm just playing around with the shader parameters until I get bored and then I leave it the way it is. The sceneMap (render target nummero three) shows the unmodified scene without applying the post screen shaders. It does not look half as cool as the final result.

I hope you enjoyed this article and that you are not as tired as I am writing this all at once (uff). It was a fun project, I have already another one in mind for next week ;-) Take care. If you have problems, post a comment. Please note that not all collada models will work, you have to follow the rules of ColladaModel or improve the class a bit for other use

 

References and Links

 

 

 Friday, December 29, 2006
Friday, December 29, 2006 6:30:45 PM UTC (  |  |  |  |  |  |  )
I developed a little Shoot'n'up game in the last couple of days. It is actually quite fun to play. It is just one level and is kind of a prototype. The game will be released together with my XNA Professional Game Development book in a few months (it will be freely available from my website shortly after that). My book features many other games too, it is not just about one game, there are many arcade, action and other games in the book (about 8 games or so) and they will be described as I explain all the important aspects of Game Programming and the XNA Framework.

For now I can only give you a little video about XNA Shooter. I hope you like it.

A "little" 1920x1200 screenshot:

These days there are a lot of discussions about XNA, especially in the GameDev.net boards and of course in the official XNA forum by Microsoft.
http://www.gamedev.net/community/forums/topic.asp?topic_id=430119
http://forums.microsoft.com/msdn/showforum.aspx?forumid=846

I also want to mention a great article by the .NET Compact Framework team about the .NET performance on the Xbox 360 with the XNA Framework. The main issue here is the Garbage Collector, which is not generational and theirfore can only collect all the objects in the GC at once and not in 3 levels like in the normal .NET Framework, which can handle a lot more dead objects and more complicated situations.

Here are the links to the .NET Compact Framework on XNA article:
http://blogs.msdn.com/netcfteam/archive/2006/12/22/
managed-code-performance-on-xbox-360-for-the-xna-framework-1-0.aspx

http://blogs.msdn.com/netcfteam/archive/2006/12/22/
managed-code-performance-on-xbox-360-for-xna-part-2-gc-and-tools.aspx

From my experience there are a couple of things you have to remember when developing XNA games on the Xbox 360. All of these issue are not a big deal on the PC, but they can cost some extra time until you get them right. One of the main problems is that if you develop your game on the PC only and then test it on the Xbox 360 only at the end a lot of things may go wrong (bad performance on the .NET Compact Framework, UI elements at the border of the screen, which are just not visible on some TVs, bad Xbox 360 controller support, which is the main input device for Xbox 360s, etc.).

  • Test test test. This is the most important tip. Write unit tests and constantly test them on your PC AND your Xbox 360. I keep 2 projects open at the same time (both of them use the same files, but I only develop the PC solution and use the Xbox 360 solution for deploying and testing only). Almost all of my classes have unit tests and I constantly test them until they are completed.
  • Don't use foreach loops, especially not in tight render loops. This may sound a little crazy since it does not matter on a PC game and todays CPUs are fast enough to handle the creation and deletion of many thousand objects each frame, which most games don't even need. But on the compact framework you will spam the memory even with things like foreach loops because a new enumerator instance is created everytime you start a foreach loop. After a while there will be a lot of dead objects, which have to be collected. This can take some time and slow your game down immensely. The PC version might run at over 200 frames, but your Xbox 360 version is stuck at something like 30-40 frames. Avoiding creation of new data each frame and avoiding foreach loops (just replace them with normal for loops, it is mostly just 1 line of extra code) can improve your performance by a factor of 100% or more.
  • In Arena Wars I never created any data during the game. All objects were created at the beginning of each mission and they were reused (which was no big deal since the game principle did not allow an infinite number of units, it always stayed around the same because you get your money back from dead units to build new units). In later project I did not care so much about creating new objects and I coded just the easy way because unit tests drive you into a direction to quickly develop solutions, which work and are tested, but may not be the best in other situations like for the Xbox 360 .NET Compact Framework. That is ok because we can now use the unit tests to check if other solutions work just they way we expect them to work. For XNA Shooter and XNA Racer (and a couple of other new game projects) I now make sure that most of the game data is created at the beginning of each level and not dynamically during the game.
  • Save-Regions on TVs can be a pain in the ass. Just google for Xbox 360 screenshots and you will notice that the GUI (graphical user interface) looks a lot different from most PC games. PC games have often UI at the screen border showing you tips, little buttons and other not so important things. If you do that in your Xbox 360 game all of these UI elements may be cut of on a regular TV. For the XNA Shooter I had to rework all the UI elements because they just did not fit on a TV screen and it was not practical to put them in a bar (like the windows task bar) because it looks so different on the PC and certain TV monitors. Instead I put all UI elements in floating bars, which will be adjusted depending on the screen the user is looking at.
    These are some of the Save-Regions I have encountered:
    • PC: 100% visible
    • Xbox 360 connected through a VGA cable: 100% (or close to 100%) visible.
    • Xbox 360 connected to an old style monitor with SCART: around 92% visible.
    • Xbox 360 connected through Component cables to my new Dell 24" Monitor (yeah HDTV): around 93-95% visible (depends on the resolution).
    • Some old TV sets (according to the XNA docs and tips on the web) have a save region of 80-90%, but I never saw the 80% case, that is probably the worst case scenario.
    The important thing is to keep the important UI element in this inner 90% (or 93% if you want to be close to the edges) rectangle. This means instead of using a full 1920x1080 pixel resolution you only use 90% of it (1728x945). Or just start rendering UI elements at about 5% of the screen (x coordinate: 96, y coordinate: 54). This pixel locations obviously depend on the screen resolution, just calculate them in your main class and use them whenever you render UI.
  • There are probably a lot more tips I can give, but I'm to lazy right now. Maybe more in a little while :)

Btw: I currently also do a lot of OpenGL development again and I have to say I have totally forgotten about the way you can program OpenGL. It is often a lot easier, it only gets hard if something does not work the way you expect it to be (but thats hard in DirectX too). Well, the most annoying part is of course that you have to wrap all OpenGL methods through PInvoke and that just costs time. On the other hand if you already have a robust framework (like I have with Arena Wars, hehe), it is relatively easy to plug in new features. It also took not long to learn the differences between glsl and hlsl. I do currently also test out the FX Composer 2.0 (alpha), which has a great idea behind it, but it is too much like Render Monkey and that is never a good thing. Render Monkey by ATI is just overcomplicated and hard to use (and was not updated for 2 years, which shows that no one even uses it anymore). The great thing about FX Composer 1 was the fact it was so easy to use and it did only support a very limited feature set. It is not the best tool ever, but it was certainly a lot easier to use than FX Composer 2.0, which will hopefully be improved before NVidia release it.
I have confidence that NVidia will deliver a great tool as always, but they have lost a lot of fans in the last months because of the lack of drivers for Vista, especially for the Geforce 8800, which does not work at all in Vista, but it is the only card on the market that even supports Direct3D 10 (and the new cool unified shader technology in DirectX). The only way you can currently use the new graphic card features is to program them yourself natively with OpenGL ... but my 8800 is in repair anyway, else I would have tried out some of the new features by now.

 Sunday, December 24, 2006
Sunday, December 24, 2006 7:08:16 AM UTC (  |  |  |  |  |  |  )

ArenaWars Reloaded - Coming Soon
Hey now!

Before you read on (I guess this is going to be a long post) please also check out www.exDream.com. We made some pictures from our new office and we recently announced ArenaWars Reloaded (see image on the right), a new game with a new graphic engine and many new cool features based on the original Arena Wars idea (the game play and levels will be similar, but look much better).

My little Christmas present for you is the new port of Rocket Commander to the XNA Framework. It allows you to play the popular Rocket Commander (113 000 played games already can't be wrong) on your Xbox 360 for the first time. You just need an Xbox 360 and have XNA on there. Here are the downloads, the file sizes are are little bit bigger than the original game (my comments are below):

  • Rocket Commander XNA on Windows (16 MB): Includes Setup, that will automatically install DirectX Dec 2006 and the XNA Framework if you don't have it yet!
  • Rocket Commander XNA on the Xbox 360 cannot be redistributed. You currently have to download the source code and run it in XNA Game Studio Express to even get it on your Xbox. Once you have Rocket Commander XNA deployed with help of the XNA Launcher you can start it anytime you want to without having your PC on or having to redeploy it.
  • Full Rocket Commander XNA source code (53 MB): All Content, Sound and Music files are included in this download, this is all you need to compile and run the game on Windows and Xbox 360. The music files are almost 50MB (5MB as mp3, which is not supported in XNA).
  • Rocket Commander XNA source code only (213 KB). No content files (models, textures, sounds, etc.) in here, just the .cs, .csproj, .sln and .fx files.
Update: 2007-01-03: Fixed some Bugs with the Input, PostScreenGlow and when device loses focus. Works now more stable. Also cleaned up some of the source code.

Note: Use RocketCommanderXna.sln to compile and run the game on Windows and RocketCommanderXnaXbox360.sln to compile and deploy it to your Xbox 360. For additional details please read the XNA documentation.

The game runs at a very good performance on the Xbox 360, you still got over 60 fps in HDTV 1920x1050 (1080p) with full AA enabled.

Check out some of the new screenshots. Warning, all of them are big, HDTV 1080p resolution. Actually I could not capture any images from the Xbox 360 directly, which runs at 60fps on 1920x1050 and uses fullscreen Antialiasing and using the highest settings. These screenshots are from my PC hooked up to my new 1920x1200 monitor, also nice :)

The main menu. Not much happend here.

The ingame HUD and general user experience has changed a bit. There is also a new object for the goal since creating a sphere dynamically is not that easy in XNA.

Rocket Commander is still fast and it pumps up your adrenaline even more in combination with a big monitor :)

Another screenshot from the last level. Please note that you can see more asteroids at the same time than in the original game. You can also look a lot farther and see more items from great distances.

The explosion is unchanged. It still looks the same crappy way, but the AnimationTexture class had to be reimplemented to work with XNA textures now.


Initially I thought "Hey, this is easy, let's port Rocket Commander to XNA.". The initial port attempt was pretty good, it took only 3-4 days to port the 25 000+ lines of code used in Rocket Commander. I could remove some classes and I also simplified some classes, the total number of lines got smaller (~20 000 lines), but after adding some new features and some new unit tests and some testing code for multithreading it is about 22 000 lines of code, still less than the original. XNA is definately the future, MDX was great, but it was not updated for a long time and if you start something new, go with the fresh XNA Framework!

Here are some of my experiences from the process of writing Rocket Commander XNA. Please note that some of these comments were written while I was developing and kinda sleep deprived. Beware of the harsh tone, in the end all worked out great :)
++ means this topic was great and better than MDX.
+ means it was good and nice to work with.
- means I did not like that feature or it was easier in MDX.
-- means this was really annoying and should be improved in the future.

By the way: I did Rocket Commander XNA just for fun, but it also proves how great XNA performs on the Xbox 360. Try to find any other game with this many polygons and effects running in 1080p (1920x1080) with AA enabled on the Xbox 360 ^^ It does not look as good as Gears of War or Halo 3, but it took only 1 man and a short time to develop and it still pushes up to 80-100mio polys each second to the GPU (in some early unit tests, the game runs fine with 20-30 mio polys per second most of the time, check out the model class and its unit tests for more details).

I also use the Rocket Commander XNA engine for 2 other smaller projects because I like the fact that I can test and play these games on the Xbox 360 too and having a complete engine up and running is always a great plus, even if you know how to do a game. It is just easier if you got all the basics covered.

Topic Rating Comments
Sound ++ Very easy to use, 1 short class instead of 2 complex ones I had in MDX. Once you get used to XAct you learn that it is a good tool for sound effects, at least if they don't have to be loaded dynamically. The porting process was very simple for sound effect files, they just had to be dragged to XACT and then the project had to be saved, that's it.
Music -- A lot of converting, different formats, hard to handle, a lot to test, bad documentation. The music from RC was below 5 MB, now it is over 50 MB, which just blows up the source code. Even the compressed take up 13 MB on the PC (ADPCM) and 9 MB on the Xbox 360 (XMA), both in a quality below the original. The rest of the game content (5MB compressed textures, models, effects, sound, etc.) stayed almost the same and could be reused for the most parts.
Unit Testing - Harder to use on the Xbox 360, no edit and continue support in the compact .NET framework. There are also no unit testing tools available and all you can do is to call static unit tests from the program class, which is still useful, but harder to do. I still prefer to test on windows. One great thing about the Xbox 360 is the fact that you get multimonitor debugging for free if you have a TV screen and your PC screen. Debug and step through code on your PC and see the result on the TV screen :)
Window handling ++ No extra code required, I could remove several classes and even the helper classes that are still in Rocket Commander Xna are not required for the most parts. Except for some of the game component classes and the design that is not really useful (more about that below) the Game class is really easy to use and simplifies the process to create a new game in a few minutes.
Shaders ++ Everything in XNA is shader based. The original Rocket Commander runs on fixed pipeline only hardware too, but it was a lot of work to handle 2 ways to render everything. With XNA you just have to write the shaders once and just use them. They work perfectly on the PC (Shader Model 1.1 up to 3.0) and on the Xbox 360, all fx files compiled without any problems.

Some shaders had to be adjusted to be right-handed now instead of left-handed like in MDX, but that did just take a few minutes to change and all the rest of the shader code could be reused. In the last few months of XNA development I never had once a problem with shaders in XNA, thats really great :)

IDE Features - MDX is much older and was never made popular by Microsoft. XNA is new, fresh and great, but it is missing some serious features like Animations for Models. You can implement it yourself, but why even bother with the content pipeline, do it all yourself. It will be much easier and you can extend it in any way you need in the future.

XNA development is currently also only avialable with XNA Game Studio Express, which is painful if you are a pure Visual Studio 2005 Professional developer and have lots of plugins you rely on every day (source code management, code rush, testdriven, slickedit, explorer, and many more). This will change in the future and XNA will grow up and dominate the whole world one day :)

Content -- Sorry, I just don't like the content pipeline (and I have been using it for several months now)! It is bad for dynamically loading textures or shaders or reloadindg them after changes (just not possible with compile-time generated content). On the windows platform you can still load textures and shaders the normal way, which is good, but loading .x file models is just not possible, you have to use the content pipeline. And the content pipeline sucks feature-wise, you have to implement all of stuff yourself.

This is my main problem, why should I re-implement generating tangents, shader technique indices, fixing other x file problems, etc. all by myself in a custom content processor, which is not easy to write IMO (bad docu again). By the time I did all that I would have implemented a much more flexible and vesatile custom importer like from .collada files, which are very popular these days ...

Performance + The overall performance especially when just doing some benchmarks and performance tests is absolutely perfect on both Windows and the Xbox 360. The GPU is pushed to its limits and there is no reason why you should be afraid of managed code. Windows performance is especially great, all my programs and games are completely GPU bound even in low resolutions and even when they only have one thread.

On the Xbox 360 the performance is much worse and you have to take many things into consideration, which is hard because there is again not much documentation around. For example the worst thing you can do on the Xbox 360 is to generate new data each frame, even if you just create an enumerator by executing a foreach loop, it will affect your performance. The good thing is that you have 3 cores (and 6 hardware threads) at your fingertips, which allow you to optimize performance. It was possible for the Rocket Commander game to optimize the game loop a lot because the physics and update threads eat up almost 50% of the CPU time. On the PC it does not matter much because my GPU is slowing everything down (see image below), but on the Xbox 360 I was able to almost double the framerate using multiple threads, nice :)


Click Image for to maximize it.

Usability - It gets a little easier though all the game helper classes, but the game component class is pretty useless, you can implement something like that in 5 minutes yourself. There is also a DrawableGameComponent class, but you have to call Draw yourself, whats the point here? My classes have some Draw or Render method anyway, I don't need to derive them from GameComponent, I can implement my own interfaces and implement exactly the features I need. Often it is easier to give the Render method a few parameters or even call it several times with different parameters, all that is not possible with DrawableGameComponent.

Next there is the content pipeline, which is just a pain in the ass for 3d models. This makes the usability very bad, especially if you develop on Visual Studio 2005 (not Express), which does not support the content pipeline. Also if you are a Vista-Developer XNA Game Studio Express will also not run as expected and my intern hates now both Vista and XNA. It should not happen that someone can get so angry about such great pieces of software, just because they don't work together ^^

Porting + If you have written a XNA game or have some XNA code flying around (like the Rocket Commander XNA source code) it is very easy to port existing MDX code to XNA. If you do it from the scratch it is a lot more work and testing until everything works out the way you expect it, but overall it is easy to port from MDX to XNA. Thats very cool, thank the main MDX man Tom Miller for that, who architected parts of XNA too. Porting is easy, but getting the game to work the way you want on the Xbox 360 is not that easy. First of all you got that annoying content pipeline again (I keep repeating myself, maybe I'm too angry ^^), then you have to make sure that you don't render important User Interface on the none-visible area of a monitor that is plugged into a Xbox 360. For example Rocket Commander was only designed for 1 resolution to look good, it had a very small font for some texts on the screen, which is unreadable on TV monitors. Rocket Commander did also not scale well on Widescreen monitors and it rendered a lot of UI elements at the screen borders, which were cut off on TV monitors.

The porting took maybe 3-4 days, but I spend at least 4 more days for fixing UI elments and improving the code on the Xbox 360, optimizing asteroid rendering, physics and multithreading. I did not expect that it would take that long and I had only some time in the evenings to even get some XNA work done.

Most annoying Porting left-handed models, matrices and other complicated math functions over to the right handed system that XNA uses. Maybe it would be easier to use left handed matrices like in the original Rocket Commander for XNA too, but XNA does not provide them and I did think getting it to work with a right handed system would be easier. Then there is of course the problem getting the models into the content pipeline. I used a special content processor, which is also included in the Rocket Commander source code and it can be used for other projects too (I use it for everything I do with XNA).

Another annoying thing is the re-deploying of existing game content to the Xbox 360. If you just have 5 files it will not matter to you, but if you got over 50 (Rocket Commander) or even several hundert content files and sometimes due some crazy bug all these files get re-compiled or re-deployed over and over again, it gets really annoying. It takes 30-60 seconds and is not fun ... good think it does not happen that often, but it is still annoying me. Maybe the main reason for regenerating the content on my PC is the fact that I often switch between the Xbox 360 and Windows platforms to test if everything is working the same way on both systems.

Missing features The XNA version does have all the features from the original Rocket Commander game, including all levels, sub menus and the whole game play. It does not have animated models however because it is not supported out of the box in XNA and I did not have time to reimplement this feature. It does also not support polygon based collision checking for asteroids, which can sometimes be annoying if you fly near asteroids or if you want to fly through the donut asteroid. The problem here is that the mesh intersection methods are missing, all you can do is render models, not much else. Last but not least XNA does not support any network code. On the windows platform it would be possible to still use the Webservice to upload and get highscores, but for compatibility with the Xbox 360 the code is currently commented out. If you want to play with online highscores, just play the original Rocket Commander game.

There are also some smaller issues like getting the bitmap data of a texture on the Xbox 360. There is method called GetData in the texture class, but it is not supported on the Xbox 360. There is also no bitmap class in XNA because you would need the System.Windows.Forms namespace, which is not included in the .NET compact framework. I ended up saving the level data into a custom file (.level) and then loading it again with help of standard IO methods (byte by byte, but the loading process is still fast, less than 1 second for all textures, levels, models and sounds).

The Rocket Commander Mods are also not supported yet, but porting them should be easy with the existing Rocket Commander XNA source code.

Improvements The controls, especially for the Xbox 360 Controller have been improved. It is now much easier to fly the rocket, the speed was increased and you can look at up to 4 times as much asteroids thanks to several optimizations and the great performance gain of using multiple threads on the Xbox 360. There are also many smaller improvements to the UI, the structure and some classes in the game, but the game looks still very similar (see screenshots above).

Maybe I will write a little more next week. I should get some sleep now, in a few hours it is christmas time and I have not packed any presents yet.

Now have fun with Rocket Commander XNA and have a nice christmas of course ;-)

PS: I know my blog has currently some problems (posting and comments do not work as they should), I will fix that in a week or two, have currently not much time to investigate this issue.

 Thursday, December 14, 2006
Thursday, December 14, 2006 7:10:42 PM UTC (  |  |  |  |  |  )
Yesterday was the german developer price 2006 event (Deutscher Entwicklerpreis 2006) in Essen (Germany).

The Lichtburg (light castle) in Essen.

Miriam Pielhau (known from german TV, well at least if you watch german TV, I don't) moderated the event together with the usual hosts (Aruba, politicians, other guys from the german game developer scene).

Martin Kesici (Sat1, Superstars star or something, never saw him before either) did make some music in a short break. Was neither great nor bad.

After about 10 prices were given to the developers almost 2 hours have passed and the rest of the 30 prices had to be given out. In a IMO unprofessional manner everyone just had to come on the stage and get his price. In a matter of minutes the rest of the prices were given out.

Then everyone left to the after-show party with more food, drinks and some games.

And Pong (actually it is called Plong) on the Xbox 360. It really shows how to use the GPU correctly and have all 3 cores at full CPU load. The game looks actually a lot worse, my bad camera just made it more beautiful because I always have a blur, glow and motion blur effect on all my pics :)

Some angle girls dancing around. Reminded me of the song: Rammstein - Engel

And finally a little in-house fireworks show at the end. Always fun to watch.

All in all it was a nice and enjoyful event and it was nice to meet all the usual faces again. If you want more photos check out: www.deutscher-entwicklerpreis.de

 Monday, December 11, 2006
Monday, December 11, 2006 5:58:09 PM UTC (  |  |  |  |  |  |  )


Microsoft released their XNA Framework 1.0 and XNA Game Studio Express today, which allow you to build games for Windows and the Xbox 360. To compile and play your XNA games on the Xbox 360 you will need to join the "XNA Creators Club" (for $49 per 4 months or $99 anually). There you will have access to additional starter kits, features, etc.

I ported the Rocket Commander game to XNA, just for fun .. and it runs great. It is optimized to run on all 3 cores of the Xbox 360 and I will finetune it a bit in the next few days to run perfectly on the XNA 1.0 release. The performance is really good, the current build has over 800 fps in PAL on the Xbox 360, in very high resolutions (have only 1600x1200 monitor, but I will test it on 1920x1080 too later this week) it still runs good with more than enough frames.

Here is a little preview picture, it shows about 8 times more asteroids and runs at over 200 fps here. I will try to post some of the porting problems in the next few days, for example all the network and internet code had to be ripped out from the Xbox 360 build and the sound features are a little stripped down in XNA (no 3d listener support, not easy or not even possible to do any stereo or surround sound, looks like playback is all mono :-( ).

Early alpha screenshot of Rocket Commander XNA:

 Friday, November 17, 2006
Friday, November 17, 2006 7:02:25 AM UTC (  |  |  |  |  |  )
As I reported few days ago a nice guy named Marc Guevremont made a pretty amazing Mod for the Rocket Commander Game called Canyon Commander.

You can download the game (just 2.8 MB) and source code on
www.RocketCommander.com

I also made a little video of the game play, which is similar to Rocket Commander very fast and action packed :)

Text from www.RocketCommander.com:

Canyon Commander

This Mod was created by Marc Guevremont and it really shows how extensible the Rocket Commander engine is.
New features include a completely new Landscape rendering algorithm and a very clever way to build canyon levels.
The mod also contains language files for german, english and french text support for the first time.

The gameplay is basically the same as Rocket Commander, just collect all the items and fly to the end of the levels.
Because the game looks so much different, you will play it very different from Rocket Commander.
Instead of avoiding asteroids you have to fly through canyons and avoid flying into a canyon wall.
This may sound easy, but it is a lot harder than just avoiding some asteroids because you can't see very far.

About the source code for this game: You can probably see quite easily that all the namespaces are still intact
and that most of the engine is unchanged, but if you take a look into the game namespace you will see a lot of new
classes. For the terrain rendering Marc implemented his own classes and he used the basic dependencies from
Rocket Commander to solve all the base rendering, physics and collision testing and finally the game management.

Good job Marc, thanks for the effort. Everyone else: Have fun!


Version 1.0 (16 November 2006) - 2.8 MB (requires Rocket Commander to be installed first)
Screenshots:


Canyon Commander main menu


Canyon Commander first level


Canyon Commander spiky canyon


Canyon Commander avoid the mines



 Tuesday, November 14, 2006
Tuesday, November 14, 2006 9:22:27 PM UTC (  |  |  |  |  |  |  )
Someone recorded XNA Racer, which was shown at some Tokio Gameshow named "kotaku".

Here is the original link. Some harsh tone in those comments, no you don't have to pay 99 dollars to play this game, it will be completly free. And about the "boring" gameplay, hey it was not done, this was just an alpha preview and the game looks much better now and is getting better physics and levels as we speak. Well, at least some are comparing it to AAA titles, thats always nice (and totally crazy, you wouldn't compare a house build by 1 guy to a scyscrapper).

Thanks for posting about it to ZMan and Ultrahead.

I guess I have to release a video of the game myself, these leaked videos look not very pretty and showing off an early alpha version has its disadvantages (almost 90% of the ingame objects are missing, the video shows the second track, which is not done yet, completely dummy and it was an early alpha version, the game runs now about 3 times faster).

As some of you (like ZMan) already found out, there is also an XNA book coming out written by me. I just started a few weeks back writing it (but it will be complete by the end of the year). Funny you can already order it on amazon. I will write more about it when its done. You will not only learn about game programming and XNA, but there will be plenty of practical examples in the book. In every of the 14 chapters a new game is introduced and you go though the process of writing a game from start to finish.



One final note: Canyon Commander is a lot of fun, it is a new mod, which will come out in the next days.


Btw: The Coding4Fun site was redesigned in the last weeks and most of the old links do not work anymore (which is something MSDN usually never does). But now most of the content is back and can be found in the new categories (Rocket Commander is under Games -> Arcade). I also updated the link on www.RocketCommander.com and the link for the video tutorials is:
http://msdn.microsoft.com/coding4fun/gaming/arcade/article.aspx?articleid=997852

Update: The old link works now too, I guess the MSDN relinking system is working as expected now :)
 Thursday, November 09, 2006
Thursday, November 09, 2006 5:08:20 AM UTC (  |  |  |  |  |  |  )
This was my first day working at Microsoft. Pretty interesting people work there and a lot of them. Good thing no one noticed that I'm not able to remember 500 names per second. I was installing stuff half of the day, but I found out more about XNA and already fixed some issues. Before talking more about my day, here are some News:

The XNA Team did a little 2 minute video of a couple of XNA games, my starter kit XNA Racer (which I hadn't talked about yet in detail, but that will come soon) can be seen at the end of the video. I got a lot of nice comments about that already :)


Here is the link to the video (Major Nelson has a nice blog btw):
http://www.majornelson.com/archive/2006/11/08/zune-video-xna-video-montage.aspx
And this is David Weller talking about it:
http://letskilldave.com/archive/2006/11/08/XNA-Video-Montage-_2300_1-is-ready-for-you_2100_.aspx

A nice guy from France with the name "Marc Guevremont" made yet another Rocket Commander Mod and this one just looks impressive. He managed to implement a landscape engine with shadow mapping (I guess precalculated). It looks very much like Rebel Assault. The game itself is still similar to Rocket Commander, but it looks so much different and he also made 3 cool levels. The game is called Canyon Commander and will hopefully be available soon.

More information, screenshots and a video can be found in the Rocket Commander Forums and here: http://www.webs7.com/Canyon/

I did not make many pictures today and it was to dark when we drove back to make any useful pictures with my phone camera.

Driving through Seattle.

And going over the long Evergreen Point Floating Bridge between Seattle and Redmond. It goes over the lake Washington and I couldn't get an answer if a Russian atom u-boot could fit under the bridge.

I was told that Bill Gates has his house somewhere on the right here, but you can't see it, too much leaves.

More pictures tomorrow.

 Friday, October 27, 2006
Friday, October 27, 2006 2:43:20 PM UTC (  |  |  |  |  |  )
Hi everyone,

sorry for not posting anything for a long time now (last post is almost 2 months away). I was very busy writing a new cool game with help of the XNA Framework, the game will also be a starter kit in the upcoming XNA Game Studio Express release and it looks really cool. More about that later ...

In the meantime our new causal games brand www.Quicksandentertainment.de released Pizza Commander on www.PizzaCommander.de (I talked about the game in August) and a new game Rocket Racer was just released, which is also based on the Rocket Commander Engine. You can check it out here: www.RocketRacer.de
For both games there is a demo available (just 20 MB), so you can check out the game and see if you like it. The full version is currently only available in Germany and Poland, but we keep searching for more publishers and continue to release it worldwide :)

In Rocket Racer you fly around with your Rocket and it feels very similar as Rocket Commander at first, but it has a lot of new graphics and effects. After a while you will see that just flying around will not do it, you have to fly through gates to get time and more points. If your time runs out, you die. The levels are quite challenging and I played the game over 10 times now from start to finish and it still is fun :D Well, call me crazy.

In the meantime the new DirectX SDK October 2006 came out. It features now a better PIX tool and makes it possible to debug shaders directly from your applications, which might be useful for Managed DirectX applications. Managed DirectX 2.0 is now also removed and will not work anymore (e.g. NormalMapCompressor v1.4 will not work anymore, use NormalMapCompressor v1.3 or v1.2).

Microsoft also announced a few days ago that there will be a second XNA beta in a few weeks, while the final release is going to happen later this year (which means december and before the holidays). The new beta will include many new cool features, for example the content pipeline and support for model files and also a lot more help and documentation.

More information about XNA, tips, my development diaries and the new upcoming XNA Starter Kit Game I wrote will come soon :)
Rocket Racer Screenshot 1:


Rocket Racer Screenshot 2:


Rocket Racer Screenshot 3:


Pizza Commander Screenshot:
 Thursday, August 31, 2006
Thursday, August 31, 2006 6:07:47 AM UTC (  |  |  |  |  |  |  )

  • Download XNA Beta1

  • XNA Framework Forum and XNA Game Studio Express Forum

  • Getting Started: Open C# Express (which is XNA Game Studio), Help->Content->Select XNA and navigate to Getting Started with XNA and read through Your First XNA Game

  • Next you could try out the Space War Starter Kit Game. If you can't control the game read this tutorial from xnaspot.com about changing it to support keyboard input.

  • x64 Bit platform support: Read this blog entry for an easy fix. Basically just add <PlatformTarget>x86</PlatformTarget> to your csproj file.
    Or download and extract this file (Xna64BitSupport.zip 14 KB) into:
    C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\VCSExpress\

  • Blogs:

  • Tutorials:

  • Interessting reads:


  • And now finally my own thoughts and tips:

    • How to render fonts like with Direct3D.Font?

      Well, thats not possible, there are not Font classes in XNA at all yet! You have to create your own font code by rendering bitmap fonts. If you want to see some code about that check out the SpaceWar Starter Kit and look inside the Font.cs class. The fonts in SpaceWar just contain numbers, but the game contains some text. How did they do that? Well, they just put most of the text in the game directly onto the textures, buttons, etc.
      Here is also a forum post about this issue and some source code, which might help.

    • How to play sounds?

      Thats quite easy, create sounds with XAct, load them in your game and then use the SoundBank class to play your sounds. Some tutorials can be found in the help and a simple example is in the Sound.cs file in SpaceWar Starter Kit.

    • Okay, where do I add my mp3 for some music playback?

      Could you stop asking this questions? Arg, I'm asking myself this, oh no. But I guess sooner or later this would come up anyway. Well the solution? There is none. No, I'm not kidding. There is no support for mp3, wma or CD playback of music in XNA. On the windows platform you could use some external stuff (DirectShow, MCI, external libraries, etc.), but on the XBox360 you are stuck with XAct, which does just support sound effect files.

      Ok, then just let add the .mp3 as a .wav file there. Yup, thats possible, but consider your game size. If your binaries are maybe 1MB, textures 5-10MB and sounds 2MB you don't want to add 3*50MB for 3 music files. I had quite a long discussion with some music artist about this issue and we agreed that it would be best to do try out some 22kHz mono sounds for the music for a smaller game size. Don't even try to think about any compression, the only format that XAct eats is PCM .Wav files. Sample them down or live with mega-files, your choice ...

    • How to add Controller (Mouse, Keyboard, XBox360 Controller) support?

      Again, this is not hard stuff. If you have worked with XInput before, this will be easy for you. Otherwise just read the XNA Programming Guide->Input pages, which all contain easy to work with code samples.

    • How to show a mouse cursor?

      You might notice that there is no mouse cursor in the samples, starter kit or any new project you create. The reason for this is that by default the Game.IsMouseVisible is set to false. If you set it to true (e.g. in your game constructor) you will see the mouse cursor again (write: this.IsMouseVisible = true;). Another way would be to display your own custom mouse cursor as a sprite at the current mouse position (see help to get mouse position, it is quit easy).

    • How to capture keyboard text?

      Well, thats not that easy. You can only check the state of each button (mouse, keyboard, whatever), but you can't get the text directly like with the OnKeyPress event in window forms. One way would be to write your own custom text handling, like this:

      string chatText = "";
      List
      keysLastFrame = new List();

      ...

      Keys[] keysNow = Keyboard.GetState().GetPressedKeys();
      foreach (Keys key in keysNow)
          if (keysLastFrame.Contains(key) == false)
              chatText += key.ToString();
      keysLastFrame = new List
      (keysNow);

      But this has the disadvantage if you run low on frames or the user types very fast you might miss some keys (test this by adding Thread.Sleep(50)), which really sucks. It is also a bit of work to get all the special keys, shift combinations, backspace, etc. working. For windows apps it might be wise to think about capuring the keyboard directly with some dummy form (very easy to get text then with OnKeyPress). Another approach would be to create an extra thread just for handling the keyboard at a high rate to make sure you catch all the keys. More about this solution can be found in this post.

    • What about drawing lines, boxes or other simple 2d stuff?

      Oh no, this is one of the parts that is really annoying and this does require some rethinking because all this kind of rendering was done with help of the fixed function pipeline (hello DirectX 7), which is no longer supported in XNA. It was never easy in DirectX to draw lines or filled boxes, you had to create your own vertex buffer or just draw some primitives and set all kinds of renderstages, but with XNA this gets even more complicated. Better not tell anyone how simple this is in OpenGL (glLine anyone ^^).

      So how can we draw some lines in 3d?

      Again: It is very important to know that you have to do EVERYTHING with shaders! The Sprite classes are just some helpers, but for 3d you need shaders, nothing else will work! I say this that often because many people in the XNA Forum already having problems rendering data and do not understand that if you don't have a shader around your rendering code, nothing will happen! Additionally you have to make sure you pass all the required data to your shader, there is a lot more work involved that just rendering some primitives in DirectX using the fixed function pipeline.

      I will try to keep this as short as possible, but you will see this is quite a lot of code for just rendering a single line. Here we go. We start with the variables we need (add to your Game class):

      Matrix Projection = Matrix.Identity,
      View = Matrix.Identity;
      Vector3 pos1 = new Vector3(0, 0, 0),
      pos2 = new Vector3(100, 100, 100);
      VertexPositionColor[] lineVertices =
      new VertexPositionColor[2];
      lineVertices[0] = new VertexPositionColor(pos1, Color.Red);
      lineVertices[1] = new VertexPositionColor(pos2, Color.Yellow);

      Effect effect = null;
      EffectParameter worldViewProj = null;

      We will use the Projection and View to calculate the worldViewProj matrix for our shader to convert the 3d coordinates to 2d (yep, I told you, we have to do everything ourself). If you want some camera control, always update the View matrix, which again you have to manage yourself (hello XNA team, some help with this basic stuff plz). Ok, lets continue before I explode, here is the initialization code (copy to your Game constructor):

      float aspectRatio = (float)TestGame.Width / (float)TestGame.Height;
      Projection = Matrix.CreatePerspectiveFieldOfView(
          (float)Math.PI / 2, aspectRatio, 0.1f, 1000.0f);
      View = Matrix.CreateLookAt(
          new Vector3(0, 0, -50), Vector3.Zero, Vector3.Up);

      CompiledEffect compiledEffect = Effect.CompileEffectFromFile(
          "Shaders\\LineRendering.fx", null, null, CompilerOptions.None,
          TargetPlatform.Windows);
      effect = new Effect(TestGame.Device,
          compiledEffect.GetShaderCode(), CompilerOptions.None, null);

      worldViewProj = effect.Parameters["worldViewProj"];

      Ok, what happens here? First of all we calculate our aspect ratio, nothing special. Then we have to calculate our projection and view matrices (please read the DirectX documentation if you have no idea what I'm talking about). Basically we have a field of view of 90 degrees (PI/2), we use our aspect ratio and we have a view range from 0.1 (near) to 1000.0 units (far). Then we create our camera at the position (0, 0, -50) looking at the center of our scene.

      Next we have to load our shader effect file. Yes, I told you about that earlier, we need a freaking shader to draw our simple line. We will get into that in a little bit, but ALWAYS make sure the .fx file is correct (test with FX Composer first). If the .fx file contains compiler errors you get unfunny NullReferenceExceptions, which won't help you (see below). Finally we are getting the worldViewProj parameter. This is the only line of this whole line code I really appreciate. Getting shader parameters is now a lot easier and cleaner, good work here! Also working with shaders is very easy now.

      Time to continue with our code, we need the rendering code (add to Draw()) now:

      // Start line shader
      effect.Begin(EffectStateOptions.Default);
      effect.Techniques[0].Passes[0].Begin();

      // Render line
      worldViewProj.SetValue(View * Projection);
      TestGame.device.VertexDeclaration = new VertexDeclaration(
      TestGame.device, VertexPositionColor.VertexElements);

      TestGame.device.DrawUserPrimitives
      (
      PrimitiveType.LineList, 1, lineVertices);

      // End shader
      effect.Techniques[0].Passes[0].End();
      effect.End();

      This code is pretty straight forward. We start our shader and select the first technique (the only one we got). Then we calculate our worldViewProj matrix from the View and Projection matrices we calculated in the constructor. After setting the VertexDeclaration we can draw our primitives, which are lines in our case. Just one to be more specific. Adding more lines is quite easy at this point. Finally we have to close the rendering pass (we just got 1 pass, else we would have to make a foreach loop around this code) and we also close the shader.

      So far so good, but how does the rendering now happen? 100% in the shader, the code we just wrote will do nothing more than calling the shader with the data we set, the line point positions and colors. So lets take a look at the shader, which does all the rendering. The shader itself is quite simple:

      // File: LineRendering.fx, Author: Abi
      // Code lines: 52, Size of file: 1,18 KB
      // Creation date: 31.08.2006 05:36
      // Last modified: 31.08.2006 06:44
      // Generated with Commenter by abi.exDream.com
      // Note: To test this use FX Composer from NVIDIA!


      string description = "Line rendering helper shader for XNA";

      // Default variables, supported by the engine
      float4x4 worldViewProj : WorldViewProjection;

      struct VertexInput
      {
          float3 pos : POSITION;
          float4 color : COLOR;
      };

      struct VertexOutput
      {
          float4 pos : POSITION;
          float4 color : COLOR;
      };

      VertexOutput LineRenderingVS(VertexInput In)
      {
          VertexOutput Out;

          // Transform position
          Out.pos = mul(float4(In.pos, 1), worldViewProj);
          Out.color = In.color;

          // And pass everything to the pixel shader
          return Out;
      } // LineRenderingVS(VertexInput In)

      float4 LineRenderingPS(VertexOutput In) : Color
      {
          return In.color;
      } // LineRenderingPS(VertexOutput In)

      // Techniques
      technique LineRendering
      {
          pass Pass0
          {
              VertexShader = compile vs_1_1 LineRenderingVS();
              PixelShader = compile ps_1_1 LineRenderingPS();
          } // Pass0
      } // LineRendering

      And thats it. As you can see we just take the input position, transform it and then output the color we interpolated through the vertex shader. The pixel shader has just to output the color. Working with other primitive types can be done in a similar way, so I hope this code helps.

      And what about 2d lines?

      2D lines can be done quite similary. In DirectX you would never think about rendering 2D lines with shaders, when it is so much easier with the fixed function pipeline. But this is not possible in XNA, so we have to use shaders again. Lets go quickly through the code that is required:

      Matrix Projection = Matrix.Identity,
      View = Matrix.Identity;
      Point pos1 = new Point(0, 0),
      pos2 = new Point(500, 250);
      VertexPositionColor[] lineVertices =
      new VertexPositionColor[2];
      Effect effect = null;
      EffectParameter worldViewProj = null;

      Very similar to what we had above, only our positions are now Points and not Vector3. Also note we don't calculate the lineVertices here because the data is resolution dependant and we have to grab the resolution from the graphics object first. Lets take a look at the initialization code:

      float aspectRatio = (float)TestGame.Width / (float)TestGame.Height;
      Projection = Matrix.CreatePerspectiveFieldOfView(
          (float)Math.PI / 2, aspectRatio, 0.1f, 1000.0f);
      View = Matrix.CreateLookAt(
          new Vector3(0, 0, -50), Vector3.Zero, Vector3.Up);

      lineVertices[0] = new VertexPositionColor(
          new Vector3(
          -1.0f + 2.0f * pos1.X / TestGame.Width,
          -(-1.0f + 2.0f * pos1.Y / TestGame.Height), 0), Color.Red);
      lineVertices[1] = new VertexPositionColor(
          new Vector3(
          -1.0f + 2.0f * pos2.X / TestGame.Width,
          -(-1.0f + 2.0f * pos2.Y / TestGame.Height), 0), Color.Green);

      CompiledEffect compiledEffect = Effect.CompileEffectFromFile(
          "Shaders\\LineRendering2D.fx", null, null, CompilerOptions.None,
          TargetPlatform.Windows);
      effect = new Effect(TestGame.Device,
          compiledEffect.GetShaderCode(), CompilerOptions.None, null);

      worldViewProj = effect.Parameters["worldViewProj"];

      This looks slightly more complex. The reason for that is the conversation from pixel coordinates to screen space, which goes from -1 to +1 and has y inverted. We could also do this calculation in the vertex shader, but I like C# more ^^ Please also note that we don't need the z coordinate, but it is way easier to just use the VertexPositionColor struct instead of creating our own struct. Lets continue with the rendering.

      // Start line shader
      effect.Begin(EffectStateOptions.Default);
      effect.Techniques[0].Passes[0].Begin();

      // Render line
      worldViewProj.SetValue(View * Projection);
      TestGame.device.VertexDeclaration = new VertexDeclaration(
      TestGame.device, VertexPositionColor.VertexElements);

      TestGame.device.DrawUserPrimitives
      (
      PrimitiveType.LineList, 1, lineVertices);

      // End shader
      effect.Techniques[0].Passes[0].End();
      effect.End();

      Nothing changed here, nothing we have to discuss. Everything works just the same. lets take a look at the shader!

      // File: LineRendering2D.fx, Author: Abi
      // Code lines: 52, Size of file: 1,18 KB
      // Creation date: 31.08.2006 05:36
      // Last modified: 31.08.2006 06:55
      // Generated with Commenter by abi.exDream.com
      // Note: To test this use FX Composer from NVIDIA!


      string description = "Line rendering in 2D space shader for XNA";

      // Default variables, supported by the engine

      float4x4 worldViewProj : WorldViewProjection;

      struct VertexInput
      {
          float3 pos : POSITION;
          float4 color : COLOR;
      };

      struct VertexOutput
      {
          float4 pos : POSITION;
          float4 color : COLOR;
      };

      VertexOutput LineRendering2DVS(VertexInput In)
      {
          VertexOutput Out;

          // Transform position
          Out.pos = float4(In.pos, 1);
          Out.color = In.color;

          // And pass everything to the pixel shader
          return Out;
      } // LineRendering2DVS(VertexInput In)

      float4 LineRendering2DPS(VertexOutput In) : Color
      {
          return In.color;
      } // LineRendering2DPS(VertexOutput In)

      // Techniques
      technique LineRendering2D
      {
          pass Pass0
          {
              VertexShader = compile vs_1_1 LineRendering2DVS();
              PixelShader = compile ps_1_1 LineRendering2DPS();
          } // Pass0
      } // LineRendering2D

      Not much changed here either. Only the vertex shader is changed, we don't have to use our worldViewProj matrix anymore. We are just copying the data over to the pixel shader for rendering the screen stuff directly.

      Thats it for rendering 2D data. I guess most 2D stuff will be covered by the Sprite class, but if you need some custom 2d stuff (lines, boxes, etc.) this code should help you out. Have fun writing more complex stuff.

    • Ok, if the line stuff is that hard, lets do some simple mesh rendering, right?

      Wrong again. While this was planed for the XNA Beta release, it didn't make it into the beta and you have to do your own mesh loading, handling and rendering. In the SpaceWar Starter Kit game you can find some code to load swm model files (wtf is this format?), but you can't render .x or .fbx files that easily yet. In the future no problem, but right know you are f .. erm, not able to ^^. When I got some code for mesh loading and rendering, I will show it :-)

    • Content Management, what about that?

      Well, its quite cool to just drop your content files into your project and then you can directly access them in your code. But since this feature is not supported yet, there is no point discussing it ... If you want to read stuff anyway, check this blog posts about the content pipeline out: http://blogs.msdn.com/xna/archive/2006/08/29/730168.aspx and http://blogs.msdn.com/shawnhar/archive/2006/08/26/725954.aspx.

    • Why are there so few help topics in the most important namespace Microsoft.XNA.Graphics, especially for 3d rendering?

      Well, since most of the line rendering, mesh or even the content pipeline is not supported, it is no wonder some important topics are missing. The help basically just tells you how to create a textured cube yet, nothing else. But this is also an early beta release, expect more help topics in the future. The many new XNA pages that are created these days (like 10 new ones each day ^^) will also provide a lot of resources. I bet XNA will have a really big community after a while. XNA has already interessted a lot of people about this new technology.

      Please also try to use the DirectX documentation as backup help in case you need more tutorials, samples and documentation.

    • Shaders?

      Yap, everything except Sprites has to be done with shaders. I guess this will be reason enough for most XNA games to never have any 3d content. Working with sprites is quite easy, but having to write custom shader code, declaring vertex types and having crazy random exceptions is nothing easy.

      For example if your shader fails to compile you get just a System.NullReferenceException: Object reference not set to an instance of an object. There is no explanation what did went wrong, which is pretty bad IMO. Shaders are really a pain in the ass because they are not managed in any way. Its just some script that gets compiled for the GPU and if anything went wrong you can hope your tools tell you exactly what to do. MDX did already suck in this regard, but from my quick early preview XNA is way worse. I really hope this part gets improved. What does nice and clean sprite, sound and controller programming help me if the 3d code is ugly as hell and as hard to write as c++ minus the debugging benefits from DirectX.

      Debugging DirectX? Yes, lets do that. First you need VS 2005 (see below how to get that to work with XNA). Now activate unmanaged Debugging and make sure DirectX is running in Debug mode (either go to your control panel and open up DirectX or use Start->Programs->DirectX->Utilities->Control Panel (which is the only available choice on x64 bit), now select debug mode and also set the Managed DirectX dlls to debug for better debugging support. Now when crazy NullReferenceExceptions happen and you are lucky you might see some helpful explanation.

      Scroll above to see some simple shaders for the line rendering stuff. There is also another shader example in the documentation, work with that code and change it with help of tools like FX Composer to find out about compiling errors beforehand.

    • Do I have to dispose textures, models, etc. like in MDX?

      Not really. I didn't notice any problems yet. I guess XNA has some mechanisms to collect all resources when disposing itself (game component and device). As you can see in the SpaceWar Starter Kit they didn't had to implement any disposing for their MeshCache or TextureCache lists in SpacewarGame.cs.

      This is quite cool IMO, it makes coding even easier than it was in MDX.

    • Why does my game crash with a NullReferenceException when I drag it over to another screen when using SpriteBatches?

      I guess this is some bug in the SpriteBatch class, which does not handle the device lost event correctly or something. It always crashes in the Begin() method when dragging the window out of my first screen. Since the SpriteBatch class does not have any events other than disposing, the best and simplest solution is just to add a event handler for the OnCreateDevice event and put your SpriteBatch creation code there too. This way it gets re-created when you need it. Would be nice if you didn't have to do this yourself ... XNA team reading this? Who knows ^^

    • Occlusion quering for example for lens flare effects?

      Not supported, check out this post.

    • What about Physics, AI, Collision, Particles, etc.?

      Not supported right now, check out this post. Since XNA is mainly a graphic engine with sound and controller support, it is not very likely you get advanced engine features soon.

    • How to get XNA working in VS 2005 (with all the plugins you might have, which do not work in Express)?

      Thats not supported or even possible out of the box! Read more about this here (Forum) and in the FAQ.

      But since I'm such a clever guy I modified the XNA templates quite a bit and added support opening the project in VS 2005. Read the full story here. Basically just download this: Xna64BitSupport.zip (14 KB) and extract it to:
      C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\VCSExpress\
      Now you can open your created XNA Game Studio Express projects in VS 2005 and continue working on them there.

    • Unit Testing in XNA?

      Quite simple, just add NUnit.Framework.dll, which is fully managed and should even work on the XBox360 (not that you need unit testing there). If you use VS Express, TestDriven.NET will not work (unless you have a version from last year, which still supported it). If you use VS 2005 use TestDriven.NET or TestRunner (tested it few weeks ago, very nice, but does not support static unit tests, big nono for me).

      I also suggest using a TestGame class and do many static unit tests to play around with XNA (I already wrote 5 static unit tests today). Thats much faster than to create a new project everytime. And each test looks much easier and shorter than a complete new project.

    • Performance of XNA compared to MDX or native DirectX.

      I couldn't detect any performance penalities yet, someone in the XNA forums had some problems archiving 800 fps when using bitmap fonts, dunno what that was about. But it is very hard to say how XNA performs in relation to MDX because there is not much code or games we can compare yet.

      But in my opinion it does not even matter, the XBox360 is fast enough even if you write really shitty code and the windows platform is also quite fast with all this dual core around. For most simpler or casual games this will never matter much. However I do strongly believe that XNA will perform on the same level as MDX and DirectX.

    • But I want to play my XNA game on my XBox 360?

      Me too, but we have to wait for the next drop of XNA ^^ Not supported yet.

    • What about Rocket Commander for the XBox 360?

      Well, I thought about that, but since many of the classes used in Rocket Commander are not supported yet in XNA and the actual XBox360 execution is not yet possible, why even bother? As soon as XBox360 XNA'ing is possible, I will consider a Rocket Commander port again.

    • Btw: Why is the SpaceWar Starter Kit so big (155 MB uncompressed)? There is not even music in it.

      Most textures are uncompressed as .tga files, not good ... Rocket Commander has more graphics, music and I guess more sound files too, but is less than 10 MB.

    • Need more help? Then ask in the XNA Forums and not here, I got stuff to do :D

Hope this helps. I will post more about XNA Trick & Tips soon ;-)

Yes, I'm writing a XNA game too. It will even be a Starter Kit for the next XNA Game Studio Release, more about that next week, I will post weekly screenshots like in the Rocket Commander Development time.

 Friday, August 18, 2006
Friday, August 18, 2006 6:32:56 AM UTC (  |  |  |  |  |  |  |  )
I installed Windows XP Professional x64 Bit today and this post is about my experiences with it. I tried it a year ago, but most drivers were not available for 64 bit back then. Now most drivers are supported and most programs will work without a problem. However some drivers and programs will still make trouble. Most of the issues could be resolved one way or another.

Generally I would say Windows XP x64 works great and is even a little bit faster than 32 bit Windows.


No problems

Had to change my mainboard because my current one went dead yesterday, I could use the same Windows x64 version without reinstalling, thats nice. Windows 32 bit does not work anymore (some driver troubles I guess). I also noticed that about Vista, no more reinstalls required if you change your board and cpu.

Games worked great, no problems here. I guess Microsoft plays a lot of games and wants to make sure all of them work, hehe. Even 15 year old games like Raptor (my all time shoot'n'up favorite) or Wolfenstein 3D worked without problems. Starcraft, Quake3 and current games worked nice too. Daemon Tools also provides a x64 bit version for Windows XP x86 for emulating CDs or DVDs.

Visual Studio 2005, DirectX SDK and all other development tools like VS Express, SharpDevelop, CodeRush, Perforce, UltraEdit, PCalc, NSIS, etc. work great too. For running 32 bit IIS apps you might have to follow these instructions.

Virtual Server 2005 works nicely and you can run virtual x64 and x86 computers, I guess the performance is also good or even better than before, but maybe my system is just faster.

Most normal programs did work too, but since nearly 99% of all programs are still 32 bit, it does not really make sense to have a 64bit platform yet. For browsing IE 64 bit is available and for Firefox (which is 32bit again) there is a 64 bit port called Deer Park, which works nicely. Both of these browsers are useful if you need more than 2 GB memory for your crazy browsing. Some programs do provide a x64 bit version, which works just the same way as the 32 bit version (I guess they did just a recompile with different compiler settings). I would say more programs and tools will be tested for x64 in the future, especially for Vista, when more users might choose x64 for their operating system.


Programs with problems

Most .NET 2.0 tools I tested did not work, but all of them could be fixed by changing the build setting from Any CPU to x86 Platform. While .NET 2.0 has NO problem running in 32 or 64 bit, it is not that easy in the case you call any external code (and almost all my tools do that). For example my AbiTrafficMonitor tool uses SharpPcap, which again uses wpcap.dll, which is only available as a 32bit dll. By forcing 32 bit to the application everything works great, in 64 bit the dll is not found and can't be forced. It is not possible to load 32 bit dlls in 64 bit mode, you will get the following error message when attempting to do that. An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

So you have to make sure a 64 bit version of all used dlls exists, else DO NOT use the Any CPU or x64 Platform settings. so this has to do something with .NET 2.0 (just some stupid compiler setting, recompile works, but a smarter version would be cool).

Here is the new installer for AbiTrafficMonitor, which works on Windows XP x64 too (by forcing the x86 mode). It does obviously still work on a normal 32 bit (x86) windows platform.

.NET 1.1 games like my Arena Wars game worked too, also .NET 1.1 tools worked fine. All .NET 1.1 assemblies run automatically as 32bit applications by design. .NET 2.0 runs automatically in 64bit mode on x64 platforms if All CPU is selected.

However my .NET 2.0 game Rocket Commander could not be started. Actually this is the same problem as above (not allowed to call 32 bit dlls from 64 bit code). .NET 2.0 runs fine in 64 bit mode and DirectX provides also 64 bit dlls, BUT Managed DirectX does NOT support using 64 bit. There is no version available to do that right now, neither MDX 1.1 nor MDX 2.0 support x64. So again, force the platform to be x86 and everything works again.

I recompiled Rocket Commander and it is available at the default download location: www.RocketCommander.com download page
There were also a couple of discussions about this issue in the Rocket Commander boards.

Another issue are external tools or helper tools like TestDriven.NET, which support x64, but it seems the underlaying NUnit Framework does work only in 32 bit. Not funny at all if you have a x64 bit app or just run All CPU on a x64 platform and want to test your code. This issue can be resolved by testing in 32 bit mode and then later switch to 64 bit if you want a 64 bit version of your app.

UltraEdit, WinZip and WinRar work fine, but all of them are 32 bit. So whats the problem? They all provide shell extensions for the Windows Explorer, which do not work in the 64bit version of the Explorer. There are 2 solutions for this.

  • Start the Windows Explorer 32 bit with the command line. Command:
    c:\windows\syswow64\explorer.exe /separate
    This didn't work very well for me, some of the shell commands did not work properly and it is really annoying to start the windows explorer this way. Often you might open a folder or jump to a containing folder, then of course the default 64 bit Windows Explorer is used.

  • Add your own shell commands in the registry. This works great for Open with UltraEdit or Extract files here, but if you need smarter commands like Extract to subfolder this doesn't help. Anyways, here is the solution. Add this file to your registry to add the following lines (change them to whatever you need):

    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\*\shell]

    [HKEY_CLASSES_ROOT\*\shell\Extract here]
    @="Extract here"
    [HKEY_CLASSES_ROOT\*\shell\Extract here\command]
    @="C:\\Program Files (x86)\\WinRAR\\winrar x \"%1\""

    [HKEY_CLASSES_ROOT\*\shell\Ultra Edit]
    @="Open with UltraEdit"
    [HKEY_CLASSES_ROOT\*\shell\Ultra Edit\command]
    @="c:\\Program Files (x86)\\ULTRAEDIT-32\\uedit32.exe \"%1\""


Programs and drivers that do not work

Some old setups like for the Panorama Wallpaper changer do not at all (wrong windows version error message), but I managed to install some of the manually (copying files and setting registry settings).

My on board network drivers do not work at all, neither does my old TV card, but I had many driver problems in Vista Beta 2 x64 too. I found a old 1Gbit network card that works and I never watch TV anyways. All other drivers (board, gfx, sound, mouse, keyboard) work just fine.

Update 2008-08-19: My onboard sound really sucks and I tried to install my old PCI Soundcard (XFire 1024), but since the vendor does not provide 64 bit drivers, there is no way I can use that card. The onboard network adapter (Marvell 88E1111) also stopped working and does not even show up. Another old VIA VT6120 1gbit card could be installed, but didn't work either. Maybe I have to try out deactivating the other cards and then it should work, a 64 bit driver is installed.

Now to my main issue: You cannot use ANY new keyboard layouts at all! I really need my own AbiKeyboardV9 layout to type efficiently. I tried like 10 different other keyboard layouts too, all of them can be installed, but as soon as you try to use a new layout you always get a error message like "Windows could not load the x keyboard layout.". Not funny at all and I found absolutely NOTHING for either vista or x64 Windows to fix this problem on the internet. I used the Microsoft Keyboard Layout Creator, which works great on Windows XP 32 bit and lower. But this tool was last updated 2003 and the support for future windows version or x64 is just not-existant. Other tools I tried (keytrans, klm, etc.) suck even more and usually cost a lot of money, none of them worked on 64 bit or provide any useful features for me. All of them work only in 32bit.

More links on that topic (all of them have x64 bit problems and are unresolved)
http://www.planetamd64.com/lofiversion/index.php/t15929.html
http://blogs.msdn.com/michkap/archive/2006/01/26/517728.aspx
http://blogs.msdn.com/michkap/archive/2005/10/06/477930.aspx

I found some information on Marks Blog from Sysinternals in which he provides a solution to his Cap2Ctrl tool (which just maps the Caps Lock key to Ctrl). Similar to that I found out which keys have which codes with help of the scancode.doc doc from Microsoft for keyboard developers and wrote my own keyboard remapping code.

While the normal keys worked great and were changed in a couple of minutes all the special keys are messed up because I had different meanings for pressing shift with special keys. I found no solution to that so I updated my keyboard layout, there were some minor changes I wanted to do anyways. This is my new keyboard layout, which now works on all windows versions (finally I can use Vista too ^^). Some keys are not optimal, but to support both the german and US keyboards some '/" have to be used twice (scan code 2B) and some keys like -/_ had to be moved to worse positions (relative to my old layout, not much of a difference compared on the US layout). This can't be fixed with scancode remapping. I've used my new layout for a couple of hours now and it seems fine. The most annoying changes are <>, (), \|- and -_, everything else stays, but I guess I will manage.

This is my new Keyboard Layout:

  • AbiKeyboardLayout v10
  • To install you can use the following file: abi keyboard installer.reg
  • And uninstall it again with this file: abi keyboard uninstall.reg
  • This is the content of abi keyboard installer.reg:

    Windows Registry Editor Version 5.00

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
    "Scancode Map"=hex:00,00,00,00, 00,00,00,00, 19,00,00,00, 2A,00,3A,00, 2B,00,0C,00, 0C,00,0D,00, 0D,00,10,00, 19,00,12,00, 15,00,14,00, 10,00,15,00, 22,00,16,00, 20,00,17,00, 21,00,18,00, 25,00,19,00, 28,00,2B,00, 18,00,1F,00, 12,00,20,00, 16,00,21,00, 17,00,22,00, 1F,00,24,00, 14,00,25,00, 31,00,26,00, 26,00,27,00, 27,00,28,00, 0C,00,56,00, 24,00,30,00, 30,00,31,00, 00,00,00,00

    To understand the scan codes and how this binary code is formated please read this document: scancode.doc.

So far so good, I will stick with x64 and you guys know now how complicated my computer is ^^

 Thursday, August 03, 2006
Thursday, August 03, 2006 8:59:19 PM UTC (  |  |  |  |  )
The new Pizza Commander game (check out my old post, Pizza Commander is the first Rocket Commander Mod going commerical) is finished and we also build a website for it, you can check that out at:
www.Quicksandentertainment.de

The game is quite a lot of fun. There are 15 Missions, some for beginners and some for better players. There are also some screenshots available on the Quicksand website. A demo will also come soon.

Other than that I'm working on updating a couple of my tools (mainly CR_Commenter and AppTrafficMonitor), adding a lot of features and fixing bugs. More on that this weekend.

More announcements of new projects I'm currently involved in are also coming soon.

Also: The new DirectX SDK August 2006 just came out. Check it out.

Quicksand entertainment website:


New Pizza Commander Screenshot:
 Monday, July 03, 2006
Monday, July 03, 2006 3:29:49 AM UTC (  |  |  |  |  |  )
It never stops, does it? There is yet another Mod for Rocket Commander. It is called Virus Commander and was made by Interwanderer aka Erdem Yarici, known from the Rocket Commander boards. In the beginning he had a lot of questions and not much experience with game development, but after watching the tutorials and playing around with the code, he managed to create his own mod. Looks pretty good for the first try, music is also nice. The gameplay itself is not much different from Flower Commander, but I bet Interwanderer will tweak that as well in the future. Anyway, have fun with the new mod :-)

Download links:

Virus Commander main menu:


Big Virus in the game:
 Friday, June 30, 2006
Friday, June 30, 2006 7:23:58 AM UTC (  |  |  |  )
I'm happy to announce, that one of my Rocket Commander Mods "Pizza Commander" got some attention by a german low budget publisher Novitas. Novitas, also known for its Green Pepper and Pepper Games series, will release a special version of Pizza Commander in September 2006. The game will not be like the original game, the game principle is completly new, but we still use the Rocket Commander engine. There will be at least 10 new levels and missions with very entertaining game rules.

More on that can be found on our new label for budget games www.quicksandentertainment.de (nothing there yet, but there will be information soon).

I might post some screens of the version and the new cool game ideas in the next month when we develop this game.

Btw: The www.Coding4Fun.de Quick Tutorials are all finished now and will hopefully be released soon, I will report on that too.

This is NOT how the Pizza Commander Reloaded retail game will look like ^^
 Wednesday, June 28, 2006
Wednesday, June 28, 2006 10:39:17 PM UTC (  |  |  |  |  )
For the upcoming "Quick Tutorials" on www.Coding4Fun.de I did a new game modification of Rocket Commander. And guess what, in times like this, where everyone is watching the WorldCup of Fussball/Soccer, we need a Fussball Commmander (not really, but it is fun anyways).

Don't expect too much, this is just a 5-minute game modification. The game is pretty simple, actually it is the same as Rocket Commander and it fits perfectly into a Quick Tutorial, where I just explain the basic steps what to do if you want to create your own game or mod. Have fun. The Coding4fun Quick Tutorials will be released shortly.

Download links:

Fussball Commander main menu:


Fussball Commander In game:
 Monday, June 26, 2006
Monday, June 26, 2006 9:05:01 PM UTC (  |  |  |  |  |  )
The biggest german magazine for dot.net technology, called "dot.net magazin" wrote a nice 3 page article about Rocket Commander, the technology and engine behind it and a little interview with me. It really sounds great reading about .NET 2.0 and games, I get the feeling like I'm being normal ^^

Jens Konerow, the author of the article, wrote really nice stuff about me, thanks :) I'm not really a regular reader of the magazine (I only read english stuff, can't speak german anymore, hehe), but I check out their cool website and articles from time to time.

More information can be found on the official dot.net magazine site. If you have a chance to pick up the magazine, go do it, lots of interessting stuff in there :)

German Dot.net magazine:
 Saturday, May 27, 2006
Saturday, May 27, 2006 8:36:03 PM UTC (  |  |  |  |  |  )
Yesterday the newest issue of the german GameStar/dev magazine came out. The title story is "Bau dein eigenes Spiel" (Build your own game) and was written by me. The article explains how you can develop your own game with the Rocket Commander as an example.

More information can be found on the official GameStar/dev site. If you have a chance to pick up the magazine, go do it, lots of interessting stuff in there :)

My little boo plugin is coming in a working stage. I really hate all this try'n'error developing with the VS SDK, but I hope I don't have to go through it again (should continue to work, shouldn't it?). Maybe I can release an early version of the boo plugin next month sometime.

German GameStar/dev magazine:
 Tuesday, May 23, 2006
Tuesday, May 23, 2006 4:36:10 PM UTC (  |  |  |  |  )
Last weekend I was on a little conference in Fulda, which turned into lan session in the evening (Prometheus). It was fun and we (orgas and me) decided to do a little fast coding contest. The idea was to create a text adventure in a couple of hours. While the contestents were working I was a little bored so I created my own adventure in just a couple of hours ;-)

I improved it a little the last 2 days (just added some graphics and sounds) and now I got a very cool adventure, which is fun to play I think. I hope you like it too. I also included the full source code. The whole game is based on the Rocket Commander Engine and shows you how easy it is (2000 lines of code) to create a fullblown 2D-Adventure with many cool effects.

Good luck in your adventure beating the evil zombies!

Download links:

Zombie Quest main menu:


Nice graphics in Zombie Quest:


Beware of the mall:
 Wednesday, May 17, 2006
Wednesday, May 17, 2006 9:39:08 PM UTC (  |  |  |  |  |  )
Hi there. If you watched one of my webcasts and need a link or something, I can help you out :-)

Searching for more webcasts?


Rocket Commander Webcast Part 1 of 3: The Graphic Engine (16 May 2006)


Rocket Commander Webcast Part 2 of 3: Shaders (17 May 2006)


Rocket Commander Webcast Part 3 of 3: Creating your own Game Modification (19 May 2006)

 Monday, May 15, 2006
Monday, May 15, 2006 12:32:00 AM UTC (  |  |  |  |  |  )
I was a NDoc User in the past, but the support for .NET 2.0 is very bad and the project isn't updated anymore. There are a couple of hotfixes, but they don't really work with any of my .NET 2.0 projects including Rocket Commander (see here (msdn forums), here (.NET 2.0 fix) and here here (blog bla)).

I tried a couple of other tools, but they either cost too much or they just don't work. Today I tried the new version of Doxygen and yes it is not only capable of analysing .NET 2.0 code, but it produces also very nice outputs in many formats:

  • Plain Html
  • Html with Frames
  • Compressed Html (.chm)
  • LaTeX
  • Man pages (wtf? they are still in use?)
  • Rich Text Format (RTF, word style)
  • Xml

I just took all the Rocket Commander sourcecode and made a html help page, check it out here: abi/RocketCommanderSourceCode/index.html">http://abi/RocketCommanderSourceCode/index.html.

You can generate your own help, as you know the full source code of Rocket Commander is freely available. Doxygen is also open source and a great tool.

Btw: I'm currently using GIMP (GNU Image Manipulation Program, or: A photoshop knock-off). I'm not really happy with many of the choices the developers made (multiple windows always overlapping and losing focus, own stupid save dialog, not many hotkey binding per default), but its free and very powerful. At least it supports a lot more stuff than Paint.NET (where you can't even paint with a soft brush for some reason). So if you are still using Paint or Paint.NET, consider becoming a GIMP user :-)

Doxygen program:


abi/RocketCommanderSourceCode/index.html">Rocket Commander SourceCode with Doxygen:
 Friday, May 12, 2006
Friday, May 12, 2006 3:05:05 PM UTC (  |  |  |  |  )

I just wanted to remind you of the 3 webcasts I will do about Game Development next week.
Its about the Rocket Commander game in particular and many other topics (see below).

I will talk about the following topics:
  • Part 1: The graphic engine
  • Learning Game Development from Rocket Commander
  • Introducing Rocket Commander
  • The graphic engine and its features
  • How to write your own graphic engine
  • Time for questions about graphics

  • Part 2: Shaders
  • What are Shaders?
  • Example Games
  • Create Shader files with FXComposer
  • Normal Mapping
  • Implementing Shaders into the Engine
  • Feel free to ask any questions you have about Shaders.

  • Part 3: Creating a Game Modification
  • Input devices and User Interface
  • Keyboard, Mouse and XBox Controller
  • Menu and IGameScreen classes
  • Game logic and how to change it
  • Creating Flower Commander
  • New main menu, new models, etc.
  • Testing the finished Mod
  • Game logic discussion and FAQ session at the end.

See you next week ;-)

 Tuesday, May 02, 2006
Tuesday, May 02, 2006 8:50:39 PM UTC (  |  |  |  |  |  )
Hey Rocket Commander players, a new Mod is out: Pizza Commander. It is a lot of fun and the most advanced mod released yet. More information and the downloads can be found on www.RocketCommander.com/Mods.html#PizzaCommander.

Features:

  • Lots of new models, check them out with the ModelViewer
  • New sounds, very funny ;-)
  • New camera controlling and better collision detection
  • The fly (tm) ^^
  • Lots more, just check it out.
  • Almost 20 000 Rocket Commander played online games right now, Wow!

No more Rocket Commander mods for me now, if you want more: Write some yourself :-)
I'm working on my Boo addin for VS now (in my free time, this blog is always about stuff I do on my free time, sorry can't tell you the ubersecret real projects yet ^^).

Btw: My polynapping attempt this weekend failed. I couldn't stay awake for more than 1-2 naps and had headaches after staying up too long. Have to try it again sometime in the future.

Pizza Commander:


 Tuesday, April 25, 2006
Tuesday, April 25, 2006 5:47:45 AM UTC (  |  |  |  |  )
I wasn't checking the Rocket Commander for the last few days and today I was adding the new Mods to the Website. I was amazed how many games were played in just 3-4 days (more than in the whole month till then). Seems the Coding4Fun site on MSDN is attracking a lot of people to try it out ^^

I've been working on the Fruit Commander and Pizza Commander Mods for Rocket Commander (sorry for the delay, had a couple of other things to do), they are both similar to the Flower Commander Mod, but more advanced and include a lot of new cool features. The Pizza Commander is still in the Beta-Stage and will be released tomorrow (I think ^^). The Fruit Commander is finished and tested, so why not release it :)

In the Fruit Commander you have to collect as much fruits as possible, but beware: There are also rotten fruits, which are bad for your health. You have also to be careful about the Vitamin levels of each fruit, it will not be healty for you just to collect 1 fruit type (you need all vitamins). There are also a lot of other cool features in the game. Just to name a few: New camera with auto-roll, SpecularMap shader, cool chilling soundtrack, new UI and a lot of game logic changes. The full source code is also provided, check out www.RocketCommander.com

Another cool tool would be the Rocket Commander Model Viewer, which allows you to view all kinds of models in the Rocket Commander game and its Mods. It is easy to use and very useful to check stuff out. There is also a VB.net and c# Version available and the best of all: It is just 300 lines of code and very easy to understand. I made the VB version just for fun, changing the code into any other .NET language shouldn't be hard either. You can find all download links in the Mods/Other section on the www.RocketCommander.com website.
RC Model Viewer Tool:

Again: Check out the Rocket Commander Video Tutorials on Coding4Fun if you haven't already: http://msdn.microsoft.com/coding4fun/ gamedevelopment/rocketcmd/default.aspx

Btw: Thanks for all the news, blog posts, etc. mentioning Rocket Commander, the website traffic increased by the factor 10 in the last couple of days ;-)


Fruit Commander Main Menu


Fruit Commander Game Screen


Pizza Commander, coming soon
 Wednesday, April 19, 2006
Wednesday, April 19, 2006 8:13:49 PM UTC (  |  |  |  |  )
Good news: The english version of the Rocket Commander Tutorial Videos are now avialable at http://msdn.microsoft.com/coding4fun/gamedevelopment/rocketcmd/default.aspx
Check them out in case you couldn't understand the german ones yet ^^

There are 10 Video Tutorials and a lot of links and help avialable for anyone interessted in game programming. This are the 10 Tutorials, each video is 40 minutes and there are plenty of links and information in the tutorials.

  • Tutorial #1. How do I setup Visual Studio for our project?
  • Tutorial #2. Design and Concept
  • Tutorial #3. Helper classes
  • Tutorial #4. Graphic classes
  • Tutorial #5. Music and Sound
  • Tutorial #6. Shader Introduction (TangentVertex class and FxComposer)
  • Tutorial #7. Shaders (Parallax, Instancing)
  • Tutorial #8. Post Screen Shaders
  • Tutorial #9. Input and Interface
  • Tutorial #10. Game logic and the Flower Commander Mod

Another good news is coming from microsoft, who decided to make all Visual Studio Express editions 100% free (prior to this they were only free to download until October 2006). In just 5 months over 5 million copies of Visual Studio Express were already downloaded, thats really a lot for just a developer tool!

Last but not least there is also some cool stuff coming up tomorrow: 2 new Mods for the Rocket Commander and more cool stuff on www.RocketCommander.com.

Rocket Commander Tutorials:
 Wednesday, April 12, 2006
Wednesday, April 12, 2006 1:29:23 AM UTC (  |  |  |  |  |  )
Before I begin brabbling about my problems, first the good news: The DirectX April 2006 SDK came out yesterday. There is more new Direct3D 10 Beta stuff and more samples for XACT (thats for audio creation), etc. This is the news for Managed DirectX:

Managed DirectX 2.0 Beta Update

Microsoft is working on a new managed gaming framework which will target Windows and Xbox 360 known as the XNA Framework. The majority of what exists today as the Managed DirectX 2.0 beta will become a key component of the XNA Framework. Managed DirectX 2.0 will continue to ship as a beta in subsequent SDK releases of the DirectX SDK until a beta of the XNA Framework is made available. While we are striving to deliver a smooth transition from code written to use the Managed DirectX 2.0 beta, Microsoft can make no guarantees about the API compatibility between the Managed DirectX 2.0 beta and the upcoming graphics API’s in the XNA Framework. Microsoft will be providing guidance about the API differences as well as migration assistance as more information becomes available regarding the XNA Framework.

The following is an initial list of known changes which will exist between the Managed DirectX 2.0 beta and what Microsoft will deliver with the XNA Framework. This list will be updated as more information is available, and is as always subject to change.

  • Managed XACT and managed XInput will replace managed DirectSound and managed DirectInput respectively. Managed DirectSound and managed DirectInput will no longer be available in the XNA Framework. However, DirectSound and DirectInput will still be available for developers who choose to use Managed DirectX 1.1.
  • Managed DxDiag will not be available in the XNA Framework. DxDiag support will still be available for developers using Managed DirectX 1.1.
  • Microsoft is actively investigating how to bring forward functionality from Direct 3DX 9.0 into the XNA Framework. D3DX9 will still be supported in MDX 1.1
  • Please note that Managed DirectX 1.1 is fully compatible with the .NET Framework 2.0.
The XNA Framework will be supported on several architectures (including 64-bit) for both Windows and Xbox 360.

So what does this mean for us fellow Managed DirectX programmers? First of all: Forget MDX2, it will never get to any final version. If you need DirectX in .NET just use MDX1 for now. The XNA framework will replace MDX2 in the future, but it isn't here yet. And to confuse us .NET programmers even more there is now a managed Direct3D 10 wrapper (but like native Direct3D 10 it requires Vista to run). For me this means I will stay with MDX1 until XNA becomes useable.

Another thing I find very annoying is the fact that there is still no documentation for MDX2 and MDX1 is still in the "August 2005 state". I hope that's going to be better with XNA ... don't really know what Microsoft expect developers to do with a beta version like MDX2 with no documentation at all. Want to read more discussions about this DirectX release? Then check out this post from David Weller yesterday at gamedev.net.

Ok back to the topic about Quo Vadis: Sorry for posting so late, but I wanted to post my impressions and pics of the Quo Vadis last week after we drove back. Sadly my handy (mda pro) decided to stop working and I couldn't charge it up again. When connecting to the PC with USB the connection was only available for a couple of seconds and then everything went dead. Today I finally opened up the device and found out that the whole usb connector was broken and actually fell of the main board in my PDA. Tomorrow I will try to mess everything up by soldering it back together. If I'm not careful that's it for the device.

Anyways, the problem was I couldn't get the photos back and I have no idea who called my since last week and I don't care anymore ^^ today I got some of the pics on the memory card back to my PC with help of a card reader (I don't have one). But most of the pics are missing, I only got a few boring ones ^^

Quo Vadis Conference pics:
Driving to the Quo Vadis with
way to high HDR lighting.


One of the conference rooms.
This is were I held my talk
about .NET 2.0 too (room 3).


People at Quo Vadis


The autodesk booth


Chilling between the sessions.
On the right side you can also
see the Rocket Commander poster.
We presented and played RC there.


Sorry, don't have any more pics :(
 Sunday, April 02, 2006
Sunday, April 02, 2006 10:56:51 AM UTC (  |  |  |  |  )
At the end of next week the German Quo Vadis Developer Conference will be held in Oberhausen near Essen (germany). The event will take place from 2006-04-06 to the 2006-04-08 and a lot of german game developers and even publishers will be there.

At the first day 2006-04-06 at 16:00 I will present the newest tricks of .NET 2.0 in game development and talk a little about Rocket Commander too. The session name is "Vortrag - Making of Rocket Commander - .NET 2.0 Technologie. Ein exDream Project - Benjamin Nitschke, exDream", you can check out the full schedule here: Quo Vadis Program pdf. Don't ask me how I will do that, I never done such thing before, but I think I will be fine. Shouldn't be much different from making video tutorials, except maybe there will be an audience, ahhhh ^^ just kidding.

In the next few weeks the english Rocket Commander Video Tutorials will be available on Microsofts Coding4Fun site. But there is even more! I will perform also 3 webcasts in May about game development and the Rocket Commander game. They will be in english and hosted by Microsoft, dunno the links yet (links will be posted as soon as I know them), but here are the times:

  • Tuesday, May 16, 2006 9AM - 10AM PST (6PM - 7PM CET)
    Rocket Commander Part 1: The graphic engine.
  • Wednesday, May 17, 2006 9AM - 10AM PST (6PM - 7PM CET)
    Rocket Commander Part 2: User Interface, Sound and more
  • Friday, May 19, 2006 9AM - 10AM PST (6PM - 7PM CET)
    Rocket Commander Part 3: Game design and creating a game mod
More on that later.

I wanted to post a couple of tools (Collision, physics, enemy unit AI, etc) earlier this week I done over the time for Rocket Commander and Coop Commander, but I got the flu and was very sick and weak all week. Maybe I will be able to finish the tools in the next couple of days and post them here, we will see.

Other than that: Hope to see ya at the Quo Vadis conference.

Quo Vadis Developer Conference

Coding4Fun site:
 Sunday, March 19, 2006
Sunday, March 19, 2006 3:33:49 AM UTC (  |  |  |  |  )
I'm not a XBox 360 User nor do I want one yet, but that has nothing to do with its great hardware features or that I like any other console better. I never owned any console and I always was on the PC side (or HC side back in the C64 days), just because it is more customizeable. But maybe this will change in the future?

Earlier this week: As many of you propably know already Tom Miller, the great Managed DirectX guy at Microsoft, switched over to the XNA team and is working on the XBox team right now. More information can be found at The Z-Buffer. This lead to some speculations and is now backed up at the GDC 2006, where several XNA sessions are held and at lot of people are bloging about it (and I'm sad I can't be there, too expensive trip for me right now ^^). Some interessting posts: Managed code on Xbox 360 Developer Kits by Dan Fernandez (Microsoft - Lead Product Manager - Visual Studio Express), did you just say .NET on XBox 360! by brains-n-brawn.com and A Market Within A Market (was .NET in HD) by Mike Zintel.

I think this all sounds promising, maybe in the near future .NET games like the Rocket Commander are possible on the XBox 360 without major pain rewriting all kinds of things.


On the other side: Hackers are working for 4 months trying to crack the XBox 360 .. and let just say they were not very succesfull in the past. I saw some videos and webcast about early XBox 360 hacking attempts in January from the 22. Chaos Communication Congress (CCC) and it didn't look very "hacked" back then.
But things have changed. Few hours ago this video was released: Xbox360 DVD Firmware Hacked. Hmm, that does not look good, does it? There are some interessting discussions about it here: XboxHacker BBS. There have not released anything but infos yet, but I don't think this will stop the "evil guys" from making prirated XBox 360 games soon and maybe there will be a "modded" XBox 360 soon too. I just thought this was interessting ...


Btw: I noticed that currently a lot of people are playing Rocket Commander, nearly 1000 games yesterday. Nice .. But there seems to be a bug with the daily details list .. hmm, have to fix that .. bye.

XBox 360 Launch in Asia.
This is a very big XBox in Hongkong:

XBox 360 hacked, the first video:
 Friday, March 17, 2006
Friday, March 17, 2006 3:41:33 PM UTC (  |  |  |  )
I finally found some time to finish the Rocket Commander website. A lot of features were still missing and it makes much more sense to have seperate highscores for each mod (each mod has a completely different scoring system). It is also cool to see who is currently good on a specific map. Maybe you are not the best overall player, but you maybe in the top players for the 'Easy Flight' Mission ^^

I'm also happy to announce that I will create Rocket Commander Video Tutorials in english (for msdn.microsoft.com/coding4fun), similar to the ones in german on www.Coding4Fun.de (check it out if you havn't visit it already - and you understand german ^^). I often get emails or icq message of people who want to do a specific thing like create a simple shader and now I can refer to the video tutorials and don't have to explain anything anymore :)

Btw: Thanks for the many positiv feedback about Rocket Commander, similar to EuroVernichter I see a lot of people playing it, but usually I never get much feedback. For example the boards are not really used right now (the german board has some discussions), but maybe this will start as people run into problems when creating their own mods. Or maybe everything runs so smooth that noone has any problems? Who knows ...

Other than that I'm now finished with all that Rocket Commander stuff and I will continue coding a little Coop Commander this weekend, but other than that I can focus my time back to my regular projects (currently writing a cool shader designer tool, if any of you want to know).

New Rocket Commander Site:
And the same site in the Flower Commander look:
 Monday, March 13, 2006
Monday, March 13, 2006 4:21:14 PM UTC (  |  |  |  |  )
I've updated the www.RocketCommander.com website a little bit, especially the Download and Mods sections. The new database for all mods is up and running, but I hadn't had time to finish the web application yet (lots of new features).


Anyways, the new Flower Commander V1.1 Mod is available too (added the features from Rocket Commander V1.1, especially the AutoUpdater) and it is available on www.RocketCommander.com now.

And finally I've made a Coop Commander Alpha Version Preview video. It just contains some basic gameplay, but it looks promising, doesn't it? Have fun. It will probably take another 1 or 2 weekends till the game is more or less finished and will be released.

Flower Commander V1.1 is out:
Coop Commander Preview Video
 Sunday, March 12, 2006
Sunday, March 12, 2006 2:05:59 PM UTC (  |  |  |  |  )
Hey everyone. The game Rocket Commander and its source code is now available on www.RocketCommander.com. More features and stuff will be available on the website in the next couple of days, stay tuned.

I've also updated Rocket Commander to Version 1.1. It contains a couple of new cool features:

  • XBox360 Controller support, just plug it in and have fun with the rumble feature.
  • A new exciting mission: The Revenge. It will be very hard and it is full of tricks. Be sure to complete it a couple of times normally before trying to attempt special tricks.
  • AutoUpdater functionallity for future updates. Will be checked every time you launch the game.
And as allways full source code is provided. Have fun!
The new www.RocketCommander.com site
 Friday, March 10, 2006
Friday, March 10, 2006 9:01:08 PM UTC (  |  |  |  |  |  )
I bought an XBox 360 Controller yesterday just for fun. I'm not a console player and I'm not very comfortable with console controllers (they are not very good for RTS or Shooter games), but I thought maybe it would be fun to play Rocket Commander with the new XBox 360 Controller. Especially the rumble feature would make sense if hitting an asteroid.

I've implemented support for the XBox 360 controller this morning with help of XInput, which was pretty easy (there are just 4 methods, I only need 3 of them, thats it). The only annoying thing is that XInput is not available for Managed DirectX yet, only the c++ dll supports it and the beta Managed DirectX for .NET 2.0 dll, which isn't used for Rocket Commander. But importing the 4 methods with DllImport is no biggy. If you want to know more about implementing XInput either check out the new Rocket Commander V1.1 source code or this link:
http://www.brains-n-brawn.com/default.aspx?vDir=mcexinput


I was on the CeBIT today and it was pretty interessting, I will be there the next couple of days too. I can be found either running around on the Microsoft booth in hall 4 or on our own booth in hall 27/C29 (esports and entertainment). At microsoft you might see the presentation about Coding4Fun.de and ClubSite4Fun and GameDev4Fun, which contains the Rocket Commander and Flower Commander too. I haven't finished the website for www.RocketCommander.com yet, but hopefully I will finish most of it this night.

Thanks to Polynapping I still have some extra time these days, but it isn't easy with the CeBIT and staying awake for longer than 10 hours most of the time. I usually sleep after the fair in the evening for 1.5 hours and before going to it again 1.5-3.0 hours. Also every 4 hours 20 minutes of sleep in the night. Most people ask me if I feel tired all day and here is the answer: No! I'm even more awake most of the time because I feel refreshed after napping or sleeping for a short while.

Back to the CeBIT: On the right you can also see a picture of me in the new Volkswagen car "Eos". Tomorrow I will make some more pictures.

I will post another blog entry later today when the new Rocket Commander website is finished.

The XBox 360 Controller


and Rocket Commander working together now :)


That's me in the new Volkswagen car "Eos" on the CeBIT 2006:
 Monday, March 06, 2006
Monday, March 06, 2006 3:04:32 PM UTC (  |  |  |  |  |  )

exDream entertainment will be at the CeBIT again this year. You can find us at the  CeBIT 2006 in Hannover: Hall 27/C29 (Digital Media by nordmedia). The CeBit starts at 2006-03-09 and ends 2006-03-15.

Polynapping: I think I will adjust my polynapping schedule for this week to stay awake for 8 hours over the day. I have several meetings and I don't think it would be cool to fall asleep there ^^ I would bet the CeBIT is also not very polynapping-friendly. Instead of sleeping 6 times 20 minutes I will sleep now only 4 times 20 minutes (evening and night) and before I go to work I sleep 3 hours straight. This will keep me awake for 8 hours (at least it worked today :-) ), then 4 polynapps follow and the same thing starts over the next day. Thats now twice as much sleep as before (4 hours instead of 2-3), but still only half the amount normal people sleep.

Coop Commander: Looks quite good, the game physics and ship control are finished now and it is quite fun to shoot around and see everything exloding. There are still 2 major issues left: Good enemy unit AI (they move pretty stupid right now, either straight ahead or on a collision path) and multiplayer syncronization. Dunno if I can make it this week, but I should have some time at nights with my new schedule to keep working on that.

 Saturday, March 04, 2006
Saturday, March 04, 2006 5:40:59 PM UTC (  |  |  |  |  |  )
Ok, I have a lot on my mind right now, hopefully I will get to most of it ^^

First of all: Here is a new screenshot of Coop Commander. I've implemented laser effects for the ships and improved some of the effects. Today I will finish up the game physic and damage system and tomorrow some multiplayer code will hopefully bring this game to life. While it may not be realistic to release the game together with Rocket Commander, at least not in its final version, I still plan to finish most of the issues till thursday, when Rocket Commander is released. Maybe I will just release an alpha version and then go from there.

I also registered the domain Coop Commander today, maybe this will make me think more seriously about Coop Commander ^^ I will start coding the website when the game is released.


As some Arena Wars players have noticed the Arena Wars boards had a lot of troubles the last couple of month (lots of spam, hacks, etc.). I installed a fresh new shiny version of the boards and copied a spam-free-version (couple of months old) of the board over it. Updating to the newest sql, phpBB, etc. versions was a lot of work. Those open source guys just don't know how to make an easy installer. The most annoying part was php, which is incredible incompatible (versions 4 and 5). First the site worked, but the board didn't, then the board was updated and worked, but the site wasn't compatible to that again. After modifying a lot of php files finally I got it working, but php is no fun at all.

There are also new discussion boards for Rocket Commander and its Mods. Hopefully they will find some use since Microsoft isn't planing to implement any boards on its german Coding4Fun site, where Rocket Commander will be hosted.


Polynapping: What happend? Well, it went ok for 2-3 weeks and I overslept only a few times, but never more than 2-3 hours per day and max. 1-2 times per week. Well it happens, especially if you stay awake for too long. That can really mess up your polynapping sleeping schedule. Then last week I crashed after a party and slept for nearly 8 hours. Must have something to do with the huge amount of alcohol I drunk (again: not good for polynapping) ^^

Then I went for a biphasic sleeping pattern (2*1.5-3 hours of sleep per day) for a couple of days and that didn't work out. I slept monophasic (thats normal 7-8 hours of sleep) for few days and then decided this wednesday I had to go back to polyphasic sleep. More time, more fun and hell, I know what to expect now.


Next week will be very hard for me because of the CeBIT fair (exDream will be there on several booths, I will post some info about that next week). Sleeping somewhere else isn't an easy thing for me, I still have some troubles getting to sleep as it is. That is also the main reason polynapping over a long period of time wasn't succesful for most testers. It is hard to get to sleep every 4 hours. Not only physically, but especially socially.

The last nap I took (only 20 minutes) was incredible refreshing, maybe I sometimes sleep to long (30-40 minutes since I don't know if I fall asleep right away or stay awake for 10-15 more minutes). Steve Pavlina posts here that 20 Minutes worked best for him too and he also gives a lot of tips and information about polynapping. He even was interviewed by the NY Times. I guess he is currently the most famous polynapper.

I nearly forgot to mention that Frederic Schneider wrote a nice article about me on GamePorts (in german). It is about Rocket Commander and my current project Coop Commander. Check it out here: http://www.gameports.net/cms/Kommentare-zu_Der-Erfolg-eines-Deutschen_966.html

Coop Commander: The new ion cannon effect.


ArenaWars.net Boards back up again.


German article about me on GamePorts.net:
 Monday, February 27, 2006
Monday, February 27, 2006 4:43:06 PM UTC (  |  |  |  |  )
Hey everyone. Sorry for not posting anything in the last week. The main reason is the fact that I have too much work to do and not much time for developing Coop Commander (it is still a secondonary project for me, but it looks quite good at the moment). Instead of doing the same mistakes this week again I will pause the development of Coop Commander until this weekend.

There were 2 main problems last week that kept me from posting any updates or screenshots. I wanted to finish the multiplayer stuff, which worked ok in the beginning (chat, lobby, simple in game messages, no problems here, worked after 2 days of coding), but later everything was screwed. The system was far to simple and there was no way to syncronize everything without rewriting a lot of game code. The other problem was the effect manager. Just adding few effects was no big deal, but finetuning every single effect and finding out each position for each unit where to spawn effects, units, smoke, etc. was a long process.

Last weekend I just finished the effects stuff and next weekend I will hopefully finish all multiplayer issues (the game isn't very syncron right now ^^). It does not really matter because there are still over 1.5 weeks left till Rocket Commander is released. By then Coop Commander should be working stable. Maybe we will also add more missions and more enemy ships.

So what is the problem with all this multiplayer code? I can tell you:

  • No Time to implement any complicated network system
  • No Engine to use, I've got sockets, thats it.
  • Directly sending all game data causes too much bandwidth. The server should be able to handle thousands of users with less than 1mbit.
  • RTS game tick based approach too indirect and jerky. Let me explain: Directly implementing a game tick based approach like in RTS games would be a lot of work and while keeping the network bandwidth low, the gameplay would be no fun at all. In RTS games the player can't control anything directly. When he orders a unit to move, the sound may play instantly, but the unit will not move for a couple of 100 ms (usually 1-2 game ticks, which is 200-400ms). While this is perfectly fine for RTS games with a lot of units, in the case of Coop Commander the player only controls 1 unit and directly sees what is going on. This makes this approach unusable.
  • Client-side prediction is both too much work and very sucky for laggy situations. It is also not supported by RC and would be quite a lot of work to implement.
  • Shooters usually use UDP and send out a lot of data, which makes them require a server for each game in contrast to MMORPGs, RTS or RPGs, which usually only require 1 master server, which either handles all the players directly or let the clients host their own games.
  • I'm crazy enough to try something new
So I wrote a concept of a new network architecture called Half'n'Half Server-Client Model and I implemented some unit tests to try it out. Some new problems did occur I hadn't thought of and testing and fixing all those problems could take some additional time. Since I don't want to be a total jerkoff and tell you how great this new network game architecture is while there is no proof that it does actually work, I will wait until I have implemented a basic version of this Half'n'Half Server-Client Model into Coop Commander and played around with it.

The basic idea is to split the network code to the server and the clients. The server manages all important data (live or die, spawning of units, etc.), while the client manages all the complicated and bandwidth-demanding data himself and only sends results to the server. This includes player collisions, doing damage, controlling the ship, etc. The server can still reject messages that make no sense and most important game actions like collecting items, powerups or killing units will not actually happen until the server confirms it.

This architecture targets very bad networks (lag situations above 500ms, up to 1000-2000ms) while making the game still "enjoyable" enough for the player and it minimizes the bandwidth for all players and the server to an absolute minimum (around max. 100 bytes/sec, that's it).

For now, just enjoy the screenshots ^^ There will be no beta because the game itself is online-only and will update itself as long as I have fun developing it. You should be able to download it from www.RocketCommander.com around 9. March 2006.

The calm before the storm:
The multiplayer game screen with 2 players:


The is a Carrier on the left side and there a lot of
fire balls in the scene comming from the Bombers on
the right side. The other player TestPC is also visible.


A little deeper in the first mission a lot of Mine Layers
put these mine field into place and the Carrier
spawns new units all the time. Not much chance for
the Lizard (my ship) on its own ^^
 Thursday, February 16, 2006
Thursday, February 16, 2006 10:27:07 PM UTC (  |  |  |  |  )
This is a very early screen of Coop Commander. The modeler is complaining that I show it on my blog because most of the textures are still missing (all the ships in the backgroud ^^). But I think it looks promising. The Effect system and all basic units are implemented and some of the game logic is working too. Basically it is just a bunch of unit tests right now, not a full game.

Today I started with the Multiplayer coding. I hope I can finish the Game Server by tomorrow. Usually this takes a couple of weeks (chat lobby, player management, game lobby, game server), but I will try to minimize the features and do it as quickly as possible (I still want Coop Commander to be finished in roufly 1 week). By the end of the week the game should be playable. Next week we plan some final balancing and finetuning of the effects and units.

The game will be released together with Rocket Commander in 2-3 weeks, stay tuned!

Polynapping: Little note to self: I worked way to much the last 2 days and missed a couple of naps and then was too excited to sleep sometimes. Then last night I overslept for 3 hours and can't even remember turning off the alarm clock. I guess I have to pay more attention keeping my polynapping schedule. Also working too much, like I do at the moment, isn't that good for polynapping, the body needs some rest. Relaxing in 1-2 phases is a good thing. I will report back next week how I'm doing with my Polynapping.

Sneak preview of Coop Commander:
 Tuesday, February 14, 2006
Tuesday, February 14, 2006 3:15:25 AM UTC (  |  |  |  |  |  )
Last week I've finished up the Rocket Commander Game Programming Video Tutorials. They will be released on the german Coding4Fun Site together with the Launch of Rocket Commander. I guess that will be at the end of this month or in the beginning of march. Anyway, for the last Tutorial I made a cool Mod (Game Modification) called Flower Commander. You can see a screenshot of that game in action on the left side. It took less than 1 day of work. The gameplay is somehow similar to the original game. However the graphics are very different.

This week is the last one for my interns (little shoutout to Christoph Rienäcker and Enrico Cieslik) and we thought we could do something cool. My current projects are mostly finished. For example today I finished the 3ds max exporter and importer for my engine, now I hope I don't have to do c++ for a long time. Maybe next week I can teleport myself back to reality with some boo coding and finishing my Visual Studio Boo Language Extension ...

Since I have so much time every day (22 hours thanks to polynapping), it is time to do something. We plan to make another Mod called Coop Commander and it will be finished by the end of this week. Basically it is a multiplayer cooperative shoot'n'up with rpg elements. Kinda Diablo2 in Space ^^ I will post some screenshots from time to time. It uses the basic engine of Rocket Commander and will be freely available like the original game. This are the basic game principles: Similar to Rocket Commander you fly through the space and try to accomplish each mission. There are 6 different kind of enemy units in the game and you can choose from 3 units, which all get stronger over the time and have completly different abilities (rpg elements). The game will be balanced for up to 3-4 players. You can also play it with just 2 players, but it will be hard. Singleplayer is considered to be impossible, you have to meet with other players to be able to fight off all enemy unit types (each unit class has it weaknesses).

Obviously Coop Commander will not be able to compete with any AAA title, but we would like to see if this idea works out and maybe it is a lot of fun to play with your friends some challenging missions. Additional elements, more beta testing, more levels and enemies can be added later. I like the idea of finishing the game in 1 week, but it will be a lot of work (there is no effect system, no unit system and no multiplayer in Rocket Commander and that need to be added).

Polynapping, the second week: Nothing special to report. The last couple of days I slept regulary every 4 hours for 20-30 minutes (never more) and I'm very awake after few minutes when staying up. Going to bed has been easier too, but I still can't go to sleep immediatly (takes up to 5-10 minutes). Another strange thing is the fact I can't remember any dreams, no lucid dreams, no day dreams, nothing. Sometimes I feel like I have slept for several hours and then I look on the clock and it was just 25 minutes. I'm very awake at day and night and neither myself nor anyone else seem to notice anything different about me except the fact that I have go to sleep every 4 hours. But that is only annoying at work (sleeping there is hard because of noise, driving home and back is a pain in the ass).

Thanks for all the emails and concerns other people have with this. I'm not telling anyone to try this for yourself and I was not expecting for this to work. I just was curious and I think it is a very cool alternative sleeping pattern, especially if you are in need of time or want to experiment around. Maybe I will keep doing this for a couple of months and then switch to a biphasic sleep pattern and go back to polynapping from time to time. I'm not going to post much more about polynapping because I think most of the blogs I've posted last week cover all the interessting stuff and I agree with most of it.

Rocket Commander in action:

Flower Commander main menu:

Flower Commander in action:

 Saturday, December 24, 2005
Saturday, December 24, 2005 1:11:48 PM UTC (  |  |  |  |  )
Merry Christmas everyone. Instead of sleeping or preparing mentally for christmas (well, you know, all that hugging and eating), I wrote a special Rocket Commander Christmas Edition. I got also many requests of people wanting to join the beta, which was internal and closed a week ago.

So to make the time more painful until Rocket Commander is released, here is a nice little video of it. Just 40 seconds long and it shows only the very beginning of a level, but it is already 10 MB big and compressing it any more doesn't really make sense for such a high speed game. Anyways, enjoy the video (tip: right click and choose save as (rename it to some .wmv file) if your browser wants to directly play the file, which may cause a lot of waiting): RocketCommanderPreviewHigh.wmv (10 MB)

I will post more stuff about this year, my experiences and some more stuff next week. Stay tuned.

 Wednesday, December 14, 2005
Wednesday, December 14, 2005 7:26:07 AM UTC (  |  |  |  |  )
The rocket commander website does support few new features now (hour, day, week lists and top 100 for all lists). Btw: Thanks to all beta testers who reported bugs.

Monday of this week the DirectX December 2005 SDK did came out (with updated Managed DirectX for .NET 2.0 stuff and even a technical preview of DirectX 10, but this does require Vista to run).

Today I tried to port my NormalMapCompressor tool to Managed DirectX for .NET 2.0 (December 2005 Edition). If you want to port your DirectX code to .NET 2.0, this post could be helpful :) If you ask why even bother porting, here is the answer: For easier debugging (using Visual Studio 2005 with .NET 1.1 DirectX causes a lot of annoying Loader Lock errors when trying to debug, etc.)! Also I like to refactor my code from time to time and make it more clean if I continue working on it, this is what happens if you port to Managed DirectX for .NET 2.0.
Please also see this post from ZMan about DirectX for .NET 2.0 changes (he already wrote about it for the October 2005 edition).

I will only mention things that happend in this little project (NormalMapCompressor), I'm sure porting Rocket Commander over will take a couple of more refactorings.

  • The DXHelp class doesn't exist anymore. For using DXHelp.GetTypeSize(typeof(YourVertexStruct)) you have to use the VertexInformation class now:
    VertexInformation.GetDeclarationVertexSize(YourVertexStruct.VertexDeclaration, 0); and obviously you have to define the VertexDeclaration in your vertex class now (but I had that done anyways).
  • TextureLoader doesn't exist anymore either, I've used it to get image information.
    For that you can now use Texture.GetImageInformationFromFile
    (was TextureLoader.ImageInformationFromFile(filename) before).
  • Many methods now expect the device as the first parameter instead of the last (more consistent method parameters now). Some examples: Mesh.FromFile, Mesh.Clone or the Mesh constructors.
  • LockVertexBuffer and many other Mesh methods are simplified now and use generics and the GraphicBuffer class now. For example the following code:
    TangentVertex[] verts =
    (TangentVertex[])someMesh.LockVertexBuffer(
    typeof(TangentVertex),
    LockFlags.None,
    new int[1] { someMesh.NumberVertices });

    gets converted to:
    TangentVertex[] verts = someMesh.LockVertexBuffer(LockFlags.None).
    ReadArray(someMesh.NumberVertices);

    If you want to write to the GraphicBuffer just use Write(.), thats also much easier.
  • PresentParameters.Windowed is now called PresentParameters.IsWindowed
  • For some strange reason the device has to be created with an IntPtr instead of a form or control, ZMan also pointed that out here. Just write form.Handle or control.Handle now.
  • Device GetDeviceCaps becomes GetDeviceCapabilities, also all other Caps became Capabilities.
  • Matrix methods got a lot longer names, say hello to Matrix.PerspectiveFieldOfViewLeftHanded and Matrix.LookAtLeftHanded (instead of Matrix.PerspectiveFovLH and Matrix.LookAtLH). There are a lot more.
  • Material does not have the .Ambient property anymore, just .AmbientColor now, which is the ColorValue. This pretty much sucks because I use Color's all over the place and have to convert them to ColorValue now, wtf? Same for Diffuse, Specular and even SpecularSharpness got renamed to Power (I still think SpecularSharpness is a way better name). I don't agree with ZMan who says "nice to see this confusing mess tidied up".
    Material mat = new Material();
    mat.Ambient = darkCol;
    mat.Diffuse = lightCol;
    mat.Specular = lightCol;
    mat.SpecularSharpness = 16.0f;

    becomes
    Material mat = new Material();
    mat.AmbientColor = ColorValue.FromColor(darkCol);
    mat.DiffuseColor = ColorValue.FromColor(lightCol);
    mat.SpecularColor = ColorValue.FromColor(lightCol);
    mat.Power = 16.0f;
  • Light.Type becomes Light.LightType, I also don't like that change (Light.Type says it all, doesn't it?), but who cares.
  • TextureLoader.FromFile(device, filename) and TextureLoader.FromCubeFile(device, filename) are now new Texture(device, filename) and new CubeTexture(device, filename), much cleaner. Why not remove Effect.FromFile and similar methods too?
  • Effect.FromFile does require an EffectPool now (I just created an empty one, I only use 1 effect in NormalMapCompressor). Also the paramerters have changed a bit.

And now the only thing I couldn't resolve yet. If anyone has ANY tips or tricks to do this, please tell me!
I could not find out how to do TextureLoader.Save or any texture save functionality at all. I need this to save the generated textures as dds files (compressed of course), saving bmp files is no problem (just locking the texture data and building a bitmap with it, then saving that bitmap). I already tried to contact specialists like Tom Miller or ZMan, but no answer yet ^^

When that problem is resolved I will release the new version of the NormalMapCompressor.

 Monday, December 12, 2005
Monday, December 12, 2005 8:25:23 AM UTC (  |  |  |  |  )
I've improved the Beta a bit, added a couple of levels and the online highscore. The cool thing is it took only half a day to implement the webservice for Rocket Commander, then implement that into the game and finally create the whole website and database for it. Last time (with .Net 1.1) this took a couple of days. There are really some great improvements made for webservices, creating aspx websites and using webservices.

Anyway, I hope the beta testers will enjoy the new version and try to compete about archiving the best highscore on www.RocketCommander.com. Let's see who got the biggest balls, erm, skill :D

 Thursday, December 08, 2005
Thursday, December 08, 2005 9:21:49 PM UTC (  |  |  |  |  )
The internal Beta-Test for Rocket Commander started this week. I'm happy to hear everyone is enjoying the game. Even I'm surprised that the game is more fun than I thought 2 weeks ago. Sorry for not posting a new screen last week, you will get 2 nice screens this week instead :)

The website for the game and online highscores will be finished up this week too. A couple of minor bug fixes did drive me a bit mad today, like copying a 1 week old level file into the beta instead of the real updated one, omg ^^

Don't ask me when the game and sourcecode are available for the public, I just don't know yet. You may have to wait till January/Feburary until VS 2005 is released here in germany (since the game and sourcecode is included with the product, cool ehh?).

More on the Rocket Commander website in a couple of days when everyone is trying to archive the highest highscore.

 Wednesday, November 30, 2005
Wednesday, November 30, 2005 2:07:13 PM UTC (  |  |  |  |  )
About Rocket Commander: The game is nearly finished. I will post a new screenshot in a couple of days. The internal beta testing will start this week too.

Today we are going to the german developer price (german: Deutscher Entwicklerpreis).
Last year we won 2 prices for Arena Wars :)
I'm excited to see who will win some prices this year.
Hope to see some developer guys there.


http://www.deutscher-entwicklerpreis.de

 Thursday, November 24, 2005
Thursday, November 24, 2005 1:43:28 AM UTC (  |  |  |  |  )
The problem with many asteroids in a scene is finally solved. I spend most of the time optimizing the game loop, rendering and physics. I should have more time now to test and play the game and add some fun to it.

The game is now capable of calculating and updating over 10 000 asteroids (each over 1200 polygons) per frame while maintaining a reasonable framerate, which was not possible a week ago (I got many asteroids, but updating them was very slow and rendering wasn't very fast either). Usually a scene consists of 2-5k asteroids and runs pretty fast (over 100 fps with all shaders on, up to 200 fps without post screen effects). Physics aren't perfect yet, but the basic stuff works. I might need to speed a bit more time on player collisions for more accurate collision checks.

Since the graphics isn't so much different from last week and some new graphical stuff isn't finished yet (items, final sky, on screen layout), I present you today the main menu screen. Pretty boring, but I didn't say there will always be fancy screens every time I post stuff here. I looks much better in action because the background is an automatically updated asteroid field in realtime while the menu is in the foreground.

Other things like sounds and music do work now too. I said that 2 weeks ago already, but now all sound effects are included and Boje did a nice music track for the game.

The game itself is missing too. Flying around works nice, but most of the game elements (menu, items, game dynamics, etc.) are still missing. For the level design I had some nice ideas too, which I will try out this week (required for the optimizations above anyway).

Most of the game should be finished by next week. I will only do an update to DirectX 9 December 2005 as soon as it is available.

 Tuesday, November 15, 2005
Tuesday, November 15, 2005 2:44:33 AM UTC (  |  |  |  )
Alrighty, the second week passed and most of the graphical effects are implemented now. There will be some updates to the background sky and some additional asteroid types next week. Other than that not much more effects will be added yet. You can see the new radial blur effect (it won't be that strong all the time, only with speed boost item) and a nice post screen glow/bloom effect in the screenshot. There are currently around 10000 asteroids in the scene (clipped if not visible) and rendering is very fast (up to 13-20 mio visible polys/sec) with help of shader instancing :)

I've got still 2 major problems left: The first one is the performance of the physics calculations. For 10000 asteroids to check every one each frame if they collide with any other asteroid is computually very expensive. Even the visibility test gets very slow if a lot of asteroids are checked. I have to implement some clever checks to optimize this. The other one is a polygon based collision check for supporting not only round asteroids (that shouldn't be too hard, but it is a still a bit of work).

The game itself is missing too. Flying around works nice, but most of the game elements (menu, items, game dynamics, etc.) are still missing. For the level design I had some nice ideas too, which I will try out this week (required for the optimizations above anyway).

To be continued .. (next week)

 Monday, November 07, 2005
Monday, November 07, 2005 4:00:02 AM UTC (  |  |  |  |  )
Well, a week isn't really over yet, but since most of the planed work for this week is finished, I'm going to post a screen now. Unlike my posts for Lost Squadron I think it is much better to have weekly steps since you can see more changes in a week.

You can see on the screen the basic framework for the engine, it supports parallax shaders, cube maps (for the space background), music, sound and all other basic graphic elements. The lens flare isn't finished yet and most of the models are not fixed yet (there is an evil bug in 3DS Max 8 preventing us to export correct normal maps, somehow the tangent calculation inside of 3DS Max 8 to bake normal maps is not working as it was in 3DS Max 7).

This is still a very early screen (at least it is realtime and 3d ^^ please don't think anything is final art yet) and you won't get a feeling for the game yet. Hopefully next week this will look much better. Currently missing are also:

  • Some simple physics for all game elements (asteroids, rocket)
  • Main menu, Highscores, logos, texts, etc.
  • Post screen effects (motion blur, glow/bloom effects, hdr stuff).
  • Level design .. hmm, havn't got a clue how to solve that yet.
  • The game itself, items, fun and so on ...
  • The website too :)

See ya next week ^^

 Thursday, November 03, 2005
Thursday, November 03, 2005 5:15:12 PM UTC (  |  |  |  |  )
It's time for another cool game: Rocket Commander!

The cool thing about this game is the fact, that Microsoft will ship it with Visual Studio 2005 (german, release: feb 2006) and hopefully push it a little to make it more known :)

The full source code and game will also be available freely and can be used to learn .NET 2.0 and DirectX (using all the newest tricks with c# 2.0 and Managed DirectX for .NET 2.0). I will develop the game this month, dunno yet when the official online release will be, we will see (we may have to wait till 2006).

I will post screens and code tricks every week for this project and hopefully get some attention for this little fun game. The idea is pretty old, I've told this game idea a lot of people in the last 1.5 years, but I wasn't able to convince anyone that this is a really cool special and unusual game. Now I told some Microsoft guys the same idea (Dirk Primbs and Lars Lippert) they were really amazed and think this idea would be great (I thought they were kidding me at first).

This is the basic game idea: Rocket Commander is a little beginner friendly casual 3D game. The player finds himself inside a rocket flying through a city, an asteriod field or other levels. The basic task is not to kill enemies or to solve any quests like in many other games, but to finish a level by flying through it without colliding with anything. Additionally there are special items, which can be collected to increase the health of the rocket, add additional fuel, increase the speed for a short time and give more lifes.

Everything will be presented in a nice space enviroment using a lot of cool shaders (parallax mapping, glow effects, motion blur, hdr lighting, etc.) and a lot of cool effects and graphic tricks. It is still a casual simple game, which is hopefully a lot of fun to play. Since the source code is free, players are encouraged to modify it or add extensions, but this is a topic for a later time.


Another topic: 3D Studio Max 8 (3dsMax8) was released a little longer than a month ago and we are currently in the progress of writing an exporter for our in-game models (has nothing to do with Rocket Commander, which will just use simple .x files, which can be exchanged by the user). I posted the following stuff it the Autodesk Sparks board (but there isn't anything going on there, 2 views per day?):

I'm having very ugly problems with IGame and 3dsMax8. Every single exporter I tested (and recompiled using max8 sdk) using IGame crashes in 3dsMax8 while it was working on 3dsMax7. I've tested: IGameExporter (sample directory), creating a plugin with the vs wizzard (in vs2002, 2003 and 2005, no difference except a bunch of header file errors, which can be fixed easily) and using other IGame exporters.

This is what happens in every single one of the exporters using IGame I debugged, I've used IGameExporter.cpp to explain the problem:

IGameExporter.cpp line 2482:

igameVersion = GetIGameVersion();
igameVersion returns always 0 in 3dsMax8, in 3dsMax7 the exact same code produces igameVersion == 1073741824

that's strange, but the following line still is valid: IGameExporter.cpp line 2498:

pIgame = GetIGameInterface();

and finally when calling InitialiseIGame (no matter with what parameters or in what order) everything crashes: IGameExporter.cpp line 2504:

pIgame->InitialiseIGame(exportSelected);

Everything after that gets never executed. If commenting out that line, every other call with pIgame crashes (pIgame, which is of type IGameScene, is not null, it got a valid pointer value).

Now the solution to all this crap: Just copy over the IGame.dll (version 7.0.0.64) from 3dsMax7 to 3dsMax8 (just save the IGame.dll version 8.0.0.92) and now everything works fine. But I guess new features of IGame 2.0 (now called 3dxi - Date Exchange Interface or something) wont work this way ^^ A fix from Autodesk would be nice anyway.

There are still some things missing in 3dsMax7 (e.g. the IGameFx class), which can be annoying, but at least 3dsMax8 does not crash all the time. Let's hope they do a 3dsMax8 SP1 sometime soon. We also found out, that it is easier to develop for 3dsMax7 and then just use the plugin in 3dsMax8 too with the IGame.dll copied over from 3dsMax7. This also works nicely with other plugins like the Panda Exporter (for .x files) and other IGame exporters (which all crash in 3dsMax8). At least Microsoft isn't the only company which screws up with their managed DirectX releases, all the managed dll hell (wtf? I thought there is no dll hell anymore in .NET) and the still missing working MDX for .NET 2.0 final.

Investing a bit more resources would be nice to support important things like Managed DirectX (well, there is just Tom Miller from Microsoft) or plugins for 3DSMax (more or less just Neil Hazzard from Discreet). They are both great guys and they do a hell of a nice job managing such big tasks, but still: It would be nice if the companies would hire more people for this things. It's not like nobody is using Managed DirectX or never going to write a plugin for 3dsMax (which again is a hard job with c++, a write only language ^^).

Enough rambling, back to work ...

Search

Projects I currently work on

MeinSport.de - German Sport Community Site

StudiHelp.de - German Student Community Site

Arena Wars Reloaded

New Arena Wars Website

My book: Professional XNA Game Programming (May 2007)

Dungeon Quest

Racing Game XNA Starter Kit

Speedy Racer Mod (from da book)

XNA Shooter

Some unannounced projects (games, websites, wikis, and my favorite: a new programming language)

See completed projects on the left side

Downloads: Games, Tools and Sourcecode

Rocket Commander, Mods and SourceCode

NormalMapCompressor v1.3

CR_Commenter

AbiKeyboardV9 layout and CountMostUsedKeys