240 lines
7.4 KiB
Python
240 lines
7.4 KiB
Python
|
bl_info = {
|
||
|
'name': 'AJM Data Panel',
|
||
|
'blender': (2, 93, 0),
|
||
|
'category': 'Object'}
|
||
|
|
||
|
import bpy
|
||
|
from bpy.props import BoolProperty, FloatProperty, FloatVectorProperty, StringProperty, PointerProperty, EnumProperty
|
||
|
|
||
|
class ajm_type(bpy.types.PropertyGroup):
|
||
|
@classmethod
|
||
|
def register(self):
|
||
|
bpy.types.Object.ajm_type = PointerProperty(
|
||
|
name = "AJM - Data Type",
|
||
|
description = "AJM - Data Type",
|
||
|
type = self)
|
||
|
|
||
|
self.audio_source = BoolProperty(
|
||
|
name = "Audio Source",
|
||
|
description = "Audio source component",
|
||
|
default = False)
|
||
|
|
||
|
self.box_collider = BoolProperty(
|
||
|
name = "Box Collider",
|
||
|
description = "Box Collider component",
|
||
|
default = False)
|
||
|
|
||
|
self.camera = BoolProperty(
|
||
|
name = "Camera",
|
||
|
description = "Camera component",
|
||
|
default = False)
|
||
|
|
||
|
self.point_light = BoolProperty(
|
||
|
name = "Point Light",
|
||
|
description = "Point Light component",
|
||
|
default = False)
|
||
|
|
||
|
self.renderable = BoolProperty(
|
||
|
name = "Renderable",
|
||
|
description = "Renderable component",
|
||
|
default = False)
|
||
|
|
||
|
@classmethod
|
||
|
def unregister(self):
|
||
|
del bpy.types.Object.ajm_type
|
||
|
|
||
|
class ajm_audio_source(bpy.types.PropertyGroup):
|
||
|
@classmethod
|
||
|
def register(self):
|
||
|
bpy.types.Object.ajm_audio_source = PointerProperty(
|
||
|
name="AJM - Audio Source",
|
||
|
description="AJM - Audio Source",
|
||
|
type=self)
|
||
|
|
||
|
self.file_path = StringProperty(
|
||
|
name="File Path",
|
||
|
description="Path of the audio WAV file",
|
||
|
subtype="FILE_PATH",
|
||
|
default="")
|
||
|
|
||
|
self.volume = FloatProperty(
|
||
|
name="Volume",
|
||
|
description="Volume of the audio source",
|
||
|
min=0.0,
|
||
|
soft_min=0.0,
|
||
|
max=1.0,
|
||
|
soft_max=1.0,
|
||
|
default=1.0)
|
||
|
|
||
|
self.type = EnumProperty(
|
||
|
name="Type",
|
||
|
description="Type of audio source",
|
||
|
items={
|
||
|
('null', 'Null', 'Null', 0),
|
||
|
('sfx', 'SFX', 'One-shot SFX', 1),
|
||
|
('music', 'Music', 'Looping music', 2)},
|
||
|
default=0)
|
||
|
|
||
|
@classmethod
|
||
|
def unregister(self):
|
||
|
del bpy.types.Object.ajm_audio_source
|
||
|
|
||
|
class ajm_box_collider(bpy.types.PropertyGroup):
|
||
|
def change_extents(self, context):
|
||
|
context.active_object.scale.x = self.extents.x
|
||
|
context.active_object.scale.y = self.extents.y
|
||
|
context.active_object.scale.z = self.extents.z
|
||
|
return None
|
||
|
|
||
|
@classmethod
|
||
|
def register(self):
|
||
|
bpy.types.Object.ajm_box_collider = PointerProperty(
|
||
|
name="AJM - Box Collider",
|
||
|
description="AJM - Box Collider",
|
||
|
type=self)
|
||
|
|
||
|
self.extents = FloatVectorProperty(
|
||
|
name="Extents",
|
||
|
description="Extents of the box",
|
||
|
subtype="XYZ",
|
||
|
min=0.0,
|
||
|
soft_min=0.0,
|
||
|
default=[1.0,1.0,1.0],
|
||
|
update=self.change_extents)
|
||
|
|
||
|
@classmethod
|
||
|
def unregister(self):
|
||
|
del bpy.types.Object.ajm_box_collider
|
||
|
|
||
|
class ajm_camera(bpy.types.PropertyGroup):
|
||
|
@classmethod
|
||
|
def register(self):
|
||
|
bpy.types.Object.ajm_camera = PointerProperty(
|
||
|
name="AJM - Camera",
|
||
|
description="AJM - Camera",
|
||
|
type=self)
|
||
|
|
||
|
@classmethod
|
||
|
def unregister(self):
|
||
|
del bpy.types.Object.ajm_camera
|
||
|
|
||
|
class ajm_point_light(bpy.types.PropertyGroup):
|
||
|
def change_radius(self, context):
|
||
|
context.active_object.empty_display_size = self.radius
|
||
|
return None
|
||
|
|
||
|
@classmethod
|
||
|
def register(self):
|
||
|
bpy.types.Object.ajm_point_light = PointerProperty(
|
||
|
name="AJM - Point Light",
|
||
|
description="AJM - Point Light",
|
||
|
type=self)
|
||
|
|
||
|
self.color = FloatVectorProperty(
|
||
|
name="Color",
|
||
|
description="Color of the light",
|
||
|
subtype="COLOR",
|
||
|
min=0.0,
|
||
|
soft_min=0.0,
|
||
|
max=1.0,
|
||
|
soft_max=1.0,
|
||
|
default=[1.0,1.0,1.0])
|
||
|
|
||
|
self.intensity = FloatProperty(
|
||
|
name="Intensity",
|
||
|
description="Intensity of the light",
|
||
|
min=0.0,
|
||
|
soft_min=0.0,
|
||
|
default=1.0)
|
||
|
|
||
|
self.radius = FloatProperty(
|
||
|
name="Radius",
|
||
|
description="Effective radius of the light",
|
||
|
min=0.0,
|
||
|
soft_min=0.0,
|
||
|
default=1.0,
|
||
|
update=self.change_radius)
|
||
|
|
||
|
@classmethod
|
||
|
def unregister(self):
|
||
|
del bpy.types.Object.ajm_point_light
|
||
|
|
||
|
class ajm_renderable(bpy.types.PropertyGroup):
|
||
|
@classmethod
|
||
|
def register(self):
|
||
|
bpy.types.Object.ajm_renderable = PointerProperty(
|
||
|
name="AJM - Renderable",
|
||
|
description="AJM - Renderable",
|
||
|
type=self)
|
||
|
|
||
|
@classmethod
|
||
|
def unregister(self):
|
||
|
del bpy.types.Object.ajm_renderable
|
||
|
|
||
|
class ajm_panel(bpy.types.Panel):
|
||
|
bl_label = "AJM Panel"
|
||
|
bl_idname = "OBJECT_PT_AJM_Panel"
|
||
|
|
||
|
bl_space_type = "PROPERTIES"
|
||
|
bl_region_type = "WINDOW"
|
||
|
bl_context = "object"
|
||
|
|
||
|
def draw(self, context):
|
||
|
column = self.layout.column()
|
||
|
|
||
|
column.prop(context.active_object.ajm_type, "audio_source")
|
||
|
if context.active_object.ajm_type.audio_source:
|
||
|
box = column.box()
|
||
|
row = box.row()
|
||
|
row.prop(context.active_object.ajm_audio_source, "file_path")
|
||
|
row = box.row()
|
||
|
row.prop(context.active_object.ajm_audio_source, "volume")
|
||
|
row = box.row()
|
||
|
row.prop(context.active_object.ajm_audio_source, "type")
|
||
|
|
||
|
column.prop(context.active_object.ajm_type, "box_collider")
|
||
|
if context.active_object.ajm_type.box_collider:
|
||
|
box = column.box()
|
||
|
row = box.row()
|
||
|
row.prop(context.active_object.ajm_box_collider, "extents")
|
||
|
|
||
|
column.prop(context.active_object.ajm_type, "camera")
|
||
|
if context.active_object.ajm_type.camera:
|
||
|
box = column.box()
|
||
|
|
||
|
column.prop(context.active_object.ajm_type, "point_light")
|
||
|
if context.active_object.ajm_type.point_light:
|
||
|
box = column.box()
|
||
|
row = box.row()
|
||
|
row.prop(context.active_object.ajm_point_light, "color")
|
||
|
row = box.row()
|
||
|
row.prop(context.active_object.ajm_point_light, "intensity")
|
||
|
row = box.row()
|
||
|
row.prop(context.active_object.ajm_point_light, "radius")
|
||
|
|
||
|
column.prop(context.active_object.ajm_type, "renderable")
|
||
|
if context.active_object.ajm_type.renderable:
|
||
|
box = column.box()
|
||
|
|
||
|
def register():
|
||
|
bpy.utils.register_class(ajm_panel)
|
||
|
bpy.utils.register_class(ajm_type)
|
||
|
bpy.utils.register_class(ajm_audio_source)
|
||
|
bpy.utils.register_class(ajm_box_collider)
|
||
|
bpy.utils.register_class(ajm_camera)
|
||
|
bpy.utils.register_class(ajm_point_light)
|
||
|
bpy.utils.register_class(ajm_renderable)
|
||
|
|
||
|
def unregister():
|
||
|
bpy.utils.unregister_class(ajm_panel)
|
||
|
bpy.utils.unregister_class(ajm_type)
|
||
|
bpy.utils.unregister_class(ajm_audio_source)
|
||
|
bpy.utils.unregister_class(ajm_box_collider)
|
||
|
bpy.utils.unregister_class(ajm_camera)
|
||
|
bpy.utils.unregister_class(ajm_point_light)
|
||
|
bpy.utils.unregister_class(ajm_renderable)
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
register()
|
||
|
|