~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to release/scripts/addons_contrib/gyes/random_texture_generator.py

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-05-12 20:02:22 UTC
  • mfrom: (14.2.16 sid)
  • Revision ID: package-import@ubuntu.com-20120512200222-lznjs2cxzaq96wua
Tags: 2.63a-1
* New upstream bugfix release
  + debian/patches/: re-worked since source code changed

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: UTF-8 -*-
2
 
# first we import all the required modules
3
 
 
4
 
import bpy ,random , copy 
5
 
from bpy.props import *
6
 
import textwrap
7
 
 
8
 
class random_texture_class:
9
 
    """ this class contains all fuctions and variables concerning generation of random material """
10
 
    
11
 
    def __init__(self):
12
 
        """ several fuctions can be found here . All options for random generation . The History dictionary and several others."""
13
 
                   
14
 
        # various gui modes (simple, template etc)
15
 
        bpy.types.Scene.rtexture_gui_mode = EnumProperty(attr='mode', name='Mode', items=(
16
 
('enable', 'Enable', 'Enable Disable texture parameters for randomisation'),
17
 
('percentage', 'Percentage' , 'here you define percentage of randomisation for each texture parameters'),
18
 
('help', 'Help', 'Help documentation')), default='enable')
19
 
 
20
 
        # Here I define the selective areas that the user can enable or disable for randomisation in simple mode               
21
 
        bpy.types.Scene.rtexture_type = EnumProperty(attr='type', name='type', items=(
22
 
('RANDOM','RANDOM','RANDOM'),
23
 
('BLEND','BLEND','BLEND'),
24
 
('CLOUDS','CLOUDS','CLOUDS'),
25
 
('DISTORTED_NOISE','DISTORTED_NOISE','DISTORTED_NOISE'),
26
 
#('ENVIRONMENT_MAP','ENVIRONMENT_MAP','ENVIRONMENT_MAP'),
27
 
#('IMAGE','IMAGE','IMAGE'),
28
 
('MAGIC','MAGIC','MAGIC'),
29
 
('MARBLE','MARBLE','MARBLE'),
30
 
('MUSGRAVE','MUSGRAVE','MUSGRAVE'),
31
 
('NOISE','NOISE','NOISE'),
32
 
#('POINT_DENSITY','POINT_DENSITY','POINT_DENSITY'),
33
 
('STUCCI','STUCCI','STUCCI'),
34
 
('VORONOI','VORONOI','VORONOI'),
35
 
('WOOD','WOOD','WOOD')), default='RANDOM')
36
 
#('VOXEL_DATA','VOXEL_DATA','VOXEL_DATA') 
37
 
 
38
 
        bpy.types.Scene.rtexture_color = BoolProperty(name= "Color Factor" ,description = "Color factor of the texture" , default = True)    
39
 
        bpy.types.Scene.rtexture_intensity = BoolProperty(name= "Intensity" ,description = "Intensity of the texture" , default = True)
40
 
        bpy.types.Scene.rtexture_contrast = BoolProperty(name= "Contrast" ,description = "Contrast of the texture" , default = True)
41
 
        bpy.types.Scene.rtexture_saturation = BoolProperty(name= "Saturation" ,description = "Saturation of the texture" , default = True)
42
 
        bpy.types.Scene.rtexture_progression = BoolProperty(name= "Progression" ,description = "Progression of the texture" , default = True)
43
 
        bpy.types.Scene.rtexture_axis = BoolProperty(name= "Progr. Axis" ,description = "Progression of the texture" , default = True)
44
 
        bpy.types.Scene.rtexture_cloud_type = BoolProperty(name= "Cloud Type" ,description = "Cloud Type of the texture" , default = True)
45
 
        bpy.types.Scene.rtexture_noise_type = BoolProperty(name= "Noise Type" ,description = "Noise Type of the texture" , default = True)
46
 
        bpy.types.Scene.rtexture_noise_basis = BoolProperty(name= "Noise Basis" ,description = "Noise Basis of the texture" , default = True)
47
 
        bpy.types.Scene.rtexture_noise_scale = BoolProperty(name= "Noise Scale" ,description = "Noise Scale of the texture" , default = True)
48
 
        bpy.types.Scene.rtexture_nabla = BoolProperty(name= "Nabla" ,description = "Nabla of the texture" , default = True)
49
 
        bpy.types.Scene.rtexture_noise_depth = BoolProperty(name= "Noise Depth" ,description = "Noise Depth of the texture" , default = True)
50
 
        bpy.types.Scene.rtexture_noise_distortion = BoolProperty(name= "Noise Distortion" ,description = "Noise Distortion of the texture" , default = True)
51
 
        bpy.types.Scene.rtexture_noise_intensity = BoolProperty(name= "Noise Intensity" ,description = "Noise Intensity of the texture" , default = True)
52
 
        bpy.types.Scene.rtexture_distortion = BoolProperty(name= "Distortion" ,description = "Distortion of the texture" , default = True)
53
 
        bpy.types.Scene.rtexture_turbulence = BoolProperty(name= "Turbulence" ,description = "Turbulence of the texture" , default = True)
54
 
        bpy.types.Scene.rtexture_marble_type = BoolProperty(name= "Marble Type" ,description = "Marble type of the texture" , default = True)
55
 
        bpy.types.Scene.rtexture_noise_basis_2 = BoolProperty(name= "Noise Basis" ,description = "Noise Basis of the texture" , default = True)
56
 
        bpy.types.Scene.rtexture_musgrave_type = BoolProperty(name= "Musgrave Type" ,description = "Musgrave Type of the texture" , default = True)
57
 
        bpy.types.Scene.rtexture_lacunarity = BoolProperty(name= "Dimension Max" ,description = "Dimension Max of the texture" , default = True)
58
 
        bpy.types.Scene.rtexture_octaves = BoolProperty(name= "Dimension Max" ,description = "Dimension Max of the texture" , default = True)
59
 
        bpy.types.Scene.rtexture_dimension_max = BoolProperty(name= "Dimension Max" ,description = "Dimension Max of the texture" , default = True)
60
 
        bpy.types.Scene.rtexture_offset = BoolProperty(name= "Offset" ,description = "Offset of the texture" , default = True)
61
 
        bpy.types.Scene.rtexture_gain = BoolProperty(name= "Gain" ,description = "Gain of the texture" , default = True)
62
 
        bpy.types.Scene.rtexture_stucci_type = BoolProperty(name= "Type" ,description = "Stucci type of the texture" , default = True)
63
 
        bpy.types.Scene.rtexture_dist_metric = BoolProperty(name= "Metric" ,description = "Distance Metric of the texture" , default = True)
64
 
        bpy.types.Scene.rtexture_exponent = BoolProperty(name= "Exponent" ,description = "Minkovsky Exponent of the texture" , default = True)
