Add export blend script.

This commit is contained in:
K. S. Ernest (iFire) Lee
2020-09-27 12:20:21 -07:00
parent aea278c36a
commit 8498629b1a
19 changed files with 7497 additions and 4 deletions

2
.gitignore vendored
View File

@@ -1,2 +1,4 @@
tests/gltf_export/.import/
tests/blend_export/.import/

View File

@@ -0,0 +1,29 @@
# blender --background --python .\blender-export.py
import bpy
import posixpath
import shutil
blend = "32678-respect-import-hints-with-empty"
bpy.ops.wm.open_mainfile(filepath=blend + ".blend")
export_type = "gltf"
shutil.rmtree("../" + export_type, ignore_errors=True)
posixpath.os.mkdir("../" + export_type, mode=0o777)
bpy.ops.export_scene.gltf(
filepath="../" + export_type + "/" + blend + ".gltf",
export_format="GLTF_SEPARATE",
export_copyright="The MIT License (MIT) Copyright (c) 2016 Godot Engine",
)
export_type = "obj"
shutil.rmtree("../" + export_type, ignore_errors=True)
posixpath.os.mkdir("../" + export_type, mode=0o777)
bpy.ops.export_scene.obj(filepath="../" + export_type + "/" + blend + "." + export_type)
export_type = "fbx"
shutil.rmtree("../" + export_type, ignore_errors=True)
posixpath.os.mkdir("../" + export_type, mode=0o777)
bpy.ops.export_scene.fbx(filepath="../" + export_type + "/" + blend + "." + export_type)

View File

@@ -0,0 +1,29 @@
# blender --background --python .\blend-export.py
import bpy
import posixpath
import shutil
blend = "32678-respect-import-hints-with-empty"
bpy.ops.wm.open_mainfile(filepath="blend/" + blend + ".blend")
export_type = "gltf"
shutil.rmtree(export_type, ignore_errors=True)
posixpath.os.mkdir(export_type, mode=0o777)
bpy.ops.export_scene.gltf(
filepath=export_type + "/" + blend + ".gltf",
export_format="GLTF_SEPARATE",
export_copyright="The MIT License (MIT) Copyright (c) 2016 Godot Engine",
)
export_type = "obj"
shutil.rmtree(export_type, ignore_errors=True)
posixpath.os.mkdir(export_type, mode=0o777)
bpy.ops.export_scene.obj(filepath=export_type + "/" + blend + "." + export_type)
export_type = "fbx"
shutil.rmtree(export_type, ignore_errors=True)
posixpath.os.mkdir(export_type, mode=0o777)
bpy.ops.export_scene.fbx(filepath=export_type + "/" + blend + "." + export_type)

View File

@@ -1,5 +1,7 @@
[gd_resource type="Environment" load_steps=2 format=2]
[sub_resource type="ProceduralSky" id=1]
[resource]
background_mode = 2
background_sky = SubResource( 1 )

View File

@@ -2,12 +2,12 @@
importer="scene"
type="PackedScene"
path="res://.import/32678-respect-import-hints-with-empty.glb-663165a219477a1d1c083014a41cb510.scn"
path="res://.import/32678-respect-import-hints-with-empty.fbx-ddfe5d5e28ffabf575efe1317d480977.scn"
[deps]
source_file="res://32678-respect-import-hints-with-empty/32678-respect-import-hints-with-empty.glb"
dest_files=[ "res://.import/32678-respect-import-hints-with-empty.glb-663165a219477a1d1c083014a41cb510.scn" ]
source_file="res://fbx/32678-respect-import-hints-with-empty.fbx"
dest_files=[ "res://.import/32678-respect-import-hints-with-empty.fbx-ddfe5d5e28ffabf575efe1317d480977.scn" ]
[params]

Binary file not shown.

View File

