# Copyright (c) 2010 www.rendering3d.net (GPL license) # author Silvio Falcinelli 2010 # silvio.falcinelli@rendering3d.net # # # experimet Yafaray integration in Blender 2.5 alpha2 # # version 0.2.1a 17-04-2010 # # know serius bug: # # matrix mesh with modiefier crash # because (bpy.types.RenderEngine) API problem ??? # the same code export in (bpy.types.Operator) no crash # # # (for some part from 'engine_render_pov.py' in Blender 2.5 aplha same problem bpy.types.RenderEngine) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # ################################################################################ import bpy from math import atan, pi, degrees import subprocess import os import sys import time import platform as pltfrm import Mathutils from rna_prop_ui import PropertyPanel from bpy.props import * import space_userpref import bgl import blf import platform import shutil updatemsg=() yafarayxmlVer='' yafarayVer ='' infoSystem ='' yafarayToBlender=True scene = bpy.context.scene #### inizialize def yaf_init(): global yafarayxmlVer , yafarayVer , infoSystem yafarayVer='' if platform.system()=='Linux': os.system('yafaray-xml -v > ver.txt') if platform.system()=='Windows': ### Find Where is Yafaray in microsoft os and choose the better Yafaray 64 bit if existing import winreg ### win xp 32 bit try: regKey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, 'Software\\YafRay Team\\YafaRay') except: () ### win server 32 bit try: regKey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\YafRay Team\\YafaRay') except: () ### win xp 64 bit try: regKey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, 'Software\\Wow6432Node\\YafRay Team\\YafaRay') except: () ### win server 64 bit try: regKey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Wow6432Node\\YafRay Team\\YafaRay') except: () yafaraypath = winreg.QueryValueEx(regKey, 'InstallDir')[0] + '\\' pid=os.system('"%syafaray-xml\" -ver > ver.txt' % yafaraypath ) try: f=open('ver.txt', 'r') yafarayVer = f.readline() yafarayxmlVer = f.readline() yafarayVer = f.readline() f.close() yafarayVer = yafarayVer.replace('\n','') yafarayxmlVer = yafarayxmlVer.replace('\n','') print(yafarayxmlVer) print(yafarayVer) except: yafarayVer = 'Yafaray engine not found' yafarayxmlVer = 'Yafaray-xml not found' infoSystem =('System: %s %s Cpus: %s' % (platform.system(),(platform.architecture()[0]),cpuCount())) return yafaraypath ############### def yaf_to_blender(): global yafarayToBlender yafarayToBlender=False scene=bpy.data.scenes[0] if scene.yaf_cam_type1==False and scene.yaf_cam_type2==False and scene.yaf_cam_type3==False and scene.yaf_cam_type4 == False: scene.yaf_cam_type1 = True rd = scene.render rd.display_mode = 'WINDOW' if(scene.get("YafRay")): if not (scene.get('YafRay').get('switch')): YR=scene.get('YafRay').get('Renderer') yaf_engine = YR.get('lightType') #print(yaf_engine) #if yaf_engine == 'Direct lighting': scene.yaf_PM_enable=False scene.yaf_PT_enable=False scene.yaf_AO_enable=False scene.yaf_SKY_enable=False rd.antialiasing=True if yaf_engine == 'Photon mapping' : scene.yaf_PM_enable=True scene.yaf_gamma =(YR.get('gamma')) scene.yaf_raydepth=YR.get('raydepth') scene.yaf_shadowdepth=YR.get('shadowDepth') scene.yaf_transp_shadows= YR.get('transpShad') if YR.get('caustics'): scene.UseCaustics=True else:scene.UseCaustics=False scene.yaf_PM_photons=YR.get('photons') scene.yaf_PT_photons=YR.get('photons') scene.yaf_AO_caus_mix=YR.get('caustic_mix') scene.yaf_PT_caus_mix=YR.get('caustic_mix') scene.yaf_PM_caus_mix=YR.get('caustic_mix') scene.yaf_AO_caus_radius = (YR.get('caustic_radius')) scene.yaf_AO_caus_depth = int(YR.get('caustic_depth')) scene.yaf_PT_caus_depth = int(YR.get('caustic_depth')) #YR.get('do_AO') scene.yaf_ao_samples = int(YR.get('AO_samples')) scene.yaf_AO_distance_calc= int(YR.get('AO_distance')) scene.world.ambient_color = tuple(YR.get('AO_color')) if YR.get('photonmapping'): scene.UsePhoton = True else: scene.UsePhoton = False scene.yaf_PT_samples=int(YR.get('fg_samples')) scene.yaf_PM_caus_radius=(YR.get('diffuseRadius')) scene.yaf_PM_caus_search=(YR.get('search')) #YR.get('show_map') scene.yaf_PM_bounces=int(YR.get('fg_bounces')) if YR.get('finalGather'): scene.FinalGather=True else: scene.FinalGather=False scene.yaf_PT_depth=(YR.get('bounces')) scene.yaf_PM_depth=(YR.get('bounces')) scene.UseBGPT=YR.get('use_background') scene.UseBG=YR.get('use_background') # print (YR.get('stepSize')) # print (YR.get('adaptive')) # print (YR.get('optimize')) # print (YR.get('dsturbidity')) # print (YR.get('sigma_t')) scene.AA_passes = YR.get('AA_passes') scene.AA_inc_samples =YR.get('AA_inc_samples') scene.AA_minsamples = YR.get('AA_minsamples') rd.filter_size= YR.get('AA_pixelwidth') try: rd.pixel_filter=(str.upper(YR.get('filter_type'))) except:() scene.yaf_threshold=YR.get('AA_threshold') # print(YR.get('world_background')) # print (YR.get('alpha')) def yaf_obj_to_blender(): for mat in bpy.data.materials: matYaf = mat.get("YafRay") if matYaf: Type =matYaf.get("type") IOR =matYaf.get("IOR") diffuse_reflect =matYaf.get("diffuse_reflect") emit =matYaf.get("emit") specular_reflect =matYaf.get("specular_reflect") translucency =matYaf.get("translucency") transmit_filter =matYaf.get("transmit_filter") transparency =matYaf.get("transparency") color =matYaf.get("color") diffuse_reflect =matYaf.get("diffuse_reflect") exp_u =matYaf.get("exp_u") exp_v =matYaf.get("exp_v") exponent =matYaf.get("exponent") transmit_filter =matYaf.get("transmit_filter") dispersion_power =matYaf.get("dispersion_power") Iabsorption_dist =matYaf.get("Iabsorption_dist") glossy_reflect =matYaf.get("glossy_reflect") diffuse_color =matYaf.get("diffuse_color") fresnel_effect =matYaf.get("fresnel_effect") #bool fake_shadows =matYaf.get("fake_shadows") #bool as_diffuse =matYaf.get("as_diffuse") #bool anisotropic =matYaf.get("anisotropic") #bool mirror_color =matYaf.get("mirror_color") #col if Type == 'glass': transparency = 5 if transparency > 0.001: mat.transparency_method = 'RAYTRACE' mat.transparency = True transparency = transparency * 4.00 mat.raytrace_transparency.fresnel = transparency mat.raytrace_transparency.fresnel_factor = transparency mat.raytrace_transparency.ior = IOR else: mat.transparency = False if glossy_reflect > 0.001 or specular_reflect > 0.001: mat.raytrace_mirror.enabled = True mat.raytrace_mirror.reflect_factor = glossy_reflect mat.diffuse_color = tuple(diffuse_color ) mat.specular_color = tuple(mirror_color ) mat.mirror_color = tuple(mirror_color ) mat.raytrace_mirror.gloss_factor = exponent / 2000 mat.translucency = translucency mat.raytrace_transparency.filter = transmit_filter mat.emit = emit #mat.subsurface_scattering.scale = Iabsorption_dist mat.specular_intensity = exponent /2000 ############### MTL_DICT = {} def yaf_exportOBJ(file, objects, scene, YafMode): import math def veckey2d(v): return round(v[0], 6), round(v[1], 6) temp_mesh_name = '~tmp-mesh' time1 = time.clock() totverts = totuvco = totno = 1 face_vert_index = 1 globalNormals = {} # Get all meshes for obj in objects: if obj.restrict_render or obj.layers[0] < 1: continue #for layer in obj.layers: #if layer in activelayers: print(obj.layers) # ignore dupli children if obj.parent and obj.parent.dupli_type != 'NONE': print(obj.name, 'is a dupli child - ignoring') continue obs = [] if obj.dupli_type != 'NONE': obj.create_dupli_list() obs = [(dob.object, dob.matrix) for dob in obj.dupli_list] else: obs = [(obj, obj.matrix)] for ob, ob_mat in obs: if ob.type != 'MESH': continue mesh = ob.create_mesh(True, 'RENDER') mesh.transform(ob_mat) Ymeshlight=False objY=obj.get("YafRay") if objY: if objY.get('meshlight'): Ymeshlight=True if obj.name.startswith('MeshLight') or obj.name.startswith('meshlight') or YafMode and Ymeshlight : mat_name = 'ML_%s' % obj.name if objY: mat_diffuse_color = objY.get('color') mat_emit = objY.get('power') mat_ds = objY.get('double_sided') else: mat_diffuse_color = obj.data.materials[0].diffuse_color if mat_emit < 0.01 : mat_emit = 0.01 mat_emit = obj.data.materials[0].emit * 100 mat_ds=str.lower(str(obj.data.double_sided)) file.write('\n' % obj.name) file.write('\t\n' % (mat_diffuse_color[0],mat_diffuse_color[1],mat_diffuse_color[2])) file.write('\t\n' % mat_ds) file.write('\t\n' % objCnt) file.write('\t\n' % mat_emit) file.write('\t\n' % scene.yaf_meshlight_samples) file.write('\t\n') file.write('\n\n') file.write('\n' % mat_name) file.write('\t\n' % (mat_diffuse_color[0],mat_diffuse_color[1],mat_diffuse_color[2])) file.write('\t\n' % mat_ds) file.write('\t\n' % mat_emit) file.write('\t\n') file.write('\n\n') file.write('' % ((len(mesh.verts)) , len(mesh.faces) )) for v in mesh.verts: file.write('\n\t\t

' % tuple(v.co)) file.write('\n\t\t' % mat_name ) faces_verts = [f.verts for f in mesh.faces] for fi, f in enumerate(mesh.faces): fv = faces_verts[fi] if len(fv) == 4: indicies = (0, 1, 2), (2, 3, 0) else: indicies = ((0, 1, 2),) for i1, i2, i3 in indicies: file.write('\n\t\t' % (fv[i1], fv[i2], fv[i3])) file.write('\n\n') continue else: pass try: uvL = mesh.active_uv_texture.data hasUV = True except: uvL = None hasUV = False hasOrco=False file.write('' % ((len(mesh.verts)) , len(mesh.faces), str.lower(str(hasOrco)), str.lower(str(hasUV)) )) #uv_layer ind = 0 for v in mesh.verts: file.write('\n\t\t

