Home

Icarus

July 14, 2014

Just trying out the new (old, as it existed in the previous AirMess) Icarus track that will be available in the next AirMess Release (sometime in August :))

Advertisements

AirMess Ships

April 4, 2014

AirMess Ships

It’s coming!

Just for fun, here’s AirMess, as it was presented for ImagineCup France 2012 Finals.

AirMess ScreenShoot  1

AirMess ScreenShoot  2

AirMess ScreenShoot  3

Note that it’s a .ccgame.
To be able to install it, you’ll need Microsoft XNA Framework Redistributable 4.0

Have fun 😉

Say you have state defining struct you want to be copy:

 

        public struct MyStruct
        {
            public int A;
        }

Then use it like that:

            var S0 = new MyStruct();
            S0.A = 42;

            var S1 = S0;
            S1.A = 1337;

            Trace.WriteLine(String.Format("S0 = {0}, S1 = {1}", S0.A, S1.A));

The output is: S0 = 42, S1 = 1337
Even though S1 = S0, because it’s a struct it was copied. If I replace struct by class I get S0 = 1337, S1 = 1337. Everything’s normal.

Let say I want to have an array in this struct:

        public struct MyStruct
        {
            // Can't initialize the array directly
            public int[] A;

            // We can't customize the parameterless constructor
            public MyStruct(int size)
            {
                A = new int[size];
            }
        }

        var S0 = new MyStruct(1);
        S0.A[0] = 42;

        var S1 = S0;
        S1.A[0] = 1337;

        Trace.WriteLine(String.Format("S0 = {0}, S1 = {1}", S0.A[0], S1.A[0]));

The output is … S0 = 1337, S1 = 1337
That’s because the reference to the array was copied in the struct, not the actual value.
How can we have the array inside the struct?

        public unsafe struct MyStruct
        {
            public fixed int A[1];
        }

        unsafe static void Main(string[] args)
        {
            var S0 = new MyStruct();
            S0.A[0] = 42;

            var S1 = S0;
            S1.A[0] = 1337;

            Trace.WriteLine(String.Format("S0 = {0}, S1 = {1}", S0.A[0], S1.A[0]));
        }

And I get S0 = 42, S1 = 1337. But there are 2 problems in this approach.

  • You now have to build everything using the unsafe keyword because now A is a int*
  • This works:
                var S0 = new MyStruct();
                S0.A[1] = 42;
    
                var S1 = S0;
                S1.A[1] = 1337;
    
                Trace.WriteLine(String.Format("S0 = {0}, S1 = {1}", S0.A[1], S1.A[1]));
    

    .
    Even though my array is 1 element long, I was able to access the second in-existent element and change it. That’s a buffer overflow: because my array is now unsafe, the runtime no longer checks the boundaries of my array and I can access memory outside my allowed space.

What would be cool is if I was able to write that:

        public struct MyStruct
        {
            // hey C# compiler, create 10 int fields in my struct (from A0 to A9) and translate S0.A[i] to S0.Ai for me
            public int A[10];
        }

Btw I realize this wouldn’t work for some cases like, what should happen if we pass this A as a parameter for a method call expecting a regular array? If we try to store the A in a local int[], what would be in that variable? A new copy of this array? The address of that array in the struct that might be allocated on the stack? How should we track that reference?

But anyway, we can dream 🙂

So, I finally got this whole thing about Light, HDR and Shininess to work. This was a needed feature because AirMess’ visuals used to play a lot on very bright scenes, and I’m trying to recreate this effect in Kadma Engine.

Image

Next : the Sky !

One of the first thing you have to do when converting a project from XNA to something else (let say, SharpDX) is reinventing yourself a way to load assets.

XNA had a great content pipeline providing ways to import and process everything in Visual Studio during the build process, and that was one of the key points of the simplicity of XNA. When going through the DirectX way, I had to basically reproduce the same thing myself.

There are some alternatives though. Some guys have implemented a content pipeline for Mono for example, but I wanted to do it myself as I’m not using Mono anyway. If you want to do the same thing, you might want to take a shortcut to load models, and that shortcut is AssimpNet. It’s a wrapper for a library specialized in loading 3d models. The next step is just to process the data from Assimp’s format to your own.

You might get it right:

Image

Or wrong …

Image

But still, it’s worth a try.

No more DirectX/XNA MVP

January 31, 2013

A very interesting post appeared today, here.

A mail was sent to Direct X and XNA MVP announcing that there won’t be any more MVP in those technologies. And for XNA, finally something “official”. Well, not a surprise, but more like a confirmation of what everyone already knew :

the XNA Game Studio is not in active development

Okay, no surprise here …