Add demo.

This commit is contained in:
K. S. Ernest (iFire) Lee 2021-11-28 11:09:16 -08:00
parent 6fde7edc5e
commit bd35c5dab2
8 changed files with 151 additions and 14 deletions

14
.gitattributes vendored
View File

@ -1,14 +0,0 @@
# FBX SDK
*.a filter=lfs diff=lfs merge=lfs -text
*.dylib filter=lfs diff=lfs merge=lfs -text
*.so filter=lfs diff=lfs merge=lfs -text
*.dll filter=lfs diff=lfs merge=lfs -text
*.lib filter=lfs diff=lfs merge=lfs -text
# TEST FILES
*.glb filter=lfs diff=lfs merge=lfs -text
*.fbx filter=lfs diff=lfs merge=lfs -text
*.tga filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.jpg filter=lfs diff=lfs merge=lfs -text

2
.gitignore vendored
View File

@ -8,3 +8,5 @@ npm/tests/test/*.js.map
build/ build/
.cache/ .cache/
sdk/ sdk/
demo/.godot/

View File

@ -0,0 +1,55 @@
@tool
extends EditorSceneFormatImporter
var settings = ProjectSettings
const settings_fbx2gltf_path = "filesystem/import/fbx/fbx2gltf_path"
var fbx2gltf_path : String
func _get_extensions():
return ["fbx"]
func _get_import_flags():
return EditorSceneFormatImporter.IMPORT_SCENE
func _import_scene(path: String, flags: int, bake_fps: int):
if not ProjectSettings.has_setting(settings_fbx2gltf_path):
ProjectSettings.set_initial_value(settings_fbx2gltf_path, "fbx2gltf")
ProjectSettings.set_setting(settings_fbx2gltf_path, "fbx2gltf")
else:
fbx2gltf_path = ProjectSettings.get_setting(settings_fbx2gltf_path)
if fbx2gltf_path.is_empty():
return null
var property_info = {
"name": settings_fbx2gltf_path,
"type": TYPE_STRING,
"hint": PROPERTY_HINT_GLOBAL_FILE,
"hint_string": ""
}
ProjectSettings.add_property_info(property_info)
var user_path_base = OS.get_user_data_dir()
var path_global : String = ProjectSettings.globalize_path(path)
var output_path : String = "res://.godot/imported/" + path.get_file().get_basename() + "-" + path.md5_text() + ".glb"
var output_path_global = ProjectSettings.globalize_path(output_path)
var stdout = [].duplicate()
var temp_dir_global = ProjectSettings.globalize_path("res://.godot/imported/")
var ret = OS.execute(fbx2gltf_path, [
"--fbx-temp-dir", temp_dir_global,
"-i", path_global,
"-o", output_path_global], stdout, true)
for line in stdout:
print(line)
if ret != 0:
print("FBX2glTF returned " + str(ret))
return null
var gstate : GLTFState = GLTFState.new()
var gltf : GLTFDocument = GLTFDocument.new()
var root_node : Node = gltf.import_scene(output_path, 0, 1000.0, gstate)
root_node.name = path.get_basename().get_file()
return root_node

View File

@ -0,0 +1,7 @@
[plugin]
name="FBX"
description="FBX Importer"
author="V-Sekai"
version="1.1.0"
script="plugin.gd"

13
demo/addons/fbx/plugin.gd Normal file
View File

@ -0,0 +1,13 @@
@tool
extends EditorPlugin
var import_plugin
func _enter_tree():
import_plugin = preload("res://addons/fbx/import_fbx.gd").new()
add_scene_format_importer_plugin(import_plugin)
func _exit_tree():
add_scene_format_importer_plugin(import_plugin)
import_plugin = null

7
demo/default_env.tres Normal file
View File

@ -0,0 +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 )

35
demo/icon.png.import Normal file
View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture2D"
uid="uid://syqf374gcodm"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://icon.png"
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
compress/streamed=false
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/HDR_as_SRGB=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0

32
demo/project.godot Normal file
View File

@ -0,0 +1,32 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=5
[application]
config/name="FBX Game Project"
config/icon="res://icon.png"
config/features=PackedStringArray("4.0")
[editor_plugins]
enabled=PackedStringArray("res://addons/fbx/plugin.cfg")
[filesystem]
import/fbx/use_fbx=false
import/fbx/fbx2gltf_path="fbx2gltf"
[physics]
common/enable_pause_aware_picking=true
[rendering]
environment/default_environment="res://default_env.tres"