Wednesday, 11 May 2016

Reading content from dll - c# or vb

So you ever wanted to read code from dll regardless if it was written in c# or vb?

There is very good free tool on the market provided by JetBrains.

https://www.jetbrains.com/decompiler/

1. After installation open application.
2. Shortcut ctrl + O, or click on first left icon under Assembly Explorer and choose dll.


3. Double click on class to see the code.


Wednesday, 17 February 2016

Solar System version 3.0 update - [Released]

I decided to improve one of my top assets in Unity 3d store. Added new UI, planets info, atmosphere shader, 5 types of Sphere meshes (super low, low, medium, high poly, super high), realistic day/night transition for planet Earth. Info for planet is being read from txt file which can be very easily modified.

Current version of Solar System : http://u3d.as/70w











Wednesday, 3 February 2016

Solar System Unity 3d Asset Used In Asteroid Challenge Game Exclusive For Nintendo Wii



Solar System project that is available http://u3d.as/70w has been used to create Nintendo Wii exclusive game - Asteroid Challenge - http://nintendonuggets.com/asteroid-challenge-coming-exclusively-to-wii-u-eshop/

I am really glad too see that my project have been used in successful commercial environment.

I am working currently on new release of Solar System that will include new shader that will give realistic atmosphere for planets, better UI, 5 different Meshes(Super Low(400 tris), Low (1000 tris), Medium(5000 tris), High(20000 tris) and Super High(120000 tris)) and mobile shader for Sun.


Saturday, 16 January 2016

Buddha Statues Collection - Damaged, Silver and Gold

Recently I released my latest work on Unity 3d asset store.

Buddha Unity 3d


It contain 1 model with 3 different materials(damaged stone, gold, silver).
Each texture is 4096x4096 and materials are using PBR metallic setup so model will contain Albedo, Normal, Oclussion and Metallic textures.







Wednesday, 30 December 2015

Mars Lander 3d model in Unity 5

Mars Lander Phoenix available now on unity 3d store.
Lander contain 4 separate animations for Antenna, Receiver, Arm Controller and Solar Panels.

Most of the materials have 4 textures - Albedo, Normal, Occlusion and Metallic (4096px x 4096px) .
Normal maps have been baked from very high poly model to reduce polygons.
Lander Body base got 4347 tris, Solar Panels 772 tris.

I focused on attention to details as I tried to recreate Mars Lander Phoenix that was used in one of Nasa's Mars missions - https://www.nasa.gov/mission_pages/phoenix/main/index.html


















Wednesday, 18 November 2015

Dogmeat from Fallout 4 in Unity 5 Engine

I am currently working on companion follower asset and decided to use Dogmeat from Fallout 4 for concept demo.

Few screenshots

Dogmeat Fallout 4 in Unity engine


Tuesday, 17 November 2015

Creating custom filter in angular JS

In this tutorial we are going to create custom filter that will truncate text and add ellipsis at the end of modified input.

Create new controller.js.

We want to add new module called filters.

angular.module('filters', [])

.filter('truncate', function(){
      return function(input, limit){
         if(input){
           return (input.length > limit) ? input.substr(0, limit)+'…' : input;
         }
      };
})


As you can see .filter is accepting name of filter as first parameter and callback function as second parameter. First we want to check if input is not empty as that will through some nasty error, then we check if input length is greater than specified limit and if so we will truncate string and add ellipsis.

Now we want to inject filter into our controller.

.controller('App', function($scope, $filter, jsonFilter){


});


Now create index.html file in the same folder as controller.js(you can put it later in different folder to keep structure consistent).

< html lang="en" ng-app="filters" ng-controller="App">





< /html>

