17#include <Alembic/AbcGeom/ILight.h>
18#include <Alembic/AbcGeom/INuPatch.h>
19#include <Alembic/AbcMaterial/IMaterial.h>
27using Alembic::Abc::IV3fArrayProperty;
28using Alembic::Abc::PropertyHeader;
29using Alembic::Abc::V3fArraySamplePtr;
49 std::string abc_name(name);
50 std::replace(abc_name.begin(), abc_name.end(),
' ',
'_');
51 std::replace(abc_name.begin(), abc_name.end(),
'.',
'_');
52 std::replace(abc_name.begin(), abc_name.end(),
':',
'_');
53 std::replace(abc_name.begin(), abc_name.end(),
'/',
'_');
68 if (dupli_parent && (ob != dupli_parent)) {
79 for (
int i = 0;
i < 4;
i++) {
80 for (
int j = 0; j < 4; j++) {
81 m[
i][j] = double(mat[
i][j]);
90 for (
int i = 0;
i < 4;
i++) {
91 for (
int j = 0; j < 4; j++) {
92 r_mat[
i][j] = float(xform[
i][j]);
97void split(
const std::string &s,
const char delim, std::vector<std::string> &tokens)
101 std::stringstream ss(s);
104 while (std::getline(ss, item, delim)) {
106 tokens.push_back(item);
111bool has_property(
const Alembic::Abc::ICompoundProperty &prop,
const std::string &name)
117 return prop.getPropertyHeader(name) !=
nullptr;
121 const Alembic::AbcGeom::ISampleSelector &selector,
122 const std::string &name)
124 for (
size_t i = 0;
i < schema.getNumProperties();
i++) {
125 const PropertyHeader &header = schema.getPropertyHeader(
i);
127 if (header.isCompound()) {
128 const Alembic::Abc::ICompoundProperty &prop = Alembic::Abc::ICompoundProperty(
129 schema, header.getName());
134 const PropertyHeader *header = prop.getPropertyHeader(name);
135 if (!IV3fArrayProperty::matches(*header)) {
139 const IV3fArrayProperty &velocity_prop = IV3fArrayProperty(prop, name, 0);
141 return velocity_prop.getValue(selector);
145 else if (header.isArray()) {
146 if (header.getName() == name && IV3fArrayProperty::matches(header)) {
147 const IV3fArrayProperty &velocity_prop = IV3fArrayProperty(schema, name, 0);
148 return velocity_prop.getValue(selector);
153 return V3fArraySamplePtr();
156using index_time_pair_t = std::pair<Alembic::AbcCoreAbstract::index_t, Alembic::AbcGeom::chrono_t>;
159 const Alembic::AbcGeom::ISampleSelector &selector,
160 const Alembic::AbcCoreAbstract::TimeSamplingPtr &time_sampling,
161 size_t samples_number)
163 const chrono_t time = selector.getRequestedTime();
164 samples_number = std::max(samples_number,
size_t(1));
167 Alembic::AbcCoreAbstract::index_t i0 = t0.first;
169 if (samples_number == 1 || (
fabs(time - t0.second) < 0.0001)) {
174 Alembic::AbcCoreAbstract::index_t i1 = t1.first;
180 const double bias = (time - t0.second) / (t1.second - t0.second);
182 if (
fabs(1.0 - bias) < 0.0001) {
195 const Alembic::AbcGeom::MetaData &md =
object.getMetaData();
197 if (Alembic::AbcGeom::IXform::matches(md)) {
200 else if (Alembic::AbcGeom::IPolyMesh::matches(md)) {
203 else if (Alembic::AbcGeom::ISubD::matches(md)) {
206 else if (Alembic::AbcGeom::INuPatch::matches(md)) {
217 else if (Alembic::AbcGeom::ICamera::matches(md)) {
220 else if (Alembic::AbcGeom::IPoints::matches(md)) {
223 else if (Alembic::AbcMaterial::IMaterial::matches(md)) {
226 else if (Alembic::AbcGeom::ILight::matches(md)) {
229 else if (Alembic::AbcGeom::IFaceSet::matches(md)) {
232 else if (Alembic::AbcGeom::ICurves::matches(md)) {
236 std::cerr <<
"Alembic: unknown how to handle objects of schema '" << md.get(
"schemaObjTitle")
237 <<
"', skipping object '" <<
object.getFullName() <<
"'" << std::endl;
258 return m_stream.str();
Platform independent time functions.
double BLI_time_now_seconds(void)
Object is a sort of wrapper for general info.
ScopeTimer(const char *message)
std::ostringstream & stream()
ccl_device_inline float2 fabs(const float2 a)
std::string get_valid_abc_name(const char *name)
std::ostream & operator<<(std::ostream &os, const SimpleLogger &logger)
std::string get_object_dag_path_name(const Object *const ob, Object *dupli_parent)
get_object_dag_path_name returns the name under which the object will be exported in the Alembic file...
V3fArraySamplePtr get_velocity_prop(const Alembic::Abc::ICompoundProperty &schema, const Alembic::AbcGeom::ISampleSelector &selector, const std::string &name)
std::string get_id_name(const Object *const ob)
Imath::M44d convert_matrix_datatype(const float mat[4][4])
std::pair< Alembic::AbcCoreAbstract::index_t, Alembic::AbcGeom::chrono_t > index_time_pair_t
bool has_property(const Alembic::Abc::ICompoundProperty &prop, const std::string &name)
AbcObjectReader * create_reader(const Alembic::AbcGeom::IObject &object, ImportSettings &settings)
std::optional< SampleInterpolationSettings > get_sample_interpolation_settings(const Alembic::AbcGeom::ISampleSelector &selector, const Alembic::AbcCoreAbstract::TimeSamplingPtr &time_sampling, size_t samples_number)
void split(const std::string &s, const char delim, std::vector< std::string > &tokens)