Make it work with blender 2.37
authorAntonio Ospite <ospite@studenti.unina.it>
Wed, 22 Mar 2006 17:25:16 +0000 (18:25 +0100)
committerAntonio Ospite <ospite@studenti.unina.it>
Wed, 23 Sep 2009 20:21:09 +0000 (22:21 +0200)
Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
vrm.py [changed mode: 0644->0755]

diff --git a/vrm.py b/vrm.py
old mode 100644 (file)
new mode 100755 (executable)
index 380a65b..bbff105
--- a/vrm.py
+++ b/vrm.py
@@ -2,7 +2,7 @@
 
 """
 Name: 'VRM'
 
 """
 Name: 'VRM'
-Blender: 228
+Blender: 237
 Group: 'Export'
 Tooltip: 'Vector Rendering Method Export Script'
 """
 Group: 'Export'
 Tooltip: 'Vector Rendering Method Export Script'
 """
@@ -12,12 +12,14 @@ import Blender
 from Blender import Scene, Object, Lamp, Camera
 from math import *
 from Blender.Window import *
 from Blender import Scene, Object, Lamp, Camera
 from math import *
 from Blender.Window import *
+from Blender.Scene import Render
    
 def init():
 
     print "Init\n"
 
    
 def init():
 
     print "Init\n"
 
-    renderDir = scena.getRenderdir()
+    renderDir = context.getRenderPath()
+    
 
 # distance from camera Z'
 def Distance(PX,PY,PZ):
 
 # distance from camera Z'
 def Distance(PX,PY,PZ):
@@ -57,7 +59,7 @@ def flatern(vertx, verty, vertz):
 
     camTyp = cam[0].getType()
 
 
     camTyp = cam[0].getType()
 
-    msize = scena.getWinSize()
+    msize = (context.imageSizeX(), context.imageSizeY())
     xres = msize[0]             # X res for output
     yres = msize[1]                # Y res for output
     ratio = xres/yres
     xres = msize[0]             # X res for output
     yres = msize[1]                # Y res for output
     ratio = xres/yres
@@ -87,14 +89,19 @@ def writesvg(ob):
 ########
 
 scena = Scene.GetCurrent()
 ########
 
 scena = Scene.GetCurrent()
+context = scena.getRenderingContext()
+
+#print dir(context)
+
 init()
 
 tacka = [0,0,0]
 lice = [3,tacka,tacka,tacka,tacka]
 
 init()
 
 tacka = [0,0,0]
 lice = [3,tacka,tacka,tacka,tacka]
 
-msize = scena.getWinSize()
+msize = (context.imageSizeX(), context.imageSizeY())
+print msize
 
 
-file=open("d:\proba.svg","w")
+file=open("proba.svg","w")
 
 file.write("<svg width=\"" + `msize[0]` + "\" height=\"" + `msize[1]` + "\"\n")
 file.write("xmlns=\"http://www.w3.org/2000/svg\" version=\"1.2\" streamable=\"true\">\n")
 
 file.write("<svg width=\"" + `msize[0]` + "\" height=\"" + `msize[1]` + "\"\n")
 file.write("xmlns=\"http://www.w3.org/2000/svg\" version=\"1.2\" streamable=\"true\">\n")
@@ -103,15 +110,16 @@ file.write("xmlns=\"http://www.w3.org/2000/svg\" version=\"1.2\" streamable=\"tr
 Objects = Blender.Object.Get()
 NUMobjects = len(Objects)
 
 Objects = Blender.Object.Get()
 NUMobjects = len(Objects)
 
-startFrm = scena.startFrame()
-endFrm = scena.endFrame()
+startFrm = context.startFrame()
+endFrm = startFrm
+#endFrm = context.endFrame()
 camera = scena.getCurrentCamera() # Get the current camera
 
 for f in range(startFrm, endFrm+1):
   #scena.currentFrame(f)
   Blender.Set('curframe', f)
 
 camera = scena.getCurrentCamera() # Get the current camera
 
 for f in range(startFrm, endFrm+1):
   #scena.currentFrame(f)
   Blender.Set('curframe', f)
 
-  DrawProgressBar (f/(endFrm+1-startFrm),"Rendering ..." + str(scena.currentFrame()))
+  DrawProgressBar (f/(endFrm+1-startFrm),"Rendering ..." + str(context.currentFrame()))
 
   print "Frame: ", f, "\n"
   if startFrm <> endFrm: file.write("<g id=\"Frame" + str(f) + "\" style=\"visibility:hidden\">\n")
 
   print "Frame: ", f, "\n"
   if startFrm <> endFrm: file.write("<g id=\"Frame" + str(f) + "\" style=\"visibility:hidden\">\n")
@@ -220,9 +228,6 @@ for f in range(startFrm, endFrm+1):
             # add/sorting in Z' direction
             #Dodaj(px,py,Distance(vertxyz[0], vertxyz[1], vertxyz[2]))
             file.write(`px` + ", " + `py`)
             # add/sorting in Z' direction
             #Dodaj(px,py,Distance(vertxyz[0], vertxyz[1], vertxyz[2]))
             file.write(`px` + ", " + `py`)
-#          svetla = Blender.Lamp.Get()
-#          svetlo = svetla[0]
-#          print svetlo.LocX
           ambient = -200
           svetlo = [1,1,-1]
           vektori = (norm[0]*svetlo[0]+norm[1]*svetlo[1]+norm[2]*svetlo[2])
           ambient = -200
           svetlo = [1,1,-1]
           vektori = (norm[0]*svetlo[0]+norm[1]*svetlo[1]+norm[2]*svetlo[2])
@@ -240,5 +245,6 @@ for f in range(startFrm, endFrm+1):
 #writesvg(objekat)
 file.write("</svg>")
 file.close()
 #writesvg(objekat)
 file.write("</svg>")
 file.close()
+print file
 DrawProgressBar (1.0,"Finished.")
 print "Finished\n"
 DrawProgressBar (1.0,"Finished.")
 print "Finished\n"