rudiHammad

Untitled

Jun 7th, 2016
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.84 KB | None | 0 0
  1. import maya.cmds as cmds
  2.  
  3. class BasicLimbRig(object):
  4.  
  5.  
  6.     def __init__(self, side, name):
  7.         self.side = side
  8.         self.name = name
  9.  
  10.  
  11.     def makeIk(self):
  12.         cmds.ikHandle( n=self.side + "_" + self.name + "_" + "ik" )
  13.  
  14.  
  15.     def twistLimb(self):
  16.         """ here some code that will make a twist system based on splineIk """
  17.  
  18.  
  19.     def makeFk(self):
  20.         " here come code that creates an Fk "
  21.  
  22.  
  23.  
  24.  
  25. class CartoonFeatures(BasicLimbRig):
  26.  
  27.     """ now I am going to inherit the method makeIk of the superclass and extend it with some
  28.        some code that will make it stretchy """
  29.     def makeIkStretchy(self):
  30.         self.makeIk()
  31.         """ more code that will make it stretchy """
  32.  
  33.  
  34.     """ now I will override the method of the superclass. The name of the method is the same, but
  35.       the code inside y completly diferent"""
  36.     def twistLimb():
  37.         """ new code that will make a twist system bases on ribbon """
  38.  
  39.  
  40. #-----------------------------------------------------------------------------------------------#
  41. # realistic character
  42. armRig = BasicLimbRig('l','arm')
  43. armRig.makeIk()
  44. armRig.twistLimb()
  45. armRig.makeFk()
  46.  
  47. # cartoon character
  48. cartoonArmRig = CartoonFeatures('l','arm')
  49. cartoonArmRig.makeIkStretchy()
  50. cartoonArmRig.twistLimb()
  51. cartoonArmRig.makeFk() # I am inheriting a method as it is, because the system is the same in
  52.                        # cartoon and realistic
  53.                        
  54. #-----------------------------------------------------------------------------------------------#
  55. """ here is why I think this is OOP:
  56. · 1 # I use inheritance of methods, I did method overriding ( that is polymorfisme right?) and I did
  57. method extension.
  58. · 2 #  I passed to the class methods the instance variables, so I don´t have to declare the arguments
  59. side and name on each method
  60. """
Advertisement
Add Comment
Please, Sign In to add comment