65
 
        bpy.types.Scene.rtexture_color_mode = BoolProperty(name= "Color Mode" ,description = "Color Mode of the texture" , default = True)
66
 
        bpy.types.Scene.rtexture_weight_1 = BoolProperty(name= "Weight 1" ,description = "Weight 1 of the texture" , default = True)
67
 
        bpy.types.Scene.rtexture_weight_2 = BoolProperty(name= "Weight 2" ,description = "Weight 2 of the texture" , default = True)
68
 
        bpy.types.Scene.rtexture_weight_3 = BoolProperty(name= "Weight 3" ,description = "Weight 3 of the texture" , default = True)
69
 
        bpy.types.Scene.rtexture_weight_4 = BoolProperty(name= "Weight 4" ,description = "Weight 4 of the texture" , default = True)
70
 
        bpy.types.Scene.rtexture_wood_type = BoolProperty(name= "Wood Type" ,description = "Wood Type of the texture" , default = True)
71
 
        
72
 
        # Percentage randomisation
73
 
        bpy.types.Scene.rtexture_general_percentage = IntProperty(name="General percentage", description = " General percentage of randomisation" , min = 0 , max = 100 , default = 100, subtype = 'PERCENTAGE')
74
 
        bpy.types.Scene.rtexture_color_percentage = IntProperty(name="Color Factor", description = " Color factor percentage of randomisation" , min = 0 , max = 100 , default = 100, subtype = 'PERCENTAGE')
75
 
        bpy.types.Scene.rtexture_intensity_percentage = IntProperty(name="Intensity", description = " Intensity of the texture" , min = 0 , max = 100 , default = 0, subtype = 'PERCENTAGE')
76
 
        bpy.types.Scene.rtexture_contrast_percentage = IntProperty(name="Contrast", description = " Contrast of the texture" , min = 0 , max = 100 , default = 0, subtype = 'PERCENTAGE')
77
 
        bpy.types.Scene.rtexture_saturation_percentage = IntProperty(name="Saturation", description = " Saturation of the texture" , min = 0 , max = 100 , default = 0, subtype = 'PERCENTAGE')
78
 
        bpy.types.Scene.rtexture_noise_scale_percentage = IntProperty(name="Noise Scale", description = " Noise Scale of the texture" , min = 0 , max = 100 , default = 0, subtype = 'PERCENTAGE')
79
 
        bpy.types.Scene.rtexture_nabla_percentage = IntProperty(name="Nabla", description = " Nabla of the texture" , min = 0 , max = 100 , default = 0, subtype = 'PERCENTAGE')
80
 
        bpy.types.Scene.rtexture_noise_depth_percentage = IntProperty(name="Noise Depth", description = " Noise Depth of the texture" , min = 0 , max = 100 , default = 0, subtype = 'PERCENTAGE')
81
 
        bpy.types.Scene.rtexture_noise_int_percentage = IntProperty(name="Noise Intensity", description = " Noise Intensity of the texture" , min = 0 , max = 100 , default = 0, subtype = 'PERCENTAGE')
82
 
        bpy.types.Scene.rtexture_distortion_percentage = IntProperty(name="Distortion", description = "Distortion of the texture" , min = 0 , max = 100 , default = 0, subtype = 'PERCENTAGE')
83
 
        bpy.types.Scene.rtexture_turbulence_percentage = IntProperty(name="Turbulence", description = "Turbulence of the texture" , min = 0 , max = 100 , default = 0, subtype = 'PERCENTAGE')
84
 
        bpy.types.Scene.rtexture_dimension_percentage = IntProperty(name="Dimension", description = "Dimension of the texture" , min = 0 , max = 100 , default = 0, subtype = 'PERCENTAGE')
85
 
        bpy.types.Scene.rtexture_lacunarity_percentage = IntProperty(name="Lacunarity", description = "Lacunarity of the texture" , min = 0 , max = 100 , default = 0, subtype = 'PERCENTAGE')
86
 
        bpy.types.Scene.rtexture_octaves_percentage = IntProperty(name="Octaves", description = "Octaves of the texture" , min = 0 , max = 100 , default = 0, subtype = 'PERCENTAGE')
87
 
        bpy.types.Scene.rtexture_offset_percentage = IntProperty(name="Offset", description = "Offset of the texture" , min = 0 , max = 100 , default = 0, subtype = 'PERCENTAGE')
88
 
        bpy.types.Scene.rtexture_gain_percentage = IntProperty(name="Gain", description = "Gain of the texture" , min = 0 , max = 100 , default = 0, subtype = 'PERCENTAGE')
89
 
        bpy.types.Scene.rtexture_exponent_percentage = IntProperty(name="Exponent", description = "Exponent of the texture" , min = 0 , max = 100 , default = 0, subtype = 'PERCENTAGE')
90
 
        bpy.types.Scene.rtexture_weight_1_percentage = IntProperty(name="Weight 1", description = "Weight 1 of the texture" , min = 0 , max = 100 , default = 0, subtype = 'PERCENTAGE')
91
 
        bpy.types.Scene.rtexture_weight_2_percentage = IntProperty(name="Weight 2", description = "Weight 2 of the texture" , min = 0 , max = 100 , default = 0, subtype = 'PERCENTAGE')
92
 
        bpy.types.Scene.rtexture_weight_3_percentage = IntProperty(name="Weight 3", description = "Weight 3 of the texture" , min = 0 , max = 100 , default = 0, subtype = 'PERCENTAGE')
93
 
        bpy.types.Scene.rtexture_weight_4_percentage = IntProperty(name="Weight 4", description = "Weight 4 of the texture" , min = 0 , max = 100 , default = 0, subtype = 'PERCENTAGE')
94
 
       
95
 
        
96
 
        
97
 
        # the prop that controls the text wrap in help menu
98
 
        bpy.types.Scene.text_width = IntProperty(name = "Text Width" , description = "The width above which the text wraps" , default = 20 , max = 180 , min = 1)
99
 
        
100
 
        
101
 
            
102
 
         # non read only material properties where keyframes can be inserted or removed
103
 
        self.animated_properties=["alpha",
104
 
        "use_vertex_color_paint"]
105
 
            
106
 
        
107
 
    # compute randomisation based on the general or specific percentage chosen
108
 
    # if the specific percentage is zero then the general percentage is used
109
 
    def compute_percentage(self,min,max,value,percentage):
110
 
        range = max-min
111
 
        general_percentage = bpy.context.scene.rtexture_general_percentage
112
 
        
113
 
        if percentage == 0:
114
 
            percentage_random = ( value -((range*(general_percentage/100))/2) )+ (range * (general_percentage / 100) * random.random())
115
 
        else:
116
 
            percentage_random = ( value - ((range*(percentage/100))/2)) + (range * (percentage / 100) * random.random())
117
 
             
118
 
        if percentage_random > max:
