1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
20 # meta-androcto, Bill Currie, Jorge Hernandez - Melenedez Jacob Morris, Oscurart #
21 # Rebellion, Antonis Karvelas, Eleanor Howick, lijenstina, Daniel Schalla, Domlysz #
22 # Unnikrishnan(kodemax), Florian Meyer, Omar ahmed, Brian Hinton (Nichod), liero #
23 # Atom, Dannyboy, Mano-Wii, Kursad Karatas, teldredge, Phil Cote #
26 "name": "Add Advanced Objects",
27 "author": "Meta Androcto",
29 "blender": (2, 78, 0),
30 "location": "View3D > Add ",
31 "description": "Add Object & Camera extras",
33 "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6"
34 "/Py/Scripts/Object/Add_Advanced",
40 importlib
.reload(add_light_template
)
41 importlib
.reload(scene_objects_bi
)
42 importlib
.reload(scene_objects_cycles
)
43 importlib
.reload(scene_texture_render
)
44 importlib
.reload(trilighting
)
45 importlib
.reload(pixelate_3d
)
46 importlib
.reload(object_add_chain
)
47 importlib
.reload(oscurart_chain_maker
)
48 importlib
.reload(circle_array
)
49 importlib
.reload(copy2
)
50 importlib
.reload(make_struts
)
51 importlib
.reload(random_box_structure
)
52 importlib
.reload(cubester
)
53 importlib
.reload(rope_alpha
)
54 importlib
.reload(add_mesh_aggregate
)
55 importlib
.reload(arrange_on_curve
)
56 importlib
.reload(mesh_easylattice
)
60 from . import add_light_template
61 from . import scene_objects_bi
62 from . import scene_objects_cycles
63 from . import scene_texture_render
64 from . import trilighting
65 from . import pixelate_3d
66 from . import object_add_chain
67 from . import oscurart_chain_maker
68 from . import circle_array
70 from . import make_struts
71 from . import random_box_structure
72 from . import cubester
73 from . import rope_alpha
74 from . import add_mesh_aggregate
75 from . import arrange_on_curve
76 from . import mesh_easylattice
80 from bpy
.types
import (
85 from bpy
.props
import (
95 # Define the "Scenes" menu
96 class INFO_MT_scene_elements_add(Menu
):
97 bl_idname
= "INFO_MT_scene_elements"
98 bl_label
= "Test Scenes"
100 def draw(self
, context
):
102 layout
.operator_context
= 'INVOKE_REGION_WIN'
103 layout
.operator("bi.add_scene",
104 text
="Scene_Objects_BI")
105 layout
.operator("objects_cycles.add_scene",
106 text
="Scene_Objects_Cycles")
107 layout
.operator("objects_texture.add_scene",
108 text
="Scene_Textures_Cycles")
111 # Define the "Lights" menu
112 class INFO_MT_mesh_lamps_add(Menu
):
113 bl_idname
= "INFO_MT_scene_lamps"
114 bl_label
= "Lighting Sets"
116 def draw(self
, context
):
118 layout
.operator_context
= 'INVOKE_REGION_WIN'
119 layout
.operator("object.add_light_template",
120 text
="Add Light Template")
121 layout
.operator("object.trilighting",
122 text
="Add Tri Lighting")
125 # Define the "Chains" menu
126 class INFO_MT_mesh_chain_add(Menu
):
127 bl_idname
= "INFO_MT_mesh_chain"
130 def draw(self
, context
):
132 layout
.operator_context
= 'INVOKE_REGION_WIN'
133 layout
.operator("mesh.primitive_chain_add", icon
="LINKED")
134 layout
.operator("mesh.primitive_oscurart_chain_add", icon
="LINKED")
137 # Define the "Array" Menu
138 class INFO_MT_array_mods_add(Menu
):
139 bl_idname
= "INFO_MT_array_mods"
140 bl_label
= "Array Mods"
142 def draw(self
, context
):
144 layout
.operator_context
= 'INVOKE_REGION_WIN'
146 layout
.menu("INFO_MT_mesh_chain", icon
="LINKED")
148 layout
.operator("objects.circle_array_operator",
149 text
="Circle Array", icon
="MOD_ARRAY")
150 layout
.operator("object.agregate_mesh",
151 text
="Aggregate Mesh", icon
="MOD_ARRAY")
152 layout
.operator("mesh.copy2",
153 text
="Copy To Vert/Edge", icon
="MOD_ARRAY")
156 # Define the "Blocks" Menu
157 class INFO_MT_quick_blocks_add(Menu
):
158 bl_idname
= "INFO_MT_quick_tools"
159 bl_label
= "Block Tools"
161 def draw(self
, context
):
163 layout
.operator_context
= 'INVOKE_REGION_WIN'
165 layout
.operator("object.pixelate", icon
="MESH_GRID")
166 layout
.operator("mesh.generate_struts",
167 text
="Struts", icon
="GRID")
168 layout
.operator("object.make_structure",
169 text
="Random Boxes", icon
="SEQ_SEQUENCER")
170 layout
.operator("object.easy_lattice",
171 text
="Easy Lattice", icon
="MOD_LATTICE")
174 # Define the "Phsysics Tools" Menu
175 class INFO_MT_Physics_tools_add(Menu
):
176 bl_idname
= "INFO_MT_physics_tools"
177 bl_label
= "Physics Tools"
179 def draw(self
, context
):
181 layout
.operator_context
= 'INVOKE_REGION_WIN'
183 layout
.operator("ball.rope",
184 text
="Wrecking Ball", icon
='PHYSICS')
185 layout
.operator("clot.rope",
186 text
="Cloth Rope", icon
='PHYSICS')
189 # Define "Extras" menu
190 def menu(self
, context
):
192 layout
.operator_context
= 'INVOKE_REGION_WIN'
193 self
.layout
.separator()
194 self
.layout
.menu("INFO_MT_scene_elements", icon
="SCENE_DATA")
195 self
.layout
.menu("INFO_MT_scene_lamps", icon
="LAMP_SPOT")
196 self
.layout
.separator()
197 self
.layout
.menu("INFO_MT_array_mods", icon
="MOD_ARRAY")
198 self
.layout
.menu("INFO_MT_quick_tools", icon
="MOD_BUILD")
199 self
.layout
.menu("INFO_MT_physics_tools", icon
="PHYSICS")
203 class AdvancedObjPreferences(AddonPreferences
):
206 show_menu_list
= BoolProperty(
208 description
="Show/Hide the Add Menu items",
211 show_panel_list
= BoolProperty(
213 description
="Show/Hide the Panel items",
217 def draw(self
, context
):
220 icon_1
= "TRIA_RIGHT" if not self
.show_menu_list
else "TRIA_DOWN"
222 box
.prop(self
, "show_menu_list", emboss
=False, icon
=icon_1
)
224 if self
.show_menu_list
:
225 box
.label(text
="Items located in the Add Menu (default shortcut Ctrl + A):",
227 box
.label(text
="Test Scenes:", icon
="LAYER_ACTIVE")
228 box
.label(text
="Scene Objects BI, Scene Objects Cycles, Scene Textures Cycles",
230 box
.label(text
="Lighting Sets:", icon
="LAYER_ACTIVE")
231 box
.label(text
="Add Light Template, Add Tri Lighting", icon
="LAYER_USED")
232 box
.label(text
="Array Mods:", icon
="LAYER_ACTIVE")
233 box
.label(text
="Circle Array, Chains submenu, Copy Vert/Edge and Aggregate Mesh",
235 box
.label(text
="Chains Submenu - Add Chain, Chain to Bones",
237 box
.label(text
="Block Tools:", icon
="LAYER_ACTIVE")
238 box
.label(text
="Pixelate Object, Struts, Random Boxes, Easy Lattice",
240 box
.label(text
="Physics Tools:", icon
="LAYER_ACTIVE")
241 box
.label(text
="Wrecking Ball and Cloth Rope", icon
="LAYER_USED")
243 icon_2
= "TRIA_RIGHT" if not self
.show_panel_list
else "TRIA_DOWN"
245 box
.prop(self
, "show_panel_list", emboss
=False, icon
=icon_2
)
247 if self
.show_panel_list
:
248 box
.label(text
="Panels located in 3D View Tools Region > Create",
250 box
.label(text
="CubeSter", icon
="LAYER_USED")
251 box
.label(text
="Arrange on Curve (Shown if an Active Curve Object is it the 3D View)",
255 # Cubester update functions
256 def find_audio_length(self
, context
):
257 adv_obj
= context
.scene
.advanced_objects
258 audio_file
= adv_obj
.cubester_audio_path
262 # confirm that strip hasn't been loaded yet
263 get_sequence
= getattr(context
.scene
.sequence_editor
, "sequences_all", [])
264 for strip
in get_sequence
:
265 if type(strip
) == bpy
.types
.SoundSequence
and strip
.sound
.filepath
== audio_file
:
266 length
= strip
.frame_final_duration
271 area
.type = "SEQUENCE_EDITOR"
273 bpy
.ops
.sequencer
.sound_strip_add(filepath
=audio_file
)
274 adv_obj
.cubester_check_audio
= True
275 except Exception as e
:
276 print("\n[Add Advanced Objects]\n Function: "
277 "find_audio_length\n {}\n".format(e
))
278 adv_obj
.cubester_check_audio
= False
284 for strip
in context
.scene
.sequence_editor
.sequences_all
:
285 if type(strip
) == bpy
.types
.SoundSequence
and strip
.sound
.filepath
== audio_file
:
286 adv_obj
.cubester_check_audio
= True
287 length
= strip
.frame_final_duration
289 adv_obj
.cubester_audio_file_length
= length
292 # load image if possible
293 def adjust_selected_image(self
, context
):
294 scene
= context
.scene
.advanced_objects
296 image
= bpy
.data
.images
.load(scene
.cubester_load_image
)
297 scene
.cubester_image
= image
.name
298 except Exception as e
:
299 print("\n[Add Advanced Objects]\n Function: "
300 "adjust_selected_image\n {}\n".format(e
))
303 # load color image if possible
304 def adjust_selected_color_image(self
, context
):
305 scene
= context
.scene
.advanced_objects
307 image
= bpy
.data
.images
.load(scene
.cubester_load_color_image
)
308 scene
.cubester_color_image
= image
.name
309 except Exception as e
:
310 print("\nAdd Advanced Objects]\n Function: "
311 "adjust_selected_color_image\n {}\n".format(e
))
314 class AdvancedObjProperties(PropertyGroup
):
317 cubester_check_audio
= BoolProperty(
321 cubester_audio_image
= EnumProperty(
323 items
=(("image", "Image",
324 "Use an Image as input for generating Geometry", "IMAGE_COL", 0),
326 "Use a Sound Strip as input for generating Geometry", "FILE_SOUND", 1))
328 cubester_audio_file_length
= IntProperty(
332 cubester_audio_path
= StringProperty(
336 update
=find_audio_length
338 cubester_audio_min_freq
= IntProperty(
339 name
="Minimum Frequency",
343 cubester_audio_max_freq
= IntProperty(
344 name
="Maximum Frequency",
348 cubester_audio_offset_type
= EnumProperty(
350 items
=(("freq", "Frequency Offset", ""),
351 ("frame", "Frame Offset", "")),
352 description
="Type of offset per row of mesh"
354 cubester_audio_frame_offset
= IntProperty(
359 cubester_audio_block_layout
= EnumProperty(
361 items
=(("rectangle", "Rectangular", ""),
362 ("radial", "Radial", ""))
364 cubester_audio_width_blocks
= IntProperty(
365 name
="Width Block Count",
369 cubester_audio_length_blocks
= IntProperty(
370 name
="Length Block Count",
375 cubester_load_type
= EnumProperty(
376 name
="Image Input Type",
377 items
=(("single", "Single Image", ""),
378 ("multiple", "Image Sequence", ""))
380 cubester_image
= StringProperty(
384 cubester_load_image
= StringProperty(
388 update
=adjust_selected_image
390 cubester_skip_images
= IntProperty(
394 description
="Step from image to image by this number"
396 cubester_max_images
= IntProperty(
397 name
="Max Number Of Images",
400 description
="Maximum number of images to be used"
402 cubester_frame_step
= IntProperty(
403 name
="Frame Step Size",
406 description
="The number of frames each picture is used"
408 cubester_skip_pixels
= IntProperty(
409 name
="Skip # Pixels",
412 description
="Skip this number of pixels before placing the next"
414 cubester_mesh_style
= EnumProperty(
416 items
=(("blocks", "Blocks", ""),
417 ("plane", "Plane", "")),
418 description
="Compose mesh of multiple blocks or of a single plane"
420 cubester_block_style
= EnumProperty(
422 items
=(("size", "Vary Size", ""),
423 ("position", "Vary Position", "")),
424 description
="Vary Z-size of block, or vary Z-position"
426 cubester_height_scale
= FloatProperty(
432 cubester_invert
= BoolProperty(
433 name
="Invert Height",
436 # general adjustments
437 cubester_size_per_hundred_pixels
= FloatProperty(
438 name
="Size Per 100 Blocks/Points",
443 # material based stuff
444 cubester_materials
= EnumProperty(
446 items
=(("vertex", "Vertex Colors", ""),
447 ("image", "Image", "")),
448 description
="Color with vertex colors, or uv unwrap and use an image"
450 cubester_use_image_color
= BoolProperty(
451 name
="Use Original Image Colors'?",
453 description
="Use original image colors, or replace with an another one"
455 cubester_color_image
= StringProperty(
459 cubester_load_color_image
= StringProperty(
461 name
="Load Color Image",
463 update
=adjust_selected_color_image
465 cubester_vertex_colors
= {}
467 cubester_advanced
= BoolProperty(
468 name
="Advanced Options",
471 cubester_random_weights
= BoolProperty(
472 name
="Random Weights",
475 cubester_weight_r
= FloatProperty(
481 cubester_weight_g
= FloatProperty(
487 cubester_weight_b
= FloatProperty(
493 cubester_weight_a
= FloatProperty(
501 arrange_c_use_selected
= BoolProperty(
503 description
="Use the selected objects to duplicate",
506 arrange_c_obj_arranjar
= StringProperty(
509 arrange_c_select_type
= EnumProperty(
511 description
="Select object or group",
513 ('O', "Object", "Make duplicates of a specific object"),
514 ('G', "Group", "Make duplicates of the objects in a group"),
521 bpy
.utils
.register_module(__name__
)
523 bpy
.types
.Scene
.advanced_objects
= PointerProperty(
524 type=AdvancedObjProperties
527 # Add "Extras" menu to the "Add" menu
528 bpy
.types
.INFO_MT_add
.append(menu
)
530 bpy
.types
.VIEW3D_MT_AddMenu
.append(menu
)
536 # Remove "Extras" menu from the "Add" menu.
537 bpy
.types
.INFO_MT_add
.remove(menu
)
539 bpy
.types
.VIEW3D_MT_AddMenu
.remove(menu
)
543 bpy
.utils
.unregister_module(__name__
)
544 del bpy
.types
.Scene
.advanced_objects
546 # cleanup Easy Lattice Scene Property if it was created
547 if hasattr(bpy
.types
.Scene
, "activelatticeobject"):
548 del bpy
.types
.Scene
.activelatticeobject
551 if __name__
== "__main__":