From 3e85ec432ef050563d75488eca3049b77497153d Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Mon, 1 Aug 2011 11:44:20 +0000 Subject: 3D Audio GSoC: Adds new speaker object type. Notes: * Needs some nice icons * Quickily review by Joshua Leung (5 mins) * Properties UI updated (with help of Thomans Dinges) * Speakers have their own theme color * No real audio functionality yet. * Minor bug regarding lamps/lattices fixed in interface_templates.c I personality tested: * Creation, Deletion, Duplication * Saving, Loading * Library linking (incl. make local) * Tracking * Dope Sheet, Outliner * Animation * Drawing (incl. Theme) --- release/scripts/modules/bpy_types.py | 2 +- release/scripts/startup/bl_ui/__init__.py | 1 + .../startup/bl_ui/properties_data_speaker.py | 129 +++++++++++++++++++++ release/scripts/startup/bl_ui/properties_scene.py | 55 ++------- release/scripts/startup/bl_ui/space_dopesheet.py | 2 + release/scripts/startup/bl_ui/space_info.py | 3 + 6 files changed, 145 insertions(+), 47 deletions(-) create mode 100644 release/scripts/startup/bl_ui/properties_data_speaker.py (limited to 'release/scripts') diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index 056899d7bda..75b199dcc26 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -57,7 +57,7 @@ class Library(bpy_types.ID): "curves", "grease_pencil", "groups", "images", \ "lamps", "lattices", "materials", "metaballs", \ "meshes", "node_groups", "objects", "scenes", \ - "sounds", "textures", "texts", "fonts", "worlds" + "sounds", "speakers", "textures", "texts", "fonts", "worlds" return tuple(id_block for attr in attr_links for id_block in getattr(bpy.data, attr) if id_block.library == self) diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py index bf63c6071b9..5fab3b7fd38 100644 --- a/release/scripts/startup/bl_ui/__init__.py +++ b/release/scripts/startup/bl_ui/__init__.py @@ -36,6 +36,7 @@ _modules = ( "properties_data_mesh", "properties_data_metaball", "properties_data_modifier", + "properties_data_speaker", "properties_game", "properties_material", "properties_object_constraint", diff --git a/release/scripts/startup/bl_ui/properties_data_speaker.py b/release/scripts/startup/bl_ui/properties_data_speaker.py new file mode 100644 index 00000000000..45f2fa5d1f7 --- /dev/null +++ b/release/scripts/startup/bl_ui/properties_data_speaker.py @@ -0,0 +1,129 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +# +import bpy +from rna_prop_ui import PropertyPanel + + +class DataButtonsPanel(): + bl_space_type = 'PROPERTIES' + bl_region_type = 'WINDOW' + bl_context = "data" + + @classmethod + def poll(cls, context): + engine = context.scene.render.engine + return context.speaker and (engine in cls.COMPAT_ENGINES) + + +class DATA_PT_context_speaker(DataButtonsPanel, bpy.types.Panel): + bl_label = "" + bl_options = {'HIDE_HEADER'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} + + def draw(self, context): + layout = self.layout + + ob = context.object + speaker = context.speaker + space = context.space_data + + split = layout.split(percentage=0.65) + + if ob: + split.template_ID(ob, "data") + elif speaker: + split.template_ID(space, "pin_id") + + +class DATA_PT_speaker(DataButtonsPanel, bpy.types.Panel): + bl_label = "Sound" + COMPAT_ENGINES = {'BLENDER_RENDER'} + + def draw(self, context): + layout = self.layout + + speaker = context.speaker + + split = layout.split(percentage=0.75) + + split.template_ID(speaker, "sound", open="sound.open") + split.prop(speaker, "muted") + + split = layout.split() + + row = split.row() + + row.prop(speaker, "volume") + row.prop(speaker, "pitch") + + +class DATA_PT_distance(DataButtonsPanel, bpy.types.Panel): + bl_label = "Distance" + COMPAT_ENGINES = {'BLENDER_RENDER'} + + def draw(self, context): + layout = self.layout + + speaker = context.speaker + + split = layout.split() + col = split.column() + + col.label("Volume:") + col.prop(speaker, "volume_min", text="Minimum") + col.prop(speaker, "volume_max", text="Maximum") + col.prop(speaker, "attenuation") + + col = split.column() + + col.label("Distance:") + col.prop(speaker, "distance_max", text="Maximum") + col.prop(speaker, "distance_reference", text="Reference") + + +class DATA_PT_cone(DataButtonsPanel, bpy.types.Panel): + bl_label = "Cone" + COMPAT_ENGINES = {'BLENDER_RENDER'} + + def draw(self, context): + layout = self.layout + + speaker = context.speaker + + split = layout.split() + col = split.column() + + col.label("Angle:") + col.prop(speaker, "cone_angle_outer", text="Outer") + col.prop(speaker, "cone_angle_inner", text="Inner") + + col = split.column() + + col.label("Volume:") + col.prop(speaker, "cone_volume_outer", text="Outer") + + +class DATA_PT_custom_props_speaker(DataButtonsPanel, PropertyPanel, bpy.types.Panel): + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} + _context_path = "object.data" + _property_type = bpy.types.Speaker + +if __name__ == "__main__": # only for live edit. + bpy.utils.register_module(__name__) diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py index aec9d88511c..a9310fcc532 100644 --- a/release/scripts/startup/bl_ui/properties_scene.py +++ b/release/scripts/startup/bl_ui/properties_scene.py @@ -51,22 +51,24 @@ class SCENE_PT_audio(SceneButtonsPanel, bpy.types.Panel): layout = self.layout scene = context.scene rd = context.scene.render - - layout.prop(scene, "audio_distance_model") - - layout.prop(scene, "audio_doppler_speed", text="Speed") - layout.prop(scene, "audio_doppler_factor") layout.prop(scene, "audio_volume") - layout.operator("sound.update_animation_flags") layout.operator("sound.bake_animation") split = layout.split() col = split.column() - col.prop(rd, "ffmpeg_audio_mixrate", text="Rate") + + col.label("Listener:") + col.prop(scene, "audio_distance_model", text="") + col.prop(scene, "audio_doppler_speed", text="Speed") + col.prop(scene, "audio_doppler_factor", text="Doppler") + col = split.column() + + col.label("Format:") col.prop(rd, "ffmpeg_audio_channels", text="") + col.prop(rd, "ffmpeg_audio_mixrate", text="Rate") class SCENE_PT_unit(SceneButtonsPanel, bpy.types.Panel): @@ -102,7 +104,6 @@ class SCENE_PT_keying_sets(SceneButtonsPanel, bpy.types.Panel): col = row.column(align=True) col.operator("anim.keying_set_add", icon='ZOOMIN', text="") col.operator("anim.keying_set_remove", icon='ZOOMOUT', text="") - col.menu("SCENE_MT_keying_set_specials", icon='DOWNARROW_HLT', text="") ks = scene.keying_sets.active if ks and ks.is_path_absolute: @@ -121,14 +122,6 @@ class SCENE_PT_keying_sets(SceneButtonsPanel, bpy.types.Panel): col.prop(ks, "bl_options") -class SCENE_MT_keying_set_specials(bpy.types.Menu): - bl_label = "Keying Set Specials" - - def draw(self, context): - layout = self.layout - - layout.operator("anim.keying_set_import", text="Import From File") - class SCENE_PT_keying_set_paths(SceneButtonsPanel, bpy.types.Panel): bl_label = "Active Keying Set" @@ -233,36 +226,6 @@ class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, bpy.types.Panel): # XXX, move operator to op/ dir -class ANIM_OT_keying_set_import(bpy.types.Operator): - "Import Keying Set from a python script." - bl_idname = "anim.keying_set_import" - bl_label = "Import Keying Set from File" - - filepath = bpy.props.StringProperty(name="File Path", description="Filepath to read file from.") - filter_folder = bpy.props.BoolProperty(name="Filter folders", description="", default=True, options={'HIDDEN'}) - filter_text = bpy.props.BoolProperty(name="Filter text", description="", default=True, options={'HIDDEN'}) - filter_python = bpy.props.BoolProperty(name="Filter python", description="", default=True, options={'HIDDEN'}) - - def execute(self, context): - if not self.filepath: - raise Exception("Filepath not set.") - - f = open(self.filepath, "r") - if not f: - raise Exception("Could not open file.") - - # lazy way of loading and running this file... - exec(compile(f.read(), self.filepath, 'exec')) - - f.close() - - return {'FINISHED'} - - def invoke(self, context, event): - wm = context.window_manager - wm.fileselect_add(self) - return {'RUNNING_MODAL'} - class ANIM_OT_keying_set_export(bpy.types.Operator): "Export Keying Set to a python script." bl_idname = "anim.keying_set_export" diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py index b4f196dab74..646a085f3f7 100644 --- a/release/scripts/startup/bl_ui/space_dopesheet.py +++ b/release/scripts/startup/bl_ui/space_dopesheet.py @@ -86,6 +86,8 @@ def dopesheet_filter(layout, context, genericFiltersOnly=False): row.prop(dopesheet, "show_armatures", text="") if bpy.data.particles: row.prop(dopesheet, "show_particles", text="") + if bpy.data.speakers: + row.prop(dopesheet, "show_speakers", text="") ####################################### diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py index f66cee7f431..eba2581252a 100644 --- a/release/scripts/startup/bl_ui/space_info.py +++ b/release/scripts/startup/bl_ui/space_info.py @@ -292,6 +292,9 @@ class INFO_MT_add(bpy.types.Menu): layout.operator_menu_enum("object.lamp_add", "type", text="Lamp", icon='OUTLINER_OB_LAMP') layout.separator() + layout.operator("object.speaker_add", text="Speaker", icon='SPEAKER') + layout.separator() + layout.operator_menu_enum("object.effector_add", "type", text="Force Field", icon='OUTLINER_OB_EMPTY') layout.separator() -- cgit v1.2.3