Posts

Image
Unity Editor Scripting : If you ever have to create an instance (in hierarchy) from an .fbx file and a prefab from an instance, you can use following commands. 1 .fbx to instance      :  PrefabUtility . InstantiatePrefab 2 instance to .prefab :  PrefabUtility . CreatePrefab Creating AnimatorController file :  AssetDatabase . CreateAsset  

Conditional / Ternary Operator

Conditional Operator / Ternary Operator : condition ? true_expression : false_expression; bool x = condition ? true : false; eg : string   result  = (percentage  >= 36)  ?  "pass"  :  "fail" ; -------------------------------------------------------- NullCoalesce (??) int totalMarks = marks ?? 0 ; The  ??  operator is called the null-coalescing operator. It returns the left-hand operand if the operand is not null; otherwise it returns the right hand operand. eg:  int ? x = null ; int y = x ?? -1; int? is a shorthand for Nullable, which itself is shorthand of Nullable. eg Nullable a = null; A nullable type can represent the correct range of values for its underlying value type, plus a additional null value. --------------------------------------------------------

Installing Ant, Svn and Git on Mac

Install home-brew if not already installed ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" or ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" sudo brew update brew install ant brew install svn brew install git Install  JDK 7 ( If apache doesn't work in Sierra here is a usefull article : https://getgrav.org/blog/macos-sierra-apache-multiple-php-versions)
           Great trick for optimization so that code doesn't have to count size of array/list again and again.    for  ( int   i  =  0 ,  count  =  objectList . Count ;  i  <  count ;  i ++)             {                 .......  =  objectList [ i ];                  if  ( .... )                 {                     ........                 }             }

Intro to Objective-C

Intro to Objective-C :  http://cocoadevcentral.com/d/learn_objectivec/

Unity - Pixel/Fragment Shader

Image
Shader   " Custom /SamplePixelShader "  {      Properties {          _Color  ( " Main   Color " ,  Color ) = ( 1 , 0 , 1 , 1 )          _MainTex  ( " Texture   RGBA " ,  2D ) =  " white "  {}          // _Alpha (" Alpha " , Range ( 0 , 1 )) =  0 . 5          // _SpecColor  (" Spec   Color ",  Color ) = ( 1 , 1 , 1 , 0 )          // _Emission  (" Emissive   Color ",  Color ) = ( 0 , 0 , 0 , 0 )          // _Shininess  (" Shininess ",  Range  ( 0 . 1 ,  1 )) =  0 . 7     }      Category {         ...

Unity - Surface Shader

Image
Shader   " Custom / Unlit / Hologram "  {      Properties  {          _Color  ( " Main   Color " ,  Color ) = ( 1 , 0 , 1 , 1 )          _MainTex  ( " Texture   RGBA " ,  2D ) =  " white "  {}          _Alpha ( " Alpha "  , Range ( 0 , 1 )) =  0.5          _SpecColor  ( " Spec   Color " ,  Color ) = ( 1 , 1 , 1 , 0 )          _Emission  ( " Emissive   Color " ,  Color ) = ( 0 , 0 , 0 , 0 )          _Shininess  ( " Shininess " ,  Range  ( 0.1 ,  1 )) =  0.7     }      Category     {     ...

Delegates

Image
Recently, I have started working with C# on a project at Disney. This is my first experience using C# professionally and I will start collecting some notes on C# on my blog. 1. Delegates Code Example ( Unity )  : using   UnityEngine ; using   System . Collections ; public   class   DelegateExample  :  MonoBehaviour  {      //   Define   and   Declare      delegate   void   iAmDelegate ();      iAmDelegate   delegateOne ;      void   MethodForCallback ( iAmDelegate   callbackFunction )     {          callbackFunction  ();     }      void   callbackOne ()     {          Debug . Log  ( " callback one " );     } ...

Normalizing one range of values to another range of values.

To add another generic answer. If you want to map the linear range [A..B] to [C..D], you can apply the following steps: Shift the range so the lower bound is 0. (subract A from both bounds: [ A .. B ] -> [ 0. . B - A ] Scale the range so it is [0..1]. (divide by the upper bound): [ 0. . B - A ] -> [ 0. . 1 ] Scale the range so it has the length of the new range which is D-C. (multiply with D-C): [ 0. . 1 ] -> [ 0. . D - C ] Shift the range so the lower bound is C. (add C to the bounds): [ 0. . D - C ] -> [ C .. D ] Combining this to a single formula, we get: ( D - C )*( X - A ) X ' = ----------- + C ( B - A ) Eg : Normalizing a range of 0.5 ----> 1.0   to 0 ------> 1  A=0.5, B=1, C=0, D=1 you get: ( X - 0.5 ) X ' = ------- = 2X - 1 ( 0.5 ) Note, if you have to convert a lot of X to X', you can change the formula to: ( D - C ) C * B - A * D X ' = --...

Great modelling break down by Carlos

Sorting Algorithms in Python

 Python Sorting Algorithms and the time taken by each algorithm to sort values.  http://www.daniweb.com/software-development/python/code/216689/sorting-algorithms-in-python

Painted Textures

Another good one!

Web GL

I have recently started learning Web-GL. I found one Web-GL course on Udacity.com, here is the link: https://www.udacity.com/course/cs291 I found this course amazing not only from Web-GL point of view but it also gives you a good understanding of rendering-concepts. And while looking at different Web-GL examples, I found following link which has some great physics simulation examples. http://lonely-pixel.com  And this presentation gives you a good idea of different rendering styles : http://acko.net/files/fullfrontal/fullfrontal/webglmath/online.html