@@ -0,0 +1,896 @@
{
"asset" : {
"copyright" : "The MIT License (MIT) Copyright (c) 2016 Godot Engine",
"generator" : "Khronos glTF Blender I/O v1.3.48",
"version" : "2.0"
},
"scene" : 0,
"scenes" : [
{
"name" : "Scene",
"nodes" : [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
]
}
],
"nodes" : [
{
"mesh" : 0,
"name" : "cube-noimp",
"translation" : [
0,
0,
10
]
},
{
"mesh" : 1,
"name" : "cube-col",
"translation" : [
0,
0,
-4
]
},
{
"mesh" : 2,
"name" : "cube-colonly",
"translation" : [
0,
0,
-8
]
},
{
"mesh" : 3,
"name" : "cube-convcolonly",
"translation" : [
0,
0,
-12
]
},
{
"mesh" : 4,
"name" : "cube-navmesh",
"translation" : [
2,
-4,
-2
]
},
{
"mesh" : 5,
"name" : "sphere-wheel",
"translation" : [
-10,
0,
0
]
},
{
"mesh" : 6,
"name" : "sphere-vehicle",
"translation" : [
-8,
-2,
-1
]
},
{
"mesh" : 7,
"name" : "cube-rigid"
},
{
"mesh" : 8,
"name" : "cube_animated",
"translation" : [
-6,
10,
18
]
},
{
"name" : "cube_empty-colonly",
"translation" : [
0,
0,
-16.017648696899414
]
}
],
"animations" : [
{
"channels" : [
{
"sampler" : 0,
"target" : {
"node" : 8,
"path" : "translation"
}
},
{
"sampler" : 1,
"target" : {
"node" : 8,
"path" : "rotation"
}
},
{
"sampler" : 2,
"target" : {
"node" : 8,
"path" : "scale"
}
}
],
"name" : "motion",
"samplers" : [
{
"input" : 29,
"interpolation" : "LINEAR",
"output" : 30
},
{
"input" : 29,
"interpolation" : "LINEAR",
"output" : 31
},
{
"input" : 29,
"interpolation" : "LINEAR",
"output" : 32
}
]
},
{
"channels" : [
{
"sampler" : 0,
"target" : {
"node" : 8,
"path" : "translation"
}
},
{
"sampler" : 1,
"target" : {
"node" : 8,
"path" : "rotation"
}
},
{
"sampler" : 2,
"target" : {
"node" : 8,
"path" : "scale"
}
}
],
"name" : "move-cycle",
"samplers" : [
{
"input" : 29,
"interpolation" : "LINEAR",
"output" : 33
},
{
"input" : 29,
"interpolation" : "LINEAR",
"output" : 34
},
{
"input" : 29,
"interpolation" : "LINEAR",
"output" : 35
}
]
},
{
"channels" : [
{
"sampler" : 0,
"target" : {
"node" : 8,
"path" : "translation"
}
},
{
"sampler" : 1,
"target" : {
"node" : 8,
"path" : "rotation"
}
},
{
"sampler" : 2,
"target" : {
"node" : 8,
"path" : "scale"
}
}
],
"name" : "move-loop",
"samplers" : [
{
"input" : 29,
"interpolation" : "LINEAR",
"output" : 36
},
{
"input" : 29,
"interpolation" : "LINEAR",
"output" : 37
},
{
"input" : 29,
"interpolation" : "LINEAR",
"output" : 38
}
]
}
],
"meshes" : [
{
"name" : "Cube",
"primitives" : [
{
"attributes" : {
"POSITION" : 0,
"NORMAL" : 1,
"TEXCOORD_0" : 2
},
"indices" : 3
}
]
},
{
"name" : "Cube.001",
"primitives" : [
{
"attributes" : {
"POSITION" : 4,
"NORMAL" : 5,
"TEXCOORD_0" : 6
},
"indices" : 3
}
]
},
{
"name" : "Cube.002",
"primitives" : [
{
"attributes" : {
"POSITION" : 7,
"NORMAL" : 8,
"TEXCOORD_0" : 9
},
"indices" : 3
}
]
},
{
"name" : "Cube.003",
"primitives" : [
{
"attributes" : {
"POSITION" : 10,
"NORMAL" : 11,
"TEXCOORD_0" : 12
},
"indices" : 3
}
]
},
{
"name" : "Cube.004",
"primitives" : [
{
"attributes" : {
"POSITION" : 13,
"NORMAL" : 14,
"TEXCOORD_0" : 15
},
"indices" : 3
}
]
},
{
"name" : "Sphere",
"primitives" : [
{
"attributes" : {
"POSITION" : 16,
"NORMAL" : 17,
"TEXCOORD_0" : 18
},
"indices" : 19
}
]
},
{
"name" : "Sphere.001",
"primitives" : [
{
"attributes" : {
"POSITION" : 20,
"NORMAL" : 21,
"TEXCOORD_0" : 22
},
"indices" : 19
}
]
},
{
"name" : "Cube.005",
"primitives" : [
{
"attributes" : {
"POSITION" : 23,
"NORMAL" : 24,
"TEXCOORD_0" : 25
},
"indices" : 3
}
]
},
{
"name" : "Cube.006",
"primitives" : [
{
"attributes" : {
"POSITION" : 26,
"NORMAL" : 27,
"TEXCOORD_0" : 28
},
"indices" : 3
}
]
}
],
"accessors" : [
{
"bufferView" : 0,
"componentType" : 5126,
"count" : 24,
"max" : [
1,
1,
1
],
"min" : [
-1,
-1,
-1
],
"type" : "VEC3"
},
{
"bufferView" : 1,
"componentType" : 5126,
"count" : 24,
"type" : "VEC3"
},
{
"bufferView" : 2,
"componentType" : 5126,
"count" : 24,
"type" : "VEC2"
},
{
"bufferView" : 3,
"componentType" : 5123,
"count" : 36,
"type" : "SCALAR"
},
{
"bufferView" : 4,
"componentType" : 5126,
"count" : 24,
"max" : [
1,
1,
1
],
"min" : [
-1,
-1,
-1
],
"type" : "VEC3"
},
{
"bufferView" : 5,
"componentType" : 5126,
"count" : 24,
"type" : "VEC3"
},
{
"bufferView" : 6,
"componentType" : 5126,
"count" : 24,
"type" : "VEC2"
},
{
"bufferView" : 7,
"componentType" : 5126,
"count" : 24,
"max" : [
1,
1,
1
],
"min" : [
-1,
-1,
-1
],
"type" : "VEC3"
},
{
"bufferView" : 8,
"componentType" : 5126,
"count" : 24,
"type" : "VEC3"
},
{
"bufferView" : 9,
"componentType" : 5126,
"count" : 24,
"type" : "VEC2"
},
{
"bufferView" : 10,
"componentType" : 5126,
"count" : 24,
"max" : [
1,
1,
1
],
"min" : [
-1,
-1,
-1
],
"type" : "VEC3"
},
{
"bufferView" : 11,
"componentType" : 5126,
"count" : 24,
"type" : "VEC3"
},
{
"bufferView" : 12,
"componentType" : 5126,
"count" : 24,
"type" : "VEC2"
},
{
"bufferView" : 13,
"componentType" : 5126,
"count" : 24,
"max" : [
1,
1,
1
],
"min" : [
-1,
-1,
-1
],
"type" : "VEC3"
},
{
"bufferView" : 14,
"componentType" : 5126,
"count" : 24,
"type" : "VEC3"
},
{
"bufferView" : 15,
"componentType" : 5126,
"count" : 24,
"type" : "VEC2"
},
{
"bufferView" : 16,
"componentType" : 5126,
"count" : 1984,
"max" : [
1.000000238418579,
1,
1.0000003576278687
],
"min" : [
-0.9999998211860657,
-1,
-1
],
"type" : "VEC3"
},
{
"bufferView" : 17,
"componentType" : 5126,
"count" : 1984,
"type" : "VEC3"
},
{
"bufferView" : 18,
"componentType" : 5126,
"count" : 1984,
"type" : "VEC2"
},
{
"bufferView" : 19,
"componentType" : 5123,
"count" : 2880,
"type" : "SCALAR"
},
{
"bufferView" : 20,
"componentType" : 5126,
"count" : 1984,
"max" : [
1.000000238418579,
1,
1.0000003576278687
],
"min" : [
-0.9999998211860657,
-1,
-1
],
"type" : "VEC3"
},
{
"bufferView" : 21,
"componentType" : 5126,
"count" : 1984,
"type" : "VEC3"
},
{
"bufferView" : 22,
"componentType" : 5126,
"count" : 1984,
"type" : "VEC2"
},
{
"bufferView" : 23,
"componentType" : 5126,
"count" : 24,
"max" : [
1,
1,
1
],
"min" : [
-1,
-1,
-1
],
"type" : "VEC3"
},
{
"bufferView" : 24,
"componentType" : 5126,
"count" : 24,
"type" : "VEC3"
},
{
"bufferView" : 25,
"componentType" : 5126,
"count" : 24,
"type" : "VEC2"
},
{
"bufferView" : 26,
"componentType" : 5126,
"count" : 24,
"max" : [
1,
1,
1
],
"min" : [
-1,
-1,
-1
],
"type" : "VEC3"
},
{
"bufferView" : 27,
"componentType" : 5126,
"count" : 24,
"type" : "VEC3"
},
{
"bufferView" : 28,
"componentType" : 5126,
"count" : 24,
"type" : "VEC2"
},
{
"bufferView" : 29,
"componentType" : 5126,
"count" : 60,
"max" : [
2.5
],
"min" : [
0.041666666666666664
],
"type" : "SCALAR"
},
{
"bufferView" : 30,
"componentType" : 5126,
"count" : 60,
"type" : "VEC3"
},
{
"bufferView" : 31,
"componentType" : 5126,
"count" : 60,
"type" : "VEC4"
},
{
"bufferView" : 32,
"componentType" : 5126,
"count" : 60,
"type" : "VEC3"
},
{
"bufferView" : 33,
"componentType" : 5126,
"count" : 60,
"type" : "VEC3"
},
{
"bufferView" : 34,
"componentType" : 5126,
"count" : 60,
"type" : "VEC4"
},
{
"bufferView" : 35,
"componentType" : 5126,
"count" : 60,
"type" : "VEC3"
},
{
"bufferView" : 36,
"componentType" : 5126,
"count" : 60,
"type" : "VEC3"
},
{
"bufferView" : 37,
"componentType" : 5126,
"count" : 60,
"type" : "VEC4"
},
{
"bufferView" : 38,
"componentType" : 5126,
"count" : 60,
"type" : "VEC3"
}
],
"bufferViews" : [
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 0
},
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 288
},
{
"buffer" : 0,
"byteLength" : 192,
"byteOffset" : 576
},
{
"buffer" : 0,
"byteLength" : 72,
"byteOffset" : 768
},
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 840
},
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 1128
},
{
"buffer" : 0,
"byteLength" : 192,
"byteOffset" : 1416
},
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 1608
},
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 1896
},
{
"buffer" : 0,
"byteLength" : 192,
"byteOffset" : 2184
},
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 2376
},
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 2664
},
{
"buffer" : 0,
"byteLength" : 192,
"byteOffset" : 2952
},
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 3144
},
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 3432
},
{
"buffer" : 0,
"byteLength" : 192,
"byteOffset" : 3720
},
{
"buffer" : 0,
"byteLength" : 23808,
"byteOffset" : 3912
},
{
"buffer" : 0,
"byteLength" : 23808,
"byteOffset" : 27720
},
{
"buffer" : 0,
"byteLength" : 15872,
"byteOffset" : 51528
},
{
"buffer" : 0,
"byteLength" : 5760,
"byteOffset" : 67400
},
{
"buffer" : 0,
"byteLength" : 23808,
"byteOffset" : 73160
},
{
"buffer" : 0,
"byteLength" : 23808,
"byteOffset" : 96968
},
{
"buffer" : 0,
"byteLength" : 15872,
"byteOffset" : 120776
},
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 136648
},
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 136936
},
{
"buffer" : 0,
"byteLength" : 192,
"byteOffset" : 137224
},
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 137416
},
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 137704
},
{
"buffer" : 0,
"byteLength" : 192,
"byteOffset" : 137992
},
{
"buffer" : 0,
"byteLength" : 240,
"byteOffset" : 138184
},
{
"buffer" : 0,
"byteLength" : 720,
"byteOffset" : 138424
},
{
"buffer" : 0,
"byteLength" : 960,
"byteOffset" : 139144
},
{
"buffer" : 0,
"byteLength" : 720,
"byteOffset" : 140104
},
{
"buffer" : 0,
"byteLength" : 720,
"byteOffset" : 140824
},
{
"buffer" : 0,
"byteLength" : 960,
"byteOffset" : 141544
},
{
"buffer" : 0,
"byteLength" : 720,
"byteOffset" : 142504
},
{
"buffer" : 0,
"byteLength" : 720,
"byteOffset" : 143224
},
{
"buffer" : 0,
"byteLength" : 960,
"byteOffset" : 143944
},
{
"buffer" : 0,
"byteLength" : 720,
"byteOffset" : 144904
}
],
"buffers" : [
{
"byteLength" : 145624,
"uri" : "32678-respect-import-hints-with-empty.bin"
}
]
}

File diff suppressed because it is too large Load Diff

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@@ -0,0 +1,10 @@
# Blender MTL File: '32678-respect-import-hints-with-empty.blend'
# Material Count: 1
newmtl None
Ns 500
Ka 0.8 0.8 0.8
Kd 0.8 0.8 0.8
Ks 0.8 0.8 0.8
d 1
illum 2

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -15,7 +15,7 @@ _global_script_class_icons={
[application]
config/name="glTF2 Project"
config/name="Blend Export Project"
config/icon="res://icon.png"
[rendering]

View File

@@ -0,0 +1 @@
blender --background --python blend_export.py