Thursday, 30 July 2015

Launched new website for game developers. Quality materials & Textures.

I launched recently new website - http://www.gamesmaterials.com which main purpose is to store high quality materials ready to be used in Unity game engine and UDK and Cry Engine in the future.

At the moment there are 14 free and premium materials but I have already created over 50 materials that can be purchased from Unity asset store in one bundle : http://u3d.as/gq7

Any feedback and suggestion will be much appreciated. I will introduce very competitive subscription payment in the future and more free stuff as well as full projects.

Some finished examples:

- simple low poly cylinder with cobble material (4 textures - diffuse, occlusion, normal and height)




- Plane with window blocks material


- Plane with Destroyed concrete bunker material





Wednesday, 29 July 2015

Exporting HTML to PDF in ASP.NET MVC C#

In this tutorial we are going to set up dev environment to use html to pdf converter and convert previously saved wikipedia page to pdf.

1. Download and install application from http://wkhtmltopdf.org/ - FREE to use
2. Create new Asp.NET MVC application.
3. Add location to exe file in your web config file(this is installation path for previously installed wkhtmltopdf) - something like that :

 <add key="HtmlToPdfPath" value="C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe"/>


4. Download  https://en.wikipedia.org/wiki/CERN page and save it in My documents folder under PdfExample folder.



5. Create new api controller and call it HtmlPdf.
6. Alter Get(int value) web api method :

public string Get(string name)
        {
            string path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "PdfExample");

            if (File.Exists(string.Format("{0}\\{1}", path, name)))
            {
                try
                {
                    string nameWithoutExtension = name.Replace(".html", string.Empty);
                    var psi = new ProcessStartInfo(System.Configuration.ConfigurationManager.AppSettings["HtmlToPdfPath"], string.Format("{0} {1}.pdf", name, nameWithoutExtension));
                    psi.WorkingDirectory = path + "/";

                    var proc = Process.Start(psi);
                    proc.WaitForExit();

                    return "completed";
                }
                catch (Exception ex)
                {
                    return ex.InnerException.ToString();
                }
                
            }
            else
            {
                return "Failed to convert";
            }


        }
}

7. Run your application and open url:

http://localhost:yourport/api/htmlpdf?name=CERN.html

8. In your folder PdfExample you can see pdf version of Cern wikipedia html website.


Wednesday, 22 July 2015

Rendering Grid, Canvas into image in WPF application

In tutorial regarding populating images from local storage in wpf application we displayed images in grid. In this tutorial I want to demonstrate how to easily convert part of grid, canvas to bitmap and save it as jpeg image.

1. Modify XAML code from the previous tutorial. It should look like that.
 <Grid x:Name="MainFrame" ShowGridLines="True">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition Height="40"/>
        </Grid.RowDefinitions>
      
        <Grid x:Name="Photo1" Grid.Row="0" Margin="10" Grid.RowSpan="1"/>
        <Grid x:Name="Photo2" Grid.Row="1" Margin="10" Grid.RowSpan="1"/>
        <Grid x:Name="Photo3" Grid.Row="2" Margin="10" Grid.RowSpan="1"/>


          <Grid x:Name="PrintFooter" HorizontalAlignment="Right" Height="75" VerticalAlignment="Bottom" Width="100" Grid.Row="3">
            <Button Content="Print"  VerticalAlignment="Bottom" Margin="10" Width="75" Click="Button_Click_1" />
        </Grid>
       
    </Grid>

2. Write a method for Button_Click_1 - you can rename the component and method.


private void Button_Click_1(object sender, RoutedEventArgs e)
        {

// Hide print footer

            PrintFooter.Visibility = Visibility.Hidden;
            MemoryStream memstream = GenerateImage(MainFrame, (int)MainFrame.ActualWidth, (int)MainFrame.ActualHeight);


            // save Image

            using (FileStream fstream = File.OpenWrite(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), string.Format("RemotePhoto\\{0}.{1}", Guid.NewGuid(), ImageFormat.Jpeg))))
            {
                memstream.WriteTo(fstream);
                fstream.Flush();
                fstream.Close();
            }
// Show print footer

            PrintFooter.Visibility = Visibility.Visible;
        }

