Welcome to mirror list, hosted at ThFree Co, Russian Federation.

abc_particles.h « alembic « pointcache « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 26d1bce78bd55325c3e96c1b97b0e863d968e2cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/*
 * Copyright 2013, Blender Foundation.
 *
 * 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.
 */

#ifndef PTC_ABC_PARTICLES_H
#define PTC_ABC_PARTICLES_H

#include <Alembic/AbcGeom/IPoints.h>
#include <Alembic/AbcGeom/OPoints.h>
#include <Alembic/AbcGeom/ICurves.h>
#include <Alembic/AbcGeom/OCurves.h>

#include "ptc_types.h"

#include "PTC_api.h"

#include "abc_reader.h"
#include "abc_schema.h"
#include "abc_writer.h"
#include "abc_cloth.h"

struct ListBase;
struct Object;
struct ParticleSystem;
struct ParticleCacheKey;
struct Strands;
struct StrandsChildren;

namespace PTC {

class AbcDerivedMeshWriter;
class AbcDerivedMeshReader;


class AbcHairChildrenWriter : public ParticlesWriter, public AbcWriter {
public:
	AbcHairChildrenWriter(const std::string &name, Object *ob, ParticleSystem *psys);
	~AbcHairChildrenWriter();
	
	void init_abc(Abc::OObject parent);
	
	void write_sample();
	
private:
	ParticleSystemModifierData *m_psmd;
	
	AbcGeom::OCurves m_curves;
	AbcGeom::OQuatfArrayProperty m_prop_root_rot;
	AbcGeom::OV3fArrayProperty m_prop_root_positions;
	AbcGeom::OFloatGeomParam m_param_cutoff;
	AbcGeom::OFloatGeomParam m_param_times;
	AbcGeom::OInt32ArrayProperty m_prop_parents;
	AbcGeom::OFloatArrayProperty m_prop_parent_weights;
	AbcGeom::OV2fArrayProperty m_prop_curve_uvs;
	AbcGeom::OC3fArrayProperty m_prop_curve_vcols;
};


class AbcHairWriter : public ParticlesWriter, public AbcWriter {
public:
	AbcHairWriter(const std::string &name, Object *ob, ParticleSystem *psys);
	~AbcHairWriter();
	
	void init(WriterArchive *archive);
	void init_abc(Abc::OObject parent);
	
	void write_sample();
	
private:
	ParticleSystemModifierData *m_psmd;
	
	AbcGeom::OCurves m_curves;
	AbcGeom::OQuatfGeomParam m_param_root_rot;
	AbcGeom::OUInt32GeomParam m_param_root_orig_verts;
	AbcGeom::OFloatGeomParam m_param_root_orig_weights;
	AbcGeom::OInt32GeomParam m_param_root_orig_poly;
	AbcGeom::OUInt32GeomParam m_param_root_orig_loops;
	AbcGeom::OFloatGeomParam m_param_times;
	AbcGeom::OFloatGeomParam m_param_weights;
	
	AbcHairChildrenWriter m_child_writer;
};


class AbcStrandsChildrenWriter : public AbcWriter {
public:
	AbcStrandsChildrenWriter(const std::string &name, const std::string &abc_name, DupliObjectData *dobdata);
	
	StrandsChildren *get_strands() const;
	
	void init_abc(Abc::OObject parent);
	
	void write_sample();
	
private:
	std::string m_name;
	std::string m_abc_name;
	DupliObjectData *m_dobdata;
	
	AbcGeom::OCurves m_curves;
	AbcGeom::OQuatfArrayProperty m_prop_root_rot;
	AbcGeom::OV3fArrayProperty m_prop_root_positions;
	AbcGeom::OFloatGeomParam m_param_cutoff;
	AbcGeom::OFloatGeomParam m_param_times;
	AbcGeom::OInt32ArrayProperty m_prop_parents;
	AbcGeom::OFloatArrayProperty m_prop_parent_weights;
	AbcGeom::OV2fArrayProperty m_prop_curve_uvs;
	AbcGeom::OC3fArrayProperty m_prop_curve_vcols;
};


class AbcStrandsWriter : public AbcWriter {
public:
	AbcStrandsWriter(const std::string &name, DupliObjectData *dobdata);
	
