[Bf-extensions-cvs] [164c7f9] master: Fixed: scale of exported Smoke simulation

Maurice Raybaud noreply at git.blender.org
Wed Feb 18 19:01:19 CET 2015


Commit: 164c7f9790c8fcb2a131773d521a9d117762eb5d
Author: Maurice Raybaud
Date:   Tue Feb 17 23:42:15 2015 +0100
Branches: master
https://developer.blender.org/rBA164c7f9790c8fcb2a131773d521a9d117762eb5d

Fixed: scale of exported Smoke simulation

===================================================================

M	render_povray/render.py

===================================================================

diff --git a/render_povray/render.py b/render_povray/render.py
index 043dbfd..e1929c3 100644
--- a/render_povray/render.py
+++ b/render_povray/render.py
@@ -1485,32 +1485,39 @@ def write_pov(filename, scene=None, info_callback=None):
                     file.write("\n//--Smoke--\n\n")
 
                 # media container shape = blender domain
-                file.write("box{<0,0,0>, <%.4g, %.4g, %.4g>\n"% \
-                            (smoke_obj.dimensions[0], smoke_obj.dimensions[1], smoke_obj.dimensions[2]))
-                file.write("    translate <%.4g, %.4g, %.4g>\n"% \
-                            (smoke_obj.location[0], smoke_obj.location[1], smoke_obj.location[2]))
+                bbox = smoke_obj.bound_box
+                # Domain is cubic and its dimension is always the biggest
+                dim = [smoke_obj.dimensions.x, smoke_obj.dimensions.y, smoke_obj.dimensions.z]
+                domdim = sorted(dim)[-1]
+                file.write("box{<%.4g,%.4g,%.4g>, <%.4g, %.4g, %.4g>\n"% \
+                            (bbox[0][0], bbox[0][1], bbox[0][2], bbox[6][0], bbox[6][1], bbox[6][2]))
                 file.write("    pigment{ rgbt 1 }\n")
                 file.write("    hollow\n")
                 file.write("    interior{ //---------------------\n")
                 file.write("        media{ method 3\n")
                 file.write("               emission <1,1,1>*1\n")# 0>1 for dark smoke to white vapour
                 file.write("               scattering{ 1, // Type\n")
-                file.write("                  <1,1,1>*5.00\n")
+                file.write("                  <1,1,1>*0.1\n")
                 file.write("                } // end scattering\n")
-                file.write("	            density{density_file df3 \"%s\"\n" % (smokePath)) 
-                file.write("                        color_map {\n") 
-                file.write("                        [0.00 rgb 0]\n") 
-                file.write("                        [0.05 rgb 0]\n") 
-                file.write("                        [0.20 rgb 0.2]\n") 
-                file.write("                        [0.30 rgb 0.6]\n") 
-                file.write("                        [0.40 rgb 1]\n") 
-                file.write("                        [1.00 rgb 1]\n") 
-                file.write("                       } // end color_map\n") 
-                file.write("               } // end of density\n") 
-                file.write("               samples 20 // higher = more precise\n")
+                file.write("                density{density_file df3 \"%s\"\n" % (smokePath))
+                file.write("                        color_map {\n")
+                file.write("                        [0.00 rgb 0]\n")
+                file.write("                        [0.05 rgb 0]\n")
+                file.write("                        [0.20 rgb 0.2]\n")
+                file.write("                        [0.30 rgb 0.6]\n")
+                file.write("                        [0.40 rgb 1]\n")
+                file.write("                        [1.00 rgb 1]\n")
+                file.write("                       } // end color_map\n")
+                file.write("               } // end of density\n")
+                file.write("               samples %i // higher = more precise\n" % resolution)
                 file.write("         } // end of media --------------------------\n")
                 file.write("    } // end of interior\n")
+                file.write("scale<%.4g,%.4g,%.4g>\n" % \
+                            (domdim, domdim, domdim))               
+                file.write("translate<%.4g,%.4g,%.4g>\n" % (bbox[0][0], bbox[0][1], bbox[0][2]))
+                writeMatrix(global_matrix * smoke_obj.matrix_world)
                 file.write("}\n")
+
                 
                 #file.write("	            interpolate 1\n")
                 #file.write("	            frequency 0\n")
@@ -1525,497 +1532,462 @@ def write_pov(filename, scene=None, info_callback=None):
             #     for object we won't export here!
             if ob.type in {'LAMP', 'CAMERA', 'EMPTY', 'META', 'ARMATURE', 'LATTICE'}:
                 continue
