Here it’s my Rocky Planet shader!

Namek planet shader
Namek

Here it’s my Rocky Planet shader!

 

After the Star Shader, here it’s a shader for rocky planets too, fully costumizable!

With this shader I can change surface colors, sea color and level, atmosphere features and turbolences!

In the gallery some results! :-)

 

 

Here it’s my star shader!

red dwarf
red dwarf

Here it’s my star shader!

My first real shader ever!

And it’s just the beginning!

p.s.: take a look to FPS! :-p

 

Data Converter Class for Unity3D serialization

xml

Data Converter Class for Unity3D serialization

If you need to save and load your game state, you could use XML files. XmlSerializer supports serialization for most of primitive types and classes. Not so for some UnityEngine types like Vector3, Quaternion, Color and so on.

I’ve released a usefull (I hope so) helper class  called “Data Converter” to simplify serialization and deserialization of such types, making them usable to XmlSerializer class.

 

Here’s the code.

 

/********************************************************************
	created:	2015/06/19
	file base:	DataConverters
	file ext:	cs
	author:		Alexandros
	Version:	1.0.0

	purpose:	data conversion methods, mainly used for serialization purposes
*********************************************************************/

using UnityEngine;

/// <summary>
/// data conversion methods, mainly used for serialization purposes
/// </summary>
public static class DataConverters
{
    #region TO PRMITIVE TYPES

    public static float[] ToFloatArray( Vector2 val )
    {
        float[] res = new float[2];
        for ( int i = 0; i < 2; i++ )
            res[i] = val[i];

        return res;
    }

    public static float[] ToFloatArray( Vector3 val )
    {
        float[] res = new float[3];
        for ( int i = 0; i < 3; i++ )
            res[i] = val[i];

        return res;
    }

    public static float[] ToFloatArray( Vector4 val )
    {
        float[] res = new float[4];
        for ( int i = 0; i < 4; i++ )
            res[i] = val[i];

        return res;
    }

    public static float[] ToFloatArray( Quaternion val )
    {
        return ToFloatArray( new Vector4( val[0], val[1], val[2], val[3] ) );
    }

    public static float[] ToFloatArray( Color val )
    {
        return ToFloatArray( (Vector4)val );
    }

    #endregion

    #region TO UNITY TYPES

    public static Vector2 ToVector2( float[] val )
    {
        Vector2 res = Vector2.zero;

        if ( val.Length >= 2 )
            for ( int i = 0; i < 2; i++ )
                res[i] = val[i];

        return res;
    }

    public static Vector3 ToVector3( float[] val )
    {
        Vector3 res = Vector3.zero;

        if ( val.Length >= 3 )
            for ( int i = 0; i < 3; i++ )
                res[i] = val[i];

        return res;
    }

    public static Vector4 ToVector4( float[] val )
    {
        Vector4 res = Vector4.zero;

        if ( val.Length >= 4 )
            for ( int i = 0; i < 4; i++ )
                res[i] = val[i];

        return res;
    }

    public static Quaternion ToQuaternion( float[] val )
    {
        Vector4 v4 = ToVector4( val );
        return new Quaternion( v4[0], v4[1], v4[2], v4[3] );
    }

    public static Color ToColor( float[] val )
    {
        Vector4 v4 = ToVector4( val );
        return new Color( v4[0], v4[1], v4[2], v4[3] );
    }

    #endregion

}

Enjoy it

 

End School Zone
End School Zone

…il 4 giugno, quanti ricordi!

Non un compleanno o altra festività, ma tanti anni fa era forse il giorno più atteso dell’anno, quello per il quale cominciavo un conto alla rovescia, alle volte partendo già da gennaio!

Ho sempre usato questo giorno come ultimo giorno di scuola, che meraviglia!

…Non tanto per la fine della scuole in sè, quanto per la prospettiva di 3 e dico TRE mesi di vacanza! Mamma mia che figata riuscire a fare ora 3 mesi di vacanza…

Vabbè… mi sa che è meglio tornare a lavorare adesso… :-)