In first line of code we included module ng-app="filters" and base controller ng-controller="App".
In next 2 lines we added google angular reference and controller.js scripts.
In 4th and 5th lines we have ng-model which is basically variable name that will bind value.
In 7th line we are using truncate filter. Using double {{ basically means accessing angular js components. truncatedText is input then filter is being applied and finally limit.

{{ input | filter : value}}

Final result

Tuesday, 27 October 2015

PBR Metal Material Package - Available now on Unity 3d store

Available now on Unity 3d store

20 metal PBR materials.
Each material will have 4 textures : Albedo, Heigh, Ambient Oclusion and Normal.


All textures are seamless varies in resolution between 1024 and 2048.

Also available Multi Texture Pack & my asset store for other cool stuff.


Metal galvanized


Airplane 

Base dented metal

Base clean metal with scratches and rust

Metal with peeled off paint 

Metal with peeled off paint 

Bronze cooper

Damaged bronze cooper

Wednesday, 21 October 2015

Setting up Unit Testing in Visual Studio C#

If you have a project with various classes and want to test some methods quickly, Microsoft provided Unit testing tools for this purpose. In this tutorial we are going to build simple class library and method that extracts value from xml. Then we are going to create separate project that will be used to test the method we just wrote. I am going to use C# as main language.

1. Create new class library in Visual Studio. I called it ABLibrary, but you can name it whatever you want, just use your name later in project reference.


2. Rename class to XMLHelpers.

public class XMLHelpers
{
    /// 
        /// Extract value from XML Node
        /// 
        ///         ///         /// 
        /// 
        public static string ExtractXMLNodeValueFromXML(string xml, string nodePath)
        {
            if (string.IsNullOrEmpty(nodePath))
                return string.Empty;

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(xml);

            XmlNode xmlNode = xmlDoc.SelectSingleNode(nodePath);

            if (xmlNode != null)
            {
                return xmlNode.InnerText;
            }
            else
            {
                return string.Empty;
            }
        }

} 

 


3. Add new project to your solution(class library again) and call it ABLibraryTest.


4. Add ABLibrary as reference and Microsoft.VisualStudio.QualityTools.UnitTestFramework. You find ABLibrary under Solution and Unit test tools in Assemblies.


5. Rename default class to XMLHelperTest (make the naming consistent) and create TestExtractValueFromXMLNode method.
[TestClass]
    public class XMLHelpersTest
    {
        public const string xmlTest = "Value1";

        [TestMethod]
        public void TestExtractValueFromXMLNode()
        {
            Assert.AreEqual("Value1", XMLHelpers.ExtractXMLNodeValueFromXML(xmlTest, "TEST/Node1"), "Extract failed or values do not match");
            Assert.AreEqual(string.Empty, XMLHelpers.ExtractXMLNodeValueFromXML(xmlTest, string.Empty), "Method fails, as it does expect empty string as path");
            Assert.AreEqual(string.Empty, XMLHelpers.ExtractXMLNodeValueFromXML(xmlTest, null), "Method fails, as it does expect null as path");
        }
    }



6. In order for visual studio to run tests we have to make test method and class public and add [TestClass] annotation on class and [TestMethod] on method.


7. Assert.AreEqual method in our case expect first parameter as expected value, actual value and returns message if test fail.


8. Press Ctrl+R then T to run the test and wait for the results.


9. Let's try to make our tests to fail while modifying the ExtractXMLNodeValueFromXML in XMLHelpers class. Change the method return if nodePath is empty string or null to return null.



        /// 
        /// Extract value from XML Node
        /// 
        ///         ///         /// 
        /// 
        public static string ExtractXMLNodeValueFromXML(string xml, string nodePath)
        {
            if (string.IsNullOrEmpty(nodePath))
                return null;

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(xml);

            XmlNode xmlNode = xmlDoc.SelectSingleNode(nodePath);

            if (xmlNode != null)
            {
                return xmlNode.InnerText;
            }
            else
            {
                return string.Empty;
            }
        }

 


10. So as you can see you can use ExtractXMLNodeValueFromXML method in some various applications and if you want change the core functionality and your test fails it is a good chance that your application might fail as wll. Good test cases prevent(limits) runtime errors and overall adding more confident in the project as future maintenance and scalability is easier achievable.

Tuesday, 20 October 2015

Updating collection in partial view from main view using Unobtrusive Ajax call in ASP.NET

So we have partial view that holds collection of customers. We want to increase the size of this collection by adding new customer on other partial view.
Using unobtrusive ajax call to controller action method we can achieve it quickly and without having to reload the whole page.

Expected results






In order for ajax helper to work we need to include unobtrusive-ajax js. In case it is not compatible with your version of jquery, install latest version by typing Install-Package Microsoft.jQuery.Unobtrusive.Ajax
More details on nuget page


After you load the page go to developer tools(F12 on most browsers - yes even on IE and go to network to find out if libraries have been loaded correctly).

Basically you will need jquery and  jquery.unobtrusive-ajax

Add jquery.unobtrusive.ajax to your _layout page

 <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>



So main Index page

@model TestFacility.View_Models.CustomersVM

@{
    ViewBag.Title = "Index";
}

Customer List

@using (Ajax.BeginForm("AddCustomer", "Collection", new AjaxOptions{UpdateTargetId = "customers_collection",InsertionMode = InsertionMode.Replace})) { @* @Html.ValidationSummary(true) *@ @Html.Partial("_AddCustomer", new TestFacility.Models.CustomerDetails()) }

Available customers

@Html.Partial("_CustomersCollection", Model.CustomerDisplayVM)

Partial views

_AddCustomer

@model TestFacility.Models.CustomerDetails


Add new customer

CustomerDetails @Html.HiddenFor(model => model.ID)
@Html.LabelFor(model => model.Name)
@Html.EditorFor(model => model.Name) @Html.ValidationMessageFor(model => model.Name)
@Html.LabelFor(model => model.Surname)
@Html.EditorFor(model => model.Surname) @Html.ValidationMessageFor(model => model.Surname)

_CustomerCollection

@model TestFacility.View_Models.CustomerDisplay

@Html.DropDownList("CustomerCollection", new SelectList(Model.CustomerCollection, "ID", "Name", "-- Select Customers --"))

Models and View models

public class CustomersVM
    {
        public CustomersVM()
        {
            // Create dummy list for test purpose
            this.CustomerDisplayVM = new CustomerDisplay
            {
                CustomerCollection = BuildCustomerDetailsList()
            };
        }

        public CustomerDisplay CustomerDisplayVM { get; set; }


        // Helper methods
        public static List<CustomerDetails> BuildCustomerDetailsList()
        {
            return new List<CustomerDetails>()
                {
                    new CustomerDetails{
                    ID = 1,
                    Name = "Adam",
                    Surname = "Bielecki"
                    },
                    new CustomerDetails{
                    ID = 2,
                    Name = "Joe",
                    Surname = "Blog"
                    }
        };

        }
    }

    public partial class CustomerDisplay
    {
        public CustomerDisplay()
        {
            this.CustomerCollection = new List<CustomerDetails>();
        }

        public IListList<CustomerDetails> CustomerCollection { get; set; }

    }


public class CustomerDetails
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public string Surname { get; set; }
    }


Finally controller


[HttpPost]

        public ActionResult Index()
        {
            // Reset session - for demo purpose only
            Session["customer_collection"] = null;
            CustomersVM vModel = new CustomersVM();
            return View(vModel);
        }

        public ActionResult AddCustomer(CustomerDetails model)
        { 
            // Get this data from DB or external service etc, for demo purpose add customers to session object

            CustomerDisplay vModel = new CustomerDisplay();

            if (Session["customer_collection"] != null)
            {
                vModel.CustomerCollection = Session["customer_collection"] as List<CustomerDetails>;
            }
            else
            {
                vModel.CustomerCollection = CustomersVM.BuildCustomerDetailsList();
            }

            vModel.CustomerCollection.Add(model);

            Session["customer_collection"] = vModel.CustomerCollection;

            return PartialView("_CustomersCollection", vModel);
        }