-
+            smokeFlag=False
             for mod in ob.modifiers:
                 if mod and hasattr(mod, 'smoke_type'):
-                    exportSmoke(ob.name)
-                    if (mod.smoke_type == 'DOMAIN') or (mod.smoke_type == 'FLOW'):
-                        continue #don't render domain mesh or flow emitter, skip to next object.
-            # Export Hair
-            renderEmitter = True
-            if hasattr(ob, 'particle_systems'):
-                renderEmitter = False
-                for pSys in ob.particle_systems:
-                    if pSys.settings.use_render_emitter:
-                        renderEmitter = True
-                    for mod in [m for m in ob.modifiers if (m is not None) and (m.type == 'PARTICLE_SYSTEM')]:
-                        if (pSys.settings.render_type == 'PATH') and mod.show_render and (pSys.name == mod.particle_system.name):
-                            tstart = time.time()
-                            texturedHair=0
-                            if ob.active_material is not None:
-                                pmaterial = ob.material_slots[pSys.settings.material - 1].material
-                                for th in pmaterial.texture_slots:
-                                    if th and th.use:
-                                        if (th.texture.type == 'IMAGE' and th.texture.image) or th.texture.type != 'IMAGE':
-                                            if th.use_map_color_diffuse:
-                                                texturedHair=1
-                                if pmaterial.strand.use_blender_units:
-                                    strandStart = pmaterial.strand.root_size
-                                    strandEnd = pmaterial.strand.tip_size
-                                    strandShape = pmaterial.strand.shape 
-                                else:  # Blender unit conversion
-                                    strandStart = pmaterial.strand.root_size / 200.0
-                                    strandEnd = pmaterial.strand.tip_size / 200.0
-                                    strandShape = pmaterial.strand.shape
-                            else:
-                                pmaterial = "default"  # No material assigned in blender, use default one
-                                strandStart = 0.01
-                                strandEnd = 0.01
-                                strandShape = 0.0
-                            # Set the number of particles to render count rather than 3d view display    
-                            pSys.set_resolution(scene, ob, 'RENDER')    
-                            steps = pSys.settings.draw_step
-                            steps = 3 ** steps # or (power of 2 rather than 3) + 1 # Formerly : len(particle.hair_keys)
-                            
-                            totalNumberOfHairs = ( len(pSys.particles) + len(pSys.child_particles) )
-                            #hairCounter = 0
-                            file.write('#declare HairArray = array[%i] {\n' % totalNumberOfHairs)
-                            for pindex in range(0, totalNumberOfHairs):
-
-                                #if particle.is_exist and particle.is_visible:
-                                    #hairCounter += 1
-                                    #controlPointCounter = 0
-                                    # Each hair is represented as a separate sphere_sweep in POV-Ray.
-                                    
-                                    file.write('sphere_sweep{')
-                                    if pSys.settings.use_hair_bspline:
-                                        file.write('b_spline ')
-                                        file.write('%i,\n' % (steps + 2))  # +2 because the first point needs tripling to be more than a handle in POV
-                                    else:
-                                        file.write('linear_spline ')
-                                        file.write('%i,\n' % (steps))
-                                    #changing world coordinates to object local coordinates by multiplying with inverted matrix    
-                                    initCo = ob.matrix_world.inverted()*(pSys.co_hair(ob, pindex, 0))
-                                    if ob.active_material is not None:
-                                        pmaterial = ob.material_slots[pSys.settings.material-1].material
-                                        for th in pmaterial.texture_slots:
-                                            if th and th.use and th.use_map_color_diffuse:
-                                                #treat POV textures as bitmaps
-                                                if (th.texture.type == 'IMAGE' and th.texture.image and th.texture_coords == 'UV' and ob.data.uv_textures != None): # or (th.texture.pov.tex_pattern_type != 'emulator' and th.texture_coords == 'UV' and ob.data.uv_textures != None):
-                                                    image=th.texture.image
-                                                    image_width = image.size[0]
-                                                    image_height = image.size[1]
-                                                    image_pixels = image.pixels[:]
-                                                    uv_co = pSys.uv_on_emitter(mod, pSys.particles[pindex], pindex, 0)
-                                                    x_co = round(uv_co[0] * (image_width - 1))
-                                                    y_co = round(uv_co[1] * (image_height - 1))
-                                                    pixelnumber = (image_width * y_co) + x_co
-                                                    r = image_pixels[pixelnumber*4]
-                                                    g = image_pixels[pixelnumber*4+1]
-                                                    b = image_pixels[pixelnumber*4+2]
-                                      

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list