Gravitards for Windows Phone 7

Today, Gravitards has been finally released for Windows Phone 7.

“Gravitards is a skill-based game with amazing graphics and real physics, where you have to drive a ball through many different levels, reaching the end zone (or “gravitard”), without dropping it, while collecting rings distributed all around. You´ll find obstacles, moving parts, force fields, guillotines, ramps, jumps, and even a pinball table to play with. Test yourself by controlling the ball with your device’s accelerometer, with on-screen buttons, or with the keyboard, and get the needed practice to complete all the levels.”

You can download Gravitards directly to your Windows Phone 7 using the following Zune link.

Some other videos and pictures:

 

 

Captura36

Captura38

Captura3

Hope you all like it!!!

3D-O-Matic. Is it feasible to make our favorite shows in 3D?

There has been several attempts to make cartoon TV shows in 3D, or look realistic. For instance, Simpsons’ first attempt looked something like this:

It was really fun, but didn’t actually capture the essence of Homer, which for me is nothing more than this:

Many artists have tried to do so since then, but honestly, they scared me more than make me laugh. Some amazing examples:

Pretty awesome, but they are stills mostly. Hard to animate that. Recently though, I have discovered other examples that seem more feasible to me, as they are just plain 3D models, not so post-processed, and in my opinion they capture pretty well the essence of the characters (from Futurama, in this case):

unti3tled

untitl6ed

un8titled

COOL !

For those of you who always asked themselves how are The Simpsons done, you can check this video (sorry it´s in Spanish only, from Chile TV apparently):

I always thought they had some kind of software to manage camera angles automatically. I even thought sometimes (specially for the most recent seasons) that backgrounds or characters where initially animated in 3D, and then rendered as 2D, but it seems they are animated traditionally.

The video is pretty old though, so things probably changed in the last years.

Some other hilarious examples:

 

untitled

 

un44titled

And some other pics as a present. Not in 3D, but really fun !!, and very appropriate for T-Shirts… ja jaaa:

untitl7ed

 

untitle22d

 

4untitled

All of them come from here.

Cheers!

Simax Forklift Simulator

We are about to release the next Simax simulator. It´s the new Forklift Simulator, a full-featured, next-gen training simulator to learn all the concepts needed to drive and work with a forklift, including basic management of the device´s features, load handling and distribution, driving in every possible situation, dangerous or emergency situations, usual load and unload works, etc. All of our virtual machines are exact replica of their real counterparts: with real motorized joints, mass distribution, and exact layout of controls like levers, joysticks, pedals, etc.

The Simax Forklift Simulator is still a beta release, but will be in the market very soon. You can find more info at: www.simaxvirt.com or at info@simax.es.

 

 

 

 

Using DirectoryInfo.GetFiles returns more files than expected (or how to get exactly what you need, with an exact extension match lookup)

Introduction

I didn’t noticed this behavior of the GetFiles() method until now, I must admit. It’s something not frequent to see, but might happen. And it’s dangerous.
As this post, and the MSDN library itself state, when you use the GetFiles() method with a search wildcard that includes the asterisk symbol, and you include a 3 characters long extension (like *.xml, or *.jpg), the GetFiles() method will return any file whose extension STARTS with the one you provided. That means that a search for *.jpg will return anything with extensions like: *.jpg, *.jpg2, *.jpegfileformat, etc.
This is a quite weird behavior (and not too elegant, I should say), introduced to support the 8.3 file name format. As stated in the above mentioned blog:
“A file with the name “alongfilename.longextension” has an equivalent 8.3 filename of “along~1.lon”. If we filter the extensions “.lon”, then the above 8.3 filename will be a match.”
That’s the reason to make the GetFiles() method behave that way. The official MSDN explanation:
Note
When using the asterisk wildcard character in a searchPattern (for example, "*.txt"), the matching behavior varies depending on the length of the specified file extension. A searchPattern with a file extension of exactly three characters returns files with an extension of three or more characters, where the first three characters match the file extension specified in the searchPattern. A searchPattern with a file extension of one, two, or more than three characters returns only files with extensions of exactly that length that match the file extension specified in the searchPattern. When using the question mark wildcard character, this method returns only files that match the specified file extension. For example, given two files in a directory, "file1.txt" and "file1.txtother", a search pattern of "file?.txt" returns only the first file, while a search pattern of "file*.txt" returns both files.
In my case, I had a bug in my software because I temporally renamed an XML file to xxx.XML2222, just to wipe it out of the application. The program was still reading it, what made it had a wrong behavior.

