Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(light): add utility functions for managing light objects #1173

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion blenderproc/python/types/LightUtility.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
""" This class allows the creation and management of lights in the scene. """

from typing import Union, Optional
from typing import Union, Optional, List

import numpy as np
import bpy
Expand Down Expand Up @@ -243,3 +243,28 @@ def get_type(self, frame: Optional[int] = None) -> str:
"""
with KeyFrame(frame):
return self.blender_obj.data.type


def get_all_blender_light_objects() -> List[bpy.types.Object]:
""" Retrieves all light objects in the current Blender scene.

:return: A list of all light objects in the current scene.
"""
return [obj for obj in bpy.context.scene.objects if obj.type == 'LIGHT']


def convert_to_lights(blender_objects: List[bpy.types.Object]) -> List[Light]:
""" Converts a list of Blender light objects to a list of BlenderProc light objects.

:param blender_objects: A list of Blender light objects.
:return: A list of BlenderProc light objects.
"""
return [Light(blender_obj=obj) for obj in blender_objects]


def get_all_light_objects() -> List[Light]:
""" Retrieves all light objects in the current Blender scene and converts them to BlenderProc light objects.

:return: A list of all light objects in the current scene.
"""
return convert_to_lights(get_all_blender_light_objects())