119
 
            percentage_random = max
120
 
        if percentage_random < min:
121
 
            percentage_random = min
122
 
        
123
 
        return percentage_random 
124
 
    
125
 
    #deletes from history an index but without leaving empty spaces, everythings is pushed back    
126
 
    def delete_from_history(self):
127
 
        
128
 
        length = len(self.history)
129
 
        index = bpy.context.scene.texture_history_index
130
 
        for x in range(index , length):
131
 
            if index != length :
132
 
                self.history[x]= self.history[x+1] 
133
 
        del self.history[length]
134
 
        length = len(self.history) 
135
 
        if index <= length:
136
 
            self.activate()
137
 
            
138
 
        bpy.context.scene.texture_historybak = str(self.rm_history)
139
 
    
140
 
    # the fuction that randomises the material 
141
 
    
142
 
    def random_texture_color(self,texture):
143
 
        scn = bpy.context.scene
144
 
        if scn.rtexture_color:
145
 
            texture.factor_red = self.compute_percentage(0,2,texture.factor_red,scn.rtexture_color_percentage)
146
 
            texture.factor_green = self.compute_percentage(0,2,texture.factor_green,scn.rtexture_color_percentage)
147
 
            texture.factor_blue = self.compute_percentage(0,2,texture.factor_blue,scn.rtexture_color_percentage)
148
 
        if scn.rtexture_intensity:
149
 
            texture.intensity = self.compute_percentage(0,2,texture.intensity,scn.rtexture_intensity_percentage)
150
 
        if scn.rtexture_contrast:
151
 
            texture.contrast = self.compute_percentage(0,5,texture.contrast,scn.rtexture_contrast_percentage)
152
 
        if scn.rtexture_saturation:
153
 
            texture.saturation = self.compute_percentage(0,2,texture.saturation,scn.rtexture_saturation_percentage)        
154
 
    
155
 
    def random_texture(self,material):
156
 
        scn = bpy.context.scene
157
 
        
158
 
        # if the texture exists use that for randomisation if not then create a new one
159
 
        if material.texture_slots[material.active_texture_index] and material.texture_slots[material.active_texture_index].texture:
160
 
            texture = material.texture_slots[material.active_texture_index].texture
161
 
            if not scn.rtexture_type=='RANDOM':
162
 
               texture.type = scn.rtexture_type
163
 
            else:
164
 
               texture.type = random.choice(['BLEND','CLOUDS','DISTORTED_NOISE','MAGIC','MARBLE','MUSGRAVE','NOISE','STUCCI','VORONOI','WOOD'])
165
 
            material.texture_slots[material.active_texture_index].texture = texture 
166
 
        else:
167
 
            material.texture_slots.create(material.active_texture_index)           
168
 
            if not scn.rtexture_type=='RANDOM':
169
 
                texture = bpy.data.textures.new('Rand_tex_',scn.rtexture_type)
170
 
            else:
171
 
                texture = bpy.data.textures.new('Rand_tex_','NOISE')
172
 
            material.texture_slots[material.active_texture_index].texture = texture
173
 
        
174
 
        # randomise parameters depending on the type of the texture
175
 
        
176
 
        if scn.rtexture_type == 'BLEND':
177
 
            
178
 
            self.random_texture_color(texture)
179
 
            
180
 
            if scn.rtexture_progression:
181
 
                texture.progression = random.choice(['LINEAR', 'QUADRATIC', 'EASING', 'DIAGONAL', 'SPHERICAL', 'QUADRATIC_SPHERE', 'RADIAL'])
182
 
            if scn.rtexture_axis and not (texture.progression=='DIAGONAL' or texture.progression=='SPHERICAL' or texture.progression=='QUADRATIC_SPHERE'):
183
 
                texture.use_flip_axis = random.choice(['HORIZONTAL', 'VERTICAL'])
184
 
        
185
 
        if scn.rtexture_type == 'CLOUDS':
186
 
            
187
 
            self.random_texture_color(texture)
188
 
            
189
 
            if scn.rtexture_cloud_type:
190
 
                texture.cloud_type = random.choice(['GREYSCALE', 'COLOR'])
191
 
            if scn.rtexture_noise_type:
192
 
                texture.noise_type = random.choice(['SOFT_NOISE', 'HARD_NOISE'])
193
 
            if scn.rtexture_noise_basis:
194
 
                texture.noise_basis = random.choice(['BLENDER_ORIGINAL', 'ORIGINAL_PERLIN', 'IMPROVED_PERLIN', 'VORONOI_F1', 'VORONOI_F2', 'VORONOI_F3',    'VORONOI_F4', 'VORONOI_F2_F1', 'BLENDER_ORIGINAL', 'VORONOI_CRACKLE', 'CELL_NOISE'])
195
 
            if scn.rtexture_noise_scale:
196
 
                texture.noise_scale = self.compute_percentage(0,2,texture.noise_scale,scn.rtexture_noise_scale_percentage)
197
 
            if scn.rtexture_nabla:
198
 
                texture.nabla = self.compute_percentage(0,0.10,texture.nabla,scn.rtexture_nabla_percentage)
199
 
            if scn.rtexture_noise_depth:
200
 
                texture.noise_depth = int(self.compute_percentage(0,24,texture.noise_depth,scn.rtexture_noise_depth_percentage))
201
 
        
202
 
        if scn.rtexture_type == 'DISTORTED_NOISE':
203
 
            
204
 
            self.random_texture_color(texture)
205
 
            if scn.rtexture_noise_distortion:
206
 
                texture.noise_distortion = random.choice(['BLENDER_ORIGINAL','ORIGINAL_PERLIN', 'IMPROVED_PERLIN', 'VORONOI_F1', 'VORONOI_F2','VORONOI_F3','VORONOI_F4', 'VORONOI_F2_F1', 'BLENDER_ORIGINAL','VORONOI_CRACKLE','CELL_NOISE'])
207
 
            if scn.rtexture_noise_basis:
208
 
                texture.noise_basis = random.choice(['BLENDER_ORIGINAL','ORIGINAL_PERLIN','IMPROVED_PERLIN','VORONOI_F1', 'VORONOI_F2','VORONOI_F3','VORONOI_F4','VORONOI_F2_F1','BLENDER_ORIGINAL','VORONOI_CRACKLE','CELL_NOISE'])
209
 
            if scn.rtexture_distortion:
210
 
                texture.distortion = self.compute_percentage(0,10,texture.distortion,scn.rtexture_distortion_percentage)
211
 
            if scn.rtexture_nabla:
212
 
                texture.nabla = self.compute_percentage(0,0.10,texture.nabla,scn.rtexture_nabla_percentage)
213
 
            if scn.rtexture_noise_scale:
214
 
                texture.noise_scale = self.compute_percentage(0,2,texture.noise_scale,scn.rtexture_noise_scale_percentage)
