RavEngine
Loading...
Searching...
No Matches
import2ozz.h
1//----------------------------------------------------------------------------//
2// //
3// ozz-animation is hosted at http://github.com/guillaumeblanc/ozz-animation //
4// and distributed under the MIT License (MIT). //
5// //
6// Copyright (c) Guillaume Blanc //
7// //
8// Permission is hereby granted, free of charge, to any person obtaining a //
9// copy of this software and associated documentation files (the "Software"), //
10// to deal in the Software without restriction, including without limitation //
11// the rights to use, copy, modify, merge, publish, distribute, sublicense, //
12// and/or sell copies of the Software, and to permit persons to whom the //
13// Software is furnished to do so, subject to the following conditions: //
14// //
15// The above copyright notice and this permission notice shall be included in //
16// all copies or substantial portions of the Software. //
17// //
18// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR //
19// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //
20// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL //
21// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //
22// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING //
23// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER //
24// DEALINGS IN THE SOFTWARE. //
25// //
26//----------------------------------------------------------------------------//
27
28#ifndef OZZ_OZZ_ANIMATION_OFFLINE_TOOLS_IMPORT2OZZ_H_
29#define OZZ_OZZ_ANIMATION_OFFLINE_TOOLS_IMPORT2OZZ_H_
30
31#include "ozz/animation/offline/tools/export.h"
32
33#include "ozz/base/containers/string.h"
34#include "ozz/base/containers/vector.h"
35
36#include "ozz/animation/offline/raw_animation.h"
37#include "ozz/animation/offline/raw_skeleton.h"
38#include "ozz/animation/offline/raw_track.h"
39
40#include "ozz/base/platform.h"
41
42namespace ozz {
43namespace animation {
44
45class Skeleton;
46
47namespace offline {
48
49// Defines ozz converter/importer interface.
50// OzzImporter implements a command line tool to convert any source data format
51// to ozz skeletons and animations. The tool exposes a set of global options
52// through the command line, and a json configuration file to tune import
53// settings. Reference json configuration is generated at
54// src\animation\offline\tools\reference.json.
55// To import a new source data format, one will implement the pure virtual
56// functions of this interface. All the conversions end error processing are
57// done by the tool.
58class OZZ_ANIMTOOLS_DLL OzzImporter {
59 public:
60 virtual ~OzzImporter() {}
61
62 // Function operator that must be called with main() arguments to start import
63 // process.
64 int operator()(int _argc, const char** _argv);
65
66 // Loads source data file.
67 // Returning false will report and error.
68 virtual bool Load(const char* _filename) = 0;
69
70 // Skeleton management.
71
72 // Defines node types that should be considered as skeleton joints.
73 struct NodeType {
74 bool skeleton : 1; // Uses skeleton nodes as skeleton joints.
75 bool marker : 1; // Uses marker nodes as skeleton joints.
76 bool camera : 1; // Uses camera nodes as skeleton joints.
77 bool geometry : 1; // Uses geometry nodes as skeleton joints.
78 bool light : 1; // Uses light nodes as skeleton joints.
79 bool null : 1; // Uses null nodes as skeleton joints.
80 bool any : 1; // Uses any node type as skeleton joints, including those
81 // listed above and any other.
82 };
83
84 // Import a skeleton from the source data file.
85 // Returning false will report and error.
86 virtual bool Import(ozz::animation::offline::RawSkeleton* _skeleton,
87 const NodeType& _types) = 0;
88
89 // Animations management.
90
91 // Gets the name of all the animations/clips/takes available from the source
92 // data file.
93 typedef ozz::vector<ozz::string> AnimationNames;
94 virtual AnimationNames GetAnimationNames() = 0;
95
96 // Import animation "_animation_name" from the source data file.
97 // The skeleton is provided such that implementation can look for its joints
98 // animations.
99 // Returning false will report and error.
100 virtual bool Import(const char* _animation_name,
101 const ozz::animation::Skeleton& _skeleton,
102 float _sampling_rate, RawAnimation* _animation) = 0;
103
104 // Tracks / properties management.
105
106 // Defines properties, aka user-channel data: animations that aren't only
107 // joint transforms.
109 ozz::string name;
110
111 enum Type { kFloat1, kFloat2, kFloat3, kFloat4, kPoint, kVector };
112 Type type;
113 };
114
115 // Get all properties available for a node.
116 typedef ozz::vector<NodeProperty> NodeProperties;
117 virtual NodeProperties GetNodeProperties(const char* _node_name) = 0;
118
119 // Imports a track of type 1, 2, 3 or 4 floats, for the triplet
120 // _animation_name/_node_name/_track_name.
121 // Returning false will report and error.
122 virtual bool Import(const char* _animation_name, const char* _node_name,
123 const char* _track_name, NodeProperty::Type _track_type,
124 float _sampling_rate, RawFloatTrack* _track) = 0;
125 virtual bool Import(const char* _animation_name, const char* _node_name,
126 const char* _track_name, NodeProperty::Type _track_type,
127 float _sampling_rate, RawFloat2Track* _track) = 0;
128 virtual bool Import(const char* _animation_name, const char* _node_name,
129 const char* _track_name, NodeProperty::Type _track_type,
130 float _sampling_rate, RawFloat3Track* _track) = 0;
131 virtual bool Import(const char* _animation_name, const char* _node_name,
132 const char* _track_name, NodeProperty::Type _track_type,
133 float _sampling_rate, RawFloat4Track* _track) = 0;
134
135 // Build a filename from a wildcard string.
136 ozz::string BuildFilename(const char* _filename,
137 const char* _data_name) const;
138};
139} // namespace offline
140} // namespace animation
141} // namespace ozz
142#endif // OZZ_OZZ_ANIMATION_OFFLINE_TOOLS_IMPORT2OZZ_H_
Definition skeleton.h:61
Definition import2ozz.h:58
Definition raw_animation.h:59
Definition raw_track.h:113
Definition raw_track.h:115
Definition raw_track.h:117
Definition raw_track.h:111
Definition raw_skeleton.h:51