forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanimPreloadTable.h
More file actions
111 lines (90 loc) · 2.77 KB
/
animPreloadTable.h
File metadata and controls
111 lines (90 loc) · 2.77 KB
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
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file animPreloadTable.h
* @author drose
* @date 2008-08-05
*/
#ifndef ANIMPRELOADTABLE_H
#define ANIMPRELOADTABLE_H
#include "pandabase.h"
#include "typedWritableReferenceCount.h"
#include "ordered_vector.h"
#include "copyOnWriteObject.h"
class BamWriter;
class BamReader;
class Datagram;
class DatagramIterator;
class FactoryParams;
/**
* This table records data about a list of animations for a particular model,
* such as number of frames and frame rate. It's used for implementating
* asynchronous binding.
*
* This table is normally built by an offline tool, such as egg-optchar.
*/
class EXPCL_PANDA_CHAN AnimPreloadTable : public CopyOnWriteObject {
public:
class AnimRecord {
public:
INLINE AnimRecord();
INLINE bool operator < (const AnimRecord &other) const;
std::string _basename;
PN_stdfloat _base_frame_rate;
int _num_frames;
};
protected:
virtual PT(CopyOnWriteObject) make_cow_copy();
PUBLISHED:
AnimPreloadTable();
virtual ~AnimPreloadTable();
int get_num_anims() const;
int find_anim(const std::string &basename) const;
INLINE std::string get_basename(int n) const;
INLINE PN_stdfloat get_base_frame_rate(int n) const;
INLINE int get_num_frames(int n) const;
void clear_anims();
void remove_anim(int n);
void add_anim(const std::string &basename, PN_stdfloat base_frame_rate, int num_frames);
void add_anims_from(const AnimPreloadTable *other);
virtual void output(std::ostream &out) const;
virtual void write(std::ostream &out, int indent_level) const;
private:
INLINE void consider_sort() const;
public:
static void register_with_read_factory();
virtual void write_datagram(BamWriter *manager, Datagram &dg);
static TypedWritable *make_from_bam(const FactoryParams ¶ms);
protected:
void fillin(DatagramIterator &scan, BamReader *manager);
private:
typedef ov_set<AnimRecord> Anims;
Anims _anims;
bool _needs_sort;
public:
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
CopyOnWriteObject::init_type();
register_type(_type_handle, "AnimPreloadTable",
CopyOnWriteObject::get_class_type());
}
private:
static TypeHandle _type_handle;
};
inline std::ostream &operator << (std::ostream &out, const AnimPreloadTable &anim) {
anim.output(out);
return out;
}
#include "animPreloadTable.I"
#endif