215
 
        
216
 
        if scn.rtexture_type == 'MAGIC':
217
 
            
218
 
            self.random_texture_color(texture)
219
 
            
220
 
            if scn.rtexture_noise_depth:
221
 
                texture.noise_depth = int(self.compute_percentage(0,24,texture.noise_depth,scn.rtexture_noise_depth_percentage))
222
 
            if scn.rtexture_turbulence:
223
 
                texture.turbulence = int(self.compute_percentage(0,1000,texture.turbulence,scn.rtexture_turbulence_percentage))    
224
 
            
225
 
        if scn.rtexture_type == 'MARBLE':
226
 
            
227
 
            self.random_texture_color(texture)
228
 
            if scn.rtexture_marble_type:
229
 
                texture.marble_type = random.choice(['SOFT', 'SHARP', 'SHARPER'])
230
 
            if scn.rtexture_noise_basis_2:
231
 
                texture.noise_basis_2 = random.choice(['SIN', 'SAW', 'TRI'])
232
 
            if scn.rtexture_noise_type:
233
 
                texture.noise_type = random.choice(['SOFT_NOISE', 'HARD_NOISE'])
234
 
            if scn.rtexture_noise_basis:
235
 
                texture.noise_basis = random.choice(['BLENDER_ORIGINAL','ORIGINAL_PERLIN','IMPROVED_PERLIN','VORONOI_F1', 'VORONOI_F2','VORONOI_F3','VORONOI_F4','VORONOI_F2_F1','BLENDER_ORIGINAL','VORONOI_CRACKLE','CELL_NOISE'])
236
 
            if scn.rtexture_noise_scale:
237
 
                texture.noise_scale = self.compute_percentage(0,2,texture.noise_scale,scn.rtexture_noise_scale_percentage)
238
 
            if scn.rtexture_turbulence:
239
 
                texture.turbulence = int(self.compute_percentage(0,1000,texture.turbulence,scn.rtexture_turbulence_percentage))    
240
 
            if scn.rtexture_noise_depth:
241
 
                texture.noise_depth = int(self.compute_percentage(0,24,texture.noise_depth,scn.rtexture_noise_depth_percentage))
242
 
            if scn.rtexture_nabla:
243
 
                texture.nabla = self.compute_percentage(0,0.10,texture.nabla,scn.rtexture_nabla_percentage)
244
 
            
245
 
        if scn.rtexture_type == 'MUSGRAVE':
246
 
            
247
 
            self.random_texture_color(texture)
248
 
            if scn.rtexture_musgrave_type:
249
 
                texture.musgrave_type = random.choice(['MULTIFRACTAL','RIDGED_MULTIFRACTAL','HYBRID_MULTIFRACTAL','FBM','HETERO_TERRAIN'])
250
 
            if scn.rtexture_dimension_max:
251
 
                texture.dimension_max = self.compute_percentage(0,2,texture.dimension_max,scn.rtexture_dimension_percentage)
252
 
            if scn.rtexture_noise_intensity:
253
 
                texture.noise_intensity = self.compute_percentage(0,10,texture.noise_intensity,scn.rtexture_noise_int_percentage)
254
 
            if scn.rtexture_lacunarity:
255
 
                texture.lacunarity= self.compute_percentage(0,6,texture.lacunarity,scn.rtexture_lacunarity_percentage)
256
 
            if scn.rtexture_noise_basis:
257
 
                texture.noise_basis = random.choice(['BLENDER_ORIGINAL','ORIGINAL_PERLIN','IMPROVED_PERLIN','VORONOI_F1', 'VORONOI_F2','VORONOI_F3','VORONOI_F4','VORONOI_F2_F1','BLENDER_ORIGINAL','VORONOI_CRACKLE','CELL_NOISE'])
258
 
            if scn.rtexture_noise_scale:
259
 
                texture.noise_scale = self.compute_percentage(0,2,texture.noise_scale,scn.rtexture_noise_scale_percentage)
260
 
            if scn.rtexture_nabla:
261
 
                texture.nabla = self.compute_percentage(0,0.10,texture.nabla,scn.rtexture_nabla_percentage)
262
 
            if scn.rtexture_offset:
263
 
                texture.offset = self.compute_percentage(0,6,texture.offset,scn.rtexture_offset_percentage)
264
 
            if scn.rtexture_gain:
265
 
                texture.offset = self.compute_percentage(0,6,texture.gain,scn.rtexture_gain_percentage)
266
 
            if scn.rtexture_octaves:
267
 
                texture.octaves = self.compute_percentage(0,8,texture.octaves,scn.rtexture_octaves_percentage)      
268
 
        
269
 
        if scn.rtexture_type == 'STUCCI':
270
 
            
271
 
            self.random_texture_color(texture)
272
 
            if scn.rtexture_stucci_type:
273
 
                texture.stucci_type = random.choice(['PLASTIC', 'WALL_IN', 'WALL_OUT'])
274
 
            if scn.rtexture_noise_type:
275
 
                texture.noise_type = random.choice(['SOFT_NOISE', 'HARD_NOISE'])
276
 
            if scn.rtexture_noise_basis:
277
 
                texture.noise_basis = random.choice(['BLENDER_ORIGINAL','ORIGINAL_PERLIN','IMPROVED_PERLIN','VORONOI_F1', 'VORONOI_F2','VORONOI_F3','VORONOI_F4','VORONOI_F2_F1','BLENDER_ORIGINAL','VORONOI_CRACKLE','CELL_NOISE'])
278
 
            if scn.rtexture_noise_scale:
279
 
                texture.noise_scale = self.compute_percentage(0,2,texture.noise_scale,scn.rtexture_noise_scale_percentage)
280
 
            if scn.rtexture_turbulence:
281
 
                texture.turbulence = int(self.compute_percentage(0,1000,texture.turbulence,scn.rtexture_turbulence_percentage))    
282
 
        
283
 
        
284
 
        if scn.rtexture_type == 'VORONOI':
285
 
            
286
 
            self.random_texture_color(texture)
287
 
            if scn.rtexture_dist_metric:
288
 
                texture.distance_metric = random.choice(['DISTANCE', 'DISTANCE_SQUARED', 'MANHATTAN', 'CHEBYCHEV', 'MINKOVSKY_HALF', 'MINKOVSKY_FOUR', 'MINKOVSKY'])
289
 
            if scn.rtexture_noise_type:
290
 
                texture.color_mode = random.choice(['INTENSITY', 'POSITION', 'POSITION_OUTLINE', 'POSITION_OUTLINE_INTENSITY'])
291
 
            if scn.rtexture_exponent:
292
 
                texture.minkovsky_exponent = self.compute_percentage(0,2,texture.minkovsky_exponent ,scn.rtexture_exponent_percentage)
293
 
            if scn.rtexture_noise_intensity:
