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
113
114
115
|
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2020 Blender Foundation.
* All rights reserved.
*/
#pragma once
#include "usd.h"
#include "usd_importer_context.h"
#include "usd_reader_prim.h"
#include <string>
#include <vector>
struct CacheFile;
struct Main;
struct Mesh;
struct Object;
namespace blender::io::usd {
class USDDataCache;
/* Wraps the UsdGeomXformable schema. Abstract base class for all readers
* that create a Blender object and compute its transform. */
class USDXformableReader : public USDPrimReader {
protected:
Object *object_;
USDXformableReader *parent_;
bool merged_with_parent_;
public:
explicit USDXformableReader(const pxr::UsdPrim &prim, const USDImporterContext &context);
virtual ~USDXformableReader();
Object *object() const;
void set_object(Object *object)
{
object_ = object;
}
USDXformableReader *parent() const
{
return parent_;
}
void set_parent(USDXformableReader *par)
{
parent_ = par;
}
void set_merged_with_parent(bool flag)
{
merged_with_parent_ = flag;
}
bool merged_with_parent() const
{
return merged_with_parent_;
}
/* Determines whether or not this reader takes into
* account the encapsulated USD primitive's parent when
* computing the object's transform and sets the value
* of the merged_with_parent_ flag accordingly. Note that
* this function may be expensive to compute. */
void eval_merged_with_parent();
std::string get_object_name() const
{
return merged_with_parent_ ? this->parent_prim_name() : this->prim_name();
}
std::string get_data_name() const
{
return this->prim_name();
}
virtual bool valid() const = 0;
virtual void create_object(Main *bmain, double time, USDDataCache *data_cache) = 0;
virtual bool can_merge_with_parent() const
{
return true;
}
void set_object_transform(const double time, CacheFile *cache_file = nullptr);
virtual void read_matrix(float r_mat[4][4],
const double time,
const float scale,
bool &is_constant) const;
};
} /* namespace blender::io::usd */
|