30 #include <Alembic/AbcCoreOgawa/All.h>
31 #include <Alembic/AbcGeom/All.h>
42 using Alembic::Abc::ErrorHandler;
43 using Alembic::Abc::kWrapExisting;
44 using Alembic::Abc::MetaData;
45 using Alembic::Abc::OArchive;
46 using Alembic::Abc::TimeSampling;
47 using Alembic::Abc::TimeSamplingPtr;
48 using Alembic::Abc::TimeSamplingType;
52 MetaData abc_metadata;
54 std::string abc_user_description(bmain->
name);
55 if (abc_user_description.empty()) {
56 abc_user_description =
"unknown";
59 abc_metadata.set(Alembic::Abc::kApplicationNameKey,
"Blender");
60 abc_metadata.set(Alembic::Abc::kUserDescriptionKey, abc_user_description);
68 #if defined _WIN32 || defined _WIN64
69 ctime_s(
buffer, 128, &raw_time);
71 ctime_r(&raw_time,
buffer);
74 const std::size_t buffer_len = strlen(
buffer);
75 if (buffer_len > 0 &&
buffer[buffer_len - 1] ==
'\n') {
76 buffer[buffer_len - 1] =
'\0';
79 abc_metadata.set(Alembic::Abc::kDateWrittenKey,
buffer);
84 const std::string &filename,
85 MetaData &abc_metadata)
93 std::wstring wstr(filename_cstr_16);
94 abc_ostream->open(wstr.c_str(), std::ios::out | std::ios::binary);
97 abc_ostream->open(filename, std::ios::out | std::ios::binary);
100 ErrorHandler::Policy policy = ErrorHandler::kThrowPolicy;
102 Alembic::AbcCoreOgawa::WriteArchive archive_writer;
103 return new OArchive(archive_writer(abc_ostream, abc_metadata), kWrapExisting, policy);
120 std::vector<double> &r_samples)
122 int frame_offset = time_relative ?
params.frame_start : 0;
123 double time_factor = time_relative ? scene_fps : 1.0;
124 double shutter_open =
params.shutter_open;
125 double shutter_close =
params.shutter_close;
126 double time_inc = (shutter_close - shutter_open) / nr_of_samples;
130 double sample_time = shutter_open + time_inc *
sample;
131 double time = (frame_offset + sample_time) / time_factor;
133 r_samples.push_back(
time);
141 std::vector<double> samples;
144 return TimeSamplingPtr(
new TimeSampling());
149 TimeSamplingType ts(
static_cast<uint32_t>(samples.size()), 1.0 / scene_fps);
150 return TimeSamplingPtr(
new TimeSampling(ts, samples));
155 unsigned int nr_of_samples,
156 std::set<double> &r_frames)
159 std::vector<double> shutter_samples;
162 for (
double frame =
params.frame_start; frame <=
params.frame_end; frame += 1.0) {
163 for (
size_t j = 0; j < nr_of_samples; j++) {
164 r_frames.insert(frame + shutter_samples[j]);
174 std::string filename)
177 double scene_fps =
FPS;
184 TimeSamplingPtr ts_xform;
185 TimeSamplingPtr ts_shapes;
188 time_sampling_index_transforms_ =
archive->addTimeSampling(*ts_xform);
190 const bool export_animation =
params.frame_start !=
params.frame_end;
191 if (!export_animation ||
params.frame_samples_shape ==
params.frame_samples_xform) {
192 ts_shapes = ts_xform;
193 time_sampling_index_shapes_ = time_sampling_index_transforms_;
197 time_sampling_index_shapes_ =
archive->addTimeSampling(*ts_shapes);
205 export_frames_.insert(xform_frames_.begin(), xform_frames_.end());
206 export_frames_.insert(shape_frames_.begin(), shape_frames_.end());
208 abc_archive_bbox_ = Alembic::AbcGeom::CreateOArchiveBounds(*
archive,
209 time_sampling_index_transforms_);
219 return time_sampling_index_transforms_;
224 return time_sampling_index_shapes_;
229 return export_frames_.begin();
233 return export_frames_.end();
237 return export_frames_.size();
242 return xform_frames_.find(frame) != xform_frames_.end();
246 return shape_frames_.find(frame) != shape_frames_.end();
258 abc_archive_bbox_.set(
bounds);
const char * BKE_blender_version_string(void)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
Frames::const_iterator frames_end() const
ABCArchive(const Main *bmain, const Scene *scene, AlembicExportParams params, std::string filename)
bool is_xform_frame(double frame) const
ExportSubset export_subset_for_frame(double frame) const
bool is_shape_frame(double frame) const
Frames::const_iterator frames_begin() const
uint32_t time_sampling_index_shapes() const
Alembic::Abc::OArchive * archive
void update_bounding_box(const Imath::Box3d &bounds)
uint32_t time_sampling_index_transforms() const
size_t total_frame_count() const
__kernel void ccl_constant KernelData ccl_global void ccl_global char ccl_global int ccl_global char ccl_global unsigned int ccl_global float * buffer
static void sample(SocketReader *reader, int x, int y, float color[4])
static void get_frames(double scene_fps, const AlembicExportParams ¶ms, unsigned int nr_of_samples, std::set< double > &r_frames)
static MetaData create_abc_metadata(const Main *bmain, double scene_fps)
static OArchive * create_archive(std::ofstream *abc_ostream, const std::string &filename, MetaData &abc_metadata)
static TimeSamplingPtr create_time_sampling(double scene_fps, const AlembicExportParams ¶ms, int nr_of_samples)
static void get_shutter_samples(double scene_fps, const AlembicExportParams ¶ms, int nr_of_samples, bool time_relative, std::vector< double > &r_samples)
std::string to_string(const T &n)
#define UTF16_ENCODE(in8str)
#define UTF16_UN_ENCODE(in8str)