294
 
                texture.noise_intensity = self.compute_percentage(0,10,texture.noise_intensity,scn.rtexture_noise_int_percentage)
295
 
            if scn.rtexture_noise_scale:
296
 
                texture.noise_scale = self.compute_percentage(0,2,texture.noise_scale,scn.rtexture_noise_scale_percentage)
297
 
            if scn.rtexture_nabla:
298
 
                texture.nabla = self.compute_percentage(0,0.10,texture.nabla,scn.rtexture_nabla_percentage)
299
 
            if scn.rtexture_weight_1:
300
 
                texture.weight_1 = self.compute_percentage(-2,2,texture.weight_1,scn.rtexture_weight_1_percentage)
301
 
            if scn.rtexture_weight_2:
302
 
                texture.weight_2 = self.compute_percentage(-2,2,texture.weight_2,scn.rtexture_weight_2_percentage)
303
 
            if scn.rtexture_weight_3:
304
 
                texture.weight_3 = self.compute_percentage(-2,2,texture.weight_3,scn.rtexture_weight_3_percentage)
305
 
            if scn.rtexture_weight_4:
306
 
                texture.weight_4 = self.compute_percentage(-2,2,texture.weight_4,scn.rtexture_weight_4_percentage) 
307
 
        
308
 
        if scn.rtexture_type == 'WOOD':
309
 
            
310
 
            self.random_texture_color(texture)
311
 
            if scn.rtexture_wood_type:
312
 
                texture.wood_type = random.choice(['BANDS', 'RINGS', 'BANDNOISE', 'RINGNOISE'])
313
 
            if scn.rtexture_noise_basis_2:
314
 
                texture.noise_basis_2 = random.choice(['SIN', 'SAW', 'TRI'])
315
 
            if scn.rtexture_noise_type:
316
 
                texture.noise_type = random.choice(['SOFT_NOISE', 'HARD_NOISE'])
317
 
            if scn.rtexture_noise_basis:
318
 
                texture.noise_basis = random.choice(['BLENDER_ORIGINAL','ORIGINAL_PERLIN','IMPROVED_PERLIN','VORONOI_F1', 'VORONOI_F2','VORONOI_F3','VORONOI_F4','VORONOI_F2_F1','BLENDER_ORIGINAL','VORONOI_CRACKLE','CELL_NOISE'])
319
 
            if scn.rtexture_noise_scale:
320
 
                texture.noise_scale = self.compute_percentage(0,2,texture.noise_scale,scn.rtexture_noise_scale_percentage)
321
 
            if scn.rtexture_turbulence:
322
 
                texture.turbulence = int(self.compute_percentage(0,1000,texture.turbulence,scn.rtexture_turbulence_percentage))    
323
 
            if scn.rtexture_nabla:
324
 
                texture.nabla = self.compute_percentage(0,0.10,texture.nabla,scn.rtexture_nabla_percentage)
325
 
                   
326
 
        if scn.rtexture_type == 'NOISE':
327
 
            
328
 
            self.random_texture_color(texture)
329
 
          
330
 
        #self.store_to_history(texture)
331
 
          
332
 
        return texture
333
 
 
334
 
    
335
 
    # a nice multi label                        
336
 
    def multi_label(self, text, ui,text_width):
337
 
        
338
 
        for x in range(0,len(text)):
339
 
            el = textwrap.wrap(text[x], width = text_width)
340
 
            
341
 
            for y in range(0,len(el)):
342
 
                ui.label(text=el[y])
343
 
    
344
 
    def draw_gui_simple_texture_color(self,context,box):
345
 
        box.prop(context.scene,"rtexture_color", toggle = True)
346
 
        box.prop(context.scene,"rtexture_intensity", toggle = True)
347
 
        box.prop(context.scene,"rtexture_contrast", toggle = True)
348
 
        box.prop(context.scene,"rtexture_saturation", toggle = True)
349
 
       
350
 
    def draw_gui_percentage_texture_color(self,context,box):
351
 
        if context.scene.rtexture_color:
352
 
            box.prop(context.scene,"rtexture_color_percentage", slider = True)
353
 
        else:
354
 
            box.label(text="Texture Intensity disabled ")
355
 
                    
356
 
        if context.scene.rtexture_intensity:
357
 
            box.prop(context.scene,"rtexture_intensity_percentage", slider = True)
358
 
        else:
359
 
            box.label(text="Texture Intensity disabled ")
360
 
                
361
 
        if context.scene.rtexture_intensity: 
362
 
            box.prop(context.scene,"rtexture_contrast_percentage", slider = True)
363
 
        else:
364
 
            box.label(text="Texture Contrast disabled ")
365
 
                
366
 
        if context.scene.rtexture_saturation: 
367
 
            box.prop(context.scene,"rtexture_saturation_percentage", slider = True)
368
 
        else:
369
 
            box.label(text="Texture Saturation disabled ")
370
 
    
371
 
        
372
 
            
373
 
    def draw_gui(self ,context,panel,rm):
374
 
        layout = panel.layout
375
 
        row = layout.row()
376
 
        row.prop(context.scene , "rtexture_gui_mode" )
377
 
        
378
 
        # check which Gui mode the user has selected (Simple is the default one and display the appropriate gui
379
 
        
380
 
        if context.scene.rtexture_gui_mode == 'enable' :
381
 
            box = layout.box()
382
 
            box.prop(context.scene,"rtexture_type")
383
 
            
384
 
            if context.scene.rtexture_type=='BLEND':
385
 
                self.draw_gui_simple_texture_color(context,box)
386
 
                box.prop(context.scene,"rtexture_progression", toggle = True)
387
 
                box.prop(context.scene,"rtexture_axis", toggle = True)
388
 
            
389
 
            if context.scene.rtexture_type=='CLOUDS':
390
 
                self.draw_gui_simple_texture_color(context,box)
391
 
                box.prop(context.scene,"rtexture_noise_type", toggle = True)
392
 
                box.prop(context.scene,"rtexture_cloud_type", toggle = True)
393
 
                box.prop(context.scene,"rtexture_noise_basis", toggle = True)
394
 
                box.prop(context.scene,"rtexture_noise_scale", toggle = True)
395
 
                box.prop(context.scene,"rtexture_nabla", toggle = True)
396
 
                box.prop(context.scene,"rtexture_noise_depth", toggle = True)
397
 
            
398
 
            if context.scene.rtexture_type=='DISTORTED_NOISE':
399
 
                self.draw_gui_simple_texture_color(context,box)
400
 
                box.prop(context.scene,"rtexture_noise_distortion", toggle = True)
401
 
                box.prop(context.scene,"rtexture_noise_basis", toggle = True)
402
 
                box.prop(context.scene,"rtexture_distortion", toggle = True)
403
 
                box.prop(context.scene,"rtexture_nabla", toggle = True)
