Update that allows for a user to disable generation of objects. This can be useful...
authorPaul Marshall <portsidepaul@hotmail.com>
Wed, 22 Feb 2012 12:59:30 +0000 (12:59 +0000)
committerPaul Marshall <portsidepaul@hotmail.com>
Wed, 22 Feb 2012 12:59:30 +0000 (12:59 +0000)
Known bug: With the BMaesh update, the rocks are no longer having "smooth" applied.  From what I can tell this might be an API bug with BMesh as my code still appears valid and compliant with the documented Python API.

add_mesh_rocks/add_mesh_rocks.xml
add_mesh_rocks/factory.xml
add_mesh_rocks/rockgen.py
add_mesh_rocks/settings.py

index af5dcacf4f7a7d65b4601b97b68047de08260fe7..116fba715d898fcaf7b9325f58210f52410b4ac8 100644 (file)
@@ -33,6 +33,7 @@
 <!ELEMENT mat_IOR (#PCDATA)>
 <!ELEMENT mat_mossy (#PCDATA)>
 <!ELEMENT random (use_random_seed,user_seed)>
+<!ELEMENT use_generate (#PCDATA)>
 <!ELEMENT use_random_seed (#PCDATA)>
 <!ELEMENT user_seed (#PCDATA)>
 
@@ -94,6 +95,7 @@
                        <mat_mossy>0.0</mat_mossy>
                </material>
                <random>
+                       <use_generate>True</use_generate>
                        <use_random_seed>True</use_random_seed>
                        <user_seed>1</user_seed>
                </random>
                        <mat_mossy>0.0</mat_mossy>
                </material>
                <random>
+                       <use_generate>True</use_generate>
                        <use_random_seed>True</use_random_seed>
                        <user_seed>1</user_seed>
                </random>
                        <mat_mossy>0.0</mat_mossy>
                </material>
                <random>
+                       <use_generate>True</use_generate>
                        <use_random_seed>True</use_random_seed>
                        <user_seed>1</user_seed>
                </random>
                        <mat_mossy>0.0</mat_mossy>
                </material>
                <random>
+                       <use_generate>True</use_generate>
                        <use_random_seed>True</use_random_seed>
                        <user_seed>1</user_seed>
                </random>
                        <mat_mossy>0.0</mat_mossy>
                </material>
                <random>
+                       <use_generate>True</use_generate>
                        <use_random_seed>True</use_random_seed>
                        <user_seed>1</user_seed>
                </random>
                        <mat_mossy>0.0</mat_mossy>
                </material>
                <random>
+                       <use_generate>True</use_generate>
                        <use_random_seed>True</use_random_seed>
                        <user_seed>1</user_seed>
                </random>
index af5dcacf4f7a7d65b4601b97b68047de08260fe7..116fba715d898fcaf7b9325f58210f52410b4ac8 100644 (file)
@@ -33,6 +33,7 @@
 <!ELEMENT mat_IOR (#PCDATA)>
 <!ELEMENT mat_mossy (#PCDATA)>
 <!ELEMENT random (use_random_seed,user_seed)>
+<!ELEMENT use_generate (#PCDATA)>
 <!ELEMENT use_random_seed (#PCDATA)>
 <!ELEMENT user_seed (#PCDATA)>
 
@@ -94,6 +95,7 @@
                        <mat_mossy>0.0</mat_mossy>
                </material>
                <random>
+                       <use_generate>True</use_generate>
                        <use_random_seed>True</use_random_seed>
                        <user_seed>1</user_seed>
                </random>
                        <mat_mossy>0.0</mat_mossy>
                </material>
                <random>
+                       <use_generate>True</use_generate>
                        <use_random_seed>True</use_random_seed>
                        <user_seed>1</user_seed>
                </random>
                        <mat_mossy>0.0</mat_mossy>
                </material>
                <random>
+                       <use_generate>True</use_generate>
                        <use_random_seed>True</use_random_seed>
                        <user_seed>1</user_seed>
                </random>
                        <mat_mossy>0.0</mat_mossy>
                </material>
                <random>
+                       <use_generate>True</use_generate>
                        <use_random_seed>True</use_random_seed>
                        <user_seed>1</user_seed>
                </random>
                        <mat_mossy>0.0</mat_mossy>
                </material>
                <random>
+                       <use_generate>True</use_generate>
                        <use_random_seed>True</use_random_seed>
                        <user_seed>1</user_seed>
                </random>
                        <mat_mossy>0.0</mat_mossy>
                </material>
                <random>
+                       <use_generate>True</use_generate>
                        <use_random_seed>True</use_random_seed>
                        <user_seed>1</user_seed>
                </random>
index 8a86fd9560d3ef70f46c689543fdec175d5c1ccd..b1efa622dc24c4269e811dcc8720add57ee55b54 100644 (file)
@@ -1475,12 +1475,15 @@ class rocks(bpy.types.Operator):
                               description = "Amount of mossiness on the rocks",
                               min = 0.0, max = 1.0, default = defaults[25])
 
+    use_generate = BoolProperty(name = "Generate Rocks",
+                                description = "Enable actual generation.",
+                                default = defaults[26])
     use_random_seed = BoolProperty(name = "Use a random seed",
                                   description = "Create a seed based on time. Causes user seed to be ignored.",
-                                  default = defaults[26])
+                                  default = defaults[27])
     user_seed = IntProperty(name = "User seed",
                             description = "Use a specific seed for the generator.",
-                            min = 0, max = 1048576, default = defaults[27])
+                            min = 0, max = 1048576, default = defaults[28])
 
 
     def draw(self, context):
@@ -1521,6 +1524,7 @@ class rocks(bpy.types.Operator):
                 box.prop(self, 'mat_IOR')
             box.prop(self, 'mat_mossy')
         box = layout.box()
+        box.prop(self, 'use_generate')
         box.prop(self, 'use_random_seed')
         if not self.use_random_seed:
             box.prop(self, 'user_seed')
@@ -1555,42 +1559,44 @@ class rocks(bpy.types.Operator):
             self.mat_cloudy = float(self.presetsList[int(self.preset_values)][23])
             self.mat_IOR = float(self.presetsList[int(self.preset_values)][24])
             self.mat_mossy = float(self.presetsList[int(self.preset_values)][25])
-            self.use_random_seed = bool(self.presetsList[int(self.preset_values)][26])
-            self.user_seed = int(self.presetsList[int(self.preset_values)][27])
+            self.use_generate = bool(self.presetsList[int(self.preset_values)][26])
+            self.use_random_seed = bool(self.presetsList[int(self.preset_values)][27])
+            self.user_seed = int(self.presetsList[int(self.preset_values)][28])
             self.lastPreset = int(self.preset_values)
 
         # todo Add deform, deform_Var, rough, and rough_Var:
         #   *** todo completed 4/23/2011 ***
         #   *** Eliminated "deform_Var" and "rough_Var" so the script is not
         #       as complex to use.  May add in again as advanced features. ***
-        generateRocks(context,
-                      self.scale_X,
-                      self.skew_X,
-                      self.scale_Y,
-                      self.skew_Y,
-                      self.scale_Z,
-                      self.skew_Z,
-                      self.scale_fac,
-                      self.detail,
-                      self.display_detail,
-                      self.deform,
-                      self.rough,
-                      self.smooth_fac,
-                      self.smooth_it,
-                      self.mat_enable,
-                      self.mat_color,
-                      self.mat_bright,
-                      self.mat_rough,
-                      self.mat_spec,
-                      self.mat_hard,
-                      self.mat_use_trans,
-                      self.mat_alpha,
-                      self.mat_cloudy,
-                      self.mat_IOR,
-                      self.mat_mossy,
-                      self.num_of_rocks,
-                      self.user_seed,
-                      self.use_scale_dis,
-                      self.use_random_seed)
+        if self.use_generate:
+            generateRocks(context,
+                          self.scale_X,
+                          self.skew_X,
+                          self.scale_Y,
+                          self.skew_Y,
+                          self.scale_Z,
+                          self.skew_Z,
+                          self.scale_fac,
+                          self.detail,
+                          self.display_detail,
+                          self.deform,
+                          self.rough,
+                          self.smooth_fac,
+                          self.smooth_it,
+                          self.mat_enable,
+                          self.mat_color,
+                          self.mat_bright,
+                          self.mat_rough,
+                          self.mat_spec,
+                          self.mat_hard,
+                          self.mat_use_trans,
+                          self.mat_alpha,
+                          self.mat_cloudy,
+                          self.mat_IOR,
+                          self.mat_mossy,
+                          self.num_of_rocks,
+                          self.user_seed,
+                          self.use_scale_dis,
+                          self.use_random_seed)
 
         return {'FINISHED'}
index 3c99c6b6d1a154a24048f1681238594e2e8e9757..647a62d75094905a68f25ceb9d0b9b86a44feb5d 100644 (file)
@@ -147,25 +147,29 @@ def parseNode(setting, title=True):
     loc += 2
 
     # Preset random values (xmlPreset.childNodes[9]):
-    if setting.childNodes[loc].childNodes[1].childNodes[0].data == 'False':
+    if setting.childNodes[loc].childNodes[1].childNodes[0].data == 'True':
+        use_generate = True
+    else:
+        use_generate = False
+    if setting.childNodes[loc].childNodes[3].childNodes[0].data == 'False':
         use_random_seed = False
     else:
         use_random_seed = True
-    user_seed = int(setting.childNodes[loc].childNodes[3].childNodes[0].data)
+    user_seed = int(setting.childNodes[loc].childNodes[5].childNodes[0].data)
 
     if title:
         parsed = [title, scaleX, scaleY, scaleZ, skewX, skewY, skewZ,
                   use_scale_dis, scale_fac, deform, rough, detail,
                   display_detail, smooth_fac, smooth_it, mat_enable, mat_color,
                   mat_bright, mat_rough, mat_spec, mat_hard, mat_use_trans,
-                  mat_alpha, mat_cloudy, mat_IOR, mat_mossy, use_random_seed,
-                  user_seed]
+                  mat_alpha, mat_cloudy, mat_IOR, mat_mossy, use_generate,
+                  use_random_seed, user_seed]
     else:
         parsed = [scaleX, scaleY, scaleZ, skewX, skewY, skewZ, use_scale_dis,
                   scale_fac, deform, rough, detail, display_detail, smooth_fac,
                   smooth_it, mat_enable, mat_color, mat_bright, mat_rough,
                   mat_spec, mat_hard, mat_use_trans, mat_alpha, mat_cloudy,
-                  mat_IOR, mat_mossy, use_random_seed, user_seed]
+                  mat_IOR, mat_mossy, use_generate, use_random_seed, user_seed]
 
     return parsed