[Bf-blender-cvs] [8c3ec52c249] temp-sybren-alembic-customprops-read: Implemented crappy reading of some property types

Sybren A. Stüvel noreply at git.blender.org
Thu Dec 7 10:36:23 CET 2017


Commit: 8c3ec52c2498562ce3592831935c6e26c0987a15
Author: Sybren A. Stüvel
Date:   Wed Nov 1 09:43:57 2017 +0100
Branches: temp-sybren-alembic-customprops-read
https://developer.blender.org/rB8c3ec52c2498562ce3592831935c6e26c0987a15

Implemented crappy reading of some property types

Still reads the data twice (from constraint and from modifier) and also
doesn't support many of the data types yet. Also just prints instead of
storing in an ID block, but it's a start.

===================================================================

M	source/blender/alembic/intern/abc_object.cc
M	source/blender/alembic/intern/abc_object.h
M	source/blender/alembic/intern/alembic_capi.cc

===================================================================

diff --git a/source/blender/alembic/intern/abc_object.cc b/source/blender/alembic/intern/abc_object.cc
index c77d7529750..2d451f93689 100644
--- a/source/blender/alembic/intern/abc_object.cc
+++ b/source/blender/alembic/intern/abc_object.cc
@@ -43,19 +43,7 @@ extern "C" {
 #include "BLI_string.h"
 }
 
-using Alembic::AbcGeom::IObject;
-using Alembic::AbcGeom::IXform;
-using Alembic::AbcGeom::IXformSchema;
-
-using Alembic::AbcGeom::OCompoundProperty;
-using Alembic::AbcGeom::ODoubleArrayProperty;
-using Alembic::AbcGeom::ODoubleProperty;
-using Alembic::AbcGeom::OFloatArrayProperty;
-using Alembic::AbcGeom::OFloatProperty;
-using Alembic::AbcGeom::OInt32ArrayProperty;
-using Alembic::AbcGeom::OInt32Property;
-using Alembic::AbcGeom::OStringArrayProperty;
-using Alembic::AbcGeom::OStringProperty;
+using namespace Alembic::AbcGeom; // Contains Abc, AbcCoreAbstract
 
 /* ************************************************************************** */
 
