Scripts updated:
authorWillian Padovani Germano <wpgermano@gmail.com>
Mon, 1 Aug 2005 03:06:24 +0000 (03:06 +0000)
committerWillian Padovani Germano <wpgermano@gmail.com>
Mon, 1 Aug 2005 03:06:24 +0000 (03:06 +0000)
- Jean-Michel Soler: 1) paths import -- ai module; 2) tex2uvbaker;
- Campbell Barton: obj exporter.

BPython:
- Campbell also provided a patch (+docs) to add shader data access to Blender.Material.

Again, thanks guys and sorry for the long delay.

release/scripts/bpymodules/ai2obj.py
release/scripts/obj_export.py
release/scripts/tex2uvbaker.py
source/blender/python/api2_2x/Material.c
source/blender/python/api2_2x/doc/API_intro.py
source/blender/python/api2_2x/doc/Material.py

index 410cbe0405a95408be4ab5da87a730a97fdbeed6..47c2dcbd57e180b5028075accc1398b41b4abda4 100644 (file)
@@ -316,6 +316,8 @@ def ligne_fermee(l,n0,CP):
     del courbes.ITEM[n0].beziers_knot[0]
     return  courbes,n0,CP    
 
+def passe(l,n0,CP):
+    return  courbes,n0,CP
 
 Actions=   {     "C" : courbe_vers_c,
                  "c" : courbe_vers_c,
@@ -326,12 +328,14 @@ Actions=   {     "C" : courbe_vers_c,
                  "m" : mouvement_vers,
                  "l" : ligne_tracee_l,
                  "L" : ligne_tracee_l,
-       
+                 "F" : passe,                      
                  "f" : ligne_fermee,
+                 "B" : passe,
                  "b" : ligne_fermee,
+                      "S" :    passe,
                  "s" : ligne_fermee,
-       
                  "N" : ligne_fermee,
+                      "n" :    passe,
                  }
      
 TAGcourbe=Actions.keys()
index 8c52c28967e873d421e25c32523f4638743904f0..205a280f878d6ba0230565f4550c1948584d801e 100644 (file)
@@ -21,7 +21,7 @@ Run this script from "File->Export" menu to export all meshes.
 
 
 # --------------------------------------------------------------------------
-# OBJ Export v0.9 by Campbell Barton (AKA Ideasman)
+# OBJ Export v0.9b by Campbell Barton (AKA Ideasman)
 # --------------------------------------------------------------------------
 # ***** BEGIN GPL LICENSE BLOCK *****
 #
@@ -63,6 +63,7 @@ def save_mtl(filename):
                file.write('Kd %.6f %.6f %.6f\n' % tuple(mat.getRGBCol())) # Diffuse
                file.write('Ka %.6f %.6f %.6f\n' % tuple(mat.getMirCol())) # Ambient, uses mirror colour,
                file.write('Ks %.6f %.6f %.6f\n' % tuple(mat.getSpecCol())) # Specular
+               file.write('Ni %.6f\n' % mat.getIOR()) # Refraction index
                file.write('d %.6f\n' % mat.getAlpha()) # Alpha (obj uses 'd' for dissolve)
                
                # illum, 0 to disable lightng, 2 is normal.
@@ -80,7 +81,7 @@ def save_obj(filename):
        save_mtl(mtlfilename)
 
        file = open(filename, "w")
-
+       
        # Write Header
        file.write('# Blender OBJ File: %s\n' % (Get('filename')))
        file.write('# www.blender.org\n')
@@ -91,6 +92,8 @@ def save_obj(filename):
        # Initialize totals, these are updated each object
        totverts = totuvco = 0
        
+       globalUVCoords = {}
+       
        # Get all meshs
        for ob in scn.getChildren():
                if ob.getType() != 'Mesh':
@@ -100,7 +103,14 @@ def save_obj(filename):
                
                if not m.faces: # Make sure there is somthing to write
                        continue #dont bother with this mesh.
-       
+               
+               faces = [ f for f in m.faces if len(f) > 2 ]
+               materials = m.materials
+               
+               # Sort by Material so we dont over context switch in the obj file.
+               if len(materials) > 1:
+                       faces.sort(lambda a,b: cmp(a.mat, b.mat))
+               
                # Set the default mat
                currentMatName = NULL_MAT
                currentImgName = NULL_IMG
@@ -112,24 +122,27 @@ def save_obj(filename):
                        file.write('v %.6f %.6f %.6f\n' % tuple(v.co))
        
                # UV
-               for f in m.faces:
-                       for uvIdx in range(len(f.v)):
-                               if f.uv:
-                                       file.write('vt %.6f %.6f 0.0\n' % f.uv[uvIdx])
-                               else:
-                                       file.write('vt 0.0 0.0 0.0\n')
-               
+               if m.hasFaceUV():
+                       for f in faces:
+                               for uv in f.uv:
+                                       uvKey = '%.6f %.6f' % uv
+                                       try:
+                                               dummy = globalUVCoords[uvKey]
+                                       except KeyError:
+                                               totuvco +=1 # 1 based index.
+                                               globalUVCoords[uvKey] = totuvco
+                                               file.write('vt %s 0.0\n' % uvKey)
+                                               
                # NORMAL
-               for f in m.faces:
-                       for v in f.v:
-                               file.write('vn %.6f %.6f %.6f\n' % tuple(v.no))
+               for v in m.verts:
+                       file.write('vn %.6f %.6f %.6f\n' % tuple(v.no))
                
                uvIdx = 0
-               for f in m.faces:
+               for f in faces:
                        # Check material and change if needed.
-                       if len(m.materials) > f.mat:
-                               if currentMatName != m.materials[f.mat].getName():
-                                       currentMatName = m.materials[f.mat].getName()
+                       if len(materials) > 0:
+                               if currentMatName != materials[f.mat].getName():
+                                       currentMatName = materials[f.mat].getName()
                                        file.write('usemtl %s\n' % (currentMatName))
                        
                        elif currentMatName != NULL_MAT:
@@ -146,19 +159,23 @@ def save_obj(filename):
                                
                        elif currentImgName != NULL_IMG: # Not using an image so set to NULL_IMG
                                currentImgName = NULL_IMG
-                               # Set a new image for all following faces
+                               # Set a ne w image for all following faces
                                file.write( 'usemap %s\n' % currentImgName) # No splitting needed.
-
-                       file.write('f ')
-                       for v in f.v:
-                               file.write( '%s/%s/%s ' % (v.index + totverts+1, uvIdx+totuvco+1, uvIdx+totuvco+1))
-
-                               uvIdx+=1
+                       
+                       file.write('f')
+                       if m.hasFaceUV():
+                               for vi, v in enumerate(f.v):
+                                       uvIdx = globalUVCoords[ '%.6f %.6f' % f.uv[vi] ]
+                                       i = v.index + totverts + 1
+                                       file.write( ' %d/%d/%d' % (i, uvIdx, i)) # vert, uv, normal
+                                       
+                       else: # No UV's
+                               for v in f.v:
+                                       file.write( ' %d' % (v.index + totverts+1))
                        file.write('\n')
                
                # Make the indicies global rather then per mesh
                totverts += len(m.verts)
-               totuvco += uvIdx
        file.close()
        print "obj export time: %.2f" % (sys.time() - time1)
 
index 326f852d53ddea70ca8805d843332755e89a46bb..0d0f4dfe065b8a3e622fb771ea7daf5358de7ca4 100644 (file)
@@ -11,7 +11,7 @@ __author__ = "Jean-Michel Soler (jms)"
 __url__ = ("blender", "elysiun",
 "Official Page, http://jmsoler.free.fr/didacticiel/blender/tutor/cpl_mesh3d2uv2d_en.htm",
 "Communicate problems and errors, http://www.zoo-logique.org/3D.Blender/newsportal/thread.php?group=3D.Blender")
-__version__ = "0.2.6 2005/5/29"
+__version__ = "0.2.8 2005/7/20"
 
 __bpydoc__ = """\
 Texture Baker "bakes" Blender procedural materials (including textures): it saves them as 2d uv-mapped images.
@@ -37,7 +37,7 @@ Notes:<br>
 """
 
 #---------------------------------------------
-# Last release : 0.2.6 ,  2005/05/29 , 22h00
+# Last release : 0.2.8 ,  2005/07/20 , 17h10
 #---------------------------------------------
 #---------------------------------------------
 # (c) jm soler  07/2004 : 'Procedural Texture Baker'
@@ -47,6 +47,26 @@ Notes:<br>
 #
 #     Released under Blender Artistic Licence
 #
+#   0.2.8
+#       -- added the forgotten image property in face
+#       data. a little longer but better.
+#       ( a remove double in the resulting mesh may be
+#       useful .) 
+#       -- the data.update() function problem is 
+#       corrected too
+#       -- no more layers problem . CAM and MESH are
+#       localised in layer 20 . This layer is
+#       the active one for the image rendering .
+#       -- mesh creation is cleaner, loop in double was
+#       removed and the abskey is set in frame 1 
+#       only  . This solves an other deform problem  .
+#       -- if user does not want an autosaved image,
+#       the "no replace" option leaves the render 
+#       window on the screen 
+#
+#   0.2.7 
+#      -- minor correction on line 147: "!=-1" added 
+#
 #   0.2.6
 #       -- Creation of LAMP object is removed and replaced
 #       by the use of the shadeless option  in material object
@@ -142,7 +162,7 @@ DIRNAME=Blender.Get('filename')
 # the file name from the path name
 #----------------------------------- 
 
-if DIRNAME.find(os.sep):
+if DIRNAME.find(os.sep)!=-1:
     k0=DIRNAME.split(os.sep)
 else:
     k0=DIRNAME.split('/')   
@@ -178,6 +198,8 @@ LIMIT=0
 XYLIMIT = [0.0, 0.0,1.0,1.0]    
 OBJPOS = 100.0
 DEBUG=1
+RENDERLAYER=20
+SCENELAYERS=[]
 
 helpmsg = """
 Texture Baker:
@@ -234,7 +256,7 @@ def RenameImage(RDIR, MYDIR, FILENAME, name):
         name = Draw.PupStrInput ('ReName Image, please :', name, 32)
         RenameImage(RDIR, MYDIR, FILENAME, name)
 
-def SAVE_image (rc, name, FRAME):
+def SAVE_image (rc, name, FRAME, result):
    """  
 # ---------------------------
 # Function  SAVE_image
@@ -268,26 +290,25 @@ def SAVE_image (rc, name, FRAME):
    rc.startFrame(NEWFRAME)
    rc.endFrame(NEWFRAME)
    rc.renderAnim()
-   Blender.Scene.Render.CloseRenderWindow()
-
-   FILENAME = "%04d" % NEWFRAME
-   FILENAME = FILENAME.replace (' ', '0')
-   FILENAME = RDIR + MYDIR + FILENAME + '.png'
-
-   RenameImage(RDIR, MYDIR, FILENAME, name)
-
+   if result!=2 and not KEEPRENDERWINDOW:
+      Blender.Scene.Render.CloseRenderWindow()
+      FILENAME = "%04d" % NEWFRAME
+      FILENAME = FILENAME.replace (' ', '0')
+      FILENAME = RDIR + MYDIR + FILENAME + '.png'
+      RenameImage(RDIR, MYDIR, FILENAME, name)
+       
    rc.endFrame(OLDEFRAME)
    rc.startFrame(OLDSFRAME)
    rc.setRenderPath(RENDERDIR)
 
-def SHOOT (XYlimit, frame, obj, name, FRAME):
+def SHOOT (XYlimit, frame, obj, name, FRAME, result):
    """
 # ---------------------------
 # Function  SHOOT
 #
 #  IN : XYlimit  list of 4 floats, smallest and biggest 
 #                uvcoords
-#       frame    cureente frame
+#       frame    current frame
 #       obj      for object location
 #       name     image name
 #       FRAME    the last animation's frame 
@@ -305,6 +326,7 @@ def SHOOT (XYlimit, frame, obj, name, FRAME):
       CAM, SC = GET_newobject('Camera','UVCAMERA')
       CAM.link(Cam)
       CAM.setName('UVCAMERA')
+      CAM.layers=[RENDERLAYER]
       Cam.lens = 30
       Cam.name = 'UVCamera'
 
@@ -333,13 +355,15 @@ def SHOOT (XYlimit, frame, obj, name, FRAME):
    elif (tres) == 5: res = 2048
    else: res = 512
 
+   SCENELAYERS=SC.layers
+   SC.layers = [20]
    context.imageSizeY(res)
    context.imageSizeX(res)
-   SAVE_image (context, name, FRAME)
+   SAVE_image (context, name, FRAME, result)
    context.imageSizeY(OLDy)
    context.imageSizeX(OLDx)
-
-   if Camold :SC.setCurrentCamera(Camold)
+   SC.layers = SCENELAYERS
+   if Camold : SC.setCurrentCamera(Camold)
 
    Blender.Set ('curframe', frame)
 
@@ -393,6 +417,8 @@ def Mesh2UVCoord (LIMIT):
 #  OUT:  nothing
 # ---------------------------   
    """
+   global PUTRAW, FRAME, SCENELAYERS
+
    try:
       MESH3D = Object.GetSelected()[0]
       if MESH3D.getType() == 'Mesh':
@@ -401,18 +427,21 @@ def Mesh2UVCoord (LIMIT):
          try:
             NewOBJECT=Blender.Object.Get('UVOBJECT')
             CurSCENE=Blender.Scene.getCurrent()            
-            MESH2 = NewOBJECT.getData()
-            
          except:
             NewOBJECT, CurSCENE = GET_newobject('Mesh','UVOBJECT')
-            MESH2 = Blender.NMesh.GetRaw()
+         MESH2 = NewOBJECT.getData() 
+         NewOBJECT.layers=[RENDERLAYER]
 
          MESH2.faces=[]
          for f in MESH.faces:
             f1 = Blender.NMesh.Face()
-
             for v in f.v:
-               v1 = Blender.NMesh.Vert (v.co[0], v.co[1], v.co[2])
+               v1 = Blender.NMesh.Vert (0.0, 0.0, 0.0)
+               for n in [0,1]:
+                  v1.co[n] = f.uv[f.v.index(v)][n]
+                  exec "if v1.co[%s] > XYLIMIT[%s]: XYLIMIT[%s] = v1.co[%s]" % (n, n+2, n+2, n)
+                  exec "if v1.co[%s] < XYLIMIT[%s]: XYLIMIT[%s] = v1.co[%s]" % (n, n, n, n)
+               v1.co[2] = 0.0
                MESH2.verts.append(v1)
                f1.v.append(MESH2.verts[len(MESH2.verts) - 1])
 
@@ -423,32 +452,23 @@ def Mesh2UVCoord (LIMIT):
             f1.mode = f.mode
             f1.flag = f.flag
             f1.mat = f.mat
+            #----------------------------------- 
+            # release : 0.2.8 ,  2005/07/19 , end
+            #----------------------------------- 
+            try:
+              f1.image=f.image
+            except :
+              pass
 
          MESH2.materials = MESH.materials[:]
-
          NewOBJECT.setLocation (OBJPOS, OBJPOS, 0.0)
          NewOBJECT.setEuler (0.0, 0.0, 0.0)
 
          MESH2.removeAllKeys()
-
          MESH2.update()
          MESH2.insertKey (1, 'absolute')
          MESH2.update()
 
-         for f in MESH2.faces:
-            for v in f.v:
-               for n in [0,1]:
-                  v.co[n] = f.uv[f.v.index(v)][n]
-                  exec "if v.co[%s] > XYLIMIT[%s]: XYLIMIT[%s] = v.co[%s]" % (n, n+2, n+2, n)
-                  exec "if v.co[%s] < XYLIMIT[%s]: XYLIMIT[%s] = v.co[%s]" % (n, n, n, n)
-               v.co[2] = 0.0
-
-         if DEBUG: print XYLIMIT
-
-         MESH2.update()
-         MESH2.insertKey (FRAME, 'absolute')
-         MESH2.update()
-
          imagename = 'uvtext'
 
          name = "CHANGE IMAGE NAME ? %t | Replace it | No replacing | Script help"
@@ -467,9 +487,9 @@ def Mesh2UVCoord (LIMIT):
             #----------------------------------- 
 
             if LIMIT :
-                 SHOOT(XYLIMIT, FRAME, NewOBJECT, imagename, FRAME)
+                 SHOOT(XYLIMIT, FRAME, NewOBJECT, imagename, FRAME,result)
             else :
-                 SHOOT([0.0,0.0,1.0,1.0], FRAME, NewOBJECT, imagename, FRAME)
+                 SHOOT([0.0,0.0,1.0,1.0], FRAME, NewOBJECT, imagename, FRAME, result)
             #----------------------------------- 
             # release : 0.2.6,  2005/05/29 , 00h00
             #----------------------------------- 
index 328c68532f1304bd973f70ed8c08c5f2b0036212..6fd9737cace9bb0fc76517f09c63a9a5e0217350 100644 (file)
@@ -85,8 +85,8 @@
 /* Material MIN, MAX values */
 #define EXPP_MAT_ADD_MIN                        0.0
 #define EXPP_MAT_ADD_MAX                        1.0
-#define EXPP_MAT_ALPHA_MIN                      0.0
-#define EXPP_MAT_ALPHA_MAX                      1.0
+#define EXPP_MAT_ALPHA_MIN        0.0
+#define EXPP_MAT_ALPHA_MAX              1.0
 #define EXPP_MAT_AMB_MIN                        0.0
 #define EXPP_MAT_AMB_MAX                        1.0
 #define EXPP_MAT_COL_MIN                        0.0 /* min/max for all ... */
 #define EXPP_MAT_REF_MAX                        1.0
 #define EXPP_MAT_SPEC_MIN                       0.0
 #define EXPP_MAT_SPEC_MAX                       2.0
-#define EXPP_MAT_SPECTRA_MIN                    0.0
-#define EXPP_MAT_SPECTRA_MAX                    1.0
+#define EXPP_MAT_SPECTRA_MIN    0.0
+#define EXPP_MAT_SPECTRA_MAX    1.0
+
+/* Shader spesific settings */
+#define EXPP_MAT_SPEC_SHADER_MIN                        0
+#define EXPP_MAT_SPEC_SHADER_MAX                        3
+#define EXPP_MAT_DIFFUSE_SHADER_MIN                     0
+#define EXPP_MAT_DIFFUSE_SHADER_MAX                     4
+
+#define EXPP_MAT_ROUGHNESS_MIN                  0.0
+#define EXPP_MAT_ROUGHNESS_MAX                  3.140
+#define EXPP_MAT_SPECSIZE_MIN                   0.0
+#define EXPP_MAT_SPECSIZE_MAX                   1.530
+#define EXPP_MAT_DIFFUSESIZE_MIN                0.0
+#define EXPP_MAT_DIFFUSESIZE_MAX                        3.140
+#define EXPP_MAT_SPECSMOOTH_MIN                         0.0
+#define EXPP_MAT_SPECSMOOTH_MAX                         1.0
+#define EXPP_MAT_DIFFUSESMOOTH_MIN                      0.0
+#define EXPP_MAT_DIFFUSESMOOTH_MAX                      1.0
+#define EXPP_MAT_DIFFUSE_DARKNESS_MIN                   0.0
+#define EXPP_MAT_DIFFUSE_DARKNESS_MAX                   2.0
+#define EXPP_MAT_REFRACINDEX_MIN                        1.0
+#define EXPP_MAT_REFRACINDEX_MAX                        10.0
+#define EXPP_MAT_RMS_MIN                        0.0
+#define EXPP_MAT_RMS_MAX                        0.4
+/* End shader settings */
+
+/* diff_shader */
+#define MA_DIFF_LAMBERT                0
+#define MA_DIFF_ORENNAYAR      1
+#define MA_DIFF_TOON           2
+#define MA_DIFF_MINNAERT    3
+
+/* spec_shader */
+#define MA_SPEC_COOKTORR       0
+#define MA_SPEC_PHONG          1
+#define MA_SPEC_BLINN          2
+#define MA_SPEC_TOON           3
+#define MA_SPEC_WARDISO                4
+
+/* shader dicts - Diffuse */
+#define EXPP_MAT_SHADER_DIFFUSE_LAMBERT                MA_DIFF_LAMBERT
+#define EXPP_MAT_SHADER_DIFFUSE_ORENNAYAR      MA_DIFF_ORENNAYAR
+#define EXPP_MAT_SHADER_DIFFUSE_TOON           MA_DIFF_TOON
+#define EXPP_MAT_SHADER_DIFFUSE_MINNAERT       MA_DIFF_MINNAERT
+/* shader dicts - Specualr */
+#define EXPP_MAT_SHADER_SPEC_COOKTORR          MA_SPEC_COOKTORR
+#define EXPP_MAT_SHADER_SPEC_PHONG                     MA_SPEC_PHONG
+#define EXPP_MAT_SHADER_SPEC_BLINN                     MA_SPEC_BLINN
+#define EXPP_MAT_SHADER_SPEC_TOON                      MA_SPEC_TOON
+#define EXPP_MAT_SHADER_SPEC_WARDISO           MA_SPEC_WARDISO
+
 #define EXPP_MAT_ZOFFS_MIN                      0.0
 #define EXPP_MAT_ZOFFS_MAX                     10.0
 #define EXPP_MAT_HALOSIZE_MIN                   0.0
 #define EXPP_MAT_HARD_MIN                               1
 #define EXPP_MAT_HARD_MAX               255    /* 127 with MODE HALO ON */
 #define EXPP_MAT_HALOSEED_MIN           1
-#define EXPP_MAT_HALOSEED_MAX            255
+#define EXPP_MAT_HALOSEED_MAX    255
 #define EXPP_MAT_NFLARES_MIN            1
 #define EXPP_MAT_NFLARES_MAX           32
 #define EXPP_MAT_FLARESEED_MIN  1
 #define EXPP_MAT_FRESNELMIRR_MAX                       5.0
 #define EXPP_MAT_FRESNELMIRRFAC_MIN                    1.0
 #define EXPP_MAT_FRESNELMIRRFAC_MAX                    5.0
+#define EXPP_MAT_FILTER_MIN                    0.0
+#define EXPP_MAT_FILTER_MAX                    1.0
+#define EXPP_MAT_TRANSLUCENCY_MIN                      0.0
+#define EXPP_MAT_TRANSLUCENCY_MAX                      1.0
 #define EXPP_MAT_ZOFFS_MIN                             0.0
 #define EXPP_MAT_ZOFFS_MAX                             10.0
 #define EXPP_MAT_IOR_MIN                               1.0
@@ -310,7 +364,7 @@ static PyObject *M_Material_Get( PyObject * self, PyObject * args )
        }
 }
 
