[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14278] trunk/blender: some fixes for python baking function
Campbell Barton
ideasman42 at gmail.com
Sat Mar 29 15:50:05 CET 2008
Revision: 14278
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14278
Author: campbellbarton
Date: 2008-03-29 15:50:05 +0100 (Sat, 29 Mar 2008)
Log Message:
-----------
some fixes for python baking function
needed to add a small value to the baking distance for it to include faces of that distance (maybe should make this happen from the user interface too)
Modified Paths:
--------------
trunk/blender/release/scripts/bpymodules/BPyRender.py
trunk/blender/source/blender/python/api2_2x/doc/Render.py
trunk/blender/source/blender/python/api2_2x/sceneRender.c
Modified: trunk/blender/release/scripts/bpymodules/BPyRender.py
===================================================================
--- trunk/blender/release/scripts/bpymodules/BPyRender.py 2008-03-29 10:31:56 UTC (rev 14277)
+++ trunk/blender/release/scripts/bpymodules/BPyRender.py 2008-03-29 14:50:05 UTC (rev 14278)
@@ -496,7 +496,7 @@
return image
-def bakeToPlane(sce, ob_from, width, height, bakemodes, axis='z', margin=0):
+def bakeToPlane(sce, ob_from, width, height, bakemodes, axis='z', margin=0, depth=32):
'''
Bakes terrain onto a plane from one object
sce - scene to bake with
@@ -505,7 +505,7 @@
bakemodes - list of baking modes to use, Blender.Scene.Render.BakeModes.NORMALS, Blender.Scene.Render.BakeModes.AO ... etc
axis - axis to allign the plane to.
margin - margin setting for baking.
-
+ depth - bit depth for the images to bake into, (32 or 128 for floating point images)
Example:
import Blender
from Blender import *
@@ -523,6 +523,7 @@
BACKUP_bakeClear = rend.bakeClear
BACKUP_bakeMargin = rend.bakeMargin
BACKUP_bakeToActive = rend.bakeToActive
+ BACKUP_bakeNormalize = rend.bakeNormalize
# Backup object selection
BACKUP_obsel = list(sce.objects.selected)
@@ -532,6 +533,7 @@
rend.bakeClear = True
rend.bakeMargin = margin
rend.bakeToActive = True
+ rend.bakeNormalize = True
# Assume a mesh
me_from = ob_from.getData(mesh=1)
@@ -554,28 +556,28 @@
xmin = min(xmin, x)
ymin = min(ymin, y)
zmin = min(zmin, z)
-
+
if axis=='x':
xmed = (xmin+xmax)/2.0
co1 = (xmed, ymin, zmin)
co2 = (xmed, ymin, zmax)
co3 = (xmed, ymax, zmax)
co4 = (xmed, ymax, zmin)
- rend.bakeDist = (xmax-xmin)/2.0
+ rend.bakeDist = ((xmax-xmin)/2.0) + 0.000001 # we need a euler value for this since it
elif axis=='y':
ymed = (ymin+ymax)/2.0
co1 = (xmin, ymed, zmin)
co2 = (xmin, ymed, zmax)
co3 = (xmax, ymed, zmax)
co4 = (xmax, ymed, zmin)
- rend.bakeDist = (ymax-ymin)/2.0
+ rend.bakeDist = ((ymax-ymin)/2.0) + 0.000001
elif axis=='z':
zmed = (zmin+zmax)/2.0
co1 = (xmin, ymin, zmed)
co2 = (xmin, ymax, zmed)
co3 = (xmax, ymax, zmed)
co4 = (xmax, ymin, zmed)
- rend.bakeDist = (zmax-zmin)/2.0
+ rend.bakeDist = ((zmax-zmin)/2.0) + 0.000001
else:
raise "invalid axis"
me_plane = Blender.Mesh.New()
@@ -601,7 +603,7 @@
images_return = []
for mode in bakemodes:
- img = Blender.Image.New('bake', width, height, 24)
+ img = Blender.Image.New('bake', width, height, depth)
me_plane_face.image = img
rend.bakeMode = mode
@@ -616,7 +618,9 @@
rend.bakeClear = BACKUP_bakeClear
rend.bakeMargin = BACKUP_bakeMargin
rend.bakeToActive = BACKUP_bakeToActive
+ rend.bakeNormalize = BACKUP_bakeNormalize
+
# Restore obsel
sce.objects.selected = BACKUP_obsel
sce.objects.active = BACKUP_obact
Modified: trunk/blender/source/blender/python/api2_2x/doc/Render.py
===================================================================
--- trunk/blender/source/blender/python/api2_2x/doc/Render.py 2008-03-29 10:31:56 UTC (rev 14277)
+++ trunk/blender/source/blender/python/api2_2x/doc/Render.py 2008-03-29 14:50:05 UTC (rev 14278)
@@ -391,8 +391,8 @@
@type bakeClear: bool
@ivar bakeToActive: When enabled, selected objects are baked onto the active object.
@type bakeToActive: bool
- @ivar bakeNormalizeAO: Normalize AO bake values.
- @type bakeNormalizeAO: bool
+ @ivar bakeNormalize: Normalize AO and displacement to the range of the distance value.
+ @type bakeNormalize: bool
@ivar bakeMargin: The pixel distance to extend baked pixels past the boundry (reduces bleeding when mipmapping)
@type bakeMargin: int
@ivar bakeDist: The distance in blender units to use when bakeToActive is enabled and geomtry does not overlap.
Modified: trunk/blender/source/blender/python/api2_2x/sceneRender.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/sceneRender.c 2008-03-29 10:31:56 UTC (rev 14277)
+++ trunk/blender/source/blender/python/api2_2x/sceneRender.c 2008-03-29 14:50:05 UTC (rev 14278)
@@ -2881,9 +2881,9 @@
(getter)RenderData_getBakeMode, (setter)RenderData_setBakeMode,
"Bake selection to active",
(void *)R_BAKE_TO_ACTIVE},
- {"bakeNormalizeAO",
+ {"bakeNormalize",
(getter)RenderData_getBakeMode, (setter)RenderData_setBakeMode,
- "Bake selection to active",
+ "Normalize AO and displacement to the dist range",
(void *)R_BAKE_NORMALIZE},
{"bakeMargin",
(getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
More information about the Bf-blender-cvs
mailing list