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 name_string(name);
50 std::replace(name_string.begin(), name_string.end(),
' ',
'_');
51 std::replace(name_string.begin(), name_string.end(),
'.',
'_');
52 std::replace(name_string.begin(), name_string.end(),
':',
'_');
67 if (dupli_parent && (ob != dupli_parent)) {
78 for (
int i = 0; i < 4; i++) {
79 for (
int j = 0; j < 4; j++) {
80 m[i][j] =
double(mat[i][j]);
89 for (
int i = 0; i < 4; i++) {
90 for (
int j = 0; j < 4; j++) {
91 r_mat[i][j] =
float(xform[i][j]);
96void split(
const std::string &s,
const char delim, std::vector<std::string> &tokens)
100 std::stringstream ss(s);
103 while (std::getline(ss, item, delim)) {
105 tokens.push_back(item);
110bool has_property(
const Alembic::Abc::ICompoundProperty &prop,
const std::string &name)
116 return prop.getPropertyHeader(name) !=
nullptr;
120 const Alembic::AbcGeom::ISampleSelector &selector,
121 const std::string &name)
123 for (
size_t i = 0; i < schema.getNumProperties(); i++) {
124 const PropertyHeader &header = schema.getPropertyHeader(i);
126 if (header.isCompound()) {
127 const Alembic::Abc::ICompoundProperty &prop = Alembic::Abc::ICompoundProperty(
128 schema, header.getName());
133 const PropertyHeader *header = prop.getPropertyHeader(name);
134 if (!IV3fArrayProperty::matches(*header)) {
138 const IV3fArrayProperty &velocity_prop = IV3fArrayProperty(prop, name, 0);
140 return velocity_prop.getValue(selector);
144 else if (header.isArray()) {
145 if (header.getName() == name && IV3fArrayProperty::matches(header)) {
146 const IV3fArrayProperty &velocity_prop = IV3fArrayProperty(schema, name, 0);
147 return velocity_prop.getValue(selector);
152 return V3fArraySamplePtr();
155using index_time_pair_t = std::pair<Alembic::AbcCoreAbstract::index_t, Alembic::AbcGeom::chrono_t>;
158 const Alembic::AbcGeom::ISampleSelector &selector,
159 const Alembic::AbcCoreAbstract::TimeSamplingPtr &time_sampling,
160 size_t samples_number)
162 const chrono_t time = selector.getRequestedTime();
163 samples_number = std::max(samples_number,
size_t(1));
166 Alembic::AbcCoreAbstract::index_t i0 = t0.first;
168 if (samples_number == 1 || (
fabs(time - t0.second) < 0.0001)) {
173 Alembic::AbcCoreAbstract::index_t i1 = t1.first;
179 const double bias = (time - t0.second) / (t1.second - t0.second);
181 if (
fabs(1.0 - bias) < 0.0001) {
194 const Alembic::AbcGeom::MetaData &md =
object.getMetaData();
196 if (Alembic::AbcGeom::IXform::matches(md)) {
199 else if (Alembic::AbcGeom::IPolyMesh::matches(md)) {
202 else if (Alembic::AbcGeom::ISubD::matches(md)) {
205 else if (Alembic::AbcGeom::INuPatch::matches(md)) {
216 else if (Alembic::AbcGeom::ICamera::matches(md)) {
219 else if (Alembic::AbcGeom::IPoints::matches(md)) {
222 else if (Alembic::AbcMaterial::IMaterial::matches(md)) {
225 else if (Alembic::AbcGeom::ILight::matches(md)) {
228 else if (Alembic::AbcGeom::IFaceSet::matches(md)) {
231 else if (Alembic::AbcGeom::ICurves::matches(md)) {
235 std::cerr <<
"Alembic: unknown how to handle objects of schema '" << md.get(
"schemaObjTitle")
236 <<
"', skipping object '" <<
object.getFullName() <<
"'" << std::endl;
257 return m_stream.str();
Platform independent time functions.
double BLI_time_now_seconds(void)
typedef double(DMatrix)[4][4]
Object is a sort of wrapper for general info.
ScopeTimer(const char *message)
std::ostringstream & stream()
draw_view in_light_buf[] float
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)