Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
|
|
|
/*
|
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): Esteban Tovagliari, Cedric Paille, Kevin Dietrich
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef __ABC_UTIL_H__
|
|
|
|
|
#define __ABC_UTIL_H__
|
|
|
|
|
|
|
|
|
|
#include <Alembic/Abc/All.h>
|
|
|
|
|
#include <Alembic/AbcGeom/All.h>
|
|
|
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
|
# define ABC_INLINE static __forceinline
|
|
|
|
|
#else
|
|
|
|
|
# define ABC_INLINE static inline
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-10-29 12:23:09 +02:00
|
|
|
struct CacheReader {
|
|
|
|
|
int unused;
|
|
|
|
|
};
|
|
|
|
|
|
Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
|
|
|
using Alembic::Abc::chrono_t;
|
|
|
|
|
|
2016-10-29 12:23:09 +02:00
|
|
|
class AbcObjectReader;
|
2016-12-01 08:32:02 +01:00
|
|
|
struct ImportSettings;
|
Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
|
|
|
|
|
|
|
|
struct ID;
|
|
|
|
|
struct Object;
|
|
|
|
|
|
|
|
|
|
std::string get_id_name(ID *id);
|
|
|
|
|
std::string get_id_name(Object *ob);
|
|
|
|
|
std::string get_object_dag_path_name(Object *ob, Object *dupli_parent);
|
|
|
|
|
|
|
|
|
|
bool object_selected(Object *ob);
|
|
|
|
|
bool parent_selected(Object *ob);
|
|
|
|
|
|
|
|
|
|
Imath::M44d convert_matrix(float mat[4][4]);
|
|
|
|
|
void create_transform_matrix(float r_mat[4][4]);
|
|
|
|
|
void create_transform_matrix(Object *obj, float transform_mat[4][4]);
|
|
|
|
|
|
|
|
|
|
void split(const std::string &s, const char delim, std::vector<std::string> &tokens);
|
|
|
|
|
|
|
|
|
|
template<class TContainer>
|
|
|
|
|
bool begins_with(const TContainer &input, const TContainer &match)
|
|
|
|
|
{
|
|
|
|
|
return input.size() >= match.size()
|
|
|
|
|
&& std::equal(match.begin(), match.end(), input.begin());
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-20 14:15:02 +02:00
|
|
|
void convert_matrix(const Imath::M44d &xform, Object *ob,
|
|
|
|
|
float r_mat[4][4], float scale, bool has_alembic_parent = false);
|
Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
|
|
|
|
|
|
|
|
template <typename Schema>
|
2016-08-17 22:20:15 +02:00
|
|
|
void get_min_max_time_ex(const Schema &schema, chrono_t &min, chrono_t &max)
|
Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
|
|
|
{
|
|
|
|
|
const Alembic::Abc::TimeSamplingPtr &time_samp = schema.getTimeSampling();
|
|
|
|
|
|
|
|
|
|
if (!schema.isConstant()) {
|
|
|
|
|
const size_t num_samps = schema.getNumSamples();
|
|
|
|
|
|
|
|
|
|
if (num_samps > 0) {
|
|
|
|
|
const chrono_t min_time = time_samp->getSampleTime(0);
|
|
|
|
|
min = std::min(min, min_time);
|
|
|
|
|
|
|
|
|
|
const chrono_t max_time = time_samp->getSampleTime(num_samps - 1);
|
|
|
|
|
max = std::max(max, max_time);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-17 22:20:15 +02:00
|
|
|
template <typename Schema>
|
|
|
|
|
void get_min_max_time(const Alembic::AbcGeom::IObject &object, const Schema &schema, chrono_t &min, chrono_t &max)
|
|
|
|
|
{
|
|
|
|
|
get_min_max_time_ex(schema, min, max);
|
|
|
|
|
|
2016-08-19 05:22:35 +02:00
|
|
|
const Alembic::AbcGeom::IObject &parent = object.getParent();
|
|
|
|
|
if (parent.valid() && Alembic::AbcGeom::IXform::matches(parent.getMetaData())) {
|
|
|
|
|
Alembic::AbcGeom::IXform xform(parent, Alembic::AbcGeom::kWrapExisting);
|
|
|
|
|
get_min_max_time_ex(xform.getSchema(), min, max);
|
|
|
|
|
}
|
2016-08-17 22:20:15 +02:00
|
|
|
}
|
|
|
|
|
|
Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
|
|
|
bool has_property(const Alembic::Abc::ICompoundProperty &prop, const std::string &name);
|
|
|
|
|
|
2016-09-20 14:15:02 +02:00
|
|
|
float get_weight_and_index(float time,
|
|
|
|
|
const Alembic::AbcCoreAbstract::TimeSamplingPtr &time_sampling,
|
|
|
|
|
int samples_number,
|
|
|
|
|
Alembic::AbcGeom::index_t &i0,
|
|
|
|
|
Alembic::AbcGeom::index_t &i1);
|
|
|
|
|
|
2016-10-29 12:23:09 +02:00
|
|
|
AbcObjectReader *create_reader(const Alembic::AbcGeom::IObject &object, ImportSettings &settings);
|
|
|
|
|
|
Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
|
|
|
/* ************************** */
|
|
|
|
|
|
|
|
|
|
/* TODO(kevin): for now keeping these transformations hardcoded to make sure
|
|
|
|
|
* everything works properly, and also because Alembic is almost exclusively
|
|
|
|
|
* used in Y-up software, but eventually they'll be set by the user in the UI
|
|
|
|
|
* like other importers/exporters do, to support other axis. */
|
|
|
|
|
|
|
|
|
|
/* Copy from Y-up to Z-up. */
|
|
|
|
|
|
2017-02-03 15:54:59 +01:00
|
|
|
ABC_INLINE void copy_zup_from_yup(float zup[3], const float yup[3])
|
Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
|
|
|
{
|
|
|
|
|
zup[0] = yup[0];
|
|
|
|
|
zup[1] = -yup[2];
|
|
|
|
|
zup[2] = yup[1];
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-03 15:54:59 +01:00
|
|
|
ABC_INLINE void copy_zup_from_yup(short zup[3], const short yup[3])
|
Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
|
|
|
{
|
|
|
|
|
zup[0] = yup[0];
|
|
|
|
|
zup[1] = -yup[2];
|
|
|
|
|
zup[2] = yup[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Copy from Z-up to Y-up. */
|
|
|
|
|
|
2017-02-03 15:54:59 +01:00
|
|
|
ABC_INLINE void copy_yup_from_zup(float yup[3], const float zup[3])
|
Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
|
|
|
{
|
|
|
|
|
yup[0] = zup[0];
|
|
|
|
|
yup[1] = zup[2];
|
|
|
|
|
yup[2] = -zup[1];
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-03 15:54:59 +01:00
|
|
|
ABC_INLINE void copy_yup_from_zup(short yup[3], const short zup[3])
|
Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
|
|
|
{
|
|
|
|
|
yup[0] = zup[0];
|
|
|
|
|
yup[1] = zup[2];
|
|
|
|
|
yup[2] = -zup[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif /* __ABC_UTIL_H__ */
|