Posts

Showing posts from 2014

PyDev with Eclipse on Mac

Image
Step 1 : Install Eclipse Step 2 : Install PyDev Here is the easiest way of drag-n-drop : http://marketplace.eclipse.org/content/pydev-python-ide-eclipse Step 3 : Configure Python Interpreter Path to MayaPy's python interpreter : /Applications/Autodesk/maya2014/Maya.app/Contents/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python Extras : 1. For Autocompletion, add following line in "Forced Builtins" : maya.cmds,maya.mel,maya.standalone,maya.app,maya.OpenMaya,maya.OpenMayaAnim,maya.OpenMayaCloth,maya.OpenMayaFX,maya.OpenMayaMPx,maya.OpenMayaRender,maya.OpenMayaUI which will add following libraries : maya.cmds maya.mel maya.standalone maya.app maya.OpenMaya maya.OpenMayaAnim maya.OpenMayaCloth maya.OpenMayaFX maya.OpenMayaMPx maya.OpenMayaRender maya.OpenMayaUI Another Resource :  http://sourceforge.net/p/pydev/discussion/293649/thread/fb1b2e45

How curves are drawn by your computer ?

Image
Cubic Bezier Curves - Under the Hood from Peter Nowell

Simple explanation of Physics based motion in games

http://www.richardlord.net/presentations/physics-for-flash-games http://www.richardlord.net/images/slides/physics2007.swf
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 {                    SubShader         {              Tags  {  " Queue "  =  " Transparent "     " IgnoreProjector " = " True "   " RenderType " = " Transparent " }              Pass {                  ZWrite   On                  ColorMask   0                  }              Pass               {                  Cull   Off                  Blend   SrcAlpha   OneMin

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     {          ZWrite   On          ColorMask   0          SubShader         {              Tags  { " Queue " = " Transparent "   " IgnoreProjector " = " True "   " RenderType " = " Transparent " }              LOD   200              //   extra   pass   that   renders   to   depth   buffer   only              Pass             {                  Blend   SrcAlpha   OneMinusSrcA

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 " );     }      void   callbackTwo ()     {          Debug . Log  ( " callback two " );     }      void   Start  () {          //   Assign          delegateOne  =  callbackOne ;          //   Pass   delegate   in   CallbackFunction          MethodForCallback ( delegateOne );     }      void   Update  () {          } }

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 ' = --