-static PyObject *Lamp_ModesDict( void )
+static PyObject *Material_ModesDict( void )
 {
        PyObject *Modes = M_constant_New(  );
 
@@ -351,32 +405,65 @@ static PyObject *Lamp_ModesDict( void )
                EXPP_ADDCONST( RAYMIRROR );
                EXPP_ADDCONST( ZTRA );
                EXPP_ADDCONST( RAYTRANSP );
-               EXPP_ADDCONST( ONLYSHADOW );
-               EXPP_ADDCONST( NOMIST );
-               EXPP_ADDCONST( ENV );
 
        }
 
        return Modes;
 }
 
+
+static PyObject *Material_ShadersDict( void )
+{
+       PyObject *Shaders = M_constant_New(  );
+
+#undef EXPP_ADDCONST
+#define EXPP_ADDCONST(name) \
+       constant_insert(c, #name, PyInt_FromLong(EXPP_MAT_SHADER_##name))
+
+/* So that:
+ * EXPP_ADDCONST(DIFFUSE_LAMBERT) becomes:
+ * constant_insert(c, "TRACEABLE", PyInt_FromLong(EXPP_MAT_SHADER_DIFFUSE_LAMBERT))
+ */
+
+       if( Shaders ) {
+               BPy_constant *c = ( BPy_constant * ) Shaders;
+
+               EXPP_ADDCONST( DIFFUSE_LAMBERT );
+               EXPP_ADDCONST( DIFFUSE_ORENNAYAR );
+               EXPP_ADDCONST( DIFFUSE_TOON );
+               EXPP_ADDCONST( DIFFUSE_MINNAERT );
+               
+               EXPP_ADDCONST( SPEC_COOKTORR );
+               EXPP_ADDCONST( SPEC_PHONG );
+               EXPP_ADDCONST( SPEC_BLINN );
+               EXPP_ADDCONST( SPEC_TOON );
+               EXPP_ADDCONST( SPEC_WARDISO );
+       }
+
+       return Shaders;
+}
+
+
 /*****************************************************************************/
 /* Function:   Material_Init */
 /*****************************************************************************/
 PyObject *Material_Init( void )
 {
-       PyObject *submodule, *Modes;
+       PyObject *submodule, *Modes, *Shaders;
 
        Material_Type.ob_type = &PyType_Type;
 
-       Modes = Lamp_ModesDict(  );
+       Modes = Material_ModesDict(  );
+       Shaders = Material_ShadersDict(  );
 
        submodule = Py_InitModule3( "Blender.Material",
                                    M_Material_methods, M_Material_doc );
 
        if( Modes )
                PyModule_AddObject( submodule, "Modes", Modes );
-
+       if( Shaders )
+               PyModule_AddObject( submodule, "Shaders", Shaders );
+       
        PyModule_AddIntConstant( submodule, "RGB", IPOKEY_RGB );
        PyModule_AddIntConstant( submodule, "ALPHA", IPOKEY_ALPHA );
        PyModule_AddIntConstant( submodule, "HALOSIZE", IPOKEY_HALOSIZE );
@@ -423,6 +510,18 @@ static PyObject *Material_getNFlares( BPy_Material * self );
 static PyObject *Material_getNStars( BPy_Material * self );
 static PyObject *Material_getNLines( BPy_Material * self );
 static PyObject *Material_getNRings( BPy_Material * self );
+/* Shader settings */
+static PyObject *Material_getSpecShader( BPy_Material * self );
+static PyObject *Material_getDiffuseShader( BPy_Material * self );
+static PyObject *Material_getRoughness( BPy_Material * self );
+static PyObject *Material_getSpecSize( BPy_Material * self );
+static PyObject *Material_getDiffuseSize( BPy_Material * self );
+static PyObject *Material_getSpecSmooth( BPy_Material * self );
+static PyObject *Material_getDiffuseSmooth( BPy_Material * self );
+static PyObject *Material_getDiffuseDarkness( BPy_Material * self );
+static PyObject *Material_getRefracIndex( BPy_Material * self );
+static PyObject *Material_getRms( BPy_Material * self );
+
 static PyObject *Material_getRayMirr( BPy_Material * self );
 static PyObject *Material_getMirrDepth( BPy_Material * self );
 static PyObject *Material_getFresnelMirr( BPy_Material * self );
@@ -431,6 +530,8 @@ static PyObject *Material_getIOR( BPy_Material * self );
 static PyObject *Material_getTransDepth( BPy_Material * self );
 static PyObject *Material_getFresnelTrans( BPy_Material * self );
 static PyObject *Material_getFresnelTransFac( BPy_Material * self );
+static PyObject *Material_getFilter( BPy_Material * self );
+static PyObject *Material_getTranslucency( BPy_Material * self );
 static PyObject *Material_getTextures( BPy_Material * self );
 static PyObject *Material_setIpo( BPy_Material * self, PyObject * args );
 static PyObject *Material_clearIpo( BPy_Material * self );
@@ -462,6 +563,19 @@ static PyObject *Material_setNFlares( BPy_Material * self, PyObject * args );
 static PyObject *Material_setNStars( BPy_Material * self, PyObject * args );
 static PyObject *Material_setNLines( BPy_Material * self, PyObject * args );
 static PyObject *Material_setNRings( BPy_Material * self, PyObject * args );
+
+/* Shader */
+static PyObject *Material_setSpecShader( BPy_Material * self, PyObject * args );
+static PyObject *Material_setDiffuseShader( BPy_Material * self, PyObject * args );
+static PyObject *Material_setRoughness( BPy_Material * self, PyObject * args );
+static PyObject *Material_setSpecSize( BPy_Material * self, PyObject * args );
+static PyObject *Material_setDiffuseSize( BPy_Material * self, PyObject * args );
+static PyObject *Material_setSpecSmooth( BPy_Material * self, PyObject * args );
+static PyObject *Material_setDiffuseSmooth( BPy_Material * self, PyObject * args );
+static PyObject *Material_setDiffuseDarkness( BPy_Material * self, PyObject * args );
+static PyObject *Material_setRefracIndex( BPy_Material * self, PyObject * args );
+static PyObject *Material_setRms( BPy_Material * self, PyObject * args );
+
 /* ** Mirror and transp ** */
 static PyObject *Material_setRayMirr( BPy_Material * self, PyObject * args );
 static PyObject *Material_setMirrDepth( BPy_Material * self, PyObject * args );
@@ -469,6 +583,10 @@ static PyObject *Material_setFresnelMirr( BPy_Material * self,
                                          PyObject * args );
 static PyObject *Material_setFresnelMirrFac( BPy_Material * self,
                                             PyObject * args );
+static PyObject *Material_setFilter( BPy_Material * self,
+                                            PyObject * args );
+static PyObject *Material_setTranslucency( BPy_Material * self,
+                                            PyObject * args );
 static PyObject *Material_setIOR( BPy_Material * self, PyObject * args );
 static PyObject *Material_setTransDepth( BPy_Material * self,
                                         PyObject * args );
@@ -519,6 +637,28 @@ static PyMethodDef BPy_Material_methods[] = {
         "() - Return Material's reflectivity"},
        {"getSpec", ( PyCFunction ) Material_getSpec, METH_NOARGS,
         "() - Return Material's specularity"},
+       /* Shader specific settings */
+       {"getSpecShader", ( PyCFunction ) Material_getSpecShader, METH_NOARGS,
+        "() - Returns Material's specular shader" },
+       {"getDiffuseShader", ( PyCFunction ) Material_getDiffuseShader, METH_NOARGS,
+        "() - Returns Material's diffuse shader" },
+        {"getRoughness", ( PyCFunction ) Material_getRoughness, METH_NOARGS,
+        "() - Returns Material's Roughness (applies to the \"Oren Nayar\" Diffuse Shader only)" },
+       {"getSpecSize", ( PyCFunction ) Material_getSpecSize, METH_NOARGS,
+        "() - Returns Material's size of specular area (applies to the \"Toon\" Specular Shader only)" },
+       {"getDiffuseSize", ( PyCFunction ) Material_getDiffuseSize, METH_NOARGS,
+        "() - Returns Material's size of diffuse area (applies to the \"Toon\" Diffuse Shader only)" },
+       {"getSpecSmooth", ( PyCFunction ) Material_getSpecSmooth, METH_NOARGS,
+        "() - Returns Material's smoothing of specular area (applies to the \"Toon\" Diffuse Shader only)" },
+       {"getDiffuseSmooth", ( PyCFunction ) Material_getDiffuseSmooth, METH_NOARGS,
+        "() - Returns Material's smoothing of diffuse area (applies to the \"Toon\" Diffuse Shader only)" },
+       {"getDiffuseDarkness", ( PyCFunction ) Material_getDiffuseDarkness, METH_NOARGS,
+        "() - Returns Material's diffuse darkness (applies to the \"Minnaert\" Diffuse Shader only)" },
+       {"getRefracIndex", ( PyCFunction ) Material_getRefracIndex, METH_NOARGS,
+        "() - Returns Material's Index of Refraction (applies to the \"Blinn\" Specular Shader only)" },        
+       {"getRms", ( PyCFunction ) Material_getRms, METH_NOARGS,
+        "() - Returns Material's standard deviation of surface slope (applies to the \"WardIso\" Specular Shader only)" },
+       /* End shader settings */
        {"getSpecTransp", ( PyCFunction ) Material_getSpecTransp, METH_NOARGS,
         "() - Return Material's specular transparency"},
        {"getAdd", ( PyCFunction ) Material_getAdd, METH_NOARGS,
@@ -558,6 +698,12 @@ static PyMethodDef BPy_Material_methods[] = {
        {"getFresnelMirrFac", ( PyCFunction ) Material_getFresnelMirrFac,
         METH_NOARGS,
         "() - Return fresnel power for refractions factor"},
+       {"getFilter", ( PyCFunction ) Material_getFilter,
+        METH_NOARGS,
+        "() - Return the amount of filtering when transparent raytrace is enabled"},
+       {"getTranslucency", ( PyCFunction ) Material_getTranslucency,
+        METH_NOARGS,
+        "() - Return the Translucency, the amount of diffuse shading of the back side"},
        {"getIOR", ( PyCFunction ) Material_getIOR, METH_NOARGS,
         "() - Return IOR"},
        {"getTransDepth", ( PyCFunction ) Material_getTransDepth, METH_NOARGS,
@@ -586,6 +732,30 @@ static PyMethodDef BPy_Material_methods[] = {
                        "(f,f,f or [f,f,f]) - Set Material's ambient color"},*/
        {"setSpecCol", ( PyCFunction ) Material_setSpecCol, METH_VARARGS,
         "(f,f,f or [f,f,f]) - Set Material's specular color"},
+        
+       /* Shader spesific settings */
+       {"setSpecShader", ( PyCFunction ) Material_setSpecShader, METH_NOARGS,
+        "(i) - Set the Material's specular shader" },
+       {"setDiffuseShader", ( PyCFunction ) Material_setDiffuseShader, METH_NOARGS,
+        "(i) - Set the Material's diffuse shader" },
+        {"setRoughness", ( PyCFunction ) Material_setRoughness, METH_NOARGS,
+        "(f) - Set the Material's Roughness (applies to the \"Oren Nayar\" Diffuse Shader only)" },
+       {"setSpecSize", ( PyCFunction ) Material_setSpecSize, METH_NOARGS,
+        "(f) - Set the Material's size of specular area (applies to the \"Toon\" Specular Shader only)" },
+       {"setDiffuseSize", ( PyCFunction ) Material_setDiffuseSize, METH_NOARGS,
+        "(f) - Set the Material's size of diffuse area (applies to the \"Toon\" Diffuse Shader only)" },
+       {"setSpecSmooth", ( PyCFunction ) Material_setSpecSmooth, METH_NOARGS,
+        "(f) - Set the Material's smoothing of specular area (applies to the \"Toon\" Specular Shader only)" },
+       {"setDiffuseSmooth", ( PyCFunction ) Material_setDiffuseSmooth, METH_NOARGS,
+        "(f) - Set the Material's smoothing of diffuse area (applies to the \"Toon\" Diffuse Shader only)" },
+       {"setDiffuseDarkness", ( PyCFunction ) Material_setDiffuseDarkness, METH_NOARGS,
+        "(f) - Set the Material's diffuse darkness (applies to the \"Minnaert\" Diffuse Shader only)" },
+       {"setRefracIndex", ( PyCFunction ) Material_setRefracIndex, METH_NOARGS,
+        "(f) - Set the Material's Index of Refraction (applies to the \"Blinn\" Specular Shader only)" },       
+       {"setRms", ( PyCFunction ) Material_setRms, METH_NOARGS,
+        "(f) - Set the Material's standard deviation of surface slope (applies to the \"WardIso\" Specular Shader only)" },
+       /* End shader settings */
+        
        {"setMirCol", ( PyCFunction ) Material_setMirCol, METH_VARARGS,
         "(f,f,f or [f,f,f]) - Set Material's mirror color"},
        {"setAmb", ( PyCFunction ) Material_setAmb, METH_VARARGS,
@@ -638,6 +808,12 @@ static PyMethodDef BPy_Material_methods[] = {
        {"setFresnelMirrFac", ( PyCFunction ) Material_setFresnelMirrFac,
         METH_VARARGS,
         "(f) - Set blend fac for mirror fresnel - [1.0, 5.0]"},
+       {"setFilter", ( PyCFunction ) Material_setFresnelMirrFac,
+        METH_VARARGS,
+        "(f) - Set the amount of filtering when transparent raytrace is enabled"},
+       {"setTranslucency", ( PyCFunction ) Material_setTranslucency,
+        METH_VARARGS,
+        "(f) - Set the Translucency, the amount of diffuse shading of the back side"},
        {"setIOR", ( PyCFunction ) Material_setIOR, METH_VARARGS,
         "(f) - Set IOR - [1.0, 3.0]"},
        {"setTransDepth", ( PyCFunction ) Material_setTransDepth, METH_VARARGS,
@@ -864,6 +1040,116 @@ static PyObject *Material_getMirCol( BPy_Material * self )
        return rgbTuple_getCol( self->mir );
 }
 
+static PyObject *Material_getSpecShader( BPy_Material * self )
+{
+       PyObject *attr = PyInt_FromLong( ( long ) self->material->spec_shader );
+
+       if( attr )
+               return attr;
+
+       return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+                                     "couldn't get Material.specShader attribute" );
+}
+
+static PyObject *Material_getDiffuseShader( BPy_Material * self )
+{
+       PyObject *attr = PyInt_FromLong( ( long ) self->material->diff_shader );
+
+       if( attr )
+               return attr;
+
+       return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+                                     "couldn't get Material.diffuseShader attribute" );
+}
+
+static PyObject *Material_getRoughness( BPy_Material * self )
+{
+       PyObject *attr = PyFloat_FromDouble( ( double ) self->material->roughness );
+
+       if( attr )
+               return attr;
+
+       return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+                                         "couldn't get Material.roughness attribute" );
+}
+
+static PyObject *Material_getSpecSize( BPy_Material * self )
+{
+       PyObject *attr = PyFloat_FromDouble( ( double ) self->material->param[2] );
+
+       if( attr )
+               return attr;
+
+       return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+                                         "couldn't get Material.specSize attribute" );
+}
+
+static PyObject *Material_getDiffuseSize( BPy_Material * self )
+{
+       PyObject *attr = PyFloat_FromDouble( ( double ) self->material->param[0] );
+
+       if( attr )
+               return attr;
+
+       return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+                                         "couldn't get Material.diffuseSize attribute" );
+}
+
+static PyObject *Material_getSpecSmooth( BPy_Material * self )
+{
+       PyObject *attr = PyFloat_FromDouble( ( double ) self->material->param[3] );
+
+       if( attr )
+               return attr;
+
+       return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+                                         "couldn't get Material.specSmooth attribute" );
+}
+
+static PyObject *Material_getDiffuseSmooth( BPy_Material * self )
+{
+       PyObject *attr = PyFloat_FromDouble( ( double ) self->material->param[1] );
+
+       if( attr )
+               return attr;
+
+       return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+                                         "couldn't get Material.diffuseSmooth( attribute" );
+}
+
+static PyObject *Material_getDiffuseDarkness( BPy_Material * self )
+{
+       PyObject *attr = PyFloat_FromDouble( ( double ) self->material->darkness );
+
+       if( attr )
+               return attr;
+
+       return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+                                         "couldn't get Material.diffuseDarkness attribute" );
+}
+
+static PyObject *Material_getRefracIndex( BPy_Material * self )
+{
+       PyObject *attr = PyFloat_FromDouble( ( double ) self->material->refrac );
+
+       if( attr )
+               return attr;
+
+       return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+                                         "couldn't get Material.refracIndex attribute" );
+}
+       
+static PyObject *Material_getRms( BPy_Material * self )
+{
+       PyObject *attr = PyFloat_FromDouble( ( double ) self->material->rms );
+
+       if( attr )
+               return attr;
+
+       return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+                                         "couldn't get Material.rms attribute" );
+}
+
 static PyObject *Material_getAmb( BPy_Material * self )
 {
        PyObject *attr = PyFloat_FromDouble( ( double ) self->material->amb );
@@ -1089,7 +1375,7 @@ static PyObject *Material_getRayMirr( BPy_Material * self )
                return attr;
 
        return EXPP_ReturnPyObjError( PyExc_RuntimeError,
-                                     "couldn't get Material.nRings attribute" );
+                                     "couldn't get Material.rayMirr attribute" );
 }
 
 static PyObject *Material_getMirrDepth( BPy_Material * self )
