[Bf-extensions-cvs] [6b465fdc] master: glTF: remove no more needed files

Julien Duroure noreply at git.blender.org
Tue Jan 29 18:16:19 CET 2019


Commit: 6b465fdceb8d05c5836c55234f07fb7a658246e2
Author: Julien Duroure
Date:   Tue Jan 29 18:16:01 2019 +0100
Branches: master
https://developer.blender.org/rBA6b465fdceb8d05c5836c55234f07fb7a658246e2

glTF: remove no more needed files

===================================================================

D	io_scene_gltf2/blender/com/gltf2_blender_image_util.py
D	io_scene_gltf2/blender/exp/gltf2_blender_animate.py
D	io_scene_gltf2/blender/exp/gltf2_blender_filter.py
D	io_scene_gltf2/blender/exp/gltf2_blender_search_scene.py
D	io_scene_gltf2/io/com/gltf2_io_functional.py

===================================================================

diff --git a/io_scene_gltf2/blender/com/gltf2_blender_image_util.py b/io_scene_gltf2/blender/com/gltf2_blender_image_util.py
deleted file mode 100755
index e2563a52..00000000
--- a/io_scene_gltf2/blender/com/gltf2_blender_image_util.py
+++ /dev/null
@@ -1,121 +0,0 @@
-# Copyright 2018 The glTF-Blender-IO authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import os
-import shutil
-import bpy
-import zlib
-import struct
-from io_scene_gltf2.blender.exp import gltf2_blender_get
-
-
-def create_image_file(context, blender_image, dst_path, file_format):
-    """Create JPEG or PNG file from a given Blender image."""
-    # Check, if source image exists e.g. does not exist if image is packed.
-    file_exists = 1
-    try:
-        src_path = bpy.path.abspath(blender_image.filepath, library=blender_image.library)
-        file = open(src_path)
-    except IOError:
-        file_exists = 0
-    else:
-        file.close()
-
-    if file_exists == 0:
-        # Image does not exist on disk ...
-        blender_image.filepath = dst_path
-        # ... so save it.
-        blender_image.save()
-
-    elif file_format == blender_image.file_format:
-        # Copy source image to destination, keeping original format.
-
-        src_path = bpy.path.abspath(blender_image.filepath, library=blender_image.library)
-
-        # Required for comapre.
-        src_path = src_path.replace('\\', '/')
-        dst_path = dst_path.replace('\\', '/')
-
-        # Check that source and destination path are not the same using os.path.abspath
-        # because bpy.path.abspath seems to not always return an absolute path
-        if os.path.abspath(dst_path) != os.path.abspath(src_path):
-            shutil.copyfile(src_path, dst_path)
-
-    else:
-        # Render a new image to destination, converting to target format.
-
-        # TODO: Reusing the existing scene means settings like exposure are applied on export,
-        # which we don't want, but I'm not sure how to create a new Scene object through the
-        # Python API. See: https://github.com/KhronosGroup/glTF-Blender-Exporter/issues/184.
-
-        tmp_file_format = context.scene.render.image_settings.file_format
-        tmp_color_depth = context.scene.render.image_settings.color_depth
-
-        context.scene.render.image_settings.file_format = file_format
-        context.scene.render.image_settings.color_depth = '8'
-        blender_image.save_render(dst_path, context.scene)
-
-        context.scene.render.image_settings.file_format = tmp_file_format
-        context.scene.render.image_settings.color_depth = tmp_color_depth
-
-
-def create_image_data(context, export_settings, blender_image, file_format):
-    """Create JPEG or PNG byte array from a given Blender image."""
-    if blender_image is None:
-        return None
-
-    if file_format == 'PNG':
-        return _create_png_data(blender_image)
-    else:
-        return _create_jpg_data(context, export_settings, blender_image)
-
-
-def _create_jpg_data(context, export_settings, blender_image):
-    """Create a JPEG byte array from a given Blender image."""
-    uri = gltf2_blender_get.get_image_uri(export_settings, blender_image)
-    path = export_settings['gltf_filedirectory'] + uri
-
-    create_image_file(context, blender_image, path, 'JPEG')
-
-    jpg_data = open(path, 'rb').read()
-    os.remove(path)
-
-    return jpg_data
-
-
-def _create_png_data(blender_image):
-    """Create a PNG byte array from a given Blender image."""
-    width, height = blender_image.size
-
-    buf = bytearray([int(channel * 255.0) for channel in blender_image.pixels])
-
-    #
-    # Taken from 'blender-thumbnailer.py' in Blender.
-    #
-
-    # reverse the vertical line order and add null bytes at the start
-    width_byte_4 = width * 4
-    raw_data = b"".join(
-        b'\x00' + buf[span:span + width_byte_4] for span in range((height - 1) * width * 4, -1, - width_byte_4))
-
-    def png_pack(png_tag, data):
-        chunk_head = png_tag + data
-        return struct.pack("!I", len(data)) + chunk_head + struct.pack("!I", 0xFFFFFFFF & zlib.crc32(chunk_head))
-
-    return b"".join([
-        b'\x89PNG\r\n\x1a\n',
-        png_pack(b'IHDR', struct.pack("!2I5B", width, height, 8, 6, 0, 0, 0)),
-        png_pack(b'IDAT', zlib.compress(raw_data, 9)),
-        png_pack(b'IEND', b'')])
-
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_animate.py b/io_scene_gltf2/blender/exp/gltf2_blender_animate.py
deleted file mode 100755
index e4b11487..00000000
--- a/io_scene_gltf2/blender/exp/gltf2_blender_animate.py
+++ /dev/null
@@ -1,638 +0,0 @@
-# Copyright 2018 The glTF-Blender-IO authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-#
-# Imports
-#
-
-import bpy
-from . import gltf2_blender_export_keys
-from . import gltf2_blender_extract
-from mathutils import Matrix, Quaternion, Euler
-
-
-#
-# Globals
-#
-
-JOINT_NODE = 'JOINT'
-
-NEEDS_CONVERSION = 'CONVERSION_NEEDED'
-CUBIC_INTERPOLATION = 'CUBICSPLINE'
-LINEAR_INTERPOLATION = 'LINEAR'
-STEP_INTERPOLATION = 'STEP'
-BEZIER_INTERPOLATION = 'BEZIER'
-CONSTANT_INTERPOLATION = 'CONSTANT'
-
-
-#
-# Functions
-#
-
-def animate_get_interpolation(export_settings, blender_fcurve_list):
-    """
-    Retrieve the glTF interpolation, depending on a fcurve list.
-
-    Blender allows mixing and more variations of interpolations.
-    In such a case, a conversion is needed.
-    """
-    if export_settings[gltf2_blender_export_keys.FORCE_SAMPLING]:
-        return NEEDS_CONVERSION
-
-    #
-
-    interpolation = None
-
-    keyframe_count = None
-
-    for blender_fcurve in blender_fcurve_list:
-        if blender_fcurve is None:
-            continue
-
-        #
-
-        current_keyframe_count = len(blender_fcurve.keyframe_points)
-
-        if keyframe_count is None:
-            keyframe_count = current_keyframe_count
-
-        if current_keyframe_count > 0 > blender_fcurve.keyframe_points[0].co[0]:
-            return NEEDS_CONVERSION
-
-        if keyframe_count != current_keyframe_count:
-            return NEEDS_CONVERSION
-
-        #
-
-        for blender_keyframe in blender_fcurve.keyframe_points:
-            is_bezier = blender_keyframe.interpolation == BEZIER_INTERPOLATION
-            is_linear = blender_keyframe.interpolation == LINEAR_INTERPOLATION
-            is_constant = blender_keyframe.interpolation == CONSTANT_INTERPOLATION
-
-            if interpolation is None:
-                if is_bezier:
-                    interpolation = CUBIC_INTERPOLATION
-                elif is_linear:
-                    interpolation = LINEAR_INTERPOLATION
-                elif is_constant:
-                    interpolation = STEP_INTERPOLATION
-                else:
-                    interpolation = NEEDS_CONVERSION
-                    return interpolation
-            else:
-                if is_bezier and interpolation != CUBIC_INTERPOLATION:
-                    interpolation = NEEDS_CONVERSION
-                    return interpolation
-                elif is_linear and interpolation != LINEAR_INTERPOLATION:
-                    interpolation = NEEDS_CONVERSION
-                    return interpolation
-                elif is_constant and interpolation != STEP_INTERPOLATION:
-                    interpolation = NEEDS_CONVERSION
-                    return interpolation
-                elif not is_bezier and not is_linear and not is_constant:
-                    interpolation = NEEDS_CONVERSION
-                    return interpolation
-
-    if interpolation is None:
-        interpolation = NEEDS_CONVERSION
-
-    return interpolation
-
-
-def animate_convert_rotation_axis_angle(axis_angle):
-    """Convert an axis angle to a quaternion rotation."""
-    q = Quaternion((axis_angle[1], axis_angle[2], axis_angle[3]), axis_angle[0])
-
-    return [q.x, q.y, q.z, q.w]
-
-
-def animate_convert_rotation_euler(euler, rotation_mode):
-    """Convert an euler angle to a quaternion rotation."""
-    rotation = Euler((euler[0], euler[1], euler[2]), rotation_mode).to_quaternion()
-
-    return [rotation.x, rotation.y, rotation.z, rotation.w]
-
-
-def animate_convert_keys(key_list):
-    """Convert Blender key frames to glTF time keys depending on the applied frames per second."""
-    times = []
-
-    for key in key_list:
-        times.append(key / bpy.context.scene.render.fps)
-
-    return times
-
-
-def animate_gather_keys(export_settings, fcurve_list, interpolation):
-    """
-    Merge and sort several key frames to one set.
-
-    If an interpolation conversion is needed, the sample key frames are created as well.
-    """
-    keys = []
-
-    frame_start = bpy.context.scene.frame_start
-    frame_end = bpy.context.scene.frame_end
-
-    if interpolation == NEEDS_CONVERSION:
-        start = None
-        end = None
-
-        for blender_fcurve in fcurve_list:
-            if blender_fcurve is None:
-                continue
-
-            if start is None:
-                start = blender_fcurve.range()[0]
-            else:
-                start = min(start, blender_fcurve.range()[0])
-
-            if end is None:
-                end = blender_fcurve.range()[1]
-            else:


@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list