Esempio n. 1
0
    def set_type(self, type: str, frame: int = None):
        """ Sets the type of the light.

        :param type: The type to set, can be one of [POINT, SUN, SPOT, AREA].
        :param frame: The frame number which the value should be set to. If None is given, the current frame number is used.
        """
        self.blender_obj.data.type = type
        Utility.insert_keyframe(self.blender_obj.data, "type", frame)
Esempio n. 2
0
    def set_distance(self, distance: float, frame: int = None):
        """ Sets the falloff distance of the light = point where light is half the original intensity.

        :param distance: The falloff distance to set.
        :param frame: The frame number which the value should be set to. If None is given, the current frame number is used.
        """
        self.blender_obj.data.distance = distance
        Utility.insert_keyframe(self.blender_obj.data, "distance", frame)
Esempio n. 3
0
    def set_color(self, color: Union[list, Color], frame: int = None):
        """ Sets the color of the light.

        :param color: The rgb color to set.
        :param frame: The frame number which the value should be set to. If None is given, the current frame number is used.
        """
        self.blender_obj.data.color = color
        Utility.insert_keyframe(self.blender_obj.data, "color", frame)
Esempio n. 4
0
    def set_energy(self, energy: float, frame: int = None):
        """ Sets the energy of the light.

        :param energy: The energy to set. If the type is SUN this value is interpreted as Watt per square meter, otherwise it is interpreted as Watt.
        :param frame: The frame number which the value should be set to. If None is given, the current frame number is used.
        """
        self.blender_obj.data.energy = energy
        Utility.insert_keyframe(self.blender_obj.data, "energy", frame)
Esempio n. 5
0
    def set_scale(self,
                  scale: Union[list, np.ndarray, Vector],
                  frame: int = None):
        """ Sets the scale of the entity along all three axes.

        :param scale: The scale to set.
        :param frame: The frame number which the value should be set to. If None is given, the current frame number is used.
        """
        self.blender_obj.scale = scale
        Utility.insert_keyframe(self.blender_obj, "scale", frame)
Esempio n. 6
0
    def set_rotation_euler(self,
                           rotation_euler: Union[list, Euler, np.ndarray],
                           frame: int = None):
        """ Sets the rotation of the entity in euler angles.

        :param rotation_euler: The euler angles to set.
        :param frame: The frame number which the value should be set to. If None is given, the current frame number is used.
        """
        self.blender_obj.rotation_euler = rotation_euler
        Utility.insert_keyframe(self.blender_obj, "rotation_euler", frame)
Esempio n. 7
0
    def set_location(self,
                     location: Union[list, Vector, np.ndarray],
                     frame: int = None):
        """ Sets the location of the entity in 3D world coordinates.

        :param location: The location to set.
        :param frame: The frame number which the value should be set to. If None is given, the current frame number is used.
        """
        self.blender_obj.location = location
        Utility.insert_keyframe(self.blender_obj, "location", frame)
    def set_cp(self, key: str, value: Any, frame: int = None):
        """ Sets the custom property with the given key.

        Keyframes can be only set for custom properties for the types int, float or bool.

        :param key: The key of the custom property.
        :param value: The value to set.
        :param frame: The frame number which the value should be set to. If None is given, the current frame number is used.
        """
        self.blender_obj[key] = value
        if isinstance(self.blender_obj[key], float) or isinstance(
                self.blender_obj[key], int):
            Utility.insert_keyframe(self.blender_obj, "[\"" + key + "\"]",
                                    frame)
Esempio n. 9
0
    def run(self):
        """ Hides objects for the set number of frames.
        """

        objects = self.config.get_list("selector")
        number_of_frames = self.config.get_int("number_of_frames",
                                               bpy.context.scene.frame_end)
        if number_of_frames > bpy.context.scene.frame_end:
            number_of_frames = bpy.context.scene.frame_end
        print(
            f"Will use {number_of_frames} number of frames, for {len(objects)} objects."
        )
        # iterate over all objects
        for obj in objects:
            obj.hide_render = False
            # Insert all selected objects to each frame for normal rendering.
            for frame in range(number_of_frames):
                Utility.insert_keyframe(obj, "hide_render", frame)

            # Insert updated selected objects to each frame with the field hide_render modified
            obj.hide_render = True
            for frame in range(number_of_frames):
                Utility.insert_keyframe(obj, "hide_render",
                                        frame + bpy.context.scene.frame_end)

        # Copy and modify camera location and rotation to the new frames where objects are hidden.
        camera = bpy.context.scene.camera
        for frame in range(number_of_frames):
            bpy.context.scene.frame_set(frame)
            Utility.insert_keyframe(camera, "location",
                                    frame + bpy.context.scene.frame_end)
            Utility.insert_keyframe(camera, "rotation_euler",
                                    frame + bpy.context.scene.frame_end)
        bpy.context.scene.frame_end += number_of_frames