@@ -1100,7 +1386,7 @@ static PyObject *Material_getMirrDepth( BPy_Material * self )
                return attr;
 
        return EXPP_ReturnPyObjError( PyExc_RuntimeError,
-                                     "couldn't get Material.nRings attribute" );
+                                     "couldn't get Material.rayMirrDepth attribute" );
 }
 
 static PyObject *Material_getFresnelMirr( BPy_Material * self )
@@ -1112,7 +1398,7 @@ static PyObject *Material_getFresnelMirr( BPy_Material * self )
                return attr;
 
        return EXPP_ReturnPyObjError( PyExc_RuntimeError,
-                                     "couldn't get Material.nRings attribute" );
+                                     "couldn't get Material.fresnelDepth attribute" );
 }
 
 static PyObject *Material_getFresnelMirrFac( BPy_Material * self )
@@ -1124,7 +1410,31 @@ static PyObject *Material_getFresnelMirrFac( BPy_Material * self )
                return attr;
 
        return EXPP_ReturnPyObjError( PyExc_RuntimeError,
-                                     "couldn't get Material.nRings attribute" );
+                                     "couldn't get Material.fresnelDepthFac attribute" );
+}
+
+static PyObject *Material_getFilter( BPy_Material * self )
+{
+       PyObject *attr =
+               PyFloat_FromDouble( ( double ) self->material->filter );
+
+       if( attr )
+               return attr;
+
+       return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+                                     "couldn't get Material.filter attribute" );
+}
+
+static PyObject *Material_getTranslucency( BPy_Material * self )
+{
+       PyObject *attr =
+               PyFloat_FromDouble( ( double ) self->material->translucency );
+
+       if( attr )
+               return attr;
+
+       return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+                                     "couldn't get Material.translucency attribute" );
 }
 
 static PyObject *Material_getIOR( BPy_Material * self )
