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
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2019-02-18 11:23:17 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup balembic
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
#include "abc_mesh.h"
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#include "abc_transform.h"
|
|
|
|
#include "abc_util.h"
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include "DNA_material_types.h"
|
|
|
|
#include "DNA_mesh_types.h"
|
2018-06-06 14:16:44 +02:00
|
|
|
#include "DNA_meshdata_types.h"
|
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
|
|
|
#include "DNA_modifier_types.h"
|
2018-02-07 11:14:08 +11:00
|
|
|
#include "DNA_object_fluidsim_types.h"
|
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
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
|
|
|
#include "BLI_math_geom.h"
|
|
|
|
#include "BLI_string.h"
|
|
|
|
|
2019-01-15 16:45:12 +01:00
|
|
|
#include "BKE_animsys.h"
|
|
|
|
#include "BKE_key.h"
|
2018-11-07 15:37:31 +01:00
|
|
|
#include "BKE_library.h"
|
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
|
|
|
#include "BKE_main.h"
|
|
|
|
#include "BKE_material.h"
|
|
|
|
#include "BKE_mesh.h"
|
2018-06-06 14:16:44 +02:00
|
|
|
#include "BKE_mesh_runtime.h"
|
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
|
|
|
#include "BKE_modifier.h"
|
|
|
|
#include "BKE_object.h"
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
#include "ED_mesh.h"
|
2016-09-09 05:30:43 +02:00
|
|
|
|
|
|
|
#include "bmesh.h"
|
|
|
|
#include "bmesh_tools.h"
|
2018-06-07 18:49:56 +02:00
|
|
|
|
|
|
|
#include "DEG_depsgraph_query.h"
|
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::FloatArraySample;
|
|
|
|
using Alembic::Abc::ICompoundProperty;
|
|
|
|
using Alembic::Abc::Int32ArraySample;
|
|
|
|
using Alembic::Abc::Int32ArraySamplePtr;
|
|
|
|
using Alembic::Abc::P3fArraySamplePtr;
|
|
|
|
using Alembic::Abc::V2fArraySample;
|
|
|
|
using Alembic::Abc::V3fArraySample;
|
|
|
|
using Alembic::Abc::C4fArraySample;
|
|
|
|
|
|
|
|
using Alembic::AbcGeom::IFaceSet;
|
|
|
|
using Alembic::AbcGeom::IFaceSetSchema;
|
|
|
|
using Alembic::AbcGeom::IObject;
|
|
|
|
using Alembic::AbcGeom::IPolyMesh;
|
|
|
|
using Alembic::AbcGeom::IPolyMeshSchema;
|
|
|
|
using Alembic::AbcGeom::ISampleSelector;
|
|
|
|
using Alembic::AbcGeom::ISubD;
|
|
|
|
using Alembic::AbcGeom::ISubDSchema;
|
|
|
|
using Alembic::AbcGeom::IV2fGeomParam;
|
|
|
|
|
|
|
|
using Alembic::AbcGeom::OArrayProperty;
|
|
|
|
using Alembic::AbcGeom::OBoolProperty;
|
|
|
|
using Alembic::AbcGeom::OC3fArrayProperty;
|
|
|
|
using Alembic::AbcGeom::OC3fGeomParam;
|
|
|
|
using Alembic::AbcGeom::OC4fGeomParam;
|
|
|
|
using Alembic::AbcGeom::OCompoundProperty;
|
|
|
|
using Alembic::AbcGeom::OFaceSet;
|
|
|
|
using Alembic::AbcGeom::OFaceSetSchema;
|
|
|
|
using Alembic::AbcGeom::OFloatGeomParam;
|
|
|
|
using Alembic::AbcGeom::OInt32GeomParam;
|
|
|
|
using Alembic::AbcGeom::ON3fArrayProperty;
|
|
|
|
using Alembic::AbcGeom::ON3fGeomParam;
|
|
|
|
using Alembic::AbcGeom::OPolyMesh;
|
|
|
|
using Alembic::AbcGeom::OPolyMeshSchema;
|
|
|
|
using Alembic::AbcGeom::OSubD;
|
|
|
|
using Alembic::AbcGeom::OSubDSchema;
|
|
|
|
using Alembic::AbcGeom::OV2fGeomParam;
|
|
|
|
using Alembic::AbcGeom::OV3fGeomParam;
|
|
|
|
|
|
|
|
using Alembic::AbcGeom::kFacevaryingScope;
|
|
|
|
using Alembic::AbcGeom::kVaryingScope;
|
|
|
|
using Alembic::AbcGeom::kVertexScope;
|
|
|
|
using Alembic::AbcGeom::kWrapExisting;
|
|
|
|
using Alembic::AbcGeom::UInt32ArraySample;
|
|
|
|
using Alembic::AbcGeom::N3fArraySamplePtr;
|
|
|
|
using Alembic::AbcGeom::IN3fGeomParam;
|
|
|
|
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
/* NOTE: Alembic's polygon winding order is clockwise, to match with Renderman. */
|
|
|
|
|
2018-06-06 14:16:44 +02:00
|
|
|
static void get_vertices(struct Mesh *mesh, std::vector<Imath::V3f> &points)
|
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
|
|
|
{
|
|
|
|
points.clear();
|
2018-06-06 14:16:44 +02:00
|
|
|
points.resize(mesh->totvert);
|
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
|
|
|
|
2018-06-06 14:16:44 +02:00
|
|
|
MVert *verts = mesh->mvert;
|
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
|
|
|
|
2018-06-06 14:16:44 +02:00
|
|
|
for (int i = 0, e = mesh->totvert; i < e; ++i) {
|
2017-02-03 15:54:59 +01:00
|
|
|
copy_yup_from_zup(points[i].getValue(), verts[i].co);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-06 14:16:44 +02:00
|
|
|
static void get_topology(struct Mesh *mesh,
|
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
|
|
|
std::vector<int32_t> &poly_verts,
|
|
|
|
std::vector<int32_t> &loop_counts,
|
|
|
|
bool &smooth_normal)
|
|
|
|
{
|
2018-06-06 14:16:44 +02:00
|
|
|
const int num_poly = mesh->totpoly;
|
|
|
|
const int num_loops = mesh->totloop;
|
|
|
|
MLoop *mloop = mesh->mloop;
|
|
|
|
MPoly *mpoly = mesh->mpoly;
|
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
|
|
|
|
|
|
|
poly_verts.clear();
|
|
|
|
loop_counts.clear();
|
|
|
|
poly_verts.reserve(num_loops);
|
|
|
|
loop_counts.reserve(num_poly);
|
|
|
|
|
|
|
|
/* NOTE: data needs to be written in the reverse order. */
|
|
|
|
for (int i = 0; i < num_poly; ++i) {
|
|
|
|
MPoly &poly = mpoly[i];
|
|
|
|
loop_counts.push_back(poly.totloop);
|
|
|
|
|
|
|
|
smooth_normal |= ((poly.flag & ME_SMOOTH) != 0);
|
|
|
|
|
|
|
|
MLoop *loop = mloop + poly.loopstart + (poly.totloop - 1);
|
|
|
|
|
|
|
|
for (int j = 0; j < poly.totloop; ++j, --loop) {
|
|
|
|
poly_verts.push_back(loop->v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-06 14:16:44 +02:00
|
|
|
static void get_creases(struct Mesh *mesh,
|
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
|
|
|
std::vector<int32_t> &indices,
|
|
|
|
std::vector<int32_t> &lengths,
|
|
|
|
std::vector<float> &sharpnesses)
|
|
|
|
{
|
|
|
|
const float factor = 1.0f / 255.0f;
|
|
|
|
|
|
|
|
indices.clear();
|
|
|
|
lengths.clear();
|
|
|
|
sharpnesses.clear();
|
|
|
|
|
2018-06-06 14:16:44 +02:00
|
|
|
MEdge *edge = mesh->medge;
|
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
|
|
|
|
2018-06-06 14:16:44 +02:00
|
|
|
for (int i = 0, e = mesh->totedge; i < e; ++i) {
|
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 float sharpness = static_cast<float>(edge[i].crease) * factor;
|
|
|
|
|
|
|
|
if (sharpness != 0.0f) {
|
|
|
|
indices.push_back(edge[i].v1);
|
|
|
|
indices.push_back(edge[i].v2);
|
|
|
|
sharpnesses.push_back(sharpness);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lengths.resize(sharpnesses.size(), 2);
|
|
|
|
}
|
|
|
|
|
2018-06-06 14:16:44 +02:00
|
|
|
static void get_vertex_normals(struct Mesh *mesh, std::vector<Imath::V3f> &normals)
|
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
|
|
|
{
|
|
|
|
normals.clear();
|
2018-06-06 14:16:44 +02:00
|
|
|
normals.resize(mesh->totvert);
|
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
|
|
|
|
2018-06-06 14:16:44 +02:00
|
|
|
MVert *verts = mesh->mvert;
|
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
|
|
|
float no[3];
|
|
|
|
|
2018-06-06 14:16:44 +02:00
|
|
|
for (int i = 0, e = mesh->totvert; i < e; ++i) {
|
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
|
|
|
normal_short_to_float_v3(no, verts[i].no);
|
2017-02-03 15:54:59 +01:00
|
|
|
copy_yup_from_zup(normals[i].getValue(), no);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-06 14:16:44 +02:00
|
|
|
static void get_loop_normals(struct Mesh *mesh, std::vector<Imath::V3f> &normals)
|
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
|
|
|
{
|
2018-06-06 14:16:44 +02:00
|
|
|
MPoly *mp = mesh->mpoly;
|
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
|
|
|
|
2018-06-06 14:16:44 +02:00
|
|
|
MLoop *mloop = mesh->mloop;
|
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
|
|
|
MLoop *ml = mloop;
|
|
|
|
|
2018-06-06 14:16:44 +02:00
|
|
|
MVert *verts = mesh->mvert;
|
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
|
|
|
|
2018-06-06 14:16:44 +02:00
|
|
|
const float (*lnors)[3] = static_cast<float(*)[3]>(CustomData_get_layer(&mesh->ldata, CD_NORMAL));
|
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
|
|
|
|
|
|
|
normals.clear();
|
2018-06-06 14:16:44 +02:00
|
|
|
normals.resize(mesh->totloop);
|
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
|
|
|
|
|
|
|
unsigned loop_index = 0;
|
|
|
|
|
|
|
|
/* NOTE: data needs to be written in the reverse order. */
|
|
|
|
|
|
|
|
if (lnors) {
|
2018-06-06 14:16:44 +02:00
|
|
|
for (int i = 0, e = mesh->totpoly; i < e; ++i, ++mp) {
|
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
|
|
|
ml = mloop + mp->loopstart + (mp->totloop - 1);
|
|
|
|
|
|
|
|
for (int j = 0; j < mp->totloop; --ml, ++j, ++loop_index) {
|
|
|
|
const int index = ml->v;
|
2017-02-03 15:54:59 +01:00
|
|
|
copy_yup_from_zup(normals[loop_index].getValue(), lnors[index]);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
float no[3];
|
|
|
|
|
2018-06-06 14:16:44 +02:00
|
|
|
for (int i = 0, e = mesh->totpoly; i < e; ++i, ++mp) {
|
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
|
|
|
ml = mloop + mp->loopstart + (mp->totloop - 1);
|
|
|
|
|
|
|
|
/* Flat shaded, use common normal for all verts. */
|
|
|
|
if ((mp->flag & ME_SMOOTH) == 0) {
|
|
|
|
BKE_mesh_calc_poly_normal(mp, ml - (mp->totloop - 1), verts, no);
|
|
|
|
|
|
|
|
for (int j = 0; j < mp->totloop; --ml, ++j, ++loop_index) {
|
2017-02-03 15:54:59 +01:00
|
|
|
copy_yup_from_zup(normals[loop_index].getValue(), no);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Smooth shaded, use individual vert normals. */
|
|
|
|
for (int j = 0; j < mp->totloop; --ml, ++j, ++loop_index) {
|
|
|
|
normal_short_to_float_v3(no, verts[ml->v].no);
|
2017-02-03 15:54:59 +01:00
|
|
|
copy_yup_from_zup(normals[loop_index].getValue(), no);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* *************** Modifiers *************** */
|
|
|
|
|
|
|
|
/* check if the mesh is a subsurf, ignoring disabled modifiers and
|
|
|
|
* displace if it's after subsurf. */
|
|
|
|
static ModifierData *get_subsurf_modifier(Scene *scene, Object *ob)
|
|
|
|
{
|
|
|
|
ModifierData *md = static_cast<ModifierData *>(ob->modifiers.last);
|
|
|
|
|
|
|
|
for (; md; md = md->prev) {
|
|
|
|
if (!modifier_isEnabled(scene, md, eModifierMode_Render)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (md->type == eModifierType_Subsurf) {
|
|
|
|
SubsurfModifierData *smd = reinterpret_cast<SubsurfModifierData*>(md);
|
|
|
|
|
|
|
|
if (smd->subdivType == ME_CC_SUBSURF) {
|
|
|
|
return md;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mesh is not a subsurf. break */
|
|
|
|
if ((md->type != eModifierType_Displace) && (md->type != eModifierType_ParticleSystem)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ModifierData *get_liquid_sim_modifier(Scene *scene, Object *ob)
|
|
|
|
{
|
|
|
|
ModifierData *md = modifiers_findByType(ob, eModifierType_Fluidsim);
|
|
|
|
|
|
|
|
if (md && (modifier_isEnabled(scene, md, eModifierMode_Render))) {
|
|
|
|
FluidsimModifierData *fsmd = reinterpret_cast<FluidsimModifierData *>(md);
|
|
|
|
|
|
|
|
if (fsmd->fss && fsmd->fss->type == OB_FLUIDSIM_DOMAIN) {
|
|
|
|
return md;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
2019-01-15 15:16:39 +01:00
|
|
|
AbcGenericMeshWriter::AbcGenericMeshWriter(Object *ob,
|
|
|
|
AbcTransformWriter *parent,
|
|
|
|
uint32_t time_sampling,
|
|
|
|
ExportSettings &settings)
|
2018-06-07 17:54:36 +02:00
|
|
|
: AbcObjectWriter(ob, time_sampling, settings, parent)
|
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
|
|
|
{
|
|
|
|
m_is_animated = isAnimated();
|
|
|
|
m_subsurf_mod = NULL;
|
|
|
|
m_is_subd = false;
|
|
|
|
|
|
|
|
/* If the object is static, use the default static time sampling. */
|
|
|
|
if (!m_is_animated) {
|
|
|
|
time_sampling = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!m_settings.apply_subdiv) {
|
2018-06-07 17:54:36 +02:00
|
|
|
m_subsurf_mod = get_subsurf_modifier(m_settings.scene, m_object);
|
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
|
|
|
m_is_subd = (m_subsurf_mod != NULL);
|
|
|
|
}
|
|
|
|
|
2018-06-07 17:54:36 +02:00
|
|
|
m_is_liquid = (get_liquid_sim_modifier(m_settings.scene, m_object) != NULL);
|
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
|
|
|
|
|
|
|
while (parent->alembicXform().getChildHeader(m_name)) {
|
|
|
|
m_name.append("_");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_settings.use_subdiv_schema && m_is_subd) {
|
|
|
|
OSubD subd(parent->alembicXform(), m_name, m_time_sampling);
|
|
|
|
m_subdiv_schema = subd.getSchema();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
OPolyMesh mesh(parent->alembicXform(), m_name, m_time_sampling);
|
|
|
|
m_mesh_schema = mesh.getSchema();
|
|
|
|
|
|
|
|
OCompoundProperty typeContainer = m_mesh_schema.getUserProperties();
|
|
|
|
OBoolProperty type(typeContainer, "meshtype");
|
|
|
|
type.set(m_is_subd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-15 15:16:39 +01:00
|
|
|
AbcGenericMeshWriter::~AbcGenericMeshWriter()
|
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
|
|
|
{
|
|
|
|
if (m_subsurf_mod) {
|
|
|
|
m_subsurf_mod->mode &= ~eModifierMode_DisableTemporary;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-15 15:16:39 +01:00
|
|
|
bool AbcGenericMeshWriter::isAnimated() const
|
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
|
|
|
{
|
2019-01-15 16:45:12 +01:00
|
|
|
if (m_object->data != NULL) {
|
|
|
|
AnimData *adt = BKE_animdata_from_id(static_cast<ID*>(m_object->data));
|
|
|
|
/* TODO(Sybren): make this check more strict, as the AnimationData may
|
|
|
|
* actually be empty (no fcurves, drivers, etc.) and thus effectively
|
|
|
|
* have no animation at all. */
|
|
|
|
if (adt != NULL) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (BKE_key_from_object(m_object) != NULL) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/* Test modifiers. */
|
|
|
|
ModifierData *md = static_cast<ModifierData *>(m_object->modifiers.first);
|
|
|
|
while (md) {
|
2019-01-15 16:45:12 +01: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
|
|
|
if (md->type != eModifierType_Subsurf) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
md = md->next;
|
|
|
|
}
|
|
|
|
|
2019-01-15 15:16:39 +01:00
|
|
|
return 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
|
|
|
}
|
|
|
|
|
2019-01-15 15:16:39 +01:00
|
|
|
void AbcGenericMeshWriter::setIsAnimated(bool is_animated)
|
2017-10-28 19:18:27 +02:00
|
|
|
{
|
|
|
|
m_is_animated = is_animated;
|
|
|
|
}
|
|
|
|
|
2019-01-15 15:16:39 +01:00
|
|
|
void AbcGenericMeshWriter::do_write()
|
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
|
|
|
{
|
|
|
|
/* We have already stored a sample for this object. */
|
|
|
|
if (!m_first_frame && !m_is_animated)
|
|
|
|
return;
|
|
|
|
|
2018-06-06 15:43:10 +02:00
|
|
|
bool needsfree;
|
|
|
|
struct Mesh *mesh = getFinalMesh(needsfree);
|
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
|
|
|
|
|
|
|
try {
|
|
|
|
if (m_settings.use_subdiv_schema && m_subdiv_schema.valid()) {
|
2018-06-06 14:16:44 +02:00
|
|
|
writeSubD(mesh);
|
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
|
|
|
}
|
|
|
|
else {
|
2018-06-06 14:16:44 +02:00
|
|
|
writeMesh(mesh);
|
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
|
|
|
}
|
|
|
|
|
2018-06-06 15:43:10 +02:00
|
|
|
if (needsfree) BKE_id_free(NULL, mesh);
|
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
|
|
|
}
|
|
|
|
catch (...) {
|
2018-06-06 15:43:10 +02:00
|
|
|
if (needsfree) BKE_id_free(NULL, mesh);
|
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
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-15 15:16:39 +01:00
|
|
|
void AbcGenericMeshWriter::writeMesh(struct Mesh *mesh)
|
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
|
|
|
{
|
|
|
|
std::vector<Imath::V3f> points, normals;
|
|
|
|
std::vector<int32_t> poly_verts, loop_counts;
|
|
|
|
|
|
|
|
bool smooth_normal = false;
|
|
|
|
|
2018-06-06 14:16:44 +02:00
|
|
|
get_vertices(mesh, points);
|
|
|
|
get_topology(mesh, poly_verts, loop_counts, smooth_normal);
|
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
|
|
|
|
2016-09-23 19:44:51 +02:00
|
|
|
if (m_first_frame && m_settings.export_face_sets) {
|
2018-06-06 14:16:44 +02:00
|
|
|
writeFaceSets(mesh, m_mesh_schema);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
m_mesh_sample = OPolyMeshSchema::Sample(V3fArraySample(points),
|
|
|
|
Int32ArraySample(poly_verts),
|
|
|
|
Int32ArraySample(loop_counts));
|
|
|
|
|
|
|
|
UVSample sample;
|
2016-10-20 19:43:22 +02:00
|
|
|
if (m_first_frame && m_settings.export_uvs) {
|
2018-06-06 14:16:44 +02:00
|
|
|
const char *name = get_uv_sample(sample, m_custom_data_config, &mesh->ldata);
|
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
|
|
|
|
|
|
|
if (!sample.indices.empty() && !sample.uvs.empty()) {
|
|
|
|
OV2fGeomParam::Sample uv_sample;
|
|
|
|
uv_sample.setVals(V2fArraySample(sample.uvs));
|
|
|
|
uv_sample.setIndices(UInt32ArraySample(sample.indices));
|
|
|
|
uv_sample.setScope(kFacevaryingScope);
|
|
|
|
|
|
|
|
m_mesh_schema.setUVSourceName(name);
|
|
|
|
m_mesh_sample.setUVs(uv_sample);
|
|
|
|
}
|
|
|
|
|
2018-06-06 14:16:44 +02:00
|
|
|
write_custom_data(m_mesh_schema.getArbGeomParams(), m_custom_data_config, &mesh->ldata, CD_MLOOPUV);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
if (m_settings.export_normals) {
|
|
|
|
if (smooth_normal) {
|
2018-06-06 14:16:44 +02:00
|
|
|
get_loop_normals(mesh, normals);
|
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
|
|
|
}
|
|
|
|
else {
|
2018-06-06 14:16:44 +02:00
|
|
|
get_vertex_normals(mesh, normals);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
ON3fGeomParam::Sample normals_sample;
|
|
|
|
if (!normals.empty()) {
|
|
|
|
normals_sample.setScope((smooth_normal) ? kFacevaryingScope : kVertexScope);
|
|
|
|
normals_sample.setVals(V3fArraySample(normals));
|
|
|
|
}
|
|
|
|
|
|
|
|
m_mesh_sample.setNormals(normals_sample);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_is_liquid) {
|
|
|
|
std::vector<Imath::V3f> velocities;
|
2018-06-06 14:16:44 +02:00
|
|
|
getVelocities(mesh, velocities);
|
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
|
|
|
|
|
|
|
m_mesh_sample.setVelocities(V3fArraySample(velocities));
|
|
|
|
}
|
|
|
|
|
|
|
|
m_mesh_sample.setSelfBounds(bounds());
|
|
|
|
|
|
|
|
m_mesh_schema.set(m_mesh_sample);
|
|
|
|
|
2018-06-06 14:16:44 +02:00
|
|
|
writeArbGeoParams(mesh);
|
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
|
|
|
}
|
|
|
|
|
2019-01-15 15:16:39 +01:00
|
|
|
void AbcGenericMeshWriter::writeSubD(struct Mesh *mesh)
|
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
|
|
|
{
|
|
|
|
std::vector<float> crease_sharpness;
|
|
|
|
std::vector<Imath::V3f> points;
|
|
|
|
std::vector<int32_t> poly_verts, loop_counts;
|
|
|
|
std::vector<int32_t> crease_indices, crease_lengths;
|
|
|
|
|
|
|
|
bool smooth_normal = false;
|
|
|
|
|
2018-06-06 14:16:44 +02:00
|
|
|
get_vertices(mesh, points);
|
|
|
|
get_topology(mesh, poly_verts, loop_counts, smooth_normal);
|
|
|
|
get_creases(mesh, crease_indices, crease_lengths, crease_sharpness);
|
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
|
|
|
|
2016-09-23 19:44:51 +02:00
|
|
|
if (m_first_frame && m_settings.export_face_sets) {
|
2018-06-06 14:16:44 +02:00
|
|
|
writeFaceSets(mesh, m_subdiv_schema);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
m_subdiv_sample = OSubDSchema::Sample(V3fArraySample(points),
|
|
|
|
Int32ArraySample(poly_verts),
|
|
|
|
Int32ArraySample(loop_counts));
|
|
|
|
|
|
|
|
UVSample sample;
|
2016-10-20 19:43:22 +02:00
|
|
|
if (m_first_frame && m_settings.export_uvs) {
|
2018-06-06 14:16:44 +02:00
|
|
|
const char *name = get_uv_sample(sample, m_custom_data_config, &mesh->ldata);
|
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
|
|
|
|
|
|
|
if (!sample.indices.empty() && !sample.uvs.empty()) {
|
|
|
|
OV2fGeomParam::Sample uv_sample;
|
|
|
|
uv_sample.setVals(V2fArraySample(sample.uvs));
|
|
|
|
uv_sample.setIndices(UInt32ArraySample(sample.indices));
|
|
|
|
uv_sample.setScope(kFacevaryingScope);
|
|
|
|
|
|
|
|
m_subdiv_schema.setUVSourceName(name);
|
|
|
|
m_subdiv_sample.setUVs(uv_sample);
|
|
|
|
}
|
|
|
|
|
2018-06-06 14:16:44 +02:00
|
|
|
write_custom_data(m_subdiv_schema.getArbGeomParams(), m_custom_data_config, &mesh->ldata, CD_MLOOPUV);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
if (!crease_indices.empty()) {
|
|
|
|
m_subdiv_sample.setCreaseIndices(Int32ArraySample(crease_indices));
|
|
|
|
m_subdiv_sample.setCreaseLengths(Int32ArraySample(crease_lengths));
|
|
|
|
m_subdiv_sample.setCreaseSharpnesses(FloatArraySample(crease_sharpness));
|
|
|
|
}
|
|
|
|
|
|
|
|
m_subdiv_sample.setSelfBounds(bounds());
|
|
|
|
m_subdiv_schema.set(m_subdiv_sample);
|
|
|
|
|
2018-06-06 14:16:44 +02:00
|
|
|
writeArbGeoParams(mesh);
|
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>
|
2019-01-15 15:16:39 +01:00
|
|
|
void AbcGenericMeshWriter::writeFaceSets(struct Mesh *me, Schema &schema)
|
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
|
|
|
{
|
2019-01-15 18:50:24 +01:00
|
|
|
std::map< std::string, std::vector<int32_t>> geo_groups;
|
2018-10-23 15:00:40 +11:00
|
|
|
getGeoGroups(me, geo_groups);
|
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
|
|
|
|
2019-01-15 18:50:24 +01:00
|
|
|
std::map< std::string, std::vector<int32_t>>::iterator it;
|
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
|
|
|
for (it = geo_groups.begin(); it != geo_groups.end(); ++it) {
|
|
|
|
OFaceSet face_set = schema.createFaceSet(it->first);
|
|
|
|
OFaceSetSchema::Sample samp;
|
|
|
|
samp.setFaces(Int32ArraySample(it->second));
|
|
|
|
face_set.getSchema().set(samp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-15 15:16:39 +01:00
|
|
|
Mesh *AbcGenericMeshWriter::getFinalMesh(bool &r_needsfree)
|
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
|
|
|
{
|
|
|
|
/* We don't want subdivided mesh data */
|
|
|
|
if (m_subsurf_mod) {
|
|
|
|
m_subsurf_mod->mode |= eModifierMode_DisableTemporary;
|
|
|
|
}
|
|
|
|
|
2019-01-15 15:16:39 +01:00
|
|
|
r_needsfree = false;
|
|
|
|
|
2018-06-07 18:49:56 +02:00
|
|
|
Scene *scene = DEG_get_evaluated_scene(m_settings.depsgraph);
|
|
|
|
Object *ob_eval = DEG_get_evaluated_object(m_settings.depsgraph, m_object);
|
2019-01-15 15:16:39 +01:00
|
|
|
struct Mesh *mesh = getEvaluatedMesh(scene, ob_eval, r_needsfree);
|
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
|
|
|
|
|
|
|
if (m_subsurf_mod) {
|
|
|
|
m_subsurf_mod->mode &= ~eModifierMode_DisableTemporary;
|
|
|
|
}
|
|
|
|
|
2016-09-09 05:30:43 +02:00
|
|
|
if (m_settings.triangulate) {
|
|
|
|
const bool tag_only = false;
|
|
|
|
const int quad_method = m_settings.quad_method;
|
|
|
|
const int ngon_method = m_settings.ngon_method;
|
|
|
|
|
2018-06-08 15:09:01 +02:00
|
|
|
struct BMeshCreateParams bmcp = {false};
|
|
|
|
struct BMeshFromMeshParams bmfmp = {true, false, false, 0};
|
2018-06-06 14:16:44 +02:00
|
|
|
BMesh *bm = BKE_mesh_to_bmesh_ex(mesh, &bmcp, &bmfmp);
|
2016-09-09 05:30:43 +02:00
|
|
|
|
2019-03-22 17:55:51 +01:00
|
|
|
BM_mesh_triangulate(bm, quad_method, ngon_method, 4, tag_only, NULL, NULL, NULL);
|
2016-09-09 05:30:43 +02:00
|
|
|
|
Refactor CDData masks, to have one mask per mesh elem type.
We already have different storages for cddata of verts, edges etc.,
'simply' do the same for the mask flags we use all around Blender code
to request some data, or limit some operation to some layers, etc.
Reason we need this is that some cddata types (like Normals) are
actually shared between verts/polys/loops, and we don’t want to generate
clnors everytime we request vnors!
As a side note, this also does final fix to T59338, which was the
trigger for this patch (need to request computed loop normals for
another mesh than evaluated one).
Reviewers: brecht, campbellbarton, sergey
Differential Revision: https://developer.blender.org/D4407
2019-03-07 11:13:40 +01:00
|
|
|
Mesh *result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL);
|
2016-09-09 05:30:43 +02:00
|
|
|
BM_mesh_free(bm);
|
|
|
|
|
2019-01-15 16:14:05 +01:00
|
|
|
if (r_needsfree) {
|
|
|
|
BKE_id_free(NULL, mesh);
|
|
|
|
}
|
|
|
|
|
2018-06-06 14:16:44 +02:00
|
|
|
mesh = result;
|
2018-06-06 15:43:10 +02:00
|
|
|
r_needsfree = true;
|
2016-09-09 05:30:43 +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
|
|
|
m_custom_data_config.pack_uvs = m_settings.pack_uv;
|
2018-06-06 14:16:44 +02:00
|
|
|
m_custom_data_config.mpoly = mesh->mpoly;
|
|
|
|
m_custom_data_config.mloop = mesh->mloop;
|
|
|
|
m_custom_data_config.totpoly = mesh->totpoly;
|
|
|
|
m_custom_data_config.totloop = mesh->totloop;
|
|
|
|
m_custom_data_config.totvert = mesh->totvert;
|
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
|
|
|
|
2018-06-06 14:16:44 +02:00
|
|
|
return mesh;
|
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
|
|
|
}
|
|
|
|
|
2019-01-15 15:16:39 +01:00
|
|
|
void AbcGenericMeshWriter::writeArbGeoParams(struct Mesh *me)
|
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
|
|
|
{
|
|
|
|
if (m_is_liquid) {
|
|
|
|
/* We don't need anything more for liquid meshes. */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-10-20 19:43:22 +02:00
|
|
|
if (m_first_frame && m_settings.export_vcols) {
|
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
|
|
|
if (m_subdiv_schema.valid()) {
|
2018-10-23 15:00:40 +11:00
|
|
|
write_custom_data(m_subdiv_schema.getArbGeomParams(), m_custom_data_config, &me->ldata, CD_MLOOPCOL);
|
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
|
|
|
}
|
|
|
|
else {
|
2018-10-23 15:00:40 +11:00
|
|
|
write_custom_data(m_mesh_schema.getArbGeomParams(), m_custom_data_config, &me->ldata, CD_MLOOPCOL);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-15 15:16:39 +01:00
|
|
|
void AbcGenericMeshWriter::getVelocities(struct Mesh *mesh, std::vector<Imath::V3f> &vels)
|
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
|
|
|
{
|
2018-06-06 14:16:44 +02:00
|
|
|
const int totverts = mesh->totvert;
|
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
|
|
|
|
|
|
|
vels.clear();
|
|
|
|
vels.resize(totverts);
|
|
|
|
|
2018-06-07 17:54:36 +02:00
|
|
|
ModifierData *md = get_liquid_sim_modifier(m_settings.scene, m_object);
|
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
|
|
|
FluidsimModifierData *fmd = reinterpret_cast<FluidsimModifierData *>(md);
|
|
|
|
FluidsimSettings *fss = fmd->fss;
|
|
|
|
|
|
|
|
if (fss->meshVelocities) {
|
|
|
|
float *mesh_vels = reinterpret_cast<float *>(fss->meshVelocities);
|
|
|
|
|
|
|
|
for (int i = 0; i < totverts; ++i) {
|
2017-02-03 15:54:59 +01:00
|
|
|
copy_yup_from_zup(vels[i].getValue(), mesh_vels);
|
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
|
|
|
mesh_vels += 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
std::fill(vels.begin(), vels.end(), Imath::V3f(0.0f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-15 15:16:39 +01:00
|
|
|
void AbcGenericMeshWriter::getGeoGroups(
|
2018-06-06 14:16:44 +02:00
|
|
|
struct Mesh *mesh,
|
2019-01-15 18:50:24 +01:00
|
|
|
std::map<std::string, std::vector<int32_t>> &geo_groups)
|
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
|
|
|
{
|
2018-06-06 14:16:44 +02:00
|
|
|
const int num_poly = mesh->totpoly;
|
|
|
|
MPoly *polygons = mesh->mpoly;
|
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
|
|
|
|
|
|
|
for (int i = 0; i < num_poly; ++i) {
|
|
|
|
MPoly ¤t_poly = polygons[i];
|
|
|
|
short mnr = current_poly.mat_nr;
|
|
|
|
|
|
|
|
Material *mat = give_current_material(m_object, mnr + 1);
|
|
|
|
|
|
|
|
if (!mat) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string name = get_id_name(&mat->id);
|
|
|
|
|
|
|
|
if (geo_groups.find(name) == geo_groups.end()) {
|
|
|
|
std::vector<int32_t> faceArray;
|
|
|
|
geo_groups[name] = faceArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
geo_groups[name].push_back(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (geo_groups.size() == 0) {
|
|
|
|
Material *mat = give_current_material(m_object, 1);
|
|
|
|
|
|
|
|
std::string name = (mat) ? get_id_name(&mat->id) : "default";
|
|
|
|
|
|
|
|
std::vector<int32_t> faceArray;
|
|
|
|
|
2018-06-06 14:16:44 +02:00
|
|
|
for (int i = 0, e = mesh->totface; i < e; ++i) {
|
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
|
|
|
faceArray.push_back(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
geo_groups[name] = faceArray;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-15 15:16:39 +01:00
|
|
|
|
|
|
|
AbcMeshWriter::AbcMeshWriter(Object *ob,
|
|
|
|
AbcTransformWriter *parent,
|
|
|
|
uint32_t time_sampling,
|
|
|
|
ExportSettings &settings)
|
|
|
|
: AbcGenericMeshWriter(ob, parent, time_sampling, settings)
|
|
|
|
{}
|
|
|
|
|
|
|
|
AbcMeshWriter::~AbcMeshWriter()
|
|
|
|
{}
|
|
|
|
|
2019-01-15 16:45:12 +01:00
|
|
|
Mesh *AbcMeshWriter::getEvaluatedMesh(Scene *scene_eval, Object *ob_eval, bool &UNUSED(r_needsfree))
|
2019-01-15 15:16:39 +01:00
|
|
|
{
|
Refactor CDData masks, to have one mask per mesh elem type.
We already have different storages for cddata of verts, edges etc.,
'simply' do the same for the mask flags we use all around Blender code
to request some data, or limit some operation to some layers, etc.
Reason we need this is that some cddata types (like Normals) are
actually shared between verts/polys/loops, and we don’t want to generate
clnors everytime we request vnors!
As a side note, this also does final fix to T59338, which was the
trigger for this patch (need to request computed loop normals for
another mesh than evaluated one).
Reviewers: brecht, campbellbarton, sergey
Differential Revision: https://developer.blender.org/D4407
2019-03-07 11:13:40 +01:00
|
|
|
return mesh_get_eval_final(m_settings.depsgraph, scene_eval, ob_eval, &CD_MASK_MESH);
|
2019-01-15 15:16:39 +01: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
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
/* Some helpers for mesh generation */
|
|
|
|
namespace utils {
|
|
|
|
|
|
|
|
static void build_mat_map(const Main *bmain, std::map<std::string, Material *> &mat_map)
|
|
|
|
{
|
2019-03-08 09:29:17 +11:00
|
|
|
Material *material = static_cast<Material *>(bmain->materials.first);
|
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
|
|
|
|
|
|
|
for (; material; material = static_cast<Material *>(material->id.next)) {
|
|
|
|
mat_map[material->id.name + 2] = material;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void assign_materials(Main *bmain, Object *ob, const std::map<std::string, int> &mat_index_map)
|
|
|
|
{
|
|
|
|
bool can_assign = true;
|
|
|
|
std::map<std::string, int>::const_iterator it = mat_index_map.begin();
|
|
|
|
|
|
|
|
int matcount = 0;
|
|
|
|
for (; it != mat_index_map.end(); ++it, ++matcount) {
|
2018-05-29 15:49:21 +02:00
|
|
|
if (!BKE_object_material_slot_add(bmain, ob)) {
|
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
|
|
|
can_assign = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* TODO(kevin): use global map? */
|
|
|
|
std::map<std::string, Material *> mat_map;
|
|
|
|
build_mat_map(bmain, mat_map);
|
|
|
|
|
|
|
|
std::map<std::string, Material *>::iterator mat_iter;
|
|
|
|
|
|
|
|
if (can_assign) {
|
|
|
|
it = mat_index_map.begin();
|
|
|
|
|
|
|
|
for (; it != mat_index_map.end(); ++it) {
|
|
|
|
std::string mat_name = it->first;
|
|
|
|
mat_iter = mat_map.find(mat_name.c_str());
|
|
|
|
|
2017-08-09 11:44:22 +02:00
|
|
|
Material *assigned_mat;
|
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
|
|
|
|
|
|
|
if (mat_iter == mat_map.end()) {
|
2017-08-09 11:44:22 +02:00
|
|
|
assigned_mat = BKE_material_add(bmain, mat_name.c_str());
|
|
|
|
mat_map[mat_name] = assigned_mat;
|
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
|
|
|
}
|
|
|
|
else {
|
2017-08-09 11:44:22 +02:00
|
|
|
assigned_mat = mat_iter->second;
|
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
|
|
|
}
|
|
|
|
|
2018-05-29 15:49:21 +02:00
|
|
|
assign_material(bmain, ob, assigned_mat, it->second, BKE_MAT_ASSIGN_OBDATA);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} /* namespace utils */
|
|
|
|
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
using Alembic::AbcGeom::UInt32ArraySamplePtr;
|
|
|
|
using Alembic::AbcGeom::V2fArraySamplePtr;
|
|
|
|
|
|
|
|
struct AbcMeshData {
|
|
|
|
Int32ArraySamplePtr face_indices;
|
|
|
|
Int32ArraySamplePtr face_counts;
|
|
|
|
|
|
|
|
P3fArraySamplePtr positions;
|
2016-09-09 05:59:20 +02:00
|
|
|
P3fArraySamplePtr ceil_positions;
|
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
|
|
|
|
|
|
|
N3fArraySamplePtr vertex_normals;
|
|
|
|
N3fArraySamplePtr face_normals;
|
|
|
|
|
|
|
|
V2fArraySamplePtr uvs;
|
|
|
|
UInt32ArraySamplePtr uvs_indices;
|
|
|
|
};
|
|
|
|
|
2016-09-09 05:59:20 +02:00
|
|
|
static void read_mverts_interp(MVert *mverts, const P3fArraySamplePtr &positions, const P3fArraySamplePtr &ceil_positions, const float weight)
|
|
|
|
{
|
|
|
|
float tmp[3];
|
|
|
|
for (int i = 0; i < positions->size(); ++i) {
|
|
|
|
MVert &mvert = mverts[i];
|
|
|
|
const Imath::V3f &floor_pos = (*positions)[i];
|
|
|
|
const Imath::V3f &ceil_pos = (*ceil_positions)[i];
|
|
|
|
|
|
|
|
interp_v3_v3v3(tmp, floor_pos.getValue(), ceil_pos.getValue(), weight);
|
2017-02-03 15:54:59 +01:00
|
|
|
copy_zup_from_yup(mvert.co, tmp);
|
2016-09-09 05:59:20 +02:00
|
|
|
|
|
|
|
mvert.bweight = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
static void read_mverts(CDStreamConfig &config, const AbcMeshData &mesh_data)
|
|
|
|
{
|
|
|
|
MVert *mverts = config.mvert;
|
|
|
|
const P3fArraySamplePtr &positions = mesh_data.positions;
|
|
|
|
const N3fArraySamplePtr &normals = mesh_data.vertex_normals;
|
|
|
|
|
2016-09-25 22:09:05 +02:00
|
|
|
if ( config.weight != 0.0f
|
|
|
|
&& mesh_data.ceil_positions != NULL
|
|
|
|
&& mesh_data.ceil_positions->size() == positions->size())
|
|
|
|
{
|
2016-09-09 05:59:20 +02:00
|
|
|
read_mverts_interp(mverts, positions, mesh_data.ceil_positions, config.weight);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
read_mverts(mverts, positions, normals);
|
|
|
|
}
|
|
|
|
|
|
|
|
void read_mverts(MVert *mverts, const P3fArraySamplePtr &positions, const N3fArraySamplePtr &normals)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < positions->size(); ++i) {
|
|
|
|
MVert &mvert = mverts[i];
|
|
|
|
Imath::V3f pos_in = (*positions)[i];
|
|
|
|
|
2017-02-03 15:54:59 +01:00
|
|
|
copy_zup_from_yup(mvert.co, pos_in.getValue());
|
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
|
|
|
|
|
|
|
mvert.bweight = 0;
|
|
|
|
|
|
|
|
if (normals) {
|
|
|
|
Imath::V3f nor_in = (*normals)[i];
|
|
|
|
|
|
|
|
short no[3];
|
|
|
|
normal_float_to_short_v3(no, nor_in.getValue());
|
|
|
|
|
2017-02-03 15:54:59 +01:00
|
|
|
copy_zup_from_yup(mvert.no, no);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void read_mpolys(CDStreamConfig &config, const AbcMeshData &mesh_data)
|
|
|
|
{
|
|
|
|
MPoly *mpolys = config.mpoly;
|
|
|
|
MLoop *mloops = config.mloop;
|
|
|
|
MLoopUV *mloopuvs = config.mloopuv;
|
|
|
|
|
|
|
|
const Int32ArraySamplePtr &face_indices = mesh_data.face_indices;
|
|
|
|
const Int32ArraySamplePtr &face_counts = mesh_data.face_counts;
|
|
|
|
const V2fArraySamplePtr &uvs = mesh_data.uvs;
|
|
|
|
const UInt32ArraySamplePtr &uvs_indices = mesh_data.uvs_indices;
|
|
|
|
const N3fArraySamplePtr &normals = mesh_data.face_normals;
|
|
|
|
|
|
|
|
const bool do_uvs = (mloopuvs && uvs && uvs_indices) && (uvs_indices->size() == face_indices->size());
|
|
|
|
unsigned int loop_index = 0;
|
|
|
|
unsigned int rev_loop_index = 0;
|
|
|
|
unsigned int uv_index = 0;
|
|
|
|
|
|
|
|
for (int i = 0; i < face_counts->size(); ++i) {
|
|
|
|
const int face_size = (*face_counts)[i];
|
|
|
|
|
|
|
|
MPoly &poly = mpolys[i];
|
|
|
|
poly.loopstart = loop_index;
|
|
|
|
poly.totloop = face_size;
|
|
|
|
|
|
|
|
if (normals != NULL) {
|
|
|
|
poly.flag |= ME_SMOOTH;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* NOTE: Alembic data is stored in the reverse order. */
|
|
|
|
rev_loop_index = loop_index + (face_size - 1);
|
|
|
|
|
|
|
|
for (int f = 0; f < face_size; ++f, ++loop_index, --rev_loop_index) {
|
|
|
|
MLoop &loop = mloops[rev_loop_index];
|
|
|
|
loop.v = (*face_indices)[loop_index];
|
|
|
|
|
|
|
|
if (do_uvs) {
|
|
|
|
MLoopUV &loopuv = mloopuvs[rev_loop_index];
|
|
|
|
|
|
|
|
uv_index = (*uvs_indices)[loop_index];
|
|
|
|
loopuv.uv[0] = (*uvs)[uv_index][0];
|
|
|
|
loopuv.uv[1] = (*uvs)[uv_index][1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ABC_INLINE void read_uvs_params(CDStreamConfig &config,
|
|
|
|
AbcMeshData &abc_data,
|
|
|
|
const IV2fGeomParam &uv,
|
|
|
|
const ISampleSelector &selector)
|
|
|
|
{
|
|
|
|
if (!uv.valid()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
IV2fGeomParam::Sample uvsamp;
|
|
|
|
uv.getIndexed(uvsamp, selector);
|
|
|
|
|
|
|
|
abc_data.uvs = uvsamp.getVals();
|
|
|
|
abc_data.uvs_indices = uvsamp.getIndices();
|
|
|
|
|
|
|
|
if (abc_data.uvs_indices->size() == config.totloop) {
|
|
|
|
std::string name = Alembic::Abc::GetSourceName(uv.getMetaData());
|
|
|
|
|
|
|
|
/* According to the convention, primary UVs should have had their name
|
|
|
|
* set using Alembic::Abc::SetSourceName, but you can't expect everyone
|
|
|
|
* to follow it! :) */
|
|
|
|
if (name.empty()) {
|
|
|
|
name = uv.getName();
|
|
|
|
}
|
|
|
|
|
|
|
|
void *cd_ptr = config.add_customdata_cb(config.user_data, name.c_str(), CD_MLOOPUV);
|
|
|
|
config.mloopuv = static_cast<MLoopUV *>(cd_ptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* TODO(kevin): normals from Alembic files are not read in anymore, this is due
|
|
|
|
* to the fact that there are many issues that are not so easy to solve, mainly
|
|
|
|
* regarding the way normals are handled in Blender (MPoly.flag vs loop normals).
|
|
|
|
*/
|
|
|
|
ABC_INLINE void read_normals_params(AbcMeshData &abc_data,
|
|
|
|
const IN3fGeomParam &normals,
|
|
|
|
const ISampleSelector &selector)
|
|
|
|
{
|
|
|
|
if (!normals.valid()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
IN3fGeomParam::Sample normsamp = normals.getExpandedValue(selector);
|
|
|
|
|
|
|
|
if (normals.getScope() == kFacevaryingScope) {
|
|
|
|
abc_data.face_normals = normsamp.getVals();
|
|
|
|
}
|
|
|
|
else if ((normals.getScope() == kVertexScope) || (normals.getScope() == kVaryingScope)) {
|
|
|
|
abc_data.vertex_normals = N3fArraySamplePtr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-06 11:06:11 +02:00
|
|
|
static bool check_smooth_poly_flag(Mesh *mesh)
|
2016-10-29 12:23:09 +02:00
|
|
|
{
|
2018-06-06 11:06:11 +02:00
|
|
|
MPoly *mpolys = mesh->mpoly;
|
2016-10-29 12:23:09 +02:00
|
|
|
|
2018-06-06 11:06:11 +02:00
|
|
|
for (int i = 0, e = mesh->totpoly; i < e; ++i) {
|
2016-10-29 12:23:09 +02:00
|
|
|
MPoly &poly = mpolys[i];
|
|
|
|
|
|
|
|
if ((poly.flag & ME_SMOOTH) != 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-06-06 11:06:11 +02:00
|
|
|
static void set_smooth_poly_flag(Mesh *mesh)
|
2016-10-29 12:23:09 +02:00
|
|
|
{
|
2018-06-06 11:06:11 +02:00
|
|
|
MPoly *mpolys = mesh->mpoly;
|
2016-10-29 12:23:09 +02:00
|
|
|
|
2018-06-06 11:06:11 +02:00
|
|
|
for (int i = 0, e = mesh->totpoly; i < e; ++i) {
|
2016-10-29 12:23:09 +02:00
|
|
|
MPoly &poly = mpolys[i];
|
|
|
|
poly.flag |= ME_SMOOTH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *add_customdata_cb(void *user_data, const char *name, int data_type)
|
|
|
|
{
|
2018-06-06 11:06:11 +02:00
|
|
|
Mesh *mesh = static_cast<Mesh *>(user_data);
|
2016-10-29 12:23:09 +02:00
|
|
|
CustomDataType cd_data_type = static_cast<CustomDataType>(data_type);
|
2017-04-12 16:33:40 +02:00
|
|
|
void *cd_ptr;
|
|
|
|
CustomData *loopdata;
|
|
|
|
int numloops;
|
|
|
|
|
|
|
|
/* unsupported custom data type -- don't do anything. */
|
|
|
|
if (!ELEM(cd_data_type, CD_MLOOPUV, CD_MLOOPCOL)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-06-06 11:06:11 +02:00
|
|
|
loopdata = &mesh->ldata;
|
2017-04-12 16:33:40 +02:00
|
|
|
cd_ptr = CustomData_get_layer_named(loopdata, cd_data_type, name);
|
|
|
|
if (cd_ptr != NULL) {
|
|
|
|
/* layer already exists, so just return it. */
|
|
|
|
return cd_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* create a new layer, taking care to construct the hopefully-soon-to-be-removed
|
|
|
|
* CD_MTEXPOLY layer too, with the same name. */
|
2018-06-06 11:06:11 +02:00
|
|
|
numloops = mesh->totloop;
|
2017-04-12 16:33:40 +02:00
|
|
|
cd_ptr = CustomData_add_layer_named(loopdata, cd_data_type, CD_DEFAULT,
|
|
|
|
NULL, numloops, name);
|
2016-10-29 12:23:09 +02:00
|
|
|
return cd_ptr;
|
|
|
|
}
|
|
|
|
|
2016-11-30 09:33:47 +01:00
|
|
|
static void get_weight_and_index(CDStreamConfig &config,
|
|
|
|
Alembic::AbcCoreAbstract::TimeSamplingPtr time_sampling,
|
|
|
|
size_t samples_number)
|
|
|
|
{
|
|
|
|
Alembic::AbcGeom::index_t i0, i1;
|
|
|
|
|
|
|
|
config.weight = get_weight_and_index(config.time,
|
|
|
|
time_sampling,
|
|
|
|
samples_number,
|
|
|
|
i0,
|
|
|
|
i1);
|
|
|
|
|
|
|
|
config.index = i0;
|
|
|
|
config.ceil_index = i1;
|
|
|
|
}
|
|
|
|
|
2017-08-15 12:43:17 +02:00
|
|
|
static void read_mesh_sample(const std::string & iobject_full_name,
|
|
|
|
ImportSettings *settings,
|
2016-11-30 09:33:47 +01:00
|
|
|
const IPolyMeshSchema &schema,
|
|
|
|
const ISampleSelector &selector,
|
|
|
|
CDStreamConfig &config,
|
|
|
|
bool &do_normals)
|
|
|
|
{
|
|
|
|
const IPolyMeshSchema::Sample sample = schema.getValue(selector);
|
|
|
|
|
|
|
|
AbcMeshData abc_mesh_data;
|
|
|
|
abc_mesh_data.face_counts = sample.getFaceCounts();
|
|
|
|
abc_mesh_data.face_indices = sample.getFaceIndices();
|
|
|
|
abc_mesh_data.positions = sample.getPositions();
|
|
|
|
|
|
|
|
read_normals_params(abc_mesh_data, schema.getNormalsParam(), selector);
|
|
|
|
|
|
|
|
do_normals = (abc_mesh_data.face_normals != NULL);
|
|
|
|
|
|
|
|
get_weight_and_index(config, schema.getTimeSampling(), schema.getNumSamples());
|
|
|
|
|
|
|
|
if (config.weight != 0.0f) {
|
|
|
|
Alembic::AbcGeom::IPolyMeshSchema::Sample ceil_sample;
|
2016-12-01 08:32:02 +01:00
|
|
|
schema.get(ceil_sample, Alembic::Abc::ISampleSelector(config.ceil_index));
|
2016-11-30 09:33:47 +01:00
|
|
|
abc_mesh_data.ceil_positions = ceil_sample.getPositions();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings->read_flag & MOD_MESHSEQ_READ_UV) != 0) {
|
|
|
|
read_uvs_params(config, abc_mesh_data, schema.getUVsParam(), selector);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings->read_flag & MOD_MESHSEQ_READ_VERT) != 0) {
|
|
|
|
read_mverts(config, abc_mesh_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings->read_flag & MOD_MESHSEQ_READ_POLY) != 0) {
|
|
|
|
read_mpolys(config, abc_mesh_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings->read_flag & (MOD_MESHSEQ_READ_UV | MOD_MESHSEQ_READ_COLOR)) != 0) {
|
2017-08-15 12:43:17 +02:00
|
|
|
read_custom_data(iobject_full_name,
|
|
|
|
schema.getArbGeomParams(), config, selector);
|
2016-11-30 09:33:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-06 11:06:11 +02:00
|
|
|
CDStreamConfig get_config(Mesh *mesh)
|
2016-10-29 12:23:09 +02:00
|
|
|
{
|
|
|
|
CDStreamConfig config;
|
|
|
|
|
2018-06-06 11:06:11 +02:00
|
|
|
BLI_assert(mesh->mvert);
|
|
|
|
|
|
|
|
config.user_data = mesh;
|
|
|
|
config.mvert = mesh->mvert;
|
|
|
|
config.mloop = mesh->mloop;
|
|
|
|
config.mpoly = mesh->mpoly;
|
|
|
|
config.totloop = mesh->totloop;
|
|
|
|
config.totpoly = mesh->totpoly;
|
|
|
|
config.loopdata = &mesh->ldata;
|
2016-10-29 12:23:09 +02:00
|
|
|
config.add_customdata_cb = add_customdata_cb;
|
|
|
|
|
|
|
|
return config;
|
|
|
|
}
|
|
|
|
|
2016-11-30 09:33:47 +01:00
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
AbcMeshReader::AbcMeshReader(const IObject &object, ImportSettings &settings)
|
|
|
|
: AbcObjectReader(object, settings)
|
|
|
|
{
|
|
|
|
m_settings->read_flag |= MOD_MESHSEQ_READ_ALL;
|
|
|
|
|
|
|
|
IPolyMesh ipoly_mesh(m_iobject, kWrapExisting);
|
|
|
|
m_schema = ipoly_mesh.getSchema();
|
|
|
|
|
|
|
|
get_min_max_time(m_iobject, m_schema, m_min_time, m_max_time);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AbcMeshReader::valid() const
|
|
|
|
{
|
|
|
|
return m_schema.valid();
|
|
|
|
}
|
|
|
|
|
2017-04-26 16:56:50 +02:00
|
|
|
void AbcMeshReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel)
|
2016-11-30 09:33:47 +01:00
|
|
|
{
|
|
|
|
Mesh *mesh = BKE_mesh_add(bmain, m_data_name.c_str());
|
|
|
|
|
|
|
|
m_object = BKE_object_add_only_object(bmain, OB_MESH, m_object_name.c_str());
|
|
|
|
m_object->data = mesh;
|
|
|
|
|
2018-06-06 11:06:11 +02:00
|
|
|
Mesh *read_mesh = this->read_mesh(mesh, sample_sel, MOD_MESHSEQ_READ_ALL, NULL);
|
Refactor CDData masks, to have one mask per mesh elem type.
We already have different storages for cddata of verts, edges etc.,
'simply' do the same for the mask flags we use all around Blender code
to request some data, or limit some operation to some layers, etc.
Reason we need this is that some cddata types (like Normals) are
actually shared between verts/polys/loops, and we don’t want to generate
clnors everytime we request vnors!
As a side note, this also does final fix to T59338, which was the
trigger for this patch (need to request computed loop normals for
another mesh than evaluated one).
Reviewers: brecht, campbellbarton, sergey
Differential Revision: https://developer.blender.org/D4407
2019-03-07 11:13:40 +01:00
|
|
|
BKE_mesh_nomain_to_mesh(read_mesh, mesh, m_object, &CD_MASK_MESH, true);
|
2016-11-30 09:33:47 +01:00
|
|
|
|
|
|
|
if (m_settings->validate_meshes) {
|
|
|
|
BKE_mesh_validate(mesh, false, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
readFaceSetsSample(bmain, mesh, 0, sample_sel);
|
|
|
|
|
|
|
|
if (has_animations(m_schema, m_settings)) {
|
|
|
|
addCacheModifier();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-28 13:48:00 +02:00
|
|
|
bool AbcMeshReader::accepts_object_type(const Alembic::AbcCoreAbstract::ObjectHeader &alembic_header,
|
|
|
|
const Object *const ob,
|
|
|
|
const char **err_str) const
|
|
|
|
{
|
|
|
|
if (!Alembic::AbcGeom::IPolyMesh::matches(alembic_header)) {
|
|
|
|
*err_str = "Object type mismatch, Alembic object path pointed to PolyMesh when importing, but not any more.";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ob->type != OB_MESH) {
|
|
|
|
*err_str = "Object type mismatch, Alembic object path points to PolyMesh.";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-06-06 11:06:11 +02:00
|
|
|
Mesh *AbcMeshReader::read_mesh(Mesh *existing_mesh,
|
|
|
|
const ISampleSelector &sample_sel,
|
|
|
|
int read_flag,
|
|
|
|
const char **err_str)
|
2016-10-29 12:23:09 +02:00
|
|
|
{
|
2018-06-07 18:34:05 +02:00
|
|
|
IPolyMeshSchema::Sample sample;
|
|
|
|
try {
|
|
|
|
sample = m_schema.getValue(sample_sel);
|
|
|
|
}
|
|
|
|
catch(Alembic::Util::Exception &ex) {
|
|
|
|
*err_str = "Error reading mesh sample; more detail on the console";
|
|
|
|
printf("Alembic: error reading mesh sample for '%s/%s' at time %f: %s\n",
|
2019-03-15 08:53:22 +11:00
|
|
|
m_iobject.getFullName().c_str(),
|
|
|
|
m_schema.getName().c_str(),
|
|
|
|
sample_sel.getRequestedTime(),
|
|
|
|
ex.what());
|
2018-06-07 18:34:05 +02:00
|
|
|
return existing_mesh;
|
|
|
|
}
|
2016-10-29 12:23:09 +02:00
|
|
|
|
|
|
|
const P3fArraySamplePtr &positions = sample.getPositions();
|
|
|
|
const Alembic::Abc::Int32ArraySamplePtr &face_indices = sample.getFaceIndices();
|
|
|
|
const Alembic::Abc::Int32ArraySamplePtr &face_counts = sample.getFaceCounts();
|
|
|
|
|
2018-06-06 11:06:11 +02:00
|
|
|
Mesh *new_mesh = NULL;
|
2016-10-29 12:23:09 +02:00
|
|
|
|
|
|
|
/* Only read point data when streaming meshes, unless we need to create new ones. */
|
|
|
|
ImportSettings settings;
|
|
|
|
settings.read_flag |= read_flag;
|
|
|
|
|
2018-06-06 11:06:11 +02:00
|
|
|
bool topology_changed = positions->size() != existing_mesh->totvert ||
|
|
|
|
face_counts->size() != existing_mesh->totpoly ||
|
|
|
|
face_indices->size() != existing_mesh->totloop;
|
2017-10-29 13:55:42 +01:00
|
|
|
if (topology_changed) {
|
2018-06-06 11:06:11 +02:00
|
|
|
new_mesh = BKE_mesh_new_nomain_from_template(existing_mesh,
|
|
|
|
positions->size(),
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
face_indices->size(),
|
|
|
|
face_counts->size());
|
2016-10-29 12:23:09 +02:00
|
|
|
|
|
|
|
settings.read_flag |= MOD_MESHSEQ_READ_ALL;
|
|
|
|
}
|
2016-11-30 09:20:45 +01:00
|
|
|
else {
|
|
|
|
/* If the face count changed (e.g. by triangulation), only read points.
|
2016-11-30 09:33:47 +01:00
|
|
|
* This prevents crash from T49813.
|
2016-11-30 09:20:45 +01:00
|
|
|
* TODO(kevin): perhaps find a better way to do this? */
|
2018-06-06 11:06:11 +02:00
|
|
|
if (face_counts->size() != existing_mesh->totpoly ||
|
|
|
|
face_indices->size() != existing_mesh->totloop)
|
2016-11-30 09:20:45 +01:00
|
|
|
{
|
|
|
|
settings.read_flag = MOD_MESHSEQ_READ_VERT;
|
|
|
|
|
|
|
|
if (err_str) {
|
|
|
|
*err_str = "Topology has changed, perhaps by triangulating the"
|
|
|
|
" mesh. Only vertices will be read!";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-10-29 12:23:09 +02:00
|
|
|
|
2018-06-06 11:06:11 +02:00
|
|
|
CDStreamConfig config = get_config(new_mesh ? new_mesh : existing_mesh);
|
2017-04-26 16:56:50 +02:00
|
|
|
config.time = sample_sel.getRequestedTime();
|
2016-10-29 12:23:09 +02:00
|
|
|
|
|
|
|
bool do_normals = false;
|
2017-08-15 12:43:17 +02:00
|
|
|
read_mesh_sample(m_iobject.getFullName(),
|
|
|
|
&settings, m_schema, sample_sel, config, do_normals);
|
2016-10-29 12:23:09 +02:00
|
|
|
|
2018-06-06 11:06:11 +02:00
|
|
|
if (new_mesh) {
|
2016-10-29 12:23:09 +02:00
|
|
|
/* Check if we had ME_SMOOTH flag set to restore it. */
|
2018-06-06 11:06:11 +02:00
|
|
|
if (!do_normals && check_smooth_poly_flag(existing_mesh)) {
|
|
|
|
set_smooth_poly_flag(new_mesh);
|
2016-10-29 12:23:09 +02:00
|
|
|
}
|
|
|
|
|
2018-06-06 11:06:11 +02:00
|
|
|
BKE_mesh_calc_normals(new_mesh);
|
|
|
|
BKE_mesh_calc_edges(new_mesh, false, false);
|
2016-10-29 12:23:09 +02:00
|
|
|
|
2017-08-09 13:05:22 +02:00
|
|
|
/* Here we assume that the number of materials doesn't change, i.e. that
|
|
|
|
* the material slots that were created when the object was loaded from
|
|
|
|
* Alembic are still valid now. */
|
2018-06-06 11:06:11 +02:00
|
|
|
size_t num_polys = new_mesh->totpoly;
|
2017-08-09 13:05:22 +02:00
|
|
|
if (num_polys > 0) {
|
|
|
|
std::map<std::string, int> mat_map;
|
2018-06-06 11:06:11 +02:00
|
|
|
assign_facesets_to_mpoly(sample_sel, 0, new_mesh->mpoly, num_polys, mat_map);
|
2017-08-09 13:05:22 +02:00
|
|
|
}
|
|
|
|
|
2018-06-06 11:06:11 +02:00
|
|
|
return new_mesh;
|
2016-10-29 12:23:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (do_normals) {
|
2018-06-06 11:06:11 +02:00
|
|
|
BKE_mesh_calc_normals(existing_mesh);
|
2016-10-29 12:23:09 +02:00
|
|
|
}
|
|
|
|
|
2018-06-06 11:06:11 +02:00
|
|
|
return existing_mesh;
|
2016-10-29 12:23:09 +02:00
|
|
|
}
|
|
|
|
|
2017-08-09 13:05:22 +02:00
|
|
|
void AbcMeshReader::assign_facesets_to_mpoly(
|
|
|
|
const ISampleSelector &sample_sel,
|
|
|
|
size_t poly_start,
|
|
|
|
MPoly *mpoly, int totpoly,
|
|
|
|
std::map<std::string, int> & r_mat_map)
|
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
|
|
|
{
|
|
|
|
std::vector<std::string> face_sets;
|
|
|
|
m_schema.getFaceSetNames(face_sets);
|
|
|
|
|
|
|
|
if (face_sets.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int current_mat = 0;
|
|
|
|
|
|
|
|
for (int i = 0; i < face_sets.size(); ++i) {
|
|
|
|
const std::string &grp_name = face_sets[i];
|
|
|
|
|
2017-08-09 13:05:22 +02:00
|
|
|
if (r_mat_map.find(grp_name) == r_mat_map.end()) {
|
|
|
|
r_mat_map[grp_name] = 1 + current_mat++;
|
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
|
|
|
}
|
|
|
|
|
2017-08-09 13:05:22 +02:00
|
|
|
const int assigned_mat = r_mat_map[grp_name];
|
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 IFaceSet faceset = m_schema.getFaceSet(grp_name);
|
|
|
|
|
|
|
|
if (!faceset.valid()) {
|
2017-08-09 13:05:22 +02:00
|
|
|
std::cerr << " Face set " << grp_name << " invalid for " << m_object_name << "\n";
|
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
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
const IFaceSetSchema face_schem = faceset.getSchema();
|
|
|
|
const IFaceSetSchema::Sample face_sample = face_schem.getValue(sample_sel);
|
|
|
|
const Int32ArraySamplePtr group_faces = face_sample.getFaces();
|
|
|
|
const size_t num_group_faces = group_faces->size();
|
|
|
|
|
|
|
|
for (size_t l = 0; l < num_group_faces; l++) {
|
|
|
|
size_t pos = (*group_faces)[l] + poly_start;
|
|
|
|
|
2017-08-09 13:05:22 +02:00
|
|
|
if (pos >= totpoly) {
|
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
|
|
|
std::cerr << "Faceset overflow on " << faceset.getName() << '\n';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-08-09 13:05:22 +02:00
|
|
|
MPoly &poly = mpoly[pos];
|
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
|
|
|
poly.mat_nr = assigned_mat - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-09 13:05:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void AbcMeshReader::readFaceSetsSample(Main *bmain, Mesh *mesh, size_t poly_start,
|
|
|
|
const ISampleSelector &sample_sel)
|
|
|
|
{
|
|
|
|
std::map<std::string, int> mat_map;
|
|
|
|
assign_facesets_to_mpoly(sample_sel,
|
|
|
|
poly_start, mesh->mpoly, mesh->totpoly,
|
|
|
|
mat_map);
|
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
|
|
|
utils::assign_materials(bmain, m_object, mat_map);
|
|
|
|
}
|
|
|
|
|
2016-11-30 09:33:47 +01:00
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
ABC_INLINE MEdge *find_edge(MEdge *edges, int totedge, int v1, int v2)
|
2016-09-09 05:59:20 +02:00
|
|
|
{
|
2016-11-30 09:33:47 +01:00
|
|
|
for (int i = 0, e = totedge; i < e; ++i) {
|
|
|
|
MEdge &edge = edges[i];
|
2016-09-09 05:59:20 +02:00
|
|
|
|
2016-11-30 09:33:47 +01:00
|
|
|
if (edge.v1 == v1 && edge.v2 == v2) {
|
|
|
|
return &edge;
|
|
|
|
}
|
|
|
|
}
|
2016-09-09 05:59:20 +02:00
|
|
|
|
2016-11-30 09:33:47 +01:00
|
|
|
return NULL;
|
2016-09-09 05:59:20 +02:00
|
|
|
}
|
|
|
|
|
2017-08-15 12:43:17 +02:00
|
|
|
static void read_subd_sample(const std::string & iobject_full_name,
|
|
|
|
ImportSettings *settings,
|
2016-11-30 09:33:47 +01:00
|
|
|
const ISubDSchema &schema,
|
|
|
|
const ISampleSelector &selector,
|
|
|
|
CDStreamConfig &config)
|
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
|
|
|
{
|
2016-11-30 09:33:47 +01:00
|
|
|
const ISubDSchema::Sample sample = schema.getValue(selector);
|
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
|
|
|
|
|
|
|
AbcMeshData abc_mesh_data;
|
|
|
|
abc_mesh_data.face_counts = sample.getFaceCounts();
|
|
|
|
abc_mesh_data.face_indices = sample.getFaceIndices();
|
2016-11-30 09:33:47 +01:00
|
|
|
abc_mesh_data.vertex_normals = N3fArraySamplePtr();
|
|
|
|
abc_mesh_data.face_normals = N3fArraySamplePtr();
|
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
|
|
|
abc_mesh_data.positions = sample.getPositions();
|
|
|
|
|
2016-09-09 05:59:20 +02:00
|
|
|
get_weight_and_index(config, schema.getTimeSampling(), schema.getNumSamples());
|
|
|
|
|
|
|
|
if (config.weight != 0.0f) {
|
2016-11-30 09:33:47 +01:00
|
|
|
Alembic::AbcGeom::ISubDSchema::Sample ceil_sample;
|
2016-12-01 08:32:02 +01:00
|
|
|
schema.get(ceil_sample, Alembic::Abc::ISampleSelector(config.ceil_index));
|
2016-09-09 05:59:20 +02:00
|
|
|
abc_mesh_data.ceil_positions = ceil_sample.getPositions();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
if ((settings->read_flag & MOD_MESHSEQ_READ_UV) != 0) {
|
|
|
|
read_uvs_params(config, abc_mesh_data, schema.getUVsParam(), selector);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings->read_flag & MOD_MESHSEQ_READ_VERT) != 0) {
|
|
|
|
read_mverts(config, abc_mesh_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings->read_flag & MOD_MESHSEQ_READ_POLY) != 0) {
|
|
|
|
read_mpolys(config, abc_mesh_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings->read_flag & (MOD_MESHSEQ_READ_UV | MOD_MESHSEQ_READ_COLOR)) != 0) {
|
2017-08-15 12:43:17 +02:00
|
|
|
read_custom_data(iobject_full_name,
|
|
|
|
schema.getArbGeomParams(), config, selector);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
AbcSubDReader::AbcSubDReader(const IObject &object, ImportSettings &settings)
|
|
|
|
: AbcObjectReader(object, settings)
|
|
|
|
{
|
|
|
|
m_settings->read_flag |= MOD_MESHSEQ_READ_ALL;
|
|
|
|
|
|
|
|
ISubD isubd_mesh(m_iobject, kWrapExisting);
|
|
|
|
m_schema = isubd_mesh.getSchema();
|
2016-08-17 22:20:15 +02:00
|
|
|
|
|
|
|
get_min_max_time(m_iobject, m_schema, m_min_time, m_max_time);
|
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 AbcSubDReader::valid() const
|
|
|
|
{
|
|
|
|
return m_schema.valid();
|
|
|
|
}
|
|
|
|
|
2017-04-28 13:48:00 +02:00
|
|
|
bool AbcSubDReader::accepts_object_type(const Alembic::AbcCoreAbstract::ObjectHeader &alembic_header,
|
|
|
|
const Object *const ob,
|
|
|
|
const char **err_str) const
|
|
|
|
{
|
|
|
|
if (!Alembic::AbcGeom::ISubD::matches(alembic_header)) {
|
|
|
|
*err_str = "Object type mismatch, Alembic object path pointed to SubD when importing, but not any more.";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ob->type != OB_MESH) {
|
|
|
|
*err_str = "Object type mismatch, Alembic object path points to SubD.";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-04-26 16:56:50 +02:00
|
|
|
void AbcSubDReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel)
|
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
|
|
|
{
|
|
|
|
Mesh *mesh = BKE_mesh_add(bmain, m_data_name.c_str());
|
|
|
|
|
|
|
|
m_object = BKE_object_add_only_object(bmain, OB_MESH, m_object_name.c_str());
|
|
|
|
m_object->data = mesh;
|
|
|
|
|
2018-06-06 11:06:11 +02:00
|
|
|
Mesh *read_mesh = this->read_mesh(mesh, sample_sel, MOD_MESHSEQ_READ_ALL, NULL);
|
Refactor CDData masks, to have one mask per mesh elem type.
We already have different storages for cddata of verts, edges etc.,
'simply' do the same for the mask flags we use all around Blender code
to request some data, or limit some operation to some layers, etc.
Reason we need this is that some cddata types (like Normals) are
actually shared between verts/polys/loops, and we don’t want to generate
clnors everytime we request vnors!
As a side note, this also does final fix to T59338, which was the
trigger for this patch (need to request computed loop normals for
another mesh than evaluated one).
Reviewers: brecht, campbellbarton, sergey
Differential Revision: https://developer.blender.org/D4407
2019-03-07 11:13:40 +01:00
|
|
|
BKE_mesh_nomain_to_mesh(read_mesh, mesh, m_object, &CD_MASK_MESH, true);
|
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
|
|
|
|
2018-06-07 18:34:05 +02:00
|
|
|
ISubDSchema::Sample sample;
|
|
|
|
try {
|
|
|
|
sample = m_schema.getValue(sample_sel);
|
|
|
|
}
|
|
|
|
catch(Alembic::Util::Exception &ex) {
|
|
|
|
printf("Alembic: error reading mesh sample for '%s/%s' at time %f: %s\n",
|
2019-03-15 08:53:22 +11:00
|
|
|
m_iobject.getFullName().c_str(),
|
|
|
|
m_schema.getName().c_str(),
|
|
|
|
sample_sel.getRequestedTime(),
|
|
|
|
ex.what());
|
2018-06-07 18:34:05 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
Int32ArraySamplePtr indices = sample.getCreaseIndices();
|
|
|
|
Alembic::Abc::FloatArraySamplePtr sharpnesses = sample.getCreaseSharpnesses();
|
|
|
|
|
|
|
|
MEdge *edges = mesh->medge;
|
|
|
|
|
|
|
|
if (indices && sharpnesses) {
|
|
|
|
for (int i = 0, s = 0, e = indices->size(); i < e; i += 2, ++s) {
|
|
|
|
MEdge *edge = find_edge(edges, mesh->totedge, (*indices)[i], (*indices)[i + 1]);
|
|
|
|
|
|
|
|
if (edge) {
|
2018-05-07 17:31:28 +02:00
|
|
|
edge->crease = unit_float_to_uchar_clamp((*sharpnesses)[s]);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mesh->cd_flag |= ME_CDFLAG_EDGE_CREASE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BKE_mesh_calc_normals(mesh);
|
|
|
|
BKE_mesh_calc_edges(mesh, false, false);
|
|
|
|
|
|
|
|
if (m_settings->validate_meshes) {
|
|
|
|
BKE_mesh_validate(mesh, false, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (has_animations(m_schema, m_settings)) {
|
|
|
|
addCacheModifier();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-06 11:06:11 +02:00
|
|
|
Mesh *AbcSubDReader::read_mesh(Mesh *existing_mesh,
|
|
|
|
const ISampleSelector &sample_sel,
|
|
|
|
int read_flag,
|
|
|
|
const char **err_str)
|
2016-10-29 12:23:09 +02:00
|
|
|
{
|
2018-06-07 18:34:05 +02:00
|
|
|
ISubDSchema::Sample sample;
|
|
|
|
try {
|
|
|
|
sample = m_schema.getValue(sample_sel);
|
|
|
|
}
|
|
|
|
catch(Alembic::Util::Exception &ex) {
|
|
|
|
*err_str = "Error reading mesh sample; more detail on the console";
|
|
|
|
printf("Alembic: error reading mesh sample for '%s/%s' at time %f: %s\n",
|
2019-03-15 08:53:22 +11:00
|
|
|
m_iobject.getFullName().c_str(),
|
|
|
|
m_schema.getName().c_str(),
|
|
|
|
sample_sel.getRequestedTime(),
|
|
|
|
ex.what());
|
2018-06-07 18:34:05 +02:00
|
|
|
return existing_mesh;
|
|
|
|
}
|
2016-10-29 12:23:09 +02:00
|
|
|
|
|
|
|
const P3fArraySamplePtr &positions = sample.getPositions();
|
|
|
|
const Alembic::Abc::Int32ArraySamplePtr &face_indices = sample.getFaceIndices();
|
|
|
|
const Alembic::Abc::Int32ArraySamplePtr &face_counts = sample.getFaceCounts();
|
|
|
|
|
2018-06-06 11:06:11 +02:00
|
|
|
Mesh *new_mesh = NULL;
|
2016-10-29 12:23:09 +02:00
|
|
|
|
|
|
|
ImportSettings settings;
|
|
|
|
settings.read_flag |= read_flag;
|
|
|
|
|
2018-06-06 11:06:11 +02:00
|
|
|
if (existing_mesh->totvert != positions->size()) {
|
|
|
|
new_mesh = BKE_mesh_new_nomain_from_template(existing_mesh,
|
|
|
|
positions->size(),
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
face_indices->size(),
|
|
|
|
face_counts->size());
|
2016-10-29 12:23:09 +02:00
|
|
|
|
|
|
|
settings.read_flag |= MOD_MESHSEQ_READ_ALL;
|
|
|
|
}
|
2016-11-30 09:20:45 +01:00
|
|
|
else {
|
|
|
|
/* If the face count changed (e.g. by triangulation), only read points.
|
2016-11-30 09:33:47 +01:00
|
|
|
* This prevents crash from T49813.
|
2016-11-30 09:20:45 +01:00
|
|
|
* TODO(kevin): perhaps find a better way to do this? */
|
2018-06-06 11:06:11 +02:00
|
|
|
if (face_counts->size() != existing_mesh->totpoly ||
|
|
|
|
face_indices->size() != existing_mesh->totpoly)
|
2016-11-30 09:20:45 +01:00
|
|
|
{
|
|
|
|
settings.read_flag = MOD_MESHSEQ_READ_VERT;
|
|
|
|
|
|
|
|
if (err_str) {
|
|
|
|
*err_str = "Topology has changed, perhaps by triangulating the"
|
|
|
|
" mesh. Only vertices will be read!";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-10-29 12:23:09 +02:00
|
|
|
|
|
|
|
/* Only read point data when streaming meshes, unless we need to create new ones. */
|
2018-06-06 11:06:11 +02:00
|
|
|
CDStreamConfig config = get_config(new_mesh ? new_mesh : existing_mesh);
|
2017-04-26 16:56:50 +02:00
|
|
|
config.time = sample_sel.getRequestedTime();
|
2017-08-15 12:43:17 +02:00
|
|
|
read_subd_sample(m_iobject.getFullName(),
|
|
|
|
&settings, m_schema, sample_sel, config);
|
2016-10-29 12:23:09 +02:00
|
|
|
|
2018-06-06 11:06:11 +02:00
|
|
|
if (new_mesh) {
|
2016-10-29 12:23:09 +02:00
|
|
|
/* Check if we had ME_SMOOTH flag set to restore it. */
|
2018-06-06 11:06:11 +02:00
|
|
|
if (check_smooth_poly_flag(existing_mesh)) {
|
|
|
|
set_smooth_poly_flag(new_mesh);
|
2016-10-29 12:23:09 +02:00
|
|
|
}
|
|
|
|
|
2018-06-06 11:06:11 +02:00
|
|
|
BKE_mesh_calc_normals(new_mesh);
|
|
|
|
BKE_mesh_calc_edges(new_mesh, false, false);
|
2016-10-29 12:23:09 +02:00
|
|
|
|
2018-06-06 11:06:11 +02:00
|
|
|
return new_mesh;
|
2016-10-29 12:23:09 +02:00
|
|
|
}
|
|
|
|
|
2018-06-06 11:06:11 +02:00
|
|
|
return existing_mesh;
|
2016-10-29 12:23:09 +02:00
|
|
|
}
|