forked from bartvdbraak/blender
comments on how edge weighting for collapsing works.
uv_auto_layout_tex now uses the recently fixed saveRenderedImage - I needed to make clean and make to get it working.
This commit is contained in:
parent
83105911bf
commit
e47719d253
@ -386,6 +386,16 @@ def redux(ob, REDUX=0.5, BOUNDRY_WEIGHT=2.0, REMOVE_DOUBLES=False, FACE_AREA_WEI
|
||||
try:
|
||||
# can use perim, but area looks better.
|
||||
if FACE_AREA_WEIGHT:
|
||||
# Psudo code for wrighting
|
||||
# angle_diff= The before and after angle difference between the collapsed and un-collapsed face.
|
||||
# ... devide by 180 so the value will be between 0 and 1.0
|
||||
# ... add 1 so we can use it as a multiplyer and not make the area have no eefect (below)
|
||||
# area_weight= The faces original area * the area weight
|
||||
# ... add 1.0 so a small area face dosent make the angle_diff have no effect.
|
||||
#
|
||||
# Now multiply - (angle_diff * area_weight)
|
||||
# ... The weight will be a minimum of 1.0 - we need to subtract this so more faces done give the collapse an uneven weighting.
|
||||
|
||||
angle_diff+= ((1+(Ang(cfa.normal, new_nos[ii])/180)) * (1+(cfa.area * FACE_AREA_WEIGHT))) -1 # 4 is how much to influence area
|
||||
else:
|
||||
angle_diff+= (Ang(cfa.normal), new_nos[ii])/180
|
||||
|
@ -159,24 +159,19 @@ def auto_layout_tex(mesh_list, scn, PREF_IMAGE_PATH, PREF_IMAGE_SIZE, PREF_KEEP_
|
||||
|
||||
|
||||
# Set the render context
|
||||
render_context= render_scn.getRenderingContext()
|
||||
render_context.currentFrame(1)
|
||||
PREF_IMAGE_PATH_EXPAND= B.sys.expandpath(PREF_IMAGE_PATH + '#') + '.png'
|
||||
|
||||
PREF_IMAGE_PATH_EXPAND= B.sys.expandpath(PREF_IMAGE_PATH) + '.png'
|
||||
|
||||
# TEST THE FILE WRITING.
|
||||
try:
|
||||
# Can we write to this file???
|
||||
f= open(PREF_IMAGE_PATH_EXPAND, 'w')
|
||||
f.write('\n')
|
||||
f.close()
|
||||
except:
|
||||
B.Draw.PupMenu('Error: Could not write to path|' + PREF_IMAGE_PATH_EXPAND)
|
||||
scn.makeCurrent()
|
||||
B.Scene.Unlink(render_scn)
|
||||
return
|
||||
|
||||
render_context.setRenderPath(PREF_IMAGE_PATH)
|
||||
|
||||
render_context= render_scn.getRenderingContext()
|
||||
render_context.imageSizeX(PREF_IMAGE_SIZE)
|
||||
render_context.imageSizeY(PREF_IMAGE_SIZE)
|
||||
render_context.startFrame(1)
|
||||
@ -275,16 +270,15 @@ def auto_layout_tex(mesh_list, scn, PREF_IMAGE_PATH, PREF_IMAGE_SIZE, PREF_KEEP_
|
||||
for c in target_face.col:
|
||||
c.r= c.g= c.b= 255
|
||||
|
||||
#render_context.render()
|
||||
#render_context.saveRenderedImage('/test.png') # BROKEN.
|
||||
render_context.renderAnim()
|
||||
render_context.render()
|
||||
render_context.saveRenderedImage(PREF_IMAGE_PATH_EXPAND)
|
||||
|
||||
#if not B.sys.exists(PREF_IMAGE_PATH):
|
||||
# raise 'Error!!!'
|
||||
Render.CloseRenderWindow()
|
||||
|
||||
# NOW APPLY THE SAVED IMAGE TO THE FACES!
|
||||
print PREF_IMAGE_PATH_EXPAND
|
||||
#print PREF_IMAGE_PATH_EXPAND
|
||||
target_image= B.Image.Load(PREF_IMAGE_PATH_EXPAND)
|
||||
|
||||
# Set to the 1 image.
|
||||
|
Loading…
Reference in New Issue
Block a user