404
 
                box.prop(context.scene,"rtexture_noise_scale", toggle = True)   
405
 
            
406
 
            if context.scene.rtexture_type=='MAGIC':
407
 
                self.draw_gui_simple_texture_color(context,box)
408
 
                box.prop(context.scene,"rtexture_turbulence", toggle = True)
409
 
                box.prop(context.scene,"rtexture_noise_depth", toggle = True)
410
 
            
411
 
            if context.scene.rtexture_type=='MARBLE':
412
 
                self.draw_gui_simple_texture_color(context,box)
413
 
                box.prop(context.scene,"rtexture_marble_type", toggle = True)
414
 
                box.prop(context.scene,"rtexture_noise_basis_2", toggle = True)
415
 
                box.prop(context.scene,"rtexture_noise_type", toggle = True)
416
 
                box.prop(context.scene,"rtexture_noise_basis", toggle = True)
417
 
                box.prop(context.scene,"rtexture_noise_scale", toggle = True)
418
 
                box.prop(context.scene,"rtexture_turbulence", toggle = True)
419
 
                box.prop(context.scene,"rtexture_noise_depth", toggle = True)
420
 
                box.prop(context.scene,"rtexture_nabla", toggle = True)
421
 
               
422
 
            if context.scene.rtexture_type=='MUSGRAVE':
423
 
                self.draw_gui_simple_texture_color(context,box)
424
 
                box.prop(context.scene,"rtexture_musgrave_type", toggle = True)
425
 
                box.prop(context.scene,"rtexture_dimension_max", toggle = True)
426
 
                box.prop(context.scene,"rtexture_noise_intensity", toggle = True)
427
 
                box.prop(context.scene,"rtexture_lacunarity", toggle = True)
428
 
                box.prop(context.scene,"rtexture_octaves", toggle = True)
429
 
                box.prop(context.scene,"rtexture_noise_basis", toggle = True)
430
 
                box.prop(context.scene,"rtexture_noise_scale", toggle = True)
431
 
                box.prop(context.scene,"rtexture_offset", toggle = True)
432
 
                box.prop(context.scene,"rtexture_gain", toggle = True)
433
 
            
434
 
            if context.scene.rtexture_type=='STUCCI':
435
 
                self.draw_gui_simple_texture_color(context,box)
436
 
                box.prop(context.scene,"rtexture_stucci_type", toggle = True)
437
 
                box.prop(context.scene,"rtexture_noise_type", toggle = True)
438
 
                box.prop(context.scene,"rtexture_noise_basis", toggle = True)
439
 
                box.prop(context.scene,"rtexture_noise_scale", toggle = True)
440
 
                box.prop(context.scene,"rtexture_turbulence", toggle = True)
441
 
            
442
 
            if context.scene.rtexture_type=='VORONOI':
443
 
                self.draw_gui_simple_texture_color(context,box)
444
 
                box.prop(context.scene,"rtexture_metric", toggle = True)
445
 
                box.prop(context.scene,"rtexture_exponent", toggle = True)
446
 
                box.prop(context.scene,"rtexture_noise_intensity", toggle = True)
447
 
                box.prop(context.scene,"rtexture_noise_scale", toggle = True)
448
 
                box.prop(context.scene,"rtexture_nablae", toggle = True)
449
 
                box.prop(context.scene,"rtexture_weight_1", toggle = True)
450
 
                box.prop(context.scene,"rtexture_weight_2", toggle = True)
451
 
                box.prop(context.scene,"rtexture_weight_3", toggle = True)
452
 
                box.prop(context.scene,"rtexture_weight_4", toggle = True)
453
 
            
454
 
            if context.scene.rtexture_type=='WOOD':
455
 
                self.draw_gui_simple_texture_color(context,box)
456
 
                box.prop(context.scene,"rtexture_wood_type", toggle = True)
457
 
                box.prop(context.scene,"rtexture_noise_basis_2", toggle = True)
458
 
                box.prop(context.scene,"rtexture_noise_type", toggle = True)
459
 
                box.prop(context.scene,"rtexture_noise_basis", toggle = True)
460
 
                box.prop(context.scene,"rtexture_noise_scale", toggle = True)
461
 
                box.prop(context.scene,"rtexture_turbulence", toggle = True)
462
 
                box.prop(context.scene,"rtexture_nabla", toggle = True)
463
 
            
464
 
            if context.scene.rtexture_type=='NOISE':
465
 
                self.draw_gui_simple_texture_color(context,box)
466
 
               
467
 
                           
468
 
            box.prop(context.scene,"rtexture_general_percentage", slider = True)
469
 
            layout.operator("gyes.random_texture")
470
 
            
471
 
        if context.scene.rtexture_gui_mode == 'percentage' :
472
 
            box = layout.box()
473
 
            
474
 
            if context.scene.rtexture_type=='BLEND':
475
 
            
476
 
                self.draw_gui_percentage_texture_color(context,box)
477
 
                            
478
 
            if context.scene.rtexture_type=='CLOUDS':
479
 
            
480
 
                self.draw_gui_percentage_texture_color(context,box)
481
 
                
482
 
                if context.scene.rtexture_noise_scale: 
483
 
                    box.prop(context.scene,"rtexture_noise_scale_percentage", slider = True)
484
 
                else:
485
 
                    box.label(text="Texture Noise Scale disabled ")
486
 
                
487
 
                if context.scene.rtexture_nabla: 
488
 
                    box.prop(context.scene,"rtexture_nabla_percentage", slider = True)
489
 
                else:
490
 
                    box.label(text="Texture Nabla disabled ")
491
 
                    
492
 
                if context.scene.rtexture_noise_depth: 
493
 
                    box.prop(context.scene,"rtexture_noise_depth_percentage", slider = True)
494
 
                else:
495
 
                    box.label(text="Texture Noise Depth disabled ")
496
 
            
497
 
            if context.scene.rtexture_type=='DISTORTED NOISE':
498
 
            
499
 
                self.draw_gui_percentage_texture_color(context,box)
500
 
                    
501
 
                if context.scene.rtexture_distortion: 
502
 
                    box.prop(context.scene,"rtexture_distortion_percentage", slider = True)
503
 
                else:
504
 
                    box.label(text="Texture Distortion disabled ")
505
 
                
506
 
                if context.scene.rtexture_nabla: 
507
 
                    box.prop(context.scene,"rtexture_nabla_percentage", slider = True)
508
 
                else:
509
 
                    box.label(text="Texture Nabla disabled ")
510
 
                    
511
 
                if context.scene.rtexture_noise_scale: 
512
 
                    box.prop(context.scene,"rtexture_noise_scale_percentage", slider = True)
513
 
                else:
514
 
                    box.label(text="Texture Noise Scale disabled ")
515
 
            
516
 
            if context.scene.rtexture_type=='MAGIC':
