summaryrefslogtreecommitdiffstats
path: root/editor/io_plugins/editor_scene_importer_fbxconv.h
blob: d191a17489a2d529df290be535a71bafa772b315 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*************************************************************************/
/*  editor_scene_importer_fbxconv.h                                      */
/*************************************************************************/
/*                       This file is part of:                           */
/*                           GODOT ENGINE                                */
/*                    http://www.godotengine.org                         */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur.                 */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md)    */
/*                                                                       */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the       */
/* "Software"), to deal in the Software without restriction, including   */
/* without limitation the rights to use, copy, modify, merge, publish,   */
/* distribute, sublicense, and/or sell copies of the Software, and to    */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions:                                             */
/*                                                                       */
/* The above copyright notice and this permission notice shall be        */
/* included in all copies or substantial portions of the Software.       */
/*                                                                       */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
/*************************************************************************/
#ifndef EDITOR_SCENE_IMPORTER_FBXCONV_H
#define EDITOR_SCENE_IMPORTER_FBXCONV_H

#include "editor/io_plugins/editor_scene_import_plugin.h"
#include "scene/3d/skeleton.h"

#if 0

class EditorSceneImporterFBXConv : public EditorSceneImporter {

	GDCLASS(EditorSceneImporterFBXConv,EditorSceneImporter );


	struct BoneInfo {

		Skeleton *skeleton;
		Transform rest;
		int index;
		bool has_anim_chan;
		bool has_rest;
		Dictionary node;
		BoneInfo() {
			has_rest=false;
			skeleton=NULL;
			index=-1;
			has_anim_chan=false;
		}
	};

	struct SurfaceInfo {
		Array array;
		Mesh::PrimitiveType primitive;
	};

	struct State {

		Node *scene;
		Array meshes;
		Array materials;
		Array nodes;
		Array animations;
		Map<String,BoneInfo > bones;
		Map<String,Skeleton*> skeletons;
		Map<String,Ref<Mesh> > mesh_cache;
		Map<String,SurfaceInfo> surface_cache;
		Map<String,Ref<Material> > material_cache;
		Map<String,Ref<Texture> > texture_cache;
		List<String> *missing_deps;
		String base_path;
		bool import_animations;
	};

	String _id(const String& p_id) const;

	Transform _get_transform_mixed(const Dictionary& d, const Dictionary& dbase);
	Transform _get_transform(const Dictionary& d);
	Color _get_color(const Array& a);
	void _detect_bones_in_nodes(State& state,const Array& p_nodes);
	void _detect_bones(State& state);

	Error _parse_bones(State& state,const Array &p_bones,Skeleton* p_skeleton);
	void _parse_skeletons(const String& p_name,State& state, const Array &p_nodes, Skeleton*p_skeleton=NULL, int p_parent=-1);

	void _add_surface(State& state,Ref<Mesh>& m,const Dictionary &part);
	Error _parse_nodes(State& state,const Array &p_nodes,Node* p_base);
	Error _parse_animations(State& state);
	void _parse_materials(State& state);
	void _parse_surfaces(State& state);
	Error _parse_json(State& state,const String& p_path);
	Error _parse_fbx(State &state, const String &p_path);

public:

	virtual uint32_t get_import_flags() const;
	virtual void get_extensions(List<String> *r_extensions) const;
	virtual Node* import_scene(const String& p_path,uint32_t p_flags,List<String> *r_missing_deps=NULL,Error* r_err=NULL);
	virtual Ref<Animation> import_animation(const String& p_path,uint32_t p_flags);

	EditorSceneImporterFBXConv();
};

#endif // EDITOR_SCENE_IMPORTER_FBXCONV_H
#endif