A workaround for this issue

If you want to prevent this behavior, you will need to do a manual check for the returned array of FileInfo classes, to remove those not matching your pattern. An elegant way to do so, is to write a MethodExtender to the DirectoryInfo class, like the following one:
/// <summary>
/// Returns array of files that matches the search wildcard, but with an exact match for the extension.
/// </summary>
/// <param name="pSearchWildcard">Search wildcard, in the format: *.xml or file?.dat</param>
/// <returns>Array of FileInfo classes</returns>
public static FileInfo[] GetFilesByExactMatchExtension(this DirectoryInfo dinfo, string pSearchWildcard)
{
         FileInfo[] files = dinfo.GetFiles(pSearchWildcard);
         if (files.Length == 0)
             return files;
 
         string extensionSearch = Path.GetExtension(pSearchWildcard).ToLowerInvariant();
         List<FileInfo> filtered = new List<FileInfo>();
         foreach (FileInfo finfo in files)
         {
             if (finfo.Extension.ToLowerInvariant() != extensionSearch)
                 continue;
             filtered.Add(finfo);
         }
         return filtered.ToArray();
}
This way, just by the regular GetFiles() method of the DirectoryInfo class, you will find now the brand new GetFilesByExactMatchExtension(), which will have the desired behavior.
Note: In order to be able to use this method in a class, just like any other MethodExtender, you will need to include a “Using” statement to the extension method’s namespace.
Hope it helps !

Enabling/Disabling properties at runtime in the PropertyGrid

Many people knows about the benefits of using PropertyGrids in user interfaces.
You probably know about the System.ComponentModel namespace, and how it can help you customizing the behavior of classes and their properties when edited through controls like the PropertyGrid. One of the attributes you can find in that namespace is the ReadOnly, which will make a property to be read only and appear in gray (even if it has the Set accessor).
The problem with this attribute is that it must be defined at build-time. Sometimes, it is very useful (and improves the User Experience quite a bit), to enable or disable properties at runtime.
Imagine the following example, where we have a “UserData” class:
public class UserData
{
...
 
        public string Country
        {
            get { return mCountry; }
            set { mCountry = value; }
        }
        public string State
        {
            get { return mState; }
            set { mState = value; }
        }
}
Now, imagine you want the user to fill the “State” field only in the case he selected U.S. as his Country. In such a case, you need to make this change at Runtime.
There are several solutions for this, but I find the following one to be the most elegant, as it´s coded in the “UserData” class itself. The final code looks like:
[RefreshProperties(System.ComponentModel.RefreshProperties.All)]
[ReadOnly(false)]
public string Country
{
  get { return mCountry; }
  set
      {
      mCountry = value;
      PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.GetType())["State"];
      ReadOnlyAttribute attribute = (ReadOnlyAttribute)
                                    descriptor.Attributes[typeof(ReadOnlyAttribute)];
      FieldInfo fieldToChange = attribute.GetType().GetField("isReadOnly",
                                       System.Reflection.BindingFlags.NonPublic |
                                       System.Reflection.BindingFlags.Instance);                   fieldToChange.SetValue(attribute, mCountry != "U.S.");
      }
}
[ReadOnly(true)]
public string State
{
   get { return mState; }
   set { mState = value; }
}

Some Tips

1.- We obviously change the “ReadOnly” attribute of the “State” property in the setter accessor of the property “Country”. That´s the exact point where we know if State should be enabled or disabled.
2.- It is important to add the “RefreshProperties” attribute to the “Country” property. That will force the PropertyGrid control to refresh all it’s properties every time the value of “Country” changes, reflecting the changes we made to the attributes of “State”
3.- In order to work properly all of this, it is important to statically define the “ReadOnly” attribute of every property of the class, to whatever value you want. If not, changing the attribute at runtime that way, will wrongly modify the attributes of every property of the class.
Hope it helps!

More Info

At The Code Project
At C-Sharp Corner
Cheers!