forked from bartvdbraak/blender
corrected image doc mistake - image.makeCurrent()
BPyRender.imageFromObjectsOrtho() returns an image Made all image bake scripts ask before overwriting a file. as well as displaying the newly created image once its rendered.
This commit is contained in:
parent
4437c27091
commit
65895ba6bd
@ -83,18 +83,17 @@ def imageFromObjectsOrtho(objects, path, width, height, smooth, alpha= True):
|
||||
#if not B.sys.exists(PREF_IMAGE_PATH_EXPAND):
|
||||
# raise 'Error!!!'
|
||||
|
||||
scn.makeCurrent()
|
||||
Scene.Unlink(render_scn)
|
||||
|
||||
# NOW APPLY THE SAVED IMAGE TO THE FACES!
|
||||
#print PREF_IMAGE_PATH_EXPAND
|
||||
try:
|
||||
target_image= Image.Load(path_expand)
|
||||
return target_image
|
||||
except:
|
||||
raise 'Error: Could not render or load the image at path "%s"' % path_expand
|
||||
return
|
||||
|
||||
scn.makeCurrent()
|
||||
Scene.Unlink(render_scn)
|
||||
|
||||
|
||||
|
||||
|
||||
@ -379,7 +378,7 @@ def vcol2image(me_s,\
|
||||
|
||||
|
||||
|
||||
im= imageFromObjectsOrtho(obs, PREF_IMAGE_PATH, PREF_IMAGE_SIZE, PREF_IMAGE_SIZE, PREF_IMAGE_SMOOTH)
|
||||
image= imageFromObjectsOrtho(obs, PREF_IMAGE_PATH, PREF_IMAGE_SIZE, PREF_IMAGE_SIZE, PREF_IMAGE_SMOOTH)
|
||||
|
||||
# Clear from memory as best as we can
|
||||
render_me.verts= None
|
||||
@ -395,3 +394,4 @@ def vcol2image(me_s,\
|
||||
if not tex_unique_materials_shadeless[i]:
|
||||
mat.mode &= ~Blender.Material.Modes.SHADELESS
|
||||
|
||||
return image
|
||||
|
@ -75,7 +75,12 @@ def main():
|
||||
PREF_USE_TEXTURE= False
|
||||
|
||||
def file_sel(PREF_IMAGE_PATH):
|
||||
BPyRender.vcol2image(me_s,\
|
||||
|
||||
if not (BPyMessages.Warning_SaveOver(PREF_IMAGE_PATH) and \
|
||||
BPyMessages.Warning_SaveOver(PREF_IMAGE_PATH+'.png')):
|
||||
return
|
||||
|
||||
image = BPyRender.vcol2image(me_s,\
|
||||
PREF_IMAGE_PATH,\
|
||||
PREF_IMAGE_SIZE.val,\
|
||||
PREF_IMAGE_BLEED.val,\
|
||||
@ -90,6 +95,9 @@ def main():
|
||||
PREF_USE_TEXTURE,\
|
||||
PREF_SEL_FACES_ONLY.val)
|
||||
|
||||
if image:
|
||||
image.makeCurrent()
|
||||
|
||||
Blender.Window.RedrawAll()
|
||||
|
||||
Blender.Window.FileSelector(file_sel, 'SAVE PNG', newpath)
|
||||
|
@ -91,7 +91,12 @@ def main():
|
||||
|
||||
PREF_USE_NORMAL= True # of course we need this one
|
||||
def file_sel(PREF_IMAGE_PATH):
|
||||
BPyRender.vcol2image(me_s,\
|
||||
|
||||
if not (BPyMessages.Warning_SaveOver(PREF_IMAGE_PATH) and \
|
||||
BPyMessages.Warning_SaveOver(PREF_IMAGE_PATH+'.png')):
|
||||
return
|
||||
|
||||
image = BPyRender.vcol2image(me_s,\
|
||||
PREF_IMAGE_PATH,\
|
||||
PREF_IMAGE_SIZE.val,\
|
||||
PREF_IMAGE_BLEED.val,\
|
||||
@ -109,7 +114,10 @@ def main():
|
||||
# Restore normals
|
||||
for me in me_s:
|
||||
me.update()
|
||||
|
||||
|
||||
if image:
|
||||
image.makeCurrent()
|
||||
|
||||
Blender.Window.RedrawAll()
|
||||
|
||||
Blender.Window.FileSelector(file_sel, 'SAVE PNG', newpath)
|
||||
|
@ -74,7 +74,12 @@ def main():
|
||||
PREF_USE_TEXTURE= True # of course we need this one
|
||||
|
||||
def file_sel(PREF_IMAGE_PATH):
|
||||
BPyRender.vcol2image(me_s,\
|
||||
|
||||
if not (BPyMessages.Warning_SaveOver(PREF_IMAGE_PATH) and \
|
||||
BPyMessages.Warning_SaveOver(PREF_IMAGE_PATH+'.png')):
|
||||
return
|
||||
|
||||
image = BPyRender.vcol2image(me_s,\
|
||||
PREF_IMAGE_PATH,\
|
||||
PREF_IMAGE_SIZE.val,\
|
||||
PREF_IMAGE_BLEED.val,\
|
||||
@ -89,6 +94,9 @@ def main():
|
||||
PREF_USE_TEXTURE,\
|
||||
PREF_SEL_FACES_ONLY.val)
|
||||
|
||||
if image:
|
||||
image.makeCurrent()
|
||||
|
||||
Blender.Window.RedrawAll()
|
||||
|
||||
Blender.Window.FileSelector(file_sel, 'SAVE PNG', newpath)
|
||||
|
@ -21,7 +21,7 @@ LSCM Unwrapper or archimap unwrapper work well to automaticaly do this.
|
||||
|
||||
import Blender
|
||||
import BPyRender
|
||||
# reload(BPyRender)
|
||||
reload(BPyRender)
|
||||
import BPyMessages
|
||||
Vector= Blender.Mathutils.Vector
|
||||
Create= Blender.Draw.Create
|
||||
@ -73,6 +73,12 @@ def main():
|
||||
PREF_USE_TEXTURE= False
|
||||
|
||||
def file_sel(PREF_IMAGE_PATH):
|
||||
|
||||
if not (BPyMessages.Warning_SaveOver(PREF_IMAGE_PATH) and \
|
||||
BPyMessages.Warning_SaveOver(PREF_IMAGE_PATH+'.png')):
|
||||
return
|
||||
|
||||
image=\
|
||||
BPyRender.vcol2image(me_s,\
|
||||
PREF_IMAGE_PATH,\
|
||||
PREF_IMAGE_SIZE.val,\
|
||||
@ -88,6 +94,9 @@ def main():
|
||||
PREF_USE_TEXTURE,\
|
||||
PREF_SEL_FACES_ONLY.val)
|
||||
|
||||
if image:
|
||||
image.makeCurrent()
|
||||
|
||||
Blender.Window.RedrawAll()
|
||||
|
||||
Blender.Window.FileSelector(file_sel, 'SAVE PNG', newpath)
|
||||
|
@ -78,7 +78,12 @@ def main():
|
||||
PREF_USE_TEXTURE= False
|
||||
|
||||
def file_sel(PREF_IMAGE_PATH):
|
||||
BPyRender.vcol2image(me_s,\
|
||||
|
||||
if not (BPyMessages.Warning_SaveOver(PREF_IMAGE_PATH) and \
|
||||
BPyMessages.Warning_SaveOver(PREF_IMAGE_PATH+'.png')):
|
||||
return
|
||||
|
||||
image = BPyRender.vcol2image(me_s,\
|
||||
PREF_IMAGE_PATH,\
|
||||
PREF_IMAGE_SIZE.val,\
|
||||
PREF_IMAGE_BLEED,\
|
||||
@ -93,6 +98,9 @@ def main():
|
||||
PREF_USE_TEXTURE,\
|
||||
PREF_SEL_FACES_ONLY.val)
|
||||
|
||||
if image:
|
||||
image.makeCurrent()
|
||||
|
||||
Blender.Window.RedrawAll()
|
||||
|
||||
Blender.Window.FileSelector(file_sel, 'SAVE PNG', newpath)
|
||||
|
@ -327,12 +327,10 @@ class Image:
|
||||
@rtype: none
|
||||
@type mode: int
|
||||
"""
|
||||
def SetCurrent (image):
|
||||
def makeCurrent():
|
||||
"""
|
||||
Set the currently displayed Image from Blenders UV/Image window.
|
||||
When multiple images are displayed, the last active UV/Image windows image is used.
|
||||
@type image: Blender Image
|
||||
@param image: The image to display in the image view.
|
||||
@rtype: bool
|
||||
@return: True if the current image could be set, if no window was available, return False.
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user