[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2440] branches/geodesic_domes/ geodesic_259.py: minimal request from gui_259: generate (only printing " generate called"
Peter K.H. Gragert
pkhgragert at gmail.com
Fri Oct 14 12:42:44 CEST 2011
Revision: 2440
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2440
Author: pkhg
Date: 2011-10-14 10:42:44 +0000 (Fri, 14 Oct 2011)
Log Message:
-----------
minimal request from gui_259: generate (only printing "generate called"
Only two def's for geodesic object left over:
get_chosen_type and get_parameter_of_chosen_type
Modified Paths:
--------------
branches/geodesic_domes/geodesic_259.py
Modified: branches/geodesic_domes/geodesic_259.py
===================================================================
--- branches/geodesic_domes/geodesic_259.py 2011-10-14 10:26:21 UTC (rev 2439)
+++ branches/geodesic_domes/geodesic_259.py 2011-10-14 10:42:44 UTC (rev 2440)
@@ -1,1094 +1,13 @@
import bpy
def generate(context):
- chosen_type = get_chosen_type(context)
- print(chosen_type) #PKHG seems to work
- parameters = get_parameter_of_chosen_type(chosen_type)
- print("parameters of ", chosen_type, parameters)
+# chosen_type = get_chosen_type(context)
+# print(chosen_type) #PKHG seems to work
+# parameters = get_parameter_of_chosen_type(chosen_type)
+# print("parameters of ", chosen_type, parameters)
+ print("generate called")
return {'FINISHED'}
-
- # Make variable that is the current .blend file main data blocks
- blend_data = context.blend_data
-
- # Make variable that is the active object selected by user
- active_object = context.active_object
-
- # Make variable scene that is current scene
- scene = context.scene
-
- # Parameters the user may want to change:
- # Number of points this number is multiplied by the volume to get
- # the number of points the scripts will put in the volume.
- numOfPoints = 1.0
- maxNumOfPoints = 100000
- maxPointDensityRadius = 1.5
- scattering = 2.5
- pointDensityRadiusFactor = 1.0
- densityScale = 1.5
-
- # What should we do?
- WhatToDo = getActionToDo(active_object)
-
- if WhatToDo == 'DEGENERATE':
- # Degenerate Cloud
- mainObj = active_object
-
- cloudMembers = active_object.children
- createdObjects = []
- definitionObjects = []
- for member in cloudMembers:
- applyScaleRotLoc(scene, member)
- if (member["CloudMember"] == "CreatedObj"):
- createdObjects.append(member)
- else:
- definitionObjects.append(member)
-
- for defObj in definitionObjects:
- #Delete cloudmember data from objects
- if "CloudMember" in defObj:
- del(defObj["CloudMember"])
-
- for createdObj in createdObjects:
- totallyDeleteObject(scene, createdObj)
-
- # Delete the blend_data object
- totallyDeleteObject(scene, mainObj)
-
- # Select all of the left over boxes so people can immediately
- # press generate again if they want.
- for eachMember in definitionObjects:
- eachMember.draw_type = 'SOLID'
- eachMember.select = True
- eachMember.hide_render = False
-
- elif WhatToDo == 'CLOUD_CONVERT_TO_MESH':
-
- cloudParticles = active_object.particle_systems.active
-
- bounds = active_object.parent
-
- ###############Create CloudPnts for putting points in#########
- # Create a new object cloudPnts
- cloudPnts = addNewObject(scene, "CloudPoints", bounds)
- cloudPnts["CloudMember"] = "CreatedObj"
- cloudPnts.draw_type = 'WIRE'
- cloudPnts.hide_render = True
-
- makeParent(bounds, cloudPnts, scene)
-
- convertParticlesToMesh(scene, cloudParticles, cloudPnts, True)
-
- removeParticleSystemFromObj(scene, active_object)
-
- pDensity = getpdensitytexture(bounds)
- pDensity.point_density.point_source = 'OBJECT'
- pDensity.point_density.object = cloudPnts
-
- #Let's resize the bound box to be more accurate.
- how_much_bigger = pDensity.point_density.radius
- makeObjectIntoBoundBox(scene, bounds, how_much_bigger, cloudPnts)
-
- else:
-
- # Generate Cloud
-
- ###############Create Combined Object bounds##################
- # Make a list of all Selected objects.
- selectedObjects = bpy.context.selected_objects
- if not selectedObjects:
- selectedObjects = [bpy.context.active_object]
-
- # Create a new object bounds
- bounds = addNewObject(scene,
- "CloudBounds",
- selectedObjects[0])
-
- bounds.draw_type = 'BOUNDS'
- bounds.hide_render = False
-
- # Just add a Definition Property designating this
- # as the blend_data object.
- bounds["CloudMember"] = "MainObj"
-
- # Since we used iteration 0 to copy with object we
- # delete it off the list.
- firstObject = selectedObjects[0]
- del selectedObjects[0]
-
- # Apply location Rotation and Scale to all objects involved.
- applyScaleRotLoc(scene, bounds)
- for each in selectedObjects:
- applyScaleRotLoc(scene, each)
-
- # Lets combine all of them together.
- combineObjects(scene, bounds, selectedObjects)
-
- # Lets add some property info to the objects.
- for selObj in selectedObjects:
- selObj["CloudMember"] = "DefinitioinObj"
- selObj.name = "DefinitioinObj"
- selObj.draw_type = 'WIRE'
- selObj.hide_render = True
- makeParent(bounds, selObj, scene)
-
- # Do the same to the 1. object since it is no longer in list.
- firstObject["CloudMember"] = "DefinitioinObj"
- firstObject.name = "DefinitioinObj"
- firstObject.draw_type = 'WIRE'
- firstObject.hide_render = True
- makeParent(bounds, firstObject, scene)
-
- ###############Create Cloud for putting Cloud Mesh############
- # Create a new object cloud.
- cloud = addNewObject(scene, "CloudMesh", bounds)
- cloud["CloudMember"] = "CreatedObj"
- cloud.draw_type = 'WIRE'
- cloud.hide_render = True
-
- makeParent(bounds, cloud, scene)
-
- bpy.ops.object.editmode_toggle()
- bpy.ops.mesh.select_all(action='SELECT')
-
- #Don't subdivide object or smooth if smoothing box not checked.
- if scene.cloudsmoothing:
- bpy.ops.mesh.subdivide(number_cuts=2, fractal=0, smoothness=1)
- bpy.ops.object.transform_apply(location=True)
- bpy.ops.mesh.vertices_smooth(repeat=20)
- bpy.ops.mesh.tris_convert_to_quads()
- bpy.ops.mesh.faces_shade_smooth()
- bpy.ops.object.editmode_toggle()
-
- ###############Create Particles in cloud obj##################
-
- # Set time to 0.
-# scene.frame_current = 0
-
- # Add a new particle system.
- bpy.ops.object.particle_system_add()
-
- #Particle settings setting it up!
-
- cloudParticles = cloud.particle_systems.active
- cloudParticles.name = "CloudParticles"
- cloudParticles.settings.frame_start = 0
- cloudParticles.settings.frame_end = 0
- cloudParticles.settings.emit_from = 'VOLUME'
- cloudParticles.settings.lifetime = scene.frame_end
- cloudParticles.settings.draw_method = 'DOT'
- cloudParticles.settings.render_type = 'NONE'
- cloudParticles.settings.distribution = 'RAND'
- cloudParticles.settings.physics_type = 'NEWTON'
- cloudParticles.settings.normal_factor = 0
-
- #Gravity does not effect the particle system
- eWeights = cloudParticles.settings.effector_weights
- eWeights.gravity = 0
-
-
- ####################Create Volume Material####################
- # Deselect All
- bpy.ops.object.select_all(action='DESELECT')
-
- # Select the object.
- bounds.select = True
- scene.objects.active = bounds
-
- # Turn bounds object into a box. Use itself as a reference.
- makeObjectIntoBoundBox(scene, bounds, 1.0, bounds)
-
- # Delete all material slots in bounds object.
- for i in range(len(bounds.material_slots)):
- bounds.active_material_index = i - 1
- bpy.ops.object.material_slot_remove()
-
- # Add a new material.
- cloudMaterial = blend_data.materials.new("CloudMaterial")
- bpy.ops.object.material_slot_add()
- bounds.material_slots[0].material = cloudMaterial
-
- # Set Up the Cloud Material
- cloudMaterial.name = "CloudMaterial"
- cloudMaterial.type = 'VOLUME'
- mVolume = cloudMaterial.volume
- mVolume.scattering = scattering
- mVolume.density = 0
- mVolume.density_scale = densityScale
- mVolume.transmission_color = [3, 3, 3]
- mVolume.step_size = 0.1
- mVolume.use_light_cache = True
- mVolume.cacheresolution = 45
-
- # Add a texture
- # vMaterialTextureSlots = cloudMaterial.texture_slots # UNUSED
- cloudtex = blend_data.textures.new("CloudTex", type='CLOUDS')
- cloudtex.noise_type = 'HARD_NOISE'
- cloudtex.noise_scale = 2
- mtex = cloudMaterial.texture_slots.add()
- mtex.texture = cloudtex
- mtex.texture_coords = 'ORCO'
- mtex.use_map_color_diffuse = True
-
- # Set time
- scene.frame_current = 1
-
- # Add a Point Density texture
- pDensity = blend_data.textures.new("CloudPointDensity", 'POINT_DENSITY')
-
- mtex = cloudMaterial.texture_slots.add()
- mtex.texture = pDensity
- mtex.texture_coords = 'GLOBAL'
- mtex.use_map_density = True
- mtex.use_rgb_to_intensity = True
- mtex.texture_coords = 'GLOBAL'
-
- pDensity.point_density.vertex_cache_space = 'WORLD_SPACE'
- pDensity.point_density.use_turbulence = True
- pDensity.point_density.noise_basis = 'VORONOI_F2'
- pDensity.point_density.turbulence_depth = 3
-
- pDensity.use_color_ramp = True
- pRamp = pDensity.color_ramp
- #pRamp.use_interpolation = 'LINEAR'
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list