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

abc_group.h « alembic « pointcache « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ae8c58edc452731d6736280b451d23e8059ab18b (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
223
224
225
226
/*
 * 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_GROUP_H
#define PTC_ABC_GROUP_H

#include "ptc_types.h"

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

#include "util_thread.h"

struct CacheLibrary;
struct DupliCache;
struct DupliObject;
struct DupliObjectData;
struct Group;
struct Object;
struct Scene;

namespace PTC {

class AbcDerivedMeshWriter;
class AbcStrandsWriter;
class AbcSimDebugWriter;
class AbcSimDebugReader;

class AbcGroupWriter : public GroupWriter, public AbcWriter {
public:
	AbcGroupWriter(const std::string &name, Group *group);
	
	void init_abc();
	void create_refs();
	
	void write_sample();
	
private:
	Abc::OObject m_abc_object;
};

class AbcGroupReader : public GroupReader, public AbcReader {
public:
	AbcGroupReader(const std::string &name, Group *group);
	
	void init_abc(Abc::IObject object);
	
	PTCReadSampleResult read_sample_abc(chrono_t time);
	
private:
	Abc::IObject m_abc_object;
};

/* ========================================================================= */

class AbcDupligroupWriter : public GroupWriter, public AbcWriter {
public:
	typedef std::vector<Abc::ObjectWriterPtr> ObjectWriterList;
	typedef std::vector<Abc::BasePropertyWriterPtr> PropertyWriterList;
	
	typedef std::map<ID *, AbcWriter *> IDWriterMap;
	typedef std::pair<ID *, AbcWriter *> IDWriterPair;
	
	AbcDupligroupWriter(const std::string &name, EvaluationContext *eval_ctx, Scene *scene, Group *group, CacheLibrary *cachelib);
	~AbcDupligroupWriter();
	
	void init_abc();
	
	void write_sample();
	void write_sample_object(Object *ob, bool write_data);
	void write_sample_dupli(DupliObject *dob, int index);
	
	AbcWriter *find_id_writer(ID *id) const;
	
private:
	EvaluationContext *m_eval_ctx;
	Scene *m_scene;
	CacheLibrary *m_cachelib;
	
	Abc::OObject m_abc_group;
	ObjectWriterList m_object_writers;
	PropertyWriterList m_property_writers;
	IDWriterMap m_id_writers;
	thread_mutex m_init_mutex;
};

class AbcDupliCacheWriter : public GroupWriter, public AbcWriter {
public:
	typedef std::vector<Abc::ObjectWriterPtr> ObjectWriterList;
	typedef std::vector<Abc::BasePropertyWriterPtr> PropertyWriterList;
	
	typedef std::map<ID *, AbcWriter *> IDWriterMap;
	typedef std::pair<ID *, AbcWriter *> IDWriterPair;
	
	AbcDupliCacheWriter(const std::string &name, Group *group, DupliCache *dupcache, int data_types, bool do_sim_debug = false);
	~AbcDupliCacheWriter();
	
	void init_abc();
	
	void write_sample();
	void write_sample_object_data(DupliObjectData *data);
	void write_sample_dupli(DupliObject *dob, int index);
	
	AbcWriter *find_id_writer(ID *id) const;
	
private:
	DupliCache *m_dupcache;
	int m_data_types;
	
	Abc::OObject m_abc_group;
	ObjectWriterList m_object_writers;
	PropertyWriterList m_property_writers;
	IDWriterMap m_id_writers;
	AbcSimDebugWriter *m_simdebug_writer;
};

class AbcDupliCacheReader : public GroupReader, public AbcReader {
public:
	typedef std::map<Abc::ObjectReaderPtr, DupliObjectData*> DupliMap;
	typedef std::pair<Abc::ObjectReaderPtr, DupliObjectData*> DupliPair;
	
	typedef std::map<std::string, Object*> ObjectMap;
	typedef std::pair<std::string, Object*> ObjectPair;
	
public:
	AbcDupliCacheReader(const std::string &name, Group *group, DupliCache *dupcache,
	                    bool read_strands_motion, bool read_strands_children, bool read_sim_debug);
	~AbcDupliCacheReader();
	
	void init_abc(Abc::IObject object);
	
	PTCReadSampleResult read_sample_abc(chrono_t time);
	
protected:
	void read_dupligroup_object(Abc::IObject object, chrono_t time);
	void read_dupligroup_group(Abc::IObject abc_group, chrono_t time);
	
	DupliObjectData *find_dupli_data(Abc::ObjectReaderPtr ptr) const;
	void insert_dupli_data(Abc::ObjectReaderPtr ptr, DupliObjectData *data);
	
	void build_object_map(Main *bmain, Group *group);
	void build_object_map_add_group(Group *group);
	Object *find_object(const std::string &name) const;
	
private:
	DupliMap dupli_map;
	DupliCache *dupli_cache;
	
	ObjectMap object_map;
	bool m_read_strands_motion, m_read_strands_children;
	AbcSimDebugReader *m_simdebug_reader;
};


class AbcDupliObjectWriter : public ObjectWriter, public AbcWriter {
public:
	typedef std::map<std::string, AbcStrandsWriter *> StrandsWriters;
	typedef std::pair<std::string, AbcStrandsWriter *> StrandsWritersPair;
	
	AbcDupliObjectWriter(const std::string &name, DupliObjectData *dupdata, bool do_mesh, bool do_strands);
	~AbcDupliObjectWriter();
	
	void init_abc();
	
	void write_sample();
	
	AbcStrandsWriter *find_strands_writer(const std::string &name) const;
	AbcStrandsWriter *add_strands_writer(const std::string &name);
	
private:
	DupliObjectData *m_dupdata;
	bool m_do_strands;
	
	Abc::OObject m_abc_object;
	AbcDerivedMeshWriter *m_dm_writer;
	StrandsWriters m_strands_writers;
};

class AbcDupliObjectReader : public ObjectReader, public AbcReader {
public:
	typedef std::map<Abc::ObjectReaderPtr, DupliObjectData*> DupliMap;
	typedef std::pair<Abc::ObjectReaderPtr, DupliObjectData*> DupliPair;
	
public:
	AbcDupliObjectReader(const std::string &name, Object *ob, DupliObjectData *dupli_data,
	                     bool read_strands_motion, bool read_strands_children);
	~AbcDupliObjectReader();
	
	void init(ReaderArchive *archive);
	void init_abc(Abc::IObject object);
	
	PTCReadSampleResult read_sample_abc(chrono_t time);
	
protected:
	void read_dupligroup_object(Abc::IObject object, chrono_t time);
	
	DupliObjectData *find_dupli_data(Abc::ObjectReaderPtr ptr) const;
	void insert_dupli_data(Abc::ObjectReaderPtr ptr, DupliObjectData *data);
	
private:
	DupliMap dupli_map;
	DupliObjectData *dupli_data;
	bool m_read_strands_motion, m_read_strands_children;
	
	Abc::IObject m_abc_object;
};

} /* namespace PTC */

#endif  /* PTC_OBJECT_H */