	Strands *get_strands() const;
	
	void init(WriterArchive *archive);
	void init_abc(Abc::OObject parent);
	
	void write_sample();
	
private:
	std::string m_name;
	DupliObjectData *m_dobdata;
	
	AbcGeom::OCurves m_curves;
	AbcGeom::OQuatfGeomParam m_param_root_rot;
	AbcGeom::OUInt32GeomParam m_param_root_orig_verts;
	AbcGeom::OFloatGeomParam m_param_root_orig_weights;
	AbcGeom::OInt32GeomParam m_param_root_orig_poly;
	AbcGeom::OUInt32GeomParam m_param_root_orig_loops;
	AbcGeom::OFloatGeomParam m_param_times;
	AbcGeom::OFloatGeomParam m_param_weights;
	AbcGeom::OCompoundProperty m_param_motion_state;
	AbcGeom::OP3fGeomParam m_param_motion_co;
	AbcGeom::OV3fGeomParam m_param_motion_vel;
	
	AbcStrandsChildrenWriter m_child_writer;
};


class AbcStrandsChildrenReader : public AbcReader {
public:
	AbcStrandsChildrenReader(StrandsChildren *strands);
	~AbcStrandsChildrenReader();
	
	void init_abc(Abc::IObject object);
	
	PTCReadSampleResult read_sample_abc(chrono_t time);
	
	StrandsChildren *get_result() { return m_strands; }
	StrandsChildren *acquire_result();
	void discard_result();
	
private:
	StrandsChildren *m_strands;
	
	AbcGeom::ICurves m_curves;
	AbcGeom::IQuatfArrayProperty m_prop_root_rot;
	AbcGeom::IV3fArrayProperty m_prop_root_positions;
	AbcGeom::IFloatGeomParam m_param_cutoff;
	AbcGeom::IFloatGeomParam m_param_times;
	AbcGeom::IInt32ArrayProperty m_prop_parents;
	AbcGeom::IFloatArrayProperty m_prop_parent_weights;
	AbcGeom::IV2fArrayProperty m_prop_curve_uvs;
	AbcGeom::IC3fArrayProperty m_prop_curve_vcols;
};


class AbcStrandsReader : public AbcReader {
public:
	AbcStrandsReader(Strands *strands, StrandsChildren *children, bool read_motion, bool read_children);
	~AbcStrandsReader();
	
	void init(ReaderArchive *archive);
	void init_abc(Abc::IObject object);
	
	PTCReadSampleResult read_sample_abc(chrono_t time);
	
	Strands *acquire_result();
	void discard_result();
	
	AbcStrandsChildrenReader &child_reader() { return m_child_reader; }
	
private:
	bool m_read_motion, m_read_children;
	Strands *m_strands;
	
	AbcGeom::ICurves m_curves;
	AbcGeom::IQuatfGeomParam m_param_root_rot;
	AbcGeom::IUInt32GeomParam m_param_root_orig_verts;
	AbcGeom::IFloatGeomParam m_param_root_orig_weights;
	AbcGeom::IInt32GeomParam m_param_root_orig_poly;
	AbcGeom::IUInt32GeomParam m_param_root_orig_loops;
	AbcGeom::IFloatGeomParam m_param_times;
	AbcGeom::IFloatGeomParam m_param_weights;
	AbcGeom::ICompoundProperty m_param_motion_state;
	AbcGeom::IP3fGeomParam m_param_motion_co;
	AbcGeom::IV3fGeomParam m_param_motion_vel;
	
	AbcStrandsChildrenReader m_child_reader;
};


} /* namespace PTC */

#endif  /* PTC_PARTICLES_H */