517
 
            
518
 
                self.draw_gui_percentage_texture_color(context,box)
519
 
                
520
 
                if context.scene.rtexture_turbulence: 
521
 
                    box.prop(context.scene,"rtexture_turbulence_percentage", slider = True)
522
 
                else:
523
 
                    box.label(text="Texture Turbulence disabled ")
524
 
                    
525
 
                if context.scene.rtexture_noise_depth: 
526
 
                    box.prop(context.scene,"rtexture_noise_depth_percentage", slider = True)
527
 
                else:
528
 
                    box.label(text="Texture Noise Depth disabled ")
529
 
            
530
 
            if context.scene.rtexture_type=='MARBLE':
531
 
            
532
 
                self.draw_gui_percentage_texture_color(context,box)
533
 
                
534
 
                if context.scene.rtexture_noise_scale: 
535
 
                    box.prop(context.scene,"rtexture_noise_scale_percentage", slider = True)
536
 
                else:
537
 
                    box.label(text="Texture Noise Scale disabled ")
538
 
                
539
 
                if context.scene.rtexture_turbulence: 
540
 
                    box.prop(context.scene,"rtexture_turbulence_percentage", slider = True)
541
 
                else:
542
 
                    box.label(text="Texture Turbulence disabled ")
543
 
                
544
 
                if context.scene.rtexture_noise_depth: 
545
 
                    box.prop(context.scene,"rtexture_noise_depth_percentage", slider = True)
546
 
                else:
547
 
                    box.label(text="Texture Noise Depth disabled ")
548
 
                
549
 
                if context.scene.rtexture_nabla: 
550
 
                    box.prop(context.scene,"rtexture_nabla_percentage", slider = True)
551
 
                else:
552
 
                    box.label(text="Texture Nabla disabled ")
553
 
                    
554
 
               
555
 
            if context.scene.rtexture_type=='MUSGRAVE':
556
 
            
557
 
                self.draw_gui_percentage_texture_color(context,box)
558
 
                
559
 
                if context.scene.rtexture_dimension_max: 
560
 
                    box.prop(context.scene,"rtexture_dimension_percentage", slider = True)
561
 
                else:
562
 
                    box.label(text="Texture Dimension Max disabled ")
563
 
                
564
 
                if context.scene.rtexture_noise_intensity: 
565
 
                    box.prop(context.scene,"rtexture_noise_int_percentage", slider = True)
566
 
                else:
567
 
                    box.label(text="Texture Noise Intensity disabled ")
568
 
                
569
 
                if context.scene.rtexture_lacunarity: 
570
 
                    box.prop(context.scene,"rtexture_lacunarity_percentage", slider = True)
571
 
                else:
572
 
                    box.label(text="Texture Lacunarity disabled ")
573
 
                    
574
 
                if context.scene.rtexture_octaves: 
575
 
                    box.prop(context.scene,"rtexture_octaves_percentage", slider = True)
576
 
                else:
577
 
                    box.label(text="Texture Lacunarity disabled ")
578
 
                        
579
 
                if context.scene.rtexture_noise_scale: 
580
 
                    box.prop(context.scene,"rtexture_noise_scale_percentage", slider = True)
581
 
                else:
582
 
                    box.label(text="Texture Noise Scale disabled ")
583
 
                
584
 
                if context.scene.rtexture_nabla: 
585
 
                    box.prop(context.scene,"rtexture_nabla_percentage", slider = True)
586
 
                else:
587
 
                    box.label(text="Texture Nabla disabled ")
588
 
                    
589
 
                if context.scene.rtexture_offset: 
590
 
                    box.prop(context.scene,"rtexture_offset_percentage", slider = True)
591
 
                else:
592
 
                    box.label(text="Texture Offset disabled ")
593
 
                    
594
 
                if context.scene.rtexture_gain: 
595
 
                    box.prop(context.scene,"rtexture_gain_percentage", slider = True)
596
 
                else:
597
 
                    box.label(text="Texture Gain disabled ")
598
 
            
599
 
            if context.scene.rtexture_type=='STUCCI':
600
 
            
601
 
                self.draw_gui_percentage_texture_color(context,box)
602
 
                
603
 
                if context.scene.rtexture_noise_scale: 
604
 
                    box.prop(context.scene,"rtexture_noise_scale_percentage", slider = True)
605
 
                else:
606
 
                    box.label(text="Texture Noise Scale disabled ")
607
 
                
608
 
                if context.scene.rtexture_turbulence: 
609
 
                    box.prop(context.scene,"rtexture_turbulence_percentage", slider = True)
610
 
                else:
611
 
                    box.label(text="Texture Turbulence disabled ")
612
 
                    
613
 
            if context.scene.rtexture_type=='VORONOI':
614
 
            
615
 
                self.draw_gui_percentage_texture_color(context,box)
616
 
                
617
 
                if context.scene.rtexture_exponent: 
618
 
                    box.prop(context.scene,"rtexture_exponent_percentage", slider = True)
619
 
                else:
620
 
                    box.label(text="Texture Exponent disabled ")
621
 
                
622
 
                if context.scene.rtexture_noise_intensity: 
623
 
                    box.prop(context.scene,"rtexture_noise_int_percentage", slider = True)
624
 
                else:
625
 
                    box.label(text="Texture Noise Intensity disabled ")
626
 
                    
627
 
                if context.scene.rtexture_noise_scale: 
628
 
                    box.prop(context.scene,"rtexture_noise_scale_percentage", slider = True)
629
 
                else:
630
 
                    box.label(text="Texture Noise Scale disabled ")
631
 
                
632
 
                if context.scene.rtexture_nabla: 
633
 
                    box.prop(context.scene,"rtexture_nabla_percentage", slider = True)
634
 
                else:
635
 
                    box.label(text="Texture Weight 1 disabled ")
636
 
                    
637
 
                if context.scene.rtexture_weight_1: 
638
 
                    box.prop(context.scene,"rtexture_weight_1_percentage", slider = True)
639
 
                else:
640
 
                    box.label(text="Texture Weight 1 disabled ")
641
 
                    
642
 
                if context.scene.rtexture_weight_2: 
643
 
                    box.prop(context.scene,"rtexture_weight_2_percentage", slider = True)
644
 
                else:
645
 
                    box.label(text="Texture Weight 2 disabled ")
646
 
                
647
 
                if context.scene.rtexture_weight_3: 
648
 
                    box.prop(context.scene,"rtexture_weight_3_percentage", slider = True)
649
 
                else:
650
 
                    box.label(text="Texture Weight 3 disabled ")
651
 
                
652
 
                if context.scene.rtexture_weight_4: 
653
 
                    box.prop(context.scene,"rtexture_weight_4_percentage", slider = True)
654
 
                else:
655
 
                    box.label(text="Texture Weight 4 disabled ")