') else: file.write(' ox=\"%.7f\" oy=\"%.7f\" oz=\"%.7f\"/>' % (v.co[0],v.co[1],v.co[2])) mi='' cMt='' Id=0 faces_verts = [f.verts for f in mesh.faces] if uvL: for f in mesh.faces: try: mi = (mesh.materials[f.material_index].name) except: if cMt == '': cMt='defaultMat' v = faces_verts[f.index] uv=uvL[f.index].uv file.write('\n\t\t' % (uv[0][0], uv[0][1])) file.write('\n\t\t' % (uv[1][0], uv[1][1])) file.write('\n\t\t' % (uv[2][0], uv[2][1])) if mi != cMt: file.write('\n\t\t' % mi) file.write('\n\t\t' % (Id,(Id+1),(Id+2))) if len(v) == 4: if uvL: file.write('\n\t\t' % (uv[3][0], uv[3][1])) #if mi != cMt: file.write('\n\t\t' % mi) file.write('\n\t\t' % (Id+2,(Id+3),(Id))) Id += 1 Id += 3 cMt=mi else: for fi, f in enumerate(mesh.faces): #print(cMt, mi) try: mi = (mesh.materials[f.material_index].name) except: if cMt == '': cMt='defaultMat' fv = faces_verts[fi] if len(fv) == 4: indicies = (0, 1, 2), (2, 3, 0) else: indicies = ((0, 1, 2),) if mi != cMt: if mi == '': file.write('\n\t\t') else: file.write('\n\t\t' % mi) for i1, i2, i3 in indicies: file.write('\n\t\t' % (fv[i1], fv[i2], fv[i3])) cMt=mi file.write('\n\n') smoothMesh = 35 file.write('\n' % smoothMesh) bpy.data.meshes.remove(mesh) if obj.dupli_type != 'NONE': obj.free_dupli_list() file.write('\n\nEND file \n\n') ############### class DataButtonsPanel(bpy.types.Panel): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "modifier" if pltfrm.architecture()[0] == '64bit': bitness = 64 else: bitness = 32 def soundalert(): import os try: windir = os.getenv("windir") pid=os.system('%s\\system32\\SNDREC32 /play /close /embedding %s\\MEDIA\\NOTIFY.WAV\n' % (windir,windir)) except: () try: pid=os.system('play /usr/share/sounds/ubuntu/stereo/service-login.ogg') except: () def cpuCount(): import sys import os if sys.platform == 'win32': try: num = int(os.environ['NUMBER_OF_PROCESSORS']) except (ValueError, KeyError): pass elif sys.platform == 'darwin': try: num = int(os.popen('sysctl -n hw.ncpu').read()) except ValueError: pass else: try: num = os.sysconf('SC_NPROCESSORS_ONLN') except (ValueError, OSError, AttributeError): pass if num >= 1: return num else: raise NotImplementedError def noise2string(ntype): if ntype == 'BLENDER': return "blender" elif ntype == 'PERLIN': return "stdperlin" elif ntype == 'IMPROVEDPERLIN': return "newperlin" elif ntype == 'VORONOI_F1': return "voronoi_f1" elif ntype == 'VORONOI_F2': return "voronoi_f2" elif ntype == 'VORONOI_F3': return "voronoi_f3" elif ntype == 'VORONOI_F4': return "voronoi_f4" elif ntype == 'VORONOI_F2_F1': return "voronoi_f2f1" elif ntype == 'VORONOICRACKLE': return "voronoi_crackle" elif ntype == 'CELLNOISE': return "cellnoise" return "newperlin" def poceduralTextures(tex,name,gamma,file): file.write('\n' % name) if tex.type=='CLOUDS' or tex.type=='MARBLE' or tex.type=='WOOD' or tex.type=='MUSGRAVE' or tex.type=='VONOROI' or tex.type=='DISTORCED_NOISE': nsz = tex.noise_size if nsz > 0: nsz = 1.0/nsz hard = 'false' try: if tex.noise_type == "hard": hard = 'true' except: () file.write('\t\n' % gamma) if tex.type == 'CLOUDS': file.write('\t\n') file.write('\t\n' % nsz) file.write('\t\n' % hard) file.write('\t\n' % tex.noise_depth) file.write('\t\n' % noise2string(tex.noise_basis)) elif tex.type == 'WOOD': file.write('\t\n') file.write('\t\n' % 0) turb = 0.0 if tex.stype == 'RINGNOISE': turb = tex.turbulence file.write('\t\n' % turb) file.write('\t\n' % nsz) file.write('\t\n' % hard) ts = "bands" if tex.stype == 'WOD_RINGS' or tex.stype == 'WOD_RINGNOISE': ts = "rings" file.write('\t\n' % ts ) file.write('\t\n' % noise2string(tex.noise_basis)) ts = "sin" if tex.noisebasis2=='SAW': ts="saw" elif tex.noisebasis2=='TRI': ts="tri" file.write('\t\n' % ts ) elif tex.type == 'MARBLE': file.write('\t\n') file.write('\t\n' % tex.noise_depth) file.write('\t\n' % tex.turbulence) file.write('\t\n' % nsz) file.write('\t\n' % hard) file.write('\t\n' % tex.stype) file.write('\t\n' % noise2string(tex.noise_basis)) ts = "sin" #print(tex.noisebasis2) if tex.noisebasis2=='SAW': ts="saw" elif tex.noisebasis2=='TRI': ts="tri" file.write('\t\n' % ts) elif tex.type == 'VORONOI': file.write('\t\n') ts = "int" if tex.coloring == 'POSITION': ts = "col1" elif tex.coloring == 'POSITION_OUTLINE': ts = "col2" elif tex.coloring == 'POSITION_OUTLINE_INTENSITY': ts = "col3" ##???? different color on blender 2.5 file.write('\t\n' % ts) file.write('\t\n' % tex.weight_1) file.write('\t\n' % tex.weight_2) file.write('\t\n' % tex.weight_3) file.write('\t\n' % tex.weight_4) file.write('\t\n' % tex.noise_intensity) file.write('\t\n' % tex.noise_size) file.write('\t\n' % nsz) ts = "actual" if tex.distance_metric == 'DISTANCE_SQUARED':ts = "squared" elif tex.distance_metric == 'MANHATTAN': ts = "manhattan" elif tex.distance_metric == 'CHEBYCHEV': ts = "chebychev" elif tex.distance_metric == 'MINKOVSKY_HALF': ts = "minkovsky_half" elif tex.distance_metric == 'MINKOVSKY_FOUR': ts = "minkovsky_four" elif tex.distance_metric == 'MINKOVSKY': ts = "minkovsky" file.write('\t\n' % ts) elif tex.type == 'MUSGRAVE': file.write('\t\n') ts = "fBm" if tex.musgrave_type == 'MUS_MFRACTAL': ts = "multifractal" elif tex.musgrave_type == 'MUS_RIDGEDMF': ts = "ridgedmf" elif tex.musgrave_type == 'MUS_HYBRIDMF': ts = "hybridmf" elif tex.musgrave_type == 'MUS_HYBRIDMF': ts = "heteroterrain" file.write('\t\n' % ts) file.write('\t\n' % noise2string(tex.noise_basis)) file.write('\t\n' % tex.highest_dimension) ### ????? file.write('\t\n' % tex.lacunarity) file.write('\t\n' % tex.octaves) file.write('\t\n' % nsz) file.write('\t\n' % tex.highest_dimension) ## ?????? elif tex.type == 'DISTORTED_NOISE': file.write('\t\n') file.write('\t\n' % tex.distortion) file.write('\t\n' % nsz) file.write('\t\n' % noise2string(tex.noise_basis)) file.write('\t\n' % noise2string(tex.noise_distortion)) file.write('\n') def write_yafaray(filename, scene=None, info_callback=None): file = open(filename, 'w') file.write('\n\n\n') file.write('\n') file.write('\t\n') file.write('\n\n') render = scene.render world = scene.world def uniqueName(name, nameSeq): if name not in nameSeq: return name name_orig = name i = 1 while name in nameSeq: name = '%s_%.3d' % (name_orig, i) i += 1 return name def writeMatrix(matrix): # this for povray and sunflow file.write('\tmatrix <%.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f>\n' %\ (matrix[0][0], matrix[0][1], matrix[0][2], matrix[1][0], matrix[1][1], matrix[1][2], matrix[2][0], matrix[2][1], matrix[2][2], matrix[3][0], matrix[3][1], matrix[3][2])) def writeMaterial(mat,YafMode): if mat: mat_name = mat.name mat_diffuse_intensity = mat.diffuse_intensity mat_ambient = mat.ambient mat_specular_hardness = mat.specular_hardness mat_diffuse_color = mat.diffuse_color mat_mirror_color = mat.mirror_color mat_specular_color = mat.specular_color mat_diffuse_ramp = mat.diffuse_ramp mat_emit = mat.emit mat_raytrace_mirror_reflect_factor = mat.raytrace_mirror.reflect_factor mat_raytrace_mirror_enabled = mat.raytrace_mirror.enabled mat_raytrace_mirror_fresnel = mat.raytrace_mirror.fresnel mat_raytrace_mirror_fresnel_factor = mat.raytrace_mirror.fresnel_factor mat_raytrace_mirror_reflect_factor = mat.raytrace_mirror.reflect_factor mat_raytrace_mirror_gloss_factor = mat.raytrace_mirror.gloss_factor mat_type = mat.type # mat_strand = mat.strand # mat_physics = mat.physics # mat_light_group = mat.light_group mat_shadeless = mat.shadeless mat_subsurface_scattering_enabled = mat.subsurface_scattering.enabled mat_shadeless = mat.shadeless mat_transparency_method = mat.transparency_method mat_transparency = mat.transparency mat_raytrace_transparency_ior = mat.raytrace_transparency.ior mat_raytrace_transparency_fresnel = mat.raytrace_transparency.fresnel mat_raytrace_transparency_fresnel_fac = mat.raytrace_transparency.fresnel_factor mat_raytrace_transparency_filter = mat.raytrace_transparency.filter mat_translucency = mat.translucency mat_subsurface_scattering_scale = mat.subsurface_scattering.scale mat_alpha = mat.alpha text_map_normal = '' text_map_colordiff = '' text_map_colorspec= '' map_coord0 = '' for t in mat.texture_slots: t_enabled = '' if t and t.texture.type != 'IMAGE': poceduralTextures(t.texture,t.texture.name,1,file) if t: t_texture_name = t.texture.name t_texture_image_filename = '' if t.texture.type == 'IMAGE' and t.texture.image: t_texture_image_filename = t.texture.image.filename # CHANNEL t_map_colordiff = t.map_colordiff t_map_normal = t.map_normal t_map_colorspec = t.map_colorspec # CHANNEL LEVEL t_normal_factor = t.normal_factor # COORD MAPPING t_from_original = t.from_original # bolean t_from_dupli = t.from_dupli # bolean t_uv_layer = t.uv_layer t_texture_coordinates = t.texture_coordinates # ORCO t_x_mapping = t.x_mapping t_y_mapping = t.y_mapping t_z_mapping = t.z_mapping t_mapping = t.mapping # CUBE t_normal_map_space = t.normal_map_space t_stencil = t.stencil t_enabled = t.enabled t_new_bump = t.new_bump if t_map_normal and t_enabled: text_map_normal ='\t\n' text_map_normal +='\t\t\n' text_map_normal +='\t\t\n' text_map_normal +='\t\t\n' text_map_normal +='\t\t\n' text_map_normal +='\t\t\n' text_map_normal +='\t\t\n' text_map_normal +='\t\t\n' text_map_normal +='\t\t\n' text_map_normal +='\t\t\n' text_map_normal +='\t\t\n' text_map_normal +='\t\t\n' text_map_normal +='\t\t\n' text_map_normal +='\t\t\n' % str.lower(str(t_stencil)) text_map_normal +='\t\t\n' text_map_normal +='\t\t\n' text_map_normal +='\t\t\n' text_map_normal +='\t\t\n' text_map_normal +='\t\t\n' text_map_normal +='\t\n' tType='uv' if t_mapping == 'FLAT': tTmap = "plain" elif t_mapping == 'CUBE': tTmap = "cube" elif t_mapping == 'TUBE': tTmap = "tube" elif t_mapping == 'SPHERE': tTmap = "sphere" if t_texture_coordinates == 'UV': tType = "uv" elif t_texture_coordinates == 'GLOBAL': tType = "global" elif t_texture_coordinates == 'ORCO': tType = "orco" # NOT FINISH SILVIO elif t_texture_coordinates == 'WINDOW': tType = "window" elif t_texture_coordinates == 'NORMAL': tType = "normal" elif t_texture_coordinates == 'REFLECTION': tType = "reflect" elif t_texture_coordinates == 'STICKY': tType = "stick" elif t_texture_coordinates == 'STRESS': tType = "stress" elif t_texture_coordinates == 'TANGENT': tType = "tangent" #elif mtex.texco == 'OBJECT': # not finish silvio #() map_coord0 ='\t\n' map_coord0 +='\t\t\n' % t_normal_factor map_coord0 +='\t\t\n' % tTmap map_coord0 +='\t\t\n' map_coord0 +='\t\t\n' % (0.0,0.0,0.0) map_coord0 +='\t\t\n' map_coord0 +='\t\t\n' map_coord0 +='\t\t\n' map_coord0 +='\t\t\n' % (1,1,1) map_coord0 +='\t\t\n' % tType map_coord0 +='\t\t\n' % t_texture_name map_coord0 +='\t\t\n' map_coord0 +='\t\n' if t_map_colordiff and t_enabled: text_map_colordiff ='\t\n' text_map_colordiff +='\t\t\n' text_map_colordiff +='\t\t\n' text_map_colordiff +='\t\t\n' text_map_colordiff +='\t\t\n' text_map_colordiff +='\t\t\n' text_map_colordiff +='\t\t\n' text_map_colordiff +='\t\t\n' text_map_colordiff +='\t\t\n' text_map_colordiff +='\t\t\n' text_map_colordiff +='\t\t\n' text_map_colordiff +='\t\t\n' text_map_colordiff +='\t\t\n' text_map_colordiff +='\t\t\n' % str.lower(str(t_stencil)) text_map_colordiff +='\t\t\n' text_map_colordiff +='\t\t\n' text_map_colordiff +='\t\t\n' text_map_colordiff +='\t\t\n' text_map_colordiff +='\t\t\n' text_map_colordiff +='\t\n' if t_enabled and t_texture_image_filename != '': file.write('\n' % t_texture_name) file.write('\t\n') file.write('\t\n') file.write('\t\n') file.write('\t\n') file.write('\t\n') file.write('\t\n') file.write('\t\n' % t_texture_image_filename) file.write('\t\n') file.write('\t\n') file.write('\t\n') file.write('\t\n') file.write('\t\n') file.write('\t\n') file.write('\n') matYaf = mat.get("YafRay") if matYaf and YafMode: matType = matYaf.get("type") file.write('\n' % mat_name) if matType == 'shinydiffusemat' or matType == 'shinydiffuse': #print('start shinydiffuse') if matYaf.get("fresnel_effect") == 1 : fresnel_effect ='true' else: fresnel_effect ='false' file.write('\t\n' % (matYaf.get("IOR"))) file.write('\t\n' % (tuple(matYaf.get("color")))) file.write('\t\n' % (matYaf.get("diffuse_reflect"))) file.write('\t\n' % (matYaf.get("emit"))) file.write('\t\n' % fresnel_effect) file.write('\t\n' % (tuple(matYaf.get("mirror_color")))) file.write('\t\n' % (matYaf.get("specular_reflect"))) file.write('\t\n' % (matYaf.get("translucency"))) file.write('\t\n' % (matYaf.get("transmit_filter"))) file.write('\t\n' % (matYaf.get("transparency"))) file.write('\t\n') #print('end shinydiffuse') if matType == 'glossy': #print('start glossy') if matYaf.get("as_diffuse") == 1 : as_diffuse ='true' else: as_diffuse ='false' if matYaf.get("anisotropic") == 1 : anisotropic ='true' else: anisotropic ='false' file.write('\t\n' % anisotropic) file.write('\t\n' % as_diffuse) file.write('\t\n' % (tuple(matYaf.get("color")))) file.write('\t\n' % (tuple(matYaf.get("diffuse_color")))) file.write('\t\n' % (matYaf.get("diffuse_reflect"))) file.write('\t\n' % (matYaf.get("exp_u"))) file.write('\t\n' % (matYaf.get("exp_v"))) file.write('\t\n' % (matYaf.get("exponent"))) file.write('\t\n' % (matYaf.get("glossy_reflect"))) file.write('\t\n') #print('end glossy') if matType == 'glass': #print('start glass') if matYaf.get("fake_shadows") == 1 : fake_shadows='true' else: fake_shadows = 'false' file.write('\t\n' % (matYaf.get("IOR"))) file.write('\t\n' % (tuple(matYaf.get("absorption")))) file.write('\t\n' % (matYaf.get("Iabsorption_dist"))) file.write('\t\n' % (matYaf.get("dispersion_power"))) file.write('\t\n' % fake_shadows) file.write('\t\n' % (tuple(matYaf.get("filter_color")))) file.write('\t\n' % (tuple(matYaf.get("mirror_color")))) file.write('\t\n' % (matYaf.get("transmit_filter"))) file.write('\t\n') #print('end glass') if matType == 'coated_glossy': #print('start coated glossy') if matYaf.get("as_diffuse") == 1 : as_diffuse ='true' else: as_diffuse ='false' if matYaf.get("anisotropic") == 1 : anisotropic ='true' else: anisotropic ='false' file.write('\t\n' % (matYaf.get("IOR"))) file.write('\t\n' % anisotropic) file.write('\t\n' % as_diffuse) file.write('\t\n' % (tuple(matYaf.get("color")))) file.write('\t\n' % (tuple(matYaf.get("diffuse_color")))) file.write('\t\n' % (matYaf.get("diffuse_reflect"))) file.write('\t\n' % (matYaf.get("exp_u"))) file.write('\t\n' % (matYaf.get("exp_v"))) file.write('\t\n' % (matYaf.get("exponent"))) file.write('\t\n' % (matYaf.get("glossy_reflect"))) file.write('\t\n') #print('end glossy') if text_map_normal != '' : file.write('\t\n') if text_map_colordiff != '' : file.write('\t\n') file.write(text_map_colordiff) file.write(text_map_normal) file.write(map_coord0) file.write(text_map_colordiff) file.write(text_map_normal) file.write(map_coord0) file.write('\n\n') ############### if not key yafaray material start translation from blender material else: if mat_raytrace_mirror_enabled: refl = mat_raytrace_mirror_reflect_factor else: refl = 0 if mat_transparency_method == 'RAYTRACE': transparency = (mat_raytrace_transparency_fresnel_fac - 1) / 4.00 else: transparency = mat_alpha transparency = (1 - transparency) if not mat_transparency: transparency=0 Blend2Mat = 0 ############################## BLEND MATERIAL 1 ### mirror glossy (GLOSSY) + transparency (GLASS) ### ### (because glossy not have transparency) if mat_raytrace_mirror_gloss_factor < 0.995 and transparency > 0: #print('blend material type 1') Blend2Mat = 1 file.write('\n' % (mat_name,'BBB')) file.write('\t\n') if text_map_normal != '': file.write('\t\n') file.write('\t\n') if text_map_colordiff != '': file.write('\t\n') file.write('\t\n' % (mat_emit / 4)) file.write('\t\n') file.write('\t\n' % mat_translucency ) file.write('\t\n' % 0) file.write('\t\n' % 0) file.write('\t\n' % (mat_raytrace_mirror_gloss_factor * 2000) ) file.write('\t\n' % refl) file.write('\t\n') file.write('\t\n' % (mat_mirror_color[0],mat_mirror_color[1],mat_mirror_color[2], mat_ambient)) file.write('\t\n' % (mat_diffuse_color[0],mat_diffuse_color[1],mat_diffuse_color[2], mat_ambient)) file.write('\t\n') file.write('\t\n') file.write('\t\n') file.write('\t\n') file.write(text_map_colordiff) file.write(text_map_normal) file.write(map_coord0) file.write('\n\n') ############################## BLEND MATERIAL 2 ### ((GLOSSY) or (SHINYDIFFUSEMAT)) + (GLASS) if IOR <> 1 ### ### (because shinydiffusemat not have IOR transparency) if mat_raytrace_transparency_ior != 1 and refl > 0.001 : #print('blend material type 2') Blend2Mat = 2 file.write('\n' % (mat_name,'BBB')) file.write('\t\n') if text_map_normal != '': file.write('\t\n') file.write('\t\n') if text_map_colordiff != '': file.write('\t\n') file.write('\t\n' % (mat_emit / 4)) file.write('\t\n') file.write('\t\n' % mat_translucency ) file.write('\t\n' % mat_raytrace_transparency_filter) file.write('\t\n' % 0) file.write('\t\n' % refl) file.write('\t\n') if refl == 0: file.write('\t\n' % (mat_specular_color[0],mat_specular_color[1],mat_specular_color[2], mat_ambient)) else: file.write('\t\n' % (mat_mirror_color[0],mat_mirror_color[1],mat_mirror_color[2], mat_ambient)) file.write('\t\n' % (mat_diffuse_color[0],mat_diffuse_color[1],mat_diffuse_color[2], mat_ambient)) file.write(text_map_colordiff) file.write(text_map_normal) file.write(map_coord0) file.write('\n\n') ############################## BLEND MATERIAL GLASS if Blend2Mat != 0: file.write('\n' % (mat_name,'AAA')) file.write('\t\n' % mat_raytrace_transparency_ior) file.write('\t\n' % (mat_diffuse_color[0],mat_diffuse_color[1],mat_diffuse_color[2], mat_ambient)) file.write('\t\n' % mat_subsurface_scattering_scale) file.write('\t\n') file.write('\t\n') file.write('\t\n') file.write('\t\n' % (mat_diffuse_color[0],mat_diffuse_color[1],mat_diffuse_color[2], mat_ambient)) file.write('\t\n') file.write('\t\n' % (mat_mirror_color[0],mat_mirror_color[1],mat_mirror_color[2], mat_ambient)) file.write('\t\n' % mat_raytrace_transparency_filter) file.write('\t\n') file.write(text_map_colordiff) file.write(text_map_normal) file.write(map_coord0) file.write('\n\n') ############################## SINGLE MATERIAL if Blend2Mat == 0 and mat_raytrace_transparency_ior == 1: file.write('\n' % mat_name) file.write('\t\n') if text_map_normal != '': file.write('\t\n') file.write('\t\n') if text_map_colordiff != '': file.write('\t\n') file.write('\t\n' % (mat_emit / 4)) file.write('\t\n') file.write('\t\n' % mat_translucency ) file.write('\t\n' % mat_raytrace_transparency_filter) file.write('\t\n' % transparency) if mat_raytrace_mirror_gloss_factor > 0.995 or not mat_raytrace_mirror_enabled: file.write('\t\n' % refl) file.write('\t\n') if refl == 0: file.write('\t\n' % (mat_specular_color[0],mat_specular_color[1],mat_specular_color[2], mat_ambient)) else: file.write('\t\n' % (mat_mirror_color[0],mat_mirror_color[1],mat_mirror_color[2], mat_ambient)) file.write('\t\n' % (mat_diffuse_color[0],mat_diffuse_color[1],mat_diffuse_color[2], mat_ambient)) else: file.write('\t\n' % (mat_raytrace_mirror_gloss_factor * 2000) ) file.write('\t\n' % refl) file.write('\t\n') file.write('\t\n' % (mat_mirror_color[0],mat_mirror_color[1],mat_mirror_color[2], mat_ambient)) file.write('\t\n' % (mat_diffuse_color[0],mat_diffuse_color[1],mat_diffuse_color[2], mat_ambient)) file.write('\t\n') file.write('\t\n') file.write('\t\n') file.write('\t\n') file.write(text_map_colordiff) file.write(text_map_normal) file.write(map_coord0) file.write('\n\n') else: file.write('\n' % (mat_name)) file.write('\t\n' % mat_raytrace_transparency_ior) file.write('\t\n' % (mat_diffuse_color[0],mat_diffuse_color[1],mat_diffuse_color[2], mat_ambient)) file.write('\t\n' % mat_subsurface_scattering_scale) file.write('\t\n') file.write('\t\n') file.write('\t\n') file.write('\t\n' % (mat_diffuse_color[0],mat_diffuse_color[1],mat_diffuse_color[2], mat_ambient)) file.write('\t\n') file.write('\t\n' % (mat_mirror_color[0],mat_mirror_color[1],mat_mirror_color[2], mat_ambient)) file.write('\t\n' % mat_raytrace_transparency_filter) file.write('\t\n') file.write(text_map_colordiff) file.write(text_map_normal) file.write(map_coord0) file.write(text_map_colordiff) file.write(text_map_normal) file.write(map_coord0) file.write('\n\n') if Blend2Mat != 0: file.write('\n' % mat_name) file.write('\t\n' % transparency ) file.write('\t\n' % (mat_name,'BBB')) file.write('\t\n' % (mat_name,'AAA')) file.write('\t\n') file.write('\n\n') def yaf_ExportLamps(YafMode): #if YafMode: print (' INFO: light Yafaray Mode enabled') #sel = scene.objects lamps=([l for l in scene.objects if l.type == 'LAMP']) for ob in lamps: if ob.restrict_render or ob.layers[0] < 1: continue yafLamp=ob.get("YafRay") lamp = ob.data matrix = ob.matrix pos = matrix[3] dir = matrix[2] to = [pos[0] - dir[0], pos[1] - dir[1], pos[2] - dir[2]] if YafMode and yafLamp: power = yafLamp.get('power') radius = yafLamp.get('radius') double_sided = yafLamp.get('double_sided') yafT = yafLamp.get('type') file.write('\n' % lamp.name) file.write('\t\n' % tuple(yafLamp.get('color'))) file.write('\t\n' % (pos[0],pos[1],pos[2])) if yafT == 'Sphere': file.write('\t\n' % (0.5*power*power/(radius * radius))) file.write('\t\n' % radius) file.write('\t\n' % (yafLamp.get('samples'))) file.write('\t\n') file.write('\n\n') if yafT == 'Point': file.write('\t\n' % (0.5*power*power/(radius * radius))) file.write('\t\n') file.write('\n\n') if yafT == 'Spot': file.write('\t\n') file.write('\t\n' % (0.5*power*power)) file.write('\t\n' % (to[0],to[1],to[2])) file.write('\t\n' % (yafLamp.get('angle'))) file.write('\t\n' % (yafLamp.get('blend'))) file.write('\n\n') if yafT == 'Directional': file.write('\t\n' % (yafLamp.get('power'))) file.write('\n' % (dir[0], dir[1],dir[2])) file.write('\t\n' % (yafLamp.get('infinite'))) file.write('\t\n' % (yafLamp.get('radius'))) file.write('\t\n' % (yafLamp.get('directional'))) file.write('\n\n') if yafT == 'Sun': file.write('\n' % (yafLamp.get('angle'))) file.write('\t\n' % (yafLamp.get('power'))) file.write('\n' % (dir[0], dir[1],dir[2])) file.write('\n' % (yafLamp.get('sample'))) file.write('\n') file.write('\n\n') if yafT == 'Area': size_x = lamp.size if lamp.shape == 'SQUARE': size_y = size_x else: size_y = lamp.size_y cor1 = matrix * Mathutils.Vector(-size_x/2.0, size_y/2.0, 0, 1) cor2 = matrix * Mathutils.Vector(size_x/2.0, size_y/2.0, 0, 1) cor3 = matrix * Mathutils.Vector(size_x/2.0, -size_y/2.0, 0, 1) file.write('\t\n' % (cor1[0], cor1[1], cor1[2])) file.write('\t\n' % (cor2[0], cor2[1], cor2[2])) file.write('\t\n' % (cor3[0], cor3[1], cor3[2])) file.write('\t\n' % (yafLamp.get('power'))) file.write('\t\n' % (yafLamp.get('samples'))) file.write('\t\n') file.write('\n\n') file.write('\n' % lamp.name) file.write('\t\n' % tuple(yafLamp.get('color'))) file.write('\t\n' % (cor1[0],cor1[1],cor1[2])) file.write('\t\n' % (pos[0],pos[1],pos[2])) file.write('\t\n' % (cor2[0],cor2[1],cor2[2])) file.write('\t\n' % (cor3[0],cor3[1],cor3[2])) file.write('\t\n' % (yafLamp.get('power'))) file.write('\t\n' % (yafLamp.get('samples'))) file.write('\t\n') file.write('\n\n') file.write('\n') file.write('\t

