Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2008-03-29 17:50:05 +0300
committerCampbell Barton <ideasman42@gmail.com>2008-03-29 17:50:05 +0300
commit8960f536763453ec6b40401c1ab22880e180b742 (patch)
tree0bf954845d654f0b79d6897f5791e7a1df6535aa /release
parent3ac7a415f75da6f55b70c49f8677a2598c80b09b (diff)
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)
Diffstat (limited to 'release')
-rw-r--r--release/scripts/bpymodules/BPyRender.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/release/scripts/bpymodules/BPyRender.py b/release/scripts/bpymodules/BPyRender.py
index 5307439f1d6..6f9c9997933 100644
--- a/release/scripts/bpymodules/BPyRender.py
+++ b/release/scripts/bpymodules/BPyRender.py
@@ -496,7 +496,7 @@ def vcol2image(me_s,\
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 @@ def bakeToPlane(sce, ob_from, width, height, bakemodes, axis='z', margin=0):
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 @@ def bakeToPlane(sce, ob_from, width, height, bakemodes, axis='z', margin=0):
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 @@ def bakeToPlane(sce, ob_from, width, height, bakemodes, axis='z', margin=0):
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 @@ def bakeToPlane(sce, ob_from, width, height, bakemodes, axis='z', margin=0):
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 @@ def bakeToPlane(sce, ob_from, width, height, bakemodes, axis='z', margin=0):
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,6 +618,8 @@ def bakeToPlane(sce, ob_from, width, height, bakemodes, axis='z', margin=0):
rend.bakeClear = BACKUP_bakeClear
rend.bakeMargin = BACKUP_bakeMargin
rend.bakeToActive = BACKUP_bakeToActive
+ rend.bakeNormalize = BACKUP_bakeNormalize
+
# Restore obsel
sce.objects.selected = BACKUP_obsel