@@ -1506,6 +1816,158 @@ static PyObject *Material_setMirCol( BPy_Material * self, PyObject * args )
        return rgbTuple_setCol( self->mir, args );
 }
 
+
+static PyObject *Material_setSpecShader( BPy_Material * self, PyObject * args )
+{
+       int value;
+
+       if( !PyArg_ParseTuple( args, "i", &value ) )
+               return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+                                               "expected int argument" ) );
+
+       self->material->spec_shader = EXPP_ClampInt( value, EXPP_MAT_SPEC_SHADER_MIN,
+                                              EXPP_MAT_SPEC_SHADER_MAX );
+       
+       Py_INCREF( Py_None );
+       return Py_None;
+}
+
+static PyObject *Material_setDiffuseShader( BPy_Material * self, PyObject * args )
+{
+       int value;
+
+       if( !PyArg_ParseTuple( args, "i", &value ) )
+               return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+                                               "expected int argument" ) );
+
+       self->material->diff_shader = EXPP_ClampInt( value, EXPP_MAT_DIFFUSE_SHADER_MIN,
+                                              EXPP_MAT_DIFFUSE_SHADER_MAX );
+       
+       Py_INCREF( Py_None );
+       return Py_None;
+}
+
+
+static PyObject *Material_setRoughness( BPy_Material * self, PyObject * args )
+{
+       float value;
+
+       if( !PyArg_ParseTuple( args, "f", &value ) )
+               return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+                                               "expected float argument in [0.0, 3.14]" ) );
+
+       self->material->roughness = EXPP_ClampFloat( value, EXPP_MAT_ROUGHNESS_MIN,
+                                               EXPP_MAT_ROUGHNESS_MAX );
+
+       return EXPP_incr_ret( Py_None );
+}
+
+
+static PyObject *Material_setSpecSize( BPy_Material * self, PyObject * args )
+{
+       float value;
+
+       if( !PyArg_ParseTuple( args, "f", &value ) )
+               return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+                                               "expected float argument in [0.0, 1.53]" ) );
+
+       self->material->param[2] = EXPP_ClampFloat( value, EXPP_MAT_SPECSIZE_MIN,
+                                               EXPP_MAT_SPECSIZE_MAX );
+
+       return EXPP_incr_ret( Py_None );
+}
+
+
+static PyObject *Material_setDiffuseSize( BPy_Material * self, PyObject * args )
+{
+       float value;
+
+       if( !PyArg_ParseTuple( args, "f", &value ) )
+               return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+                                               "expected float argument in [0.0, 3.14]" ) );
+
+       self->material->param[0] = EXPP_ClampFloat( value, EXPP_MAT_DIFFUSESIZE_MIN,
+                                               EXPP_MAT_DIFFUSESIZE_MAX );
+
+       return EXPP_incr_ret( Py_None );
+}
+
+
+static PyObject *Material_setSpecSmooth( BPy_Material * self, PyObject * args )
+{
+       float value;
+
+       if( !PyArg_ParseTuple( args, "f", &value ) )
+               return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+                                               "expected float argument in [0.0, 1.0]" ) );
+
+       self->material->param[2] = EXPP_ClampFloat( value, EXPP_MAT_SPECSMOOTH_MIN,
+                                               EXPP_MAT_SPECSMOOTH_MAX );
+
+       return EXPP_incr_ret( Py_None );
+}
+
+
+static PyObject *Material_setDiffuseSmooth( BPy_Material * self, PyObject * args )
+{
+       float value;
+
+       if( !PyArg_ParseTuple( args, "f", &value ) )
+               return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+                                               "expected float argument in [0.0, 1.0]" ) );
+
+       self->material->param[1] = EXPP_ClampFloat( value, EXPP_MAT_DIFFUSESMOOTH_MIN,
+                                               EXPP_MAT_DIFFUSESMOOTH_MAX );
+
+       return EXPP_incr_ret( Py_None );
+}
+       
+
+static PyObject *Material_setDiffuseDarkness( BPy_Material * self, PyObject * args )
+{
+       float value;
+
+       if( !PyArg_ParseTuple( args, "f", &value ) )
+               return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+                                               "expected float argument in [0.0, 2.0]" ) );
+
+       self->material->darkness = EXPP_ClampFloat( value, EXPP_MAT_DIFFUSE_DARKNESS_MIN,
+                                               EXPP_MAT_DIFFUSE_DARKNESS_MAX );
+
+       return EXPP_incr_ret( Py_None );
+}
+
+
+static PyObject *Material_setRefracIndex( BPy_Material * self, PyObject * args )
+{
+       float value;
+
+       if( !PyArg_ParseTuple( args, "f", &value ) )
+               return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+                                               "expected float argument in [1.0, 10.0]" ) );
+
+       self->material->refrac = EXPP_ClampFloat( value, EXPP_MAT_REFRACINDEX_MIN,
+                                               EXPP_MAT_REFRACINDEX_MAX );
+
+       return EXPP_incr_ret( Py_None );
+}
+
+
+static PyObject *Material_setRms( BPy_Material * self, PyObject * args )
+{
+       float value;
+
+       if( !PyArg_ParseTuple( args, "f", &value ) )
+               return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+                                               "expected float argument in [0.0, 0.4]" ) );
+
+       self->material->rms = EXPP_ClampFloat( value, EXPP_MAT_RMS_MIN,
+                                               EXPP_MAT_RMS_MAX );
+
+       return EXPP_incr_ret( Py_None );
+}
+
+
 static PyObject *Material_setColorComponent( BPy_Material * self, char *key,
                                             PyObject * args )
 {                              /* for compatibility with old bpython */
@@ -1864,6 +2326,38 @@ static PyObject *Material_setFresnelMirrFac( BPy_Material * self,
        return EXPP_incr_ret( Py_None );
 }
 
+static PyObject *Material_setFilter( BPy_Material * self,
+                                            PyObject * args )
+{
+       float value;
+
+       if( !PyArg_ParseTuple( args, "f", &value ) )
+               return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+                                               "expected float argument in [0.0, 1.0]" ) );
+
+       self->material->filter =
+               EXPP_ClampFloat( value, EXPP_MAT_FILTER_MIN,
+                                EXPP_MAT_FILTER_MAX );
+
+       return EXPP_incr_ret( Py_None );
+}
+
+static PyObject *Material_setTranslucency( BPy_Material * self,
+                                            PyObject * args )
+{
+       float value;
+
+       if( !PyArg_ParseTuple( args, "f", &value ) )
+               return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+                                               "expected float argument in [0.0, 1.0]" ) );
+
+       self->material->translucency =
+               EXPP_ClampFloat( value, EXPP_MAT_TRANSLUCENCY_MIN,
+                                EXPP_MAT_TRANSLUCENCY_MAX );
+
+       return EXPP_incr_ret( Py_None );
+}
+
 static PyObject *Material_setIOR( BPy_Material * self, PyObject * args )
 {
        float value;
@@ -2111,6 +2605,12 @@ static PyObject *Material_getAttr( BPy_Material * self, char *name )
        else if( strcmp( name, "fresnelDepthFac" ) == 0 )
                attr = PyFloat_FromDouble( ( double ) self->material->
                                           fresnel_mir_i );
+       else if( strcmp( name, "filter" ) == 0 )
+               attr = PyFloat_FromDouble( ( double ) self->material->
+                                          filter );
+       else if( strcmp( name, "translucency" ) == 0 )
+               attr = PyFloat_FromDouble( ( double ) self->material->
+                                          translucency );
        else if( strcmp( name, "IOR" ) == 0 )
                attr = PyFloat_FromDouble( ( double ) self->material->ang );
        else if( strcmp( name, "transDepth" ) == 0 )
@@ -2125,6 +2625,38 @@ static PyObject *Material_getAttr( BPy_Material * self, char *name )
        else if( strcmp( name, "users" ) == 0 )
                attr = PyInt_FromLong( ( long ) self->material->
                                           id.us );
+       /* Shader settings*/
+       else if( strcmp( name, "specShader" ) == 0 )
+               attr = PyInt_FromLong( ( double ) self->material->
+                                          spec_shader );
+       else if( strcmp( name, "diffuseShader" ) == 0 )
+               attr = PyInt_FromLong( ( double ) self->material->
+                                          diff_shader );
+       else if( strcmp( name, "roughness" ) == 0 )
+               attr = PyFloat_FromDouble( ( double ) self->material->
+                                          roughness );
+       else if( strcmp( name, "specSize" ) == 0 )
+               attr = PyFloat_FromDouble( ( double ) self->material->
+                                          param[2] );
+       else if( strcmp( name, "diffuseSize" ) == 0 )
+               attr = PyFloat_FromDouble( ( double ) self->material->
+                                          param[0] );
+       else if( strcmp( name, "specSmooth" ) == 0 )
+               attr = PyFloat_FromDouble( ( double ) self->material->
+                                          param[3] );
+       else if( strcmp( name, "diffuseSmooth" ) == 0 )
+               attr = PyFloat_FromDouble( ( double ) self->material->
+                                          param[1] );
+       else if( strcmp( name, "diffuseDarkness" ) == 0 )
+               attr = PyFloat_FromDouble( ( double ) self->material->
+                                          darkness );
+       else if( strcmp( name, "refracIndex" ) == 0 )
+               attr = PyFloat_FromDouble( ( double ) self->material->
+                                          refrac );
+       else if( strcmp( name, "rms" ) == 0 )
+               attr = PyFloat_FromDouble( ( double ) self->material->
+                                          rms );
+       
   else if (strcmp(name, "oopsLoc") == 0) {
     if (G.soops) { 
       Oops *oops= G.soops->oops.first;
@@ -2162,17 +2694,19 @@ static PyObject *Material_getAttr( BPy_Material * self, char *name )
        else if( strcmp( name, "__members__" ) == 0 ) {
                attr =          /* 30 items */
                        Py_BuildValue
-                       ( "[s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s]",
+                       ( "[s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,                                        s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s]",
                          "name", "mode", "rgbCol", "specCol", "mirCol", "R",
-                         "G", "B", "alpha", "amb", "emit", "ref", "spec",
-                         "specTransp", "add", "zOffset", "haloSize",
-                         "haloSeed", "flareSize", "flareBoost", "flareSeed",
-                         "subSize", "hard", "nFlares", "nStars", "nLines",
-                         "nRings", "rayMirr", "rayMirrDepth", "fresnelDepth",
+                         "G", "B", "alpha", "amb", "emit", "ref",
+                               "spec", "specTransp", "add", "zOffset", "haloSize", "haloSeed",
+                               "flareSize", "flareBoost", "flareSeed", "subSize", "hard", "nFlares",
+                               "nStars", "nLines", "nRings", "rayMirr", "rayMirrDepth", "fresnelDepth",
                          "fresnelDepthFac", "IOR", "transDepth",
-                         "fresnelTrans", "fresnelTransFac", "users", "oopsLoc", "oopsSel" );
-       }
-
+                               "fresnelTrans", "fresnelTransFac", "users",
+                               "oopsLoc", "oopsSel", "filter", "translucency", "shader", "roughness",
+                               "specSize", "diffuseSize", "specSmooth",
+                         "diffuseSmooth", "diffuseDarkness", "refracIndex", "rms");
+       }       
+       
        if( !attr )
                return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
                                                "couldn't create PyObject" ) );