public MemoryStream GenerateImage(Visual visual, int width, int height)
        {
            BitmapEncoder encoder = new JpegBitmapEncoder();
           
            if (encoder == null) return null;

            RenderTargetBitmap rtb = this.RenderVisualToBitmap(visual, width, height);
            MemoryStream file = new MemoryStream();
            encoder.Frames.Add(BitmapFrame.Create(rtb));
            encoder.Save(file);

            return file;
        }

public RenderTargetBitmap RenderVisualToBitmap(Visual visual, int width, int height)
        {
            RenderTargetBitmap rtb = new RenderTargetBitmap
                (width, height, 96, 96, PixelFormats.Default);
            rtb.Render(visual);
           
            BitmapSource bsource = rtb;
            
            return rtb;
        }



GenerateImage method will accept Visual component which in our case is grid. Using RenderVisualToBitmap method we are going to create RenderTargetBitmap object from Visual component.

New image should appear in your pictures under RemotePhoto folder, you can of course change the location as next print you make will include the image from the results which might look odd.






Thursday, 16 July 2015

Realtime Material Previewer - Unity 3d - Coming soon to Unity store FREE



Sample materials used from http://u3d.as/gq7
Get single game materials - http://www.gamesmaterials.com

Free tool to allow user to preview materials in realtime in Unity 3d game engine.

Just drag and drop created materials into script and they will automatically appear in the preview dropdown list.

This tool allows you to change light intensity, day & night transition speed, normal, occlusion, specularity and height volume.

You can tweak X & Y tiling as well.






Wednesday, 15 July 2015

Populating images from local storage into WPF application

1. Create new WPF Application.
2. In your main window xaml add 3 grids, your code should looks like this:

<Grid x:Name="MainFrame" ShowGridLines="True">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
      
        <Grid x:Name="Photo1" Grid.Row="0" Margin="10" Grid.RowSpan="1"/>
        <Grid x:Name="Photo2" Grid.Row="1" Margin="10" Grid.RowSpan="1"/>
        <Grid x:Name="Photo3" Grid.Row="2" Margin="10" Grid.RowSpan="1"/>
</Grid>

3. Open code behind the file and create new function:

private void PutImagesIntoFrame()
        {
            // Get last 3 images saved

            string path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "RemotePhoto");

            var directory = new DirectoryInfo(path);

            int numberOfImages = 3;

            List<fileinfo> images = directory.GetFiles("*.jpg").OrderByDescending(m => m.LastWriteTime).Take(numberOfImages).ToList();

            List<imagebrush> imageBrushes = new List<imagebrush>();

            if (images.Count == numberOfImages)
            {
                foreach (FileInfo item in images)
                {
                    ImageBrush imageBrush = new ImageBrush();
                    Image image = new Image();
                    image.Source = new BitmapImage(
                      new Uri(item.FullName));

                    imageBrushes.Add(imageBrush);
                    imageBrush.ImageSource = image.Source;

                }
            }

            // Add image brushes to individual grids

            Photo1.Background = imageBrushes[0];
            Photo2.Background = imageBrushes[1];
            Photo3.Background = imageBrushes[2];

        }
4. Add some pictures to My Pictures folder inside RemotePhoto Folder.
5. Your application should looks like this.





Thursday, 28 May 2015

Scary, Creepy, Mystery FX Sounds For Horror, Thriller, Mystery etc. Games & Movies - Available on Unity 3d store

Created horror, scary game/movie and looking for some creepy fx sounds or seamless ambient royalty free tracks?
This package contains 20 seamless ambient scary tracks and 58 FX sounds that will add some scariness to your project.

Available on Unity 3d store : Scary, Creepy FX Sounds for the price of coffee!


Demo sounds
Silent Hills demo with FX from this package.

Scary FX and Ambient sounds



Saturday, 9 May 2015

Multi texture pack optimized for Game Engines. Available now on Unity 3d store.

Available now on Unity 3d store : Multi Texture Pack

Launched website http://www.gamesmaterials.com - single materials can be aquired (some free and premium content)

Finishing work on multi texture package for Unity 3d asset store and Unreal market place.
Each material consist of 4 textures (diffuse, normal, height and ambient occlusion). 
Textures that are tillable are perfectly seamless. 
First launch will consist of 60 materials - 240 textures! 
Future update is already planned. 

Actual screenshot from planes in Unity Engine 5 with default light settings.

Categories:
Enironment -> Trees, Grass Frozen, Sand
Floor ->Asphalt, Carpet, Concrete, Gravel & Rock, Medieval, Metal, Stone, Wood
Glass
Leather
Fabric
Roof
Walls -> Bones, Brick, Concrete, Rock, Temples
Misc - Containers