@@ -248,7 +236,7 @@ Imath::M44d get_matrix(const IXformSchema &schema, const float time)
 }
 
 DerivedMesh *AbcObjectReader::read_derivedmesh(DerivedMesh *dm,
-                                               const Alembic::Abc::ISampleSelector &UNUSED(sample_sel),
+                                               const Alembic::Abc::ISampleSelector &sample_sel,
                                                int UNUSED(read_flag),
                                                const char **UNUSED(err_str))
 {
@@ -306,6 +294,10 @@ Alembic::AbcGeom::IXform AbcObjectReader::xform()
 void AbcObjectReader::read_matrix(float r_mat[4][4], const float time,
                                   const float scale, bool &is_constant)
 {
+	using Alembic::Abc::ISampleSelector;
+	ISampleSelector sample_sel(time, ISampleSelector::kFloorIndex);
+	read_custom_properties(sample_sel);
+
 	IXform ixform = xform();
 	if (!ixform) {
 		return;
@@ -385,6 +377,82 @@ void AbcObjectReader::decref()
 
 void AbcObjectReader::read_custom_properties(const Alembic::Abc::ISampleSelector &sample_sel)
 {
+	using Alembic::AbcCoreAbstract::ArraySamplePtr;
+
 	/* Maya seems to write custom properties to the .abcGeomParams Alembic property. */
+	ICompoundProperty params = getArbGeomParams();
+	if (!params.valid()) {
+		std::cerr << "Params for " << m_object_name << " invalid, skipping\n";
+		return;
+	}
+	IXform my_xform = xform();
+
+	size_t pcount = params.getNumProperties();
+	std::cerr << "Found " << pcount << " properties on " << params.getName() << "\n";
+	for (size_t pidx=0; pidx < pcount; pidx++) {
+		PropertyHeader header = params.getPropertyHeader(pidx);
+		std::cerr << "Found property: " << header.getName() << "\n";
+		std::cerr << "    - data type is " << header.getDataType() << "\n";
+
+		if (header.isCompound()) {
+			std::cerr << "Custom property " << header.getName() << " is compound, not supported yet.\n";
+			continue;
+		}
+		if (header.isArray()) {
+			Alembic::AbcGeom::IArrayProperty ap(params, header.getName());
+			if (!ap.isScalarLike()) {
+				std::cerr << "Custom property " << header.getName() << " is array of " << ap.getNumSamples() << " items, not supported yet.\n";
+				continue;
+			}
+			std::cerr << "    - array is constant: " << ap.isConstant() << "\n";
+
+			ArraySamplePtr val;
+			ap.get(val, sample_sel);
+
+			/* Inspired by ArrayPropertiesTests.cpp in the Alembic source code. */
+			switch (ap.getDataType().getPod()) {
+//				case Alembic::Util::kBooleanPOD: break;
+//				case Alembic::Util::kUint8POD: break;
+//				case Alembic::Util::kInt8POD: break;
+//				case Alembic::Util::kUint16POD: break;
+				case Alembic::Util::kInt16POD:
+				{
+					Alembic::Util::int16_t *data = (Alembic::Util::int16_t *)(val->getData());
+					std::cerr << "    - value is: " << data[0] << "\n";
+					break;
+				}
+//				case Alembic::Util::kUint32POD: break;
+//				case Alembic::Util::kInt32POD: break;
+//				case Alembic::Util::kUint64POD: break;
+//				case Alembic::Util::kInt64POD: break;
+//				case Alembic::Util::kFloat16POD: break;
+//				case Alembic::Util::kFloat32POD: break;
+//				case Alembic::Util::kFloat64POD: break;
+				case Alembic::Util::kStringPOD:
+				{
+					Alembic::Util::string * data = (Alembic::Util::string *)(val->getData());
+					std::cerr << "    - value is: " << data[0] << "\n";
+					break;
+				}
+//				case Alembic::Util::kWstringPOD: break;
+				default:
+					std::cerr << "Custom property " << header.getName() << " is array of unknown data type " << header.getDataType() << "; not supported.\n";
+			}
+		}
+
+		Alembic::AbcGeom::XformSample samp = my_xform.getSchema().getValue(sample_sel);
+		std::cerr << "    - time sampling: " << header.getTimeSampling()->getTimeSamplingType() << "\n";
+
+	}
+}
+
+ICompoundProperty AbcObjectReader::getArbGeomParams()
+{
+	IXform my_xform = xform();
+	if (!my_xform.valid()) {
+		std::cerr << "XForm for " << m_object_name << " invalid, skipping\n";
+		return ICompoundProperty();
+	}
 
+	return my_xform.getSchema().getArbGeomParams();
 }
diff --git a/source/blender/alembic/intern/abc_object.h b/source/blender/alembic/intern/abc_object.h
index b948c5653d6..4f9618bf4e9 100644
--- a/source/blender/alembic/intern/abc_object.h
+++ b/source/blender/alembic/intern/abc_object.h
@@ -198,10 +198,11 @@ public:
 	void read_matrix(float r_mat[4][4], const float time,
 	                 const float scale, bool &is_constant);
 
+	void read_custom_properties(const Alembic::Abc::ISampleSelector &sample_sel);
 protected:
 	void determine_inherits_xform();
 
-	void read_custom_properties(const Alembic::Abc::ISampleSelector &sample_sel);
+	virtual Alembic::AbcGeom::ICompoundProperty getArbGeomParams();
 };
 
 Imath::M44d get_matrix(const Alembic::AbcGeom::IXformSchema &schema, const float time);
diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc
index 0d2316ce7d9..440b0ee27c6 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -948,6 +948,7 @@ DerivedMesh *ABC_read_mesh(CacheReader *reader,
 	/* kFloorIndex is used to be compatible with non-interpolating
 	 * properties; they use the floor. */
 	ISampleSelector sample_sel(time, ISampleSelector::kFloorIndex);
+	abc_reader->read_custom_properties(sample_sel);
 	return abc_reader->read_derivedmesh(dm, sample_sel, read_flag, err_str);
 }



More information about the Bf-blender-cvs mailing list