656
 
            
657
 
            if context.scene.rtexture_type=='WOOD':
658
 
            
659
 
                self.draw_gui_percentage_texture_color(context,box)
660
 
                
661
 
                if context.scene.rtexture_noise_scale: 
662
 
                    box.prop(context.scene,"rtexture_noise_scale_percentage", slider = True)
663
 
                else:
664
 
                    box.label(text="Texture Noise Scale disabled ")
665
 
                
666
 
                if context.scene.rtexture_turbulence: 
667
 
                    box.prop(context.scene,"rtexture_turbulence_percentage", slider = True)
668
 
                else:
669
 
                    box.label(text="Texture Turbulence disabled ")
670
 
                
671
 
                if context.scene.rtexture_nabla: 
672
 
                    box.prop(context.scene,"rtexture_nabla_percentage", slider = True)
673
 
                else:
674
 
                    box.label(text="Texture Nabla disabled ")
675
 
            
676
 
            if context.scene.rtexture_type=='NOISE':
677
 
            
678
 
                self.draw_gui_percentage_texture_color(context,box)
679
 
               
680
 
            box.prop(context.scene,"rtexture_general_percentage", slider = True)
681
 
            layout.operator("gyes.random_texture")
682
 
        
683
 
        if context.scene.rtexture_gui_mode== 'templates' : 
684
 
            box = layout.box()
685
 
            box.label(text="Not yet implemented")
686
 
                    
687
 
        if context.scene.rtexture_gui_mode== 'help' :
688
 
            box = layout.box()
689
 
            help_text=["","Copyright 2011 Kilon  ",
690
 
            "GYES - RTG",    
691
 
            "Random Material  Generator",
692
 
            "A tool that generates random materials.",
693
 
            "",
694
 
            "Simple Mode",
695
 
            "--------------------------",
696
 
            "In this mode you can do basic randomisation. Choose parameters you want to randomise by turning them on or off with clicking on them. Hit the random button when you are ready. Each time you hit the button a new random texture is generated using existing texture or if there is not one it creates a new one",
697
 
            "",
698
 
            "History",
699
 
            "--------------------------",
700
 
            "History index -> choose index",
701
 
            "( < ) -> Previous index (activate)",
702
 
            "( > ) -> Next index (activate)",
703
 
            "( |< ) -> First history index",
704
 
            "( >| ) -> Last history index",
705
 
            "Activate -> use this index as active material",
706
 
            "Animate -> Insert a keyframe in the current frame for every singly non read only material property",
707
 
            "X -> Remove a keyframe in the current frame for every singly non read only material property",
708
 
            "R -> works just like activate but instead of using the current selected index use a randomly selected one",
709
 
            "Delete -> delete this index",
710
 
            "Del start -> start deletion from here",
711
 
            "Del end -> end deletion here",
712
 
            "Restore -> restores history from the saved blend file",
713
 
            "Filter -> Text that used to filter material selection for import",
714
 
            "Import -> import materials that match the filter even partially and store them one by one in history "
715
 
            "Percentage",
716
 
            "--------------------------",
717
 
            "Percentage randomisation means that the parameter is randomised inside a range of percentage of the full range of the value. When a specific percentage is zero, the general percentage is used instead for that area. When a specific percentage is not zero then general percentage is ignored and specific percentage is used instead. If you don't want to randomise that parameter at all, in Simple Mode use the corresponding button to completely disable that parameter , the percentage slider will also be disabled in the percentage mode. Randomization takes always the current value as starting point so the next randomization will use the current randomized value. Randomization is always 50% of the specific percentage bellow the current value and 50% above . If the percentage exceeds minimum and maximum values of the full range, then it will default to minimum and maximum accordingly. "]
718
 
            w=bpy.context.scene.text_width
719
 
            box.prop(context.scene,"text_width", slider =True)
720
 
            self.multi_label(help_text,box,w) 
721
 
        
722
 
        # Display the History Gui for all modes
723
 
        
724
 
        layout.label(text="History (RMG + RTG)")
725
 
        history_box= layout.box()
726
 
        history_box.prop(context.scene, "history_index")
727
 
        row = history_box.row()
728
 
        row.operator("gyes.first")
729
 
        row.operator("gyes.previous")
730
 
        row.operator("gyes.next")
731
 
        row.operator("gyes.last")
732
 
        rm_index = context.scene.history_index
733
 
        
734
 
        if rm_index in rm.rm_history and rm.rm_history[rm_index] :
735
 
            row = history_box.row()
736
 
            a = row.split(percentage = 0.3, align = True)
737
 
            a.operator("gyes.activate")
738
 
            a.operator("gyes.animate")
739
 
            b=a.split(percentage = 0.3, align = True)
740
 
            b.operator("gyes.x")
741
 
            b.operator("gyes.random_activate")                       
742
 
        else: 
743
 
            row = history_box.row()
744
 
            a = row.split(percentage = 0.3, align = True)
745
 
            a.label(text= "Empty Index ! ")
746
 
            a.operator("gyes.animate")
747
 
            b=a.split(percentage = 0.3, align = True)
748
 
            b.operator("gyes.x")
749
 
            b.operator("gyes.random_activate")  
750
 
        
751
 
        if context.scene.history_index < len(rm.rm_history)+2:
752
 
            history_box.operator("gyes.store")
753
 
        else:
754
 
            history_box.label(text= "Not the first Empty Index")
755
 
            
756
 
        if rm_index in rm.rm_history and rm.rm_history[rm_index] :
757
 
            history_box.operator("gyes.delete")
758
 
            row2 = history_box.row()
759
 
            row2.operator("gyes.delete_start")
760
 
            row2.operator("gyes.delete_end")
761
 
            
762
 
        if hasattr(bpy.context.scene,"historybak") and bpy.context.scene.historybak!='':
763
 
            history_box.operator("gyes.restore")
764
 
        else:
765
 
            history_box.label(text="Backup not Found")
766
 
                                
767
 
rt =random_texture_class()
768
 
 
769
 
            
770
 
        
771
 
# Generate the random material button
772
 
class gyes_random_texture(bpy.types.Operator):
773
 
    
774
 
    bl_idname = "gyes.random_texture"
775
 
    bl_label = "Random Texture"
776
 
    label = bpy.props.StringProperty()
777
 
    bl_description = "Generate the random texture"
778
 
    
779
 
    def execute(self, context):
780
 
        for i in context.selected_objects :
781
 
            rt.random_texture(i.active_material)
782
 
 
783
 
        return{'FINISHED'}
784
 
 
785
 
#registration is necessary for the script to appear in the GUI
786
 
def register():
787
 
    bpy.utils.register_class(gyes_random_texture)
788
 
def unregister():
789
 
    bpy.utils.unregister_class(gyes_random_texture)
790
 
if __name__ == '__main__':
791
 
    register()