@@ -2282,6 +2816,10 @@ static int Material_setAttr( BPy_Material * self, char *name,
                error = Material_setFresnelMirr( self, valtuple );
        else if( strcmp( name, "fresnelDepthFac" ) == 0 )
                error = Material_setFresnelMirrFac( self, valtuple );
+       else if( strcmp( name, "filter" ) == 0 )
+               error = Material_setFilter( self, valtuple );
+       else if( strcmp( name, "translucency" ) == 0 )
+               error = Material_setTranslucency( self, valtuple );
        else if( strcmp( name, "IOR" ) == 0 )
                error = Material_setIOR( self, valtuple );
        else if( strcmp( name, "transDepth" ) == 0 )
@@ -2290,6 +2828,27 @@ static int Material_setAttr( BPy_Material * self, char *name,
                error = Material_setFresnelTrans( self, valtuple );
        else if( strcmp( name, "fresnelTransFac" ) == 0 )
                error = Material_setFresnelTransFac( self, valtuple );
+       /* Shader settings */
+       else if( strcmp( name, "specShader" ) == 0 )
+               error = Material_setSpecShader( self, valtuple );
+       else if( strcmp( name, "diffuseShader" ) == 0 )
+               error = Material_setDiffuseShader( self, valtuple );    
+       else if( strcmp( name, "roughness" ) == 0 )
+               error = Material_setRoughness( self, valtuple );
+       else if( strcmp( name, "specSize" ) == 0 )
+               error = Material_setSpecSize( self, valtuple );
+       else if( strcmp( name, "diffuseSize" ) == 0 )
+               error = Material_setDiffuseSize( self, valtuple );
+       else if( strcmp( name, "specSmooth" ) == 0 )
+               error = Material_setSpecSmooth( self, valtuple );
+       else if( strcmp( name, "diffuseSmooth" ) == 0 )
+               error = Material_setDiffuseSmooth( self, valtuple );
+       else if( strcmp( name, "diffuseDarkness" ) == 0 )
+               error = Material_setDiffuseDarkness( self, valtuple );
+       else if( strcmp( name, "refracIndex" ) == 0 )
+               error = Material_setRefracIndex( self, valtuple );
+       else if( strcmp( name, "rms" ) == 0 )
+               error = Material_setRms( self, valtuple );      
   else if (strcmp (name, "oopsLoc") == 0) {
     if (G.soops) {
       Oops *oops= G.soops->oops.first;
index 813770a1b65d9ba586aee20a73006f5ba03a2ff0..876c39b36b399947fa4335d230e037bc4b0f532c 100644 (file)
@@ -9,43 +9,43 @@ The Blender Python API Reference
  Top Module:
  -----------
 
-  - L{Blender} (*)
+  - L{Blender}
 
  Submodules:
  -----------
-  - L{Armature}
+  - L{Armature} (broken, needs rewrite)
      - L{Bone}
      - L{NLA}
   - L{BGL}
-  - L{Camera} (*)
-  - L{Curve} (*)
-  - L{Draw} (*)
+  - L{Camera}
+  - L{Curve}
+  - L{Draw}
   - L{Effect}
-  - L{Image} (*)
-  - L{Ipo} (*)
+  - L{Image}
+  - L{Ipo}
   - L{Lamp}
   - L{Lattice}
   - L{Library}
-  - L{Material}
+  - L{Material} (*)
   - L{Mathutils} (*)
   - L{Metaball}
   - L{NMesh} (*)
   - L{Noise}
   - L{Object} (*)
-  - L{Registry} (*)
-  - L{Scene} (*)
+  - L{Registry}
+  - L{Scene}
      - L{Radio}
      - L{Render}
   - L{Sound}
   - L{Text}
-  - L{Text3d} (new)
-     - L{Font} (new)
+  - L{Text3d}
+     - L{Font}
   - L{Texture}
   - L{Types}
   - L{Window}
      - L{Theme}
   - L{World}
-  - L{sys<Sys>} (*)
+  - L{sys<Sys>}
 
  Additional information:
  -----------------------
index 936154c0c29cff6103f941da392f4f6e1c2ef476..8d74162e17a24908d4a4c9a4e14a33bd316ac350 100644 (file)
@@ -3,7 +3,7 @@
 """
 The Blender.Material submodule.
 
-B{New}: L{Material.clearScriptLinks} accepts a parameter now.
+B{New}: access to shader data.
 
 Material 
 ========
@@ -56,6 +56,19 @@ Example::
     such possibilities in the Modes dict below: each halo-related mode that
     uses an already taken value is preceded by "-" and appear below the normal
     mode which also uses that value.
+
+
+@type Shaders: readonly dictionary
+@var Shaders: The available Material Shaders.
+    - DIFFUSE_LAMBERT    - Make Material use the lambert diffuse shader.
+    - DIFFUSE_ORENNAYAR       - Make Material use the orennayar diffuse shader.
+    - DIFFUSE_TOON    - Make Material use the toon diffuse shader.
+    - DIFFUSE_MINNAERT  - Make Material use the minnaert diffuse shader.
+    - SPEC_COOKTORR   - Make Material use the cooktorr specular shader.
+    - SPEC_PHONG   - Make Material use the phong specular shader.
+    - SPEC_BLINN         - Make Material use the blinn specular shader.
+    - SPEC_TOON      - Make Material use the toon specular shader.
+    - SPEC_WARDISO      - Make Material use the wardiso specular shader.
 """
 
 def New (name = 'Mat'):
@@ -124,6 +137,18 @@ class Material:
   @ivar fresnelTrans: Power of Fresnel for transparency.
   @ivar fresnelTransFac: Blending factor for Fresnel.
   @ivar specTrans: Makes specular areas opaque on transparent materials.
+  @cvar specShader: Specular shader from one of the shaders in Material.Shaders dict - [0, 4].
+  @cvar diffuseShader: Diffuse shader from one of the shaders in Material.Shaders dict - [0, 3].
+  @cvar roughness: Material's Roughness (applies to the \"Oren Nayar\" Diffuse Shader only) - [0.0, 3.14].
+  @cvar specSize: Material's size of speculara area (applies to the \"Toon\" Specular Shader only) - [0.0, 1.53].
+  @cvar diffuseSize: Material's size of diffuse area (applies to the \"Toon\" Diffuse Shader only) - [0.0, 3.14].
+  @cvar specSmooth: Material's smoothing of specular area (applies to the \"Toon\" Specular Shader only) - [0.0, 1.0].
+  @cvar diffuseSmooth: Material's smoothing of diffuse area (applies to the \"Toon\" Diffuse Shader only) - [0.0, 1.0].
+  @cvar diffuseDarkness: Material's diffuse darkness (applies to the \"Minnaert\" Diffuse Shader only) - [0.0, 2.0].
+  @cvar refracIndex: Material's Index of Refraction (applies to the \"Blinn\" Specular Shader only) - [1.0, 10.0].
+  @cvar rms: Material's standard deviation of surface slope (applies to the \"WardIso\" Specular Shader only) - [0.0, 0.4].
+  @cvar filter: Amount of filtering when transparent raytrace is enabled - [0.0, 1.0].
+  @cvar translucency: Amount of diffuse shading of the back side - [0.0, 1.0].
   @warning: Most member variables assume values in some [Min, Max] interval.
    When trying to set them, the given parameter will be clamped to lie in
    that range: if val < Min, then val = Min, if val > Max, then val = Max.
@@ -206,7 +231,7 @@ class Material:
     "ZTransp", "ZInvert", "HaloRings", "HaloLines", "OnlyShadow",
     "HaloXAlpha", "HaloStar", "TexFace", "HaloTex", "HaloPuno", "NoMist",
     "HaloShaded", "HaloFlare", "Radio", "RayMirr", "ZTransp", "RayTransp",
-    "OnlyShadow", "NoMist", "Env"
+    "Env"
 
     An integer can also be given, which directly sets the mode flag.  The
     Modes dictionary keys can (and should) be added or ORed to specify
@@ -345,6 +370,162 @@ class Material:
     @param spectransp: The new value in [0.0, 1.0].
     """
 
+  def setSpecShader(specShader):
+    """
+    Set the material's specular shader from one of the shaders in Material.Shaders dict.
+    @type specShader: int
+    @param specShader: The new value in [0, 4].
+    """
+
+  def getSpecShader(specShader):
+    """
+    Get the material's specular shader from one of the shaders in Material.Shaders dict.
+    @rtype: int
+    """
+
+  def setDiffuseShader(diffuseShader):
+    """
+    Set the material's diffuse shader from one of the shaders in Material.Shaders dict.
+    @type diffuseShader: int
+    @param diffuseShader: The new value in [0, 3].
+    """
+
+  def getDiffuseShader():
+    """
+    Get the material's diffuse shader from one of the shaders in Material.Shaders dict.
+    @rtype: int
+    """
+
+  def setRoughness(roughness):
+    """
+    Set the material's roughness (applies to the \"Oren Nayar\" Diffuse Shader only)
+    @type roughness: float
+    @param roughness: The new value in [0.0, 3.14].
+    """
+
+  def getRoughness():
+    """
+    Get the material's roughness (applies to the \"Oren Nayar\" Diffuse Shader only)
+    @rtype: float
+    """
+
+  def setSpecSize(specSize):
+    """
+    Set the material's size of speculara area (applies to the \"Toon\" Specular Shader only)
+    @type specSize: float
+    @param specSize: The new value in [0.0, 1.53].
+    """
+
+  def getSpecSize():
+    """
+    Get the material's size of speculara area (applies to the \"Toon\" Specular Shader only)
+    @rtype specSize: float
+    """
+
+  def setSpecSize(diffuseSize):
+    """
+    Set the material's size of diffuse area (applies to the \"Toon\" Diffuse Shader only)
+    @type diffuseSize: float
+    @param diffuseSize: The new value in [0.0, 3.14].
+    """
+
+  def getSpecSize():
+    """
+    Get the material's size of diffuse area (applies to the \"Toon\" Diffuse Shader only)
+    @rtype: float
+    """
+
+  def setSpecSmooth(specSmooth):
+    """
+    Set the material's smoothing of specular area (applies to the \"Toon\" Specular Shader only)
+    @type specSmooth: float
+    @param specSmooth: The new value in [0.0, 1.0].
+    """
+
+  def getSpecSmooth():
+    """
+    Get the material's smoothing of specular area (applies to the \"Toon\" Specular Shader only)
+    @rtype: float
+    """
+
+  def setDiffuseSmooth(diffuseSmooth):
+    """
+    Set the material's smoothing of diffuse area (applies to the \"Toon\" Diffuse Shader only)
+    @type diffuseSmooth: float
+    @param diffuseSmooth: The new value in [0.0, 1.0].
+    """
+
+  def getDiffuseSmooth():
+    """
+    Get the material's smoothing of diffuse area (applies to the \"Toon\" Diffuse Shader only)
+    @rtype: float
+    """
+
+  def setDiffuseDarkness(diffuseDarkness):
+    """
+    Set the material's diffuse darkness (applies to the \"Minnaert\" Diffuse Shader only)
+    @type diffuseDarkness: float
+    @param diffuseDarkness: The new value in [0.0, 2.0].
+    """
+
+  def getDiffuseDarkness():
+    """
+    Get the material's diffuse darkness (applies to the \"Minnaert\" Diffuse Shader only)
+    @rtype: float
+    """
+
+  def setRefracIndex(refracIndex):
+    """
+    Set the material's Index of Refraction (applies to the \"Blinn\" Specular Shader only)
+    @type refracIndex: float
+    @param refracIndex: The new value in [1.0, 10.0].
+    """
+
+  def getRefracIndex():
+    """
+    Get the material's Index of Refraction (applies to the \"Blinn\" Specular Shader only)
+    @rtype: float
+    """
+
+  def setRms(rms):
+    """
+    Set the material's standard deviation of surface slope (applies to the \"WardIso\" Specular Shader only)
+    @type rms: float
+    @param rms: The new value in [0.0, 0.4].
+    """
+
+  def getRms():
+    """
+    Get the material's standard deviation of surface slope (applies to the \"WardIso\" Specular Shader only)
+    @rtype: float
+    """
+
+  def setFilter(filter):
+    """
+    Set the material's amount of filtering when transparent raytrace is enabled
+    @type filter: float
+    @param filter: The new value in [0.0, 1.0].
+    """
+
+  def getFilter():
+    """
+    Get the material's amount of filtering when transparent raytrace is enabled
+    @rtype: float
+    """
+
+  def setTranslucency(translucency):
+    """
+    Set the material's amount of diffuse shading of the back side
+    @type translucency: float
+    @param translucency: The new value in [0.0, 1.0].
+    """
+
+  def getTranslucency():
+    """
+    Get the material's amount of diffuse shading of the back side
+    @rtype: float
+    """
+
   def getAdd():
     """
     Get the glow factor.