New material added available at : http://gamesmaterials.com/en/gravel-rock-cobble-material




























Tuesday, 31 March 2015

SCi Fi Kit - Unity3d and UDK

Started working on Sci Fi Kit. Package will include sci fi levels, objects such as crates, barrels, pipes etc, preety much everything you would expect to find in Sci Fi game. High influence from Deus Ex, Dead Space. I will also include sci fi sounds(ambient & fx). I will target Unity 5 users and UE4 so I can use full power of new features in both game engines.


I will keep posting and adding more images from work.
Si
Sci Fi Crate 1 - Simple crate with no extra features. 168 tris.



Sci Fi Crate 2 - Found concept here : concept
Simple low poly model with 1200 tris, Baked normal from high poly and added few details to normal map. Wanted to keep it simple, however I will add more details(only to normal map) and few extra stripes of paint, possibly on the edges. Exported model to Unity 3d and looks almost the same as on the picture below.


Wednesday, 18 February 2015

Realistic planet Earth Shader for Unity 3d - Massive update

For some time now my realistic planet Earth shader is available at Unity 3d store :
https://www.assetstore.unity3d.com/#/content/23363

Video : https://www.youtube.com/watch?v=wVm_hW5zVpg

Current demo : http://abdeveloper.com/earth/unityprojects.html

I want to thank you all for support and decided to release huge update that will contain:
30 new randomly generated Earth like planets + 30 Real time Night transitions
10 new clouds

I also added facility to switch between planets, change clouds and increase zoom rate.







Tuesday, 10 February 2015

Using reflection to dynamically set the value on the class property in ASP.NET MVC

We have a situation where we received some data from API and we save each file into NameValueCollection. Each property match our class property, so we want to use reflection to dynamically set values for our class from values in NameValueCollection. This is very fast and easy way to not repeat ourselves when mapping values from one object to another.

I used unit test to demonstrate functionality. 
class PolicyManager
    {
        public string ImportJobTypeID { get; set; }
        public string ImportDate { get; set; }
        public string ImportSourceID { get; set; }
        public string APIUserID { get; set; }
        public string APIUserKey { get; set; }
        public string ImportTypeID { get; set; }
        public string ImportUID { get; set; }
        public string Title { get; set; }
        public string FirstName { get; set; }
        public string Surname { get; set; }
        public string Company { get; set; }
        public string Tel { get; set; }
        public string Email { get; set; }
        public string DOB { get; set; }
        public string Address1 { get; set; }
        public string Address2 { get; set; }

        public static NameValueCollection RetrieveDataFromAPIMockUp()
        {
            dynamic values = new NameValueCollection() {
                {"ImportJobTypeID", "1"},
                {"ImportDate", DateTime.Today.ToString()},
                {"ImportSourceID", "1"},
                {"APIUserID", "7"},
                {"APIUserKey", "f4a03091a6a505d10fdebeb707d59e42"},
                {"ImportTypeID", "3"},
                {"ImportUID", DateTime.Now.ToString()},
                {"Title", "Mr"},
                {"FirstName", "Adam"},
                {"Surname", "Black"},
                {"Company", "AbDeveloper.com"},
                {"Tel", "07817 458784"},
                {"Email", "ab@example.com"},
                {"DOB", "10/04/1974"},
                {"Address1", "36 Portland"},
                {"Address2", "Avenue"}
              
            };

            return values;
        }
    }

Because we know exactly what properties we are getting from API it is ok to create a class that matches those properties.
Static method RetrieveDataFromAPIMockUp will generate some dummy data(for test purposes only, this is what we would get from API).

Now simple test.

{
        [TestMethod]
        public void TestReflection()
        {
            PolicyManager pManager = new PolicyManager();

            NameValueCollection values = PolicyManager.RetrieveDataFromAPIMockUp();

            foreach (var value in values)
            {
                PropertyInfo propInfo = typeof(PolicyManager).GetProperty(value.ToString());
                if (propInfo != null)
                {
                    propInfo.SetValue(pManager, values[value.ToString()]);
                }
            }
        }
    }

Pic 1 shows the result and confirm that method works as expected.
If API will change and send more properties our method will still works but will ignore it.

Using reflection to dynamically set the value on the class property in ASP.NET MVC
pic 1