\n' % (cor1[0],cor1[1],cor1[2])) file.write('\t

\n' % (cor2[0],cor2[1],cor2[2])) file.write('\t

\n' % (cor1[0],cor3[1],cor3[2])) file.write('\t

\n' % (cor3[0],cor3[1],cor3[2])) file.write('\t\n' % lamp.name) file.write('\t\n') file.write('\t\n') file.write('\n') ### if lamp not have yafaray key start translation from blender lamp else: softSwadow= lamp.shadow_soft_size if scene.yaf_master_light_samples: Lsamples = scene.yaf_lights_samples else: try: Lsamples = lamp.shadow_ray_samples except: () try: Lsamples = lamp.shadow_ray_samples_x except: () if not (lamp.type == 'SUN' and lamp.name == 'SUN' and scene.UseSun and scene.yaf_SKY_enable): file.write('\n' % (lamp.name)) file.write('\t\n' % (lamp.color[0],lamp.color[1],lamp.color[2],1)) file.write('\t\n' % (pos[0],pos[1],pos[2])) if lamp.type == 'POINT': # Point Lamp if softSwadow > 0.1 and lamp.shadow_ray_samples > 1: file.write('\t') file.write('\t\n' % (((lamp.energy * 2) * lamp.distance ) / (softSwadow * softSwadow)) ) file.write('\t\n' % softSwadow) file.write('\t\n' % Lsamples) else: file.write('\t\n') file.write('\t\n' % (lamp.energy * lamp.distance)) elif lamp.type == 'SPOT': # Spot file.write('\t\n') file.write('\t\n' % (lamp.energy * lamp.distance)) file.write('\t\n' % (to[0],to[1],to[2])) file.write('\t\n' % (degrees(lamp.spot_size) / 2.0)) file.write('\t\n' % lamp.spot_blend) elif lamp.type == 'SUN' and (lamp.name != 'SUN' or (not scene.UseSun or not scene.yaf_SKY_enable)): if softSwadow > 0.1 and lamp.shadow_ray_samples > 1: file.write('\n' % softSwadow) file.write('\t\n' % (lamp.energy / 1.000) ) file.write('\n' % (dir[0], dir[1],dir[2])) file.write('\n' % Lsamples) file.write('\n') else: file.write('\t\n' % (lamp.energy / 1.000) ) file.write('\n' % (dir[0], dir[1],dir[2])) file.write('\t\n') file.write('\t\n') file.write('\t\n') elif lamp.type == 'AREA': size_x = lamp.size if lamp.shape == 'SQUARE': size_y = size_x else: size_y = lamp.size_y cor1 = matrix * Mathutils.Vector(-size_x/2.0, size_y/2.0, 0, 1) cor2 = matrix * Mathutils.Vector(size_x/2.0, size_y/2.0, 0, 1) cor3 = matrix * Mathutils.Vector(size_x/2.0, -size_y/2.0, 0, 1) file.write('\t\n' % (cor1[0], cor1[1], cor1[2])) file.write('\t\n' % (cor2[0], cor2[1], cor2[2])) file.write('\t\n' % (cor3[0], cor3[1], cor3[2])) file.write('\t\n' % (lamp.energy * 2 * lamp.distance)) file.write('\t\n' % (Lsamples * 2)) file.write('\t\n') file.write('\n') ################################################################# def yaf_ExportWorld(world,YafMode): global SunLamp file.write('\n') if scene.yaf_SKY_enable: SunLamp=None lamps=([l for l in scene.objects if l.type == 'LAMP']) for ob in lamps: lamp = ob.data if lamp.type == 'SUN' and lamp.name == 'SUN': SunLamp= lamp.sky if SunLamp: print(' INFO: SunLamp Found') file.write('\t\n' % SunLamp.horizon_brightness) # scene.yaf_SKY_A) file.write('\t\n' % SunLamp.spread) #scene.yaf_SKY_HorSpr) file.write('\t\n' % SunLamp.sun_brightness) # scene.yaf_SKY_C) file.write('\t\n' % SunLamp.sun_size) # scene.yaf_SKY_sun) file.write('\t\n' % SunLamp.backscattered_light) # scene.yaf_SKY_E) file.write('\t\n' % SunLamp.atmosphere_turbidity) # scene.yaf_SKY_turb) file.write('\t\n' % str.lower(str(scene.UseSkyLight))) ### find SUN light name SUN dir = (0,0,0) if scene.UseSun: #sel = scene.objects lamps=([l for l in scene.objects if l.type == 'LAMP']) for ob in lamps: lamp = ob.data if lamp.type == 'SUN' and lamp.name == 'SUN': matrix = ob.matrix dir = matrix[2] if dir == (0,0,0): file.write('\t\n') file.write('\t\n'% 0) file.write('\t\n' % (1, 1, 1)) else: file.write('\t\n') file.write('\t\n' % (lamp.energy * 10.0)) file.write('\t\n' % (dir[0], dir[1],dir[2])) file.write('\t\n' % scene.yaf_SKY_samples) file.write('\t\n' % scene.yaf_SKY_power) #file.write('\t\n') file.write('\t\n') else: file.write('\t\n' % (tuple(world.horizon_color))) file.write('\t\n') file.write('\t\n') file.write('\n') file.write('\n') file.write('\t\t\n') file.write('\n') if not scene.yaf_AO_enable and not scene.yaf_PT_enable and not scene.yaf_PM_enable: file.write('\n') file.write('\t\n') file.write('\t\n' % scene.yaf_raydepth ) file.write('\t\n' % scene.yaf_shadowdepth) file.write('\t\n' % str.lower(str(scene.yaf_transp_shadows))) file.write('\t\n') file.write('\n') if scene.yaf_AO_enable: file.write('\n') file.write('\t\n' % tuple(world.ambient_color)) file.write('\t\n' % scene.yaf_AO_distance_calc) file.write('\t\n' % scene.yaf_ao_samples) file.write('\t\n') file.write('\t\n' % str.lower(str(scene.UseCaustics))) if scene.UseCaustics: file.write('\t\n' % scene.yaf_AO_caus_depth) file.write('\t\n' % scene.yaf_AO_caus_mix) file.write('\t\n' % scene.yaf_AO_caus_radius) file.write('\t\n' % scene.yaf_raydepth ) file.write('\t\n' % scene.yaf_shadowdepth) file.write('\t\n' % str.lower(str(scene.yaf_transp_shadows))) file.write('\t\n') file.write('\n') ### pathtracing if scene.yaf_PT_enable: if scene.UsePhoton: file.write('\n') file.write('\t\n' % scene.yaf_PT_depth) file.write('\t\n' % scene.yaf_PT_caus_depth) file.write('\t\n' % scene.yaf_PT_caus_mix) file.write('\t\n' % scene.yaf_PT_caus_radius) file.write('\t\n') file.write('\t\n' % str.lower(str(scene.NoRec))) file.write('\t\n' % scene.yaf_PT_samples) file.write('\t\n' % scene.yaf_PT_photons) file.write('\t\n' % scene.yaf_raydepth) file.write('\t\n' % scene.yaf_shadowdepth) file.write('\t\n' % str.lower(str(scene.yaf_transp_shadows))) file.write('\t\n') file.write('\t\n' % str.lower(str(scene.UseBGPT))) file.write('\n') else: file.write('\n') file.write('\t\n' % scene.yaf_PT_depth) file.write('\t\n') file.write('\t\n' % str.lower(str(scene.NoRec))) file.write('\t\n' % scene.yaf_PT_samples) file.write('\t\n' % scene.yaf_raydepth) file.write('\t\n' % scene.yaf_shadowdepth) file.write('\t\n' % str.lower(str(scene.yaf_transp_shadows))) file.write('\t\n') file.write('\t\n' % str.lower(str(scene.UseBGPT))) file.write('\n') ### photon map if scene.yaf_PM_enable: file.write('\n') file.write('\t\n' % scene.yaf_PM_depth) file.write('\t\n' % scene.yaf_PM_caus_mix) file.write('\t\n' % scene.yaf_PM_caus_radius) file.write('\t\n' % scene.yaf_PM_bounces) file.write('\t\n' % scene.yaf_PM_samples) file.write('\t\n' % str.lower(str(scene.FinalGather))) file.write('\t\n' % scene.yaf_PM_photons) file.write('\t\n' % scene.yaf_raydepth) file.write('\t\n' % scene.yaf_PM_caus_search) file.write('\t\n' % scene.yaf_shadowdepth) file.write('\t\n' % str.lower(str(scene.ShowMap))) file.write('\t\n' % str.lower(str(scene.yaf_transp_shadows))) file.write('\t\n') file.write('\t\n' % str.lower(str(scene.UseBG))) file.write('\n') def yaf_exportGlobSett(scene,YafMode): DELAY = 0.06 time.sleep(DELAY) render = scene.render render.color_mode = 'RGBA' print(scene) x = int(render.resolution_x * render.resolution_percentage * 0.01) y = int(render.resolution_y * render.resolution_percentage * 0.01) threads = cpuCount() Filter = 'mitchell' render.use_file_extension = True if render.antialiasing: if render.pixel_filter == 'GAUSSIAN': Filter = 'gauss' if render.pixel_filter == 'MITCHELL': Filter = 'mitchell' if render.pixel_filter == 'BOX': Filter = 'box' AA_inc_samples = scene.AA_inc_samples AA_minsamples = scene.AA_minsamples AA_passes = scene.AA_passes else: AA_inc_samples = 0 AA_minsamples = 0 AA_passes = 0 # Needed for border render. not complete silvio ''' file.write('Start_Column=%d\n' % part.x) file.write('End_Column=%d\n' % (part.x+part.w)) file.write('Start_Row=%d\n' % (part.y)) file.write('End_Row=%d\n' % (part.y+part.h)) ''' camera = scene.camera matrix = camera.matrix pos=matrix[3] dir = matrix[2] up = matrix[1] to = [pos[0] - dir[0], pos[1] - dir[1], pos[2] - dir[2]] f_aspect = 1.0; if (x * x) <= (y * y): f_aspect=(x * x) / (y * y) camT='perspective' if scene.yaf_cam_type2: camT='orthographic' if scene.yaf_cam_type3: camT='angular' if scene.yaf_cam_type4: camT='architect' #if camera.data.type == 'ORTHO': camT='orthographic' bokeh_type = 'disk1' if scene.yaf_cam_bb2: bokeh_type='disk2' if scene.yaf_cam_bb3: bokeh_type='triangle' if scene.yaf_cam_bb4: bokeh_type='square' if scene.yaf_cam_bb5: bokeh_type='pentagon' if scene.yaf_cam_bb6: bokeh_type='hexagon' if scene.yaf_cam_bb2: bokeh_type='ring' # bokeh_rot = 'center' # if scene.yaf_cam_br1: bokeh_rot='edge' # if scene.yaf_cam_br2: bokeh_rot='uniform' file.write('\n') file.write('\t\n' % scene.yaf_cam_aperture) file.write('\t\n' % scene.yaf_cam_brokeh) file.write('\t\n' % bokeh_type) file.write('\t\n' % scene.yaf_cam_dof) file.write('\t\n' % str(camera.data.lens/(f_aspect*32.0)) ) file.write('\t\n' % (pos[0],pos[1],pos[2])) file.write('\t\n' % x) file.write('\t\n' % y) file.write('\t\n' % (to[0], to[1], to[2]) ) file.write('\t\n' % camT) file.write(' \t\n' % (pos[0] + up[0], pos[1] + up[1], pos[2] + up[2])) if scene.yaf_cam_type3: file.write('\t\n' % scene.yaf_cam_ang1) file.write('\t\n' % str.lower(str(scene.yaf_cam_opt1))) file.write('\t\n' % scene.yaf_cam_ang2) file.write('\t\n' % str.lower(str(scene.yaf_cam_opt1))) if scene.yaf_cam_type2: file.write('\t\n' % scene.yaf_cam_oscale) file.write('\n') file.write('\n') file.write('\t\n' % AA_inc_samples) file.write('\t\n' % AA_minsamples) file.write('\t\n' % AA_passes) file.write('\t\n' % render.filter_size) file.write('\t\n' % scene.yaf_threshold) file.write('\t\n') file.write('\t\n' % 'cam') file.write('\t\n' % 'false') file.write('\t\n' % Filter) file.write('\t\n' % scene.yaf_gamma) file.write('\t\n' % y) file.write('\t\n') file.write('\t\n' % threads) file.write('\t\n') file.write('\t\n' % x) file.write('\t\n' % 0) file.write('\t\n' % 0) file.write('\t\n') file.write('\n') file.write('\n') # Convert all materials time.sleep(0.02) if(scene.get("YafRay")) and scene.yaf_MASTER_enable: hasYafRay = True else: hasYafRay = False for material in bpy.data.materials: writeMaterial(material,hasYafRay) yaf_ExportLamps(hasYafRay) time.sleep(0.06) yaf_exportOBJ(file, scene.objects, scene,hasYafRay) yaf_ExportWorld(scene.world,hasYafRay) yaf_exportGlobSett(scene,hasYafRay) ########## matrix object in bpy.types.RenderEngine crash class YafaRay(bpy.types.RenderEngine): DELAY=0.02 bl_idname = 'YAFARAY_RENDER' bl_label = "Yafaray 0.2.1a" DELAY = 0.05 def _export(self, scene): import tempfile self._temp_file_in = tempfile.mktemp(suffix='.xml') def info_callback(txt): self.update_stats("", "YAFARAY: " + txt) time.sleep(self.DELAY) write_yafaray(self._temp_file_in, scene, info_callback) def _render(self): print ("***-STARTING-***") time.sleep(self.DELAY) def render(self, scene): import platform _SYS = platform.system() global updatemsg updatemsg=self info= 'Yafaray OS %s %s cpu %s Silvio Falcinelli' % (_SYS , (platform.architecture()[0]) , cpuCount() ) self = self render = scene.render self.update_stats("", "Yafaray: Exporting data from Blender") self._export(scene) self.update_stats("", "Yafaray: Silvio Falcinelli Export done, rendering in progress...") render.color_mode = 'RGBA' if render.file_format == 'OPENEXR': fformat = 'EXR' render.color_mode = 'RGBA' else: fformat = 'TGA' render.file_format = 'TARGA' render.color_mode = 'RGBA' x= int(render.resolution_x*render.resolution_percentage*0.01) y= int(render.resolution_y*render.resolution_percentage*0.01) if _SYS != 'Windows': comando=('xterm -bg "#444" -fg "#eee" -fa face:terminal:Italic:pixelsize=10 -title "%s" -e "yafaray-xml %s -f %s -o /tmp/" ' % (info, self._temp_file_in , fformat)) pid=os.system(comando) if render.output_path == '': render.output_path = '/tmp/YafaRay.tga' if render.output_path == '/tmp/': render.output_path = '/tmp/YafaRay.tga' if render.output_path == '/tmp/yafaray.tga': render.output_path = '/tmp/YafaRay.tga' try: os.rename('/tmp/yafaray.tga' , render.output_path) print ("***-DONE-***") result = self.begin_result(0, 0, x, y) lay = result.layers[0] lay.load_from_file(render.output_path) self.end_result(result) id=os.popen('eog -n %s' % render.output_path) if scene.yaf_sound_alert: soundalert() try: os.remove(self._temp_file_in) # so as not to load the old file ###trovami () except: pass except: self.update_stats("", "General Error...") print ("***-ERROR-***") else: yafaraypath=yaf_init() import tempfile wintempdir = tempfile.gettempdir() windir = os.getenv("windir") winsysdrive = os.getenv("SystemDrive") output_path=render.output_path if output_path == '' or not (os.path.exists(os.path.dirname(output_path))) or output_path == '/tmp\\' or output_path.find("yafaray.tga") > -1 : render.output_path = '%s\\Yafa_Ray.tga' % wintempdir batfile = ('%s.bat' % self._temp_file_in) f = open(batfile, 'w') f.write('%s:\n' % wintempdir.partition(':')[0] ) f.write('cd %s\n' % wintempdir.partition(':')[2] ) f.write('"%syafaray-xml\" "%s" -f %s -o "%s" \n' % (yafaraypath, self._temp_file_in , fformat, wintempdir)) f.write('copy %s\\yafaray.tga %s\n\n' % (wintempdir, render.output_path)) f.close() pid=os.system('%s.bat' % self._temp_file_in) print ("***-DONE-***") time.sleep(self.DELAY) result = self.begin_result(0, 0, x, y) lay = result.layers[0] lay.load_from_file(render.output_path) self.end_result(result) try: os.remove(self._temp_file_in) except: pass try: os.remove('%s.bat' % self._temp_file_in) if scene.yaf_sound_alert: soundalert() except: pass # Use some of the existing buttons. import properties_render properties_render.RENDER_PT_render.COMPAT_ENGINES.add('YAFARAY_RENDER') properties_render.RENDER_PT_dimensions.COMPAT_ENGINES.add('YAFARAY_RENDER') properties_render.RENDER_PT_output.COMPAT_ENGINES.add('YAFARAY_RENDER') del properties_render # Use only a subset of the world panels import properties_world #properties_world.WORLD_PT_preview.COMPAT_ENGINES.add('YAFARAY_RENDER') #properties_world.WORLD_PT_context_world.COMPAT_ENGINES.add('YAFARAY_RENDER') properties_world.WORLD_PT_world.COMPAT_ENGINES.add('YAFARAY_RENDER') #properties_world.WORLD_PT_mist.COMPAT_ENGINES.add('YAFARAY_RENDER') del properties_world #import properties_material #properties_material.DIFFUSE_PT.COMPAT_ENGINES.add('YAFARAY_RENDER') #del properties_material # Example of wrapping every class 'as is' import properties_material for member in dir(properties_material): subclass = getattr(properties_material, member) try: subclass.COMPAT_ENGINES.add('YAFARAY_RENDER') except: pass del properties_material class RenderPanel(bpy.types.Panel): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "render" () class RenderButtonsPanel(bpy.types.Panel): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "render" # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here () def poll(self, context): rd = context.scene.render return (rd.use_game_engine == False) and (rd.engine in self.COMPAT_ENGINES) # AO panel, use in the scene for now. FloatProperty = bpy.types.Scene.FloatProperty IntProperty = bpy.types.Scene.IntProperty BoolProperty = bpy.types.Scene.BoolProperty BoolPropertyg = bpy.types.Scene.BoolProperty # skylight BoolProperty(attr="yaf_SKY_enable", name="Enable SKY", description="Enable yafarays ambient occlusion calculation", default=False) FloatProperty(attr="yaf_SKY_HorSpr", min=0.00, max=10.00, default=3.80) FloatProperty(attr="yaf_SKY_turb", min=0.00, max=20.000, default=2.850) FloatProperty(attr="yaf_SKY_A", min=0.000, max=10.000, default=0.900) FloatProperty(attr="yaf_SKY_C", min=0.000, max=10.000, default=0.850) FloatProperty(attr="yaf_SKY_E", min=0.000, max=10.000, default=0.300) BoolProperty(attr="UseSun", name="Visible Sun", description="use one Direct Light name SUN in the scene", default=False) FloatProperty(attr="yaf_SKY_sun", min=0.00, max=10.00, default=0.50) BoolProperty(attr="UseSkyLight", name="Sky Light", description="Sky Light for exteriors scene is better AO", default=False) IntProperty(attr="yaf_SKY_samples", name="SKY samples", description="Number of samples SKY value has to be calculated", min=6, max=128, default=24) FloatProperty(attr="yaf_SKY_power", name="Power", description="Power", min=0, max=1, default=0.6) ## general setting BoolProperty(attr="yaf_transp_shadows", name="transparent shadows", description="", default=False) IntProperty(attr="yaf_raydepth", name="ray depht", description="", min=0, max=20, default=6) IntProperty(attr="yaf_shadowdepth", name="shadows depth", description="", min=0, max=20, default=2) FloatProperty(attr="yaf_gamma", name="gamma", description="", min=0.0, max=5.0, default=1.8) FloatProperty(attr="yaf_threshold", name="threshold", description="", min=0.00000, max=1.0000, default=0.0500) IntProperty(attr="yaf_meshlight_samples", name="mesh light samples", description="", min=1, max=128, default=24) BoolProperty(attr="yaf_master_light_samples", name="All Lights samples: ", description="over setting", default=False) IntProperty(attr="yaf_lights_samples", name="Samples", description="", min=1, max=128, default=24) BoolProperty(attr="yaf_sound_alert", name="Sound Notify at finish Rendering: ", description="", default=True) FloatProperty(attr="yaf_color_0_r", name="", description="", default=True) FloatProperty(attr="yaf_color_0_g", name="", description="", default=True) FloatProperty(attr="yaf_color_0_b", name="", description="", default=True) class RENDER_yafaray_set(RenderPanel): bl_label = "YafaRay General Settings" COMPAT_ENGINES = {'YAFARAY_RENDER'} def draw_header(self, context): scene = context.scene def draw(self, context): layout = self.layout scene = context.scene rd = scene.render split = layout.split() split.prop(scene, "yaf_raydepth", text="ray depth") split = layout.split() split.prop(scene, "yaf_shadowdepth", text="shadows depth") split = layout.split() split.prop(scene, "yaf_gamma", text="Gamma:") split = layout.split() col = split.column() col.prop(scene, "yaf_transp_shadows") col = split.column() col.prop(scene, "yaf_threshold", text="AA Threshold:") split = layout.split() split = layout.split() split = layout.split() split = layout.split() layout.label(text="Option Master Setting") split = layout.split() split.prop(scene, "yaf_meshlight_samples") split = layout.split() col = split.column() col.prop(scene, "yaf_master_light_samples" , icon='OUTLINER_OB_LAMP') col = split.column() col.prop(scene, "yaf_lights_samples") split = layout.split() split = layout.split() split = layout.split() col = split.column() col.prop(scene, "yaf_sound_alert") class RENDER_PT_yafaray_SKY(RenderButtonsPanel): global SunLamp bl_label = "SKY" COMPAT_ENGINES = {'YAFARAY_RENDER'} def draw_header(self, context): scene = context.scene self.layout.prop(scene, "yaf_SKY_enable", text="") def draw(self, context): global SunLamp layout = self.layout scene = context.scene rd = scene.render layout.active = scene.yaf_SKY_enable split = layout.split() split = layout.split() col = split.column() col.prop(scene, "UseSkyLight") col = split.column() col.prop(scene, "yaf_SKY_samples", text="Samples") col = split.column() col.prop(scene, "yaf_SKY_power", text="Power") split = layout.split() split = layout.split() split = layout.split() col = split.column() col.prop(scene, "UseSun") if scene.UseSun: SunDir = (0,0,0) #sel = scene.objects lamps=([l for l in scene.objects if l.type == 'LAMP']) for ob in lamps: lamp = ob.data if lamp.type == 'SUN' and lamp.name == 'SUN': SunLamp= lamp.sky matrix = ob.matrix SunDir = matrix[2] if SunDir == (0,0,0): layout.label(text="not found any direct lamp name SUN") layout.label(text="please make Sun lamp name SUN") else: layout.label(text=' SUN Direction: ', icon='OUTLINER_OB_LAMP') layout.label(text='X: %f Y: %f Z: %f' % (SunDir[0], SunDir[1], SunDir[2])) SunLamp.use_sky=True col.template_preview(lamp, "preview" ) row = layout.row() row.active = SunLamp.use_sky or SunLamp.use_atmosphere row.prop(SunLamp, "atmosphere_turbidity", slider=True, text="Turbidity") split = layout.split() col = split.column() sub = col.column() sub.prop(SunLamp, "sky_blend", slider=True, text="Factor") col.active = SunLamp.use_sky col.label(text="Horizon:") sub = col.column() sub.prop(SunLamp, "horizon_brightness", slider=True, text="A Brightness") sub.prop(SunLamp, "spread", slider=True, text="B Spread") col.label(text="Sun:") sub = col.column() sub.prop(SunLamp, "sun_brightness", slider=True, text="C Brightness") sub.prop(SunLamp, "sun_size", slider=True, text="D Size") sub.prop(SunLamp, "backscattered_light", slider=True, text="E Back Light") () # Ambient Occlusion BoolProperty(attr="yaf_AO_enable", name="Enable AO", description="Enable yafarays ambient occlusion calculation", default=False) BoolProperty(attr="UseCaustics", name="Use Caustics", description="Use Caustics", default=False) IntProperty(attr="yaf_ao_samples", name="AO samples", description="Number of samples AO value has to be calculated", min=1, max=128, default=32) IntProperty(attr="yaf_AO_distance_calc", name="Recursion Limit", description="distance AO nice 3 unit meter", min=1, max=100, default=3) IntProperty(attr="yaf_AO_photons", name="photons", description="", min=100, max=10000000, default=500000) IntProperty(attr="yaf_AO_caus_depth", name="AO caustics depth", description="Caustics scatter depth", min=0, max=50, default=10) IntProperty(attr="yaf_AO_caus_mix", name="Mix", description="Caustics mix", min=1, max=10000, default=100) FloatProperty(attr="yaf_AO_caus_radius", name="Radius", description="Caustics radius", min=0.000, max=100.000, default=50.000) class RENDER_PT_yafaray_AO(RenderButtonsPanel): bl_label = " " COMPAT_ENGINES = {'YAFARAY_RENDER'} def draw_header(self, context): scene = context.scene self.layout.prop(scene, "yaf_AO_enable", text="Engine - Ambient Occlusion") if scene.yaf_AO_enable: scene.yaf_PT_enable = False scene.yaf_PM_enable = False def draw(self, context): layout = self.layout scene = context.scene rd = scene.render layout.active = scene.yaf_AO_enable split = layout.split() col = split.column() col.prop(scene, "yaf_ao_samples", text="Samples") col = split.column() col.prop(scene, "yaf_AO_distance_calc", text="Distance") split = layout.split() col = split.column() column=col row = col.row() col.row().prop(scene.world, "ambient_color", text="") col = split.column() col.label(text=" Ambient Color:", icon='WORLD_DATA') split = layout.split() split = layout.split() split = layout.split() col = split.column() col.prop(scene, "UseCaustics") col = split.column() col.prop(scene, "yaf_AO_photons", text="Photn") split = layout.split() split.prop(scene, "yaf_AO_caus_depth", text="Caustics depth") split = layout.split() col = split.column() col.prop(scene, "yaf_AO_caus_mix") col = split.column() col.prop(scene, "yaf_AO_caus_radius") () # PathTracing BoolProperty(attr="yaf_PT_enable", name="Enable PT", description="Enable yafarays Pathtracing calculation", default=False) BoolProperty(attr="UseBGPT", name="Use Background", description="Use Background", default=False) BoolProperty(attr="NoRec", name="No recursion", description="No recursion", default=False) BoolProperty(attr="UsePhoton", name="Use Photon", description="", default=False) IntProperty(attr="yaf_PT_samples", name="PT samples", description="Number of samples Pathtracing value has to be calculated", min=1, max=128, default=16) IntProperty(attr="yaf_PT_depth", name="Pathtracing light bounces", description="", min=0, max=50, default=5) IntProperty(attr="yaf_PT_photons", name="photons", description="", min=100, max=10000000, default=500000) IntProperty(attr="yaf_PT_caus_depth", name="PT caustics depth", description="Caustics scatter depth", min=0, max=50, default=10) IntProperty(attr="yaf_PT_caus_mix", name="Mix", description="Caustics mix", min=1, max=10000, default=100) FloatProperty(attr="yaf_PT_caus_radius", name="Radius", description="Caustics radius", min=0.000, max=100.000, default=1) class RENDER_PT_yafaray_PT(RenderButtonsPanel): bl_label = " " COMPAT_ENGINES = {'YAFARAY_RENDER'} def draw_header(self, context): scene = context.scene self.layout.prop(scene, "yaf_PT_enable", text="Engine - Pathtracing Radiosity") if scene.yaf_PT_enable: scene.yaf_AO_enable = False scene.yaf_PM_enable = False def draw(self, context): layout = self.layout scene = context.scene rd = scene.render layout.active = scene.yaf_PT_enable split = layout.split() col = split.column() col.prop(scene, "yaf_PT_samples", text="FG Samples") col = split.column() col.prop(scene, "yaf_PT_depth", text="Depth") split = layout.split() col = split.column() col.prop(scene, "UsePhoton") col = split.column() col.prop(scene, "yaf_PT_photons", text="Photn") split = layout.split() split.prop(scene, "yaf_PT_caus_depth", text="Caustics depth") split = layout.split() col = split.column() col.prop(scene, "yaf_PT_caus_mix") col = split.column() col.prop(scene, "yaf_PT_caus_radius") split = layout.split() col = split.column() col.prop(scene, "UseBGPT") col = split.column() col.prop(scene, "NoRec") () # photon mapp BoolProperty(attr="yaf_PM_enable", name="Enable PM", description="Enable yafarays Photon Mapping calculation", default=False) BoolProperty(attr="UseBG", name="Use Background", description="Use Background", default=False) BoolProperty(attr="NoRec", name="No recursion", description="No recursion", default=False) IntProperty(attr="yaf_PM_samples", name="FG Samples", description="Number of samples Pathtracing value has to be calculated", min=1, max=128, default=35) IntProperty(attr="yaf_PM_bounces", name="FG bounces", description="", min=1, max=20, default=3) IntProperty(attr="yaf_PM_depth", name="depth", description="", min=0, max=50, default=5) IntProperty(attr="yaf_PM_photons", name="photons", description="", min=100, max=10000000, default=500000) IntProperty(attr="yaf_PM_caus_mix", name="Mix", description="Caustics mix", min=1, max=10000, default=10) IntProperty(attr="yaf_PM_caus_search", name="Search", description="Caustics search", min=1, max=10000, default=100) FloatProperty(attr="yaf_PM_caus_radius", name="Radius", description="Caustics search", min=0.0001, max=100.000, default=0.5) BoolProperty(attr="ShowMap", name="Show mapp", description="", default=False) BoolProperty(attr="FinalGather", name="Final Gather", description="", default=False) class RENDER_PT_yafaray_PM(RenderButtonsPanel): bl_label = " " COMPAT_ENGINES = {'YAFARAY_RENDER'} def draw_header(self, context): scene = context.scene self.layout.prop(scene, "yaf_PM_enable", text="Engine - Photon mapping") if scene.yaf_PM_enable: scene.yaf_PT_enable = False scene.yaf_AO_enable = False def draw(self, context): layout = self.layout scene = context.scene rd = scene.render layout.active = scene.yaf_PM_enable split = layout.split() col = split.column() col.prop(scene, "yaf_PM_samples" ) col = split.column() col.prop(scene, "yaf_PM_bounces" ) split = layout.split() col = split.column() col.prop(scene, "FinalGather") split = layout.split() split = layout.split() split = layout.split() split.prop(scene, "yaf_PM_photons", text="Photons") split = layout.split() col = split.column() col.prop(scene, "yaf_PM_caus_radius") col = split.column() col.prop(scene, "yaf_PM_depth", text="Depth") split = layout.split() split = layout.split() split = layout.split() col = split.column() col.label(text=" Caustics") col = split.column() col.prop(scene, "yaf_PM_caus_mix") col = split.column() col.prop(scene, "yaf_PM_caus_search") split = layout.split() split = layout.split() split = layout.split() split = layout.split() col = split.column() col.prop(scene, "UseBG") col = split.column() col.prop(scene, "ShowMap") () BoolProperty(attr="yaf_cam_enable", name="Enable", description="Enable yafarays Pathtracing calculation", default=False) FloatProperty(attr="yaf_cam_dof", name="yaf_cam_Dof", description="depth of field", min=0.00, max=1000.00, default=0.00) FloatProperty(attr="yaf_cam_aperture", name="yaf_cam_aperture", description="", min=0.000, max=20.000, default=0.000) FloatProperty(attr="yaf_cam_brokeh", name="yaf_cam_Brokeh", description="camera dof Brokeh", min=0.00, max=180.0, default=0.00) FloatProperty(attr="yaf_cam_oscale", name="yaf_cam_Oscale", description="", min=0.00, max=1000.0, default=10.00) FloatProperty(attr="yaf_cam_ang1", name="yaf_cam_Ang1", description="", min=0.00, max=180.0, default=90.00) FloatProperty(attr="yaf_cam_ang2", name="yaf_cam_Ang2", description="", min=0.00, max=180.0, default=90.00) BoolProperty(attr="yaf_cam_opt1", name="yaf_cam_AngOpt1", description="", default=False) BoolProperty(attr="yaf_cam_opt2", name="yaf_cam_AngOpt2", description="", default=False) BoolProperty(attr="yaf_cam_type1") BoolProperty(attr="yaf_cam_type2") BoolProperty(attr="yaf_cam_type3") BoolProperty(attr="yaf_cam_type4") BoolProperty(attr="yaf_cam_bb1") BoolProperty(attr="yaf_cam_bb2") BoolProperty(attr="yaf_cam_bb3") BoolProperty(attr="yaf_cam_bb4") BoolProperty(attr="yaf_cam_bb5") BoolProperty(attr="yaf_cam_bb6") BoolProperty(attr="yaf_cam_bb7") class RENDER_PT_yafaray_CAM(RenderButtonsPanel): bl_label = " Yafaray Camera" COMPAT_ENGINES = {'YAFARAY_RENDER'} def draw_header(self, context): scene = context.scene ############################### blender 2.5 radio button or menu where ?????????? ##### temporaly bad solution, for better wait API documentation after for blender 2.6... if scene.yaf_cam_type1 == True: scene.yaf_cam_type2 = False scene.yaf_cam_type3 = False scene.yaf_cam_type4 = False if scene.yaf_cam_type2 == True: scene.yaf_cam_type1 = False scene.yaf_cam_type3 = False scene.yaf_cam_type4 = False if scene.yaf_cam_type3 == True: scene.yaf_cam_type2 = False scene.yaf_cam_type1 = False scene.yaf_cam_type4 = False if scene.yaf_cam_type4 == True: scene.yaf_cam_type2 = False scene.yaf_cam_type3 = False scene.yaf_cam_type1 = False if scene.yaf_cam_bb1 == True: scene.yaf_cam_bb2 = False scene.yaf_cam_bb3 = False scene.yaf_cam_bb4 = False scene.yaf_cam_bb5 = False scene.yaf_cam_bb6 = False scene.yaf_cam_bb7 = False if scene.yaf_cam_bb2 == True: scene.yaf_cam_bb1 = False scene.yaf_cam_bb3 = False scene.yaf_cam_bb4 = False scene.yaf_cam_bb5 = False scene.yaf_cam_bb6 = False scene.yaf_cam_bb7 = False if scene.yaf_cam_bb3 == True: scene.yaf_cam_bb2 = False scene.yaf_cam_bb1 = False scene.yaf_cam_bb4 = False scene.yaf_cam_bb5 = False scene.yaf_cam_bb6 = False scene.yaf_cam_bb7 = False if scene.yaf_cam_bb4 == True: scene.yaf_cam_bb2 = False scene.yaf_cam_bb3 = False scene.yaf_cam_bb1 = False scene.yaf_cam_bb5 = False scene.yaf_cam_bb6 = False scene.yaf_cam_bb7 = False if scene.yaf_cam_bb5 == True: scene.yaf_cam_bb2 = False scene.yaf_cam_bb3 = False scene.yaf_cam_bb4 = False scene.yaf_cam_bb1 = False scene.yaf_cam_bb6 = False scene.yaf_cam_bb7 = False if scene.yaf_cam_bb6 == True: scene.yaf_cam_bb2 = False scene.yaf_cam_bb3 = False scene.yaf_cam_bb4 = False scene.yaf_cam_bb5 = False scene.yaf_cam_bb1 = False scene.yaf_cam_bb7 = False if scene.yaf_cam_bb7 == True: scene.yaf_cam_bb2 = False scene.yaf_cam_bb3 = False scene.yaf_cam_bb4 = False scene.yaf_cam_bb5 = False scene.yaf_cam_bb6 = False scene.yaf_cam_bb1 = False () def draw(self, context): layout = self.layout scene = context.scene rd = scene.render #layout.label(text=" Camera Type") split = layout.split() col = split.column() col.prop(scene, "yaf_cam_type1", text="Perspective", toggle=True) col = split.column() col.prop(scene, "yaf_cam_type2", text="Orthographic", toggle=True) split = layout.split() col = split.column() col.prop(scene, "yaf_cam_type3", text="Angular", toggle=True) col = split.column() col.prop(scene, "yaf_cam_type4", text="Architect", toggle=True) split = layout.split() split = layout.split() split = layout.split() if scene.yaf_cam_type2: split = layout.split() split.prop(scene, "yaf_cam_oscale" , text="Scale Orthographics") if scene.yaf_cam_type3: split = layout.split() col = split.column() col.prop(scene, "yaf_cam_ang1" , text="Angle ") col = split.column() col.prop(scene, "yaf_cam_ang2" , text="Max angle ") split = layout.split() col = split.column() col.prop(scene, "yaf_cam_opt1" , text="Mirrored" , toggle=True) col = split.column() col.prop(scene, "yaf_cam_opt2" , text="Circolar" , toggle=True) if scene.yaf_cam_type1 or scene.yaf_cam_type4: split = layout.split() col = split.column() col = split.column() col.prop(scene, "yaf_cam_aperture" , text="DOF Aperture") split = layout.split() col = split.column() col.label(text=" Depht of field") col = split.column() col.prop(scene, "yaf_cam_dof" , text="DOF distance") split = layout.split() col = split.column() col = split.column() col.prop(scene, "yaf_cam_brokeh" , text="Brokeh" ) split = layout.split() split = layout.split() col = split.column() col.label(text="Bokeh bias") col = split.column() col.prop(scene, "yaf_cam_bb1", text="Disk1", toggle=True) col = split.column() col.prop(scene, "yaf_cam_bb2", text="Disk2", toggle=True) col = split.column() col.prop(scene, "yaf_cam_bb3", text="Triangle", toggle=True) split = layout.split() col = split.column() col.prop(scene, "yaf_cam_bb4", text="Square", toggle=True) col = split.column() col.prop(scene, "yaf_cam_bb5", text="Pentagon", toggle=True) col = split.column() col.prop(scene, "yaf_cam_bb6", text="Hexagon", toggle=True) col = split.column() col.prop(scene, "yaf_cam_bb7", text="Ring", toggle=True ) split = layout.split() split = layout.split() () BoolProperty(attr="yaf_MASTER_enable", name="Enable PT", description="Enable yafarays Pathtracing calculation", default=False) BoolProperty(attr="yaf_OBJ_to_blender", default=False) class RENDER_PT_yafaray_MASTER(RenderButtonsPanel): bl_label = "Use Yafaray settings" COMPAT_ENGINES = {'YAFARAY_RENDER'} def draw_header(self, context): global yafarayToBlender scene = context.scene self.layout.prop(scene, "yaf_MASTER_enable", text="") if yafarayToBlender and scene.yaf_MASTER_enable: yaf_to_blender() def draw(self, context): global yafarayToBlender global updatemsg if not context.scene.yaf_MASTER_enable: yafarayToBlender=True layout = self.layout scene = context.scene rd = scene.render layout = self.layout if(scene.get("YafRay")): layout.label(text='Yafary scene available') layout.prop(scene, "yaf_OBJ_to_blender", text="yafaray setting to blender", toggle=True) else: layout.label(text='Blender Translation mode') if scene.yaf_OBJ_to_blender: yaf_to_blender() print( 'INFO: convert done') scene.yaf_OBJ_to_blender=False () updatemsg=self split = layout.split() split = layout.split() layout.label(text=infoSystem) layout.label(text= yafarayVer) layout.label(text= yafarayxmlVer) () IntProperty(attr="AA_passes", min=0, max=20, default=2) IntProperty(attr="AA_inc_samples", min=0, max=128, default=8) IntProperty(attr="AA_minsamples", min=0, max=64, default=2) class RENDER_PT_yafaray_AA(RenderButtonsPanel): bl_label = "Anti-Aliasing" COMPAT_ENGINES = {'YAFARAY_RENDER'} def draw_header(self, context): scene = context.scene self.layout.prop(scene.render, "antialiasing", text="") def draw(self, context): layout = self.layout scene = context.scene rd = scene.render layout = self.layout split = layout.split() col = split.column() #col.row().prop(scene.render, "antialiasing_samples", text="1", expand=True) col.label(text="filter type") col = split.column() col.row().prop(scene.render, "pixel_filter", text="") split = layout.split() col = split.column() col.label(text="pixel width") col = split.column() col.row().prop(scene.render, "filter_size", text="") split = layout.split() split = layout.split() split = layout.split() col = split.column() col.label(text="Passes") col = split.column() col.prop(scene, "AA_passes" , text="") split = layout.split() col = split.column() col.label(text="Samples") col = split.column() col.prop(scene, "AA_minsamples" , text="") split = layout.split() col = split.column() col.label(text="Samples passes") col = split.column() col.prop(scene, "AA_inc_samples" ,text="") split = layout.split() class RENDER_PT_yafaray_About(RenderButtonsPanel): bl_label = "About Yafaray Export " COMPAT_ENGINES = {'YAFARAY_RENDER'} def draw(self, context): layout = self.layout layout.label(text="WARNING this is beta experimen 04-04-2010") layout.label(text="last modify 14-04-2010") layout.label(text=" ") layout.label(text="some geometry modifies not support, (ALT C for collaps in mesh)") layout.label(text="for better solution i wait documentation of the new API ") layout.label(text="because to match change in new API ") split = layout.split() split = layout.split() split = layout.split() split = layout.split() layout.label(text="for Bug report and suggestions write me ") layout.label(text="silvio.falcinelli@rendering3d.net") split = layout.split() split = layout.split() split = layout.split() split = layout.split() layout.label(text="Author: Silvio Falcinelli") split = layout.split() split = layout.split() layout.label(text="04-04-2010 KhonKaen Thailand") try: yaf_init() except: () #try: # yaf_to_blender() #except: () classes = [ YafaRay, RENDER_yafaray_set, RENDER_PT_yafaray_AA, RENDER_PT_yafaray_MASTER, RENDER_PT_yafaray_CAM, RENDER_PT_yafaray_SKY, RENDER_PT_yafaray_AO, RENDER_PT_yafaray_PT, RENDER_PT_yafaray_PM, RENDER_PT_yafaray_About] def register(): register = bpy.types.register for cls in classes: register(cls) def unregister(): unregister = bpy.types.unregister for cls in classes: unregister(cls) if __name__ == "__main__": register() ########## matrix object in bpy.types.Operator is ok no crash #### menu render #def splitExt(path): # dotidx = path.rfind('.') # if dotidx == -1: # return path, '' # else: # return path[:dotidx], path[dotidx:] # #from bpy.props import * # #class YafarayXML(bpy.types.Operator): # bl_idname = "export_yafaray" # bl_label = 'Export XML' # # def execute(self, context): # if platform.system()=='Linux': file = open('/tmp/yafaray-test.xml', "w") # else: file = open('c:\\temp\\yafaray-test.xml', "w") # yaf_exportOBJ(file, context.scene.objects, context.scene, True) # file.close # return {'FINISHED'} # # #menu_func = lambda self, context: self.layout.operator(YafarayXML.bl_idname, text="YafaRay") #def register(): # bpy.types.register(YafarayXML) # bpy.types.INFO_MT_render.append(menu_func) #def unregister(): # bpy.types.unregister(YafarayXML) # bpy.types.INFO_MT_render.remove(menu_func) #if __name__ == "__main__": # register() ################## ''' spiegazione del problema: sia nel mio script che in altri dalla blender fondation quando viene eseguito matrix ad una mesh con modificatore attivo tipo subdivision surface blender 2.5 va in crash se eseguito da (bpy.types.RenderEngine) lo stesso identico codice se eseguito da (bpy.types.Operator) funziona perfettamente credo che sia un problema delle API di blender 2.5 se qualcuno ha una idea di come risolvere o raggirare questo problema prego di scrivermi silvio.falcinelli@rendering3d.net ''' ################# BUG FIX and changed HISTORY # # bugfix 05-04-2010 # fixed autoload in start blender # off softshadows if samples < 1 # sky light on/off fixed # glossy reflection off if not mirror # direct light power lever # sky SUN direction automatic from SUN light name SUN # # ------------------------------------------------- # # bugfix 06-04-2010 # fixed for os windows not save output image # fixed for phat os windows read environment # fixed softshadows # # tested in : # blender 2.5 alpha 2 32 bit in windows 64 bit # blender 2.5 alpha 2 64 bit # blender 2.5 alpha 2 64 bit in linux ubuntu 9.10 64 bit # # # add 07-04-2010 # texture: UV,GLOBAL,ORCO,WINDOW,NORMAL,REFLECTION,STICKY,STRESS,TANGENT # texture proiection: flat, cube, tube , sphere # filter restrict render and layer 0 (not finish) # area light square rectangle # mesh light # # add 08=04-2010 # procedural textures: # cloud, marble, wood, musgrave, voronoi, distorced noise # node material # # fixed crash in old existing scenes # # add 09-04-2010 0.2h # varius yafaray camera # sky preview rt (but now not work correct) # # fixed geometry disaster in 4 verts face and uv #