52 return (
int)_anims.size();
63find_anim(
const std::string &basename)
const {
66 record._basename = basename;
67 Anims::const_iterator ai = _anims.find(record);
68 if (ai != _anims.end()) {
69 return int(ai - _anims.begin());
89 nassertv(n >= 0 && n < (
int)_anims.size());
90 _anims.erase(_anims.begin() + n);
99add_anim(
const std::string &basename, PN_stdfloat base_frame_rate,
int num_frames) {
101 record._basename = basename;
102 record._base_frame_rate = base_frame_rate;
103 record._num_frames = num_frames;
105 _anims.push_back(record);
115 _anims.reserve(_anims.size() + other->_anims.
size());
116 Anims::const_iterator ai;
117 for (ai = other->_anims.
begin(); ai != other->_anims.
end(); ++ai) {
118 _anims.push_back(*ai);
126void AnimPreloadTable::
127output(std::ostream &out)
const {
129 out <<
"AnimPreloadTable, " << _anims.
size() <<
" animation records.";
135void AnimPreloadTable::
136write(std::ostream &out,
int indent_level)
const {
139 <<
"AnimPreloadTable, " << _anims.size() <<
" animation records:\n";
140 Anims::const_iterator ai;
141 for (ai = _anims.begin(); ai != _anims.end(); ++ai) {
143 indent(out, indent_level + 2)
144 << record._basename <<
": " << record._num_frames <<
" frames at "
145 << record._base_frame_rate <<
" fps\n";
166 Anims::const_iterator ai;
167 for (ai = _anims.begin(); ai != _anims.end(); ++ai) {
180 AnimPreloadTable *me =
new AnimPreloadTable;
185 me->fillin(scan, manager);
194void AnimPreloadTable::
198 for (
int i = 0; i < num_anims; ++i) {
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This table records data about a list of animations for a particular model, such as number of frames a...
void add_anim(const std::string &basename, PN_stdfloat base_frame_rate, int num_frames)
Adds a new animation record to the table.
void clear_anims()
Removes all animation records from the table.
int get_num_anims() const
Returns the number of animation records in the table.
static void register_with_read_factory()
Factory method to generate an AnimPreloadTable object.
int find_anim(const std::string &basename) const
Returns the index number in the table of the animation record with the indicated name,...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Function to write the important information in the particular object to a Datagram.
void remove_anim(int n)
Removes the nth animation records from the table.
static TypedWritable * make_from_bam(const FactoryParams ¶ms)
Factory method to generate an AnimPreloadTable object.
void add_anims_from(const AnimPreloadTable *other)
Copies the animation records from the other table into this one.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
This base class provides basic reference counting, but also can be used with a CopyOnWritePointer to ...
A class to retrieve the individual data elements previously stored in a Datagram.
PN_stdfloat get_stdfloat()
Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_doubl...
uint16_t get_uint16()
Extracts an unsigned 16-bit integer.
std::string get_string()
Extracts a variable-length string.
int32_t get_int32()
Extracts a signed 32-bit integer.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void add_int32(int32_t value)
Adds a signed 32-bit integer to the datagram.
void add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
void add_uint16(uint16_t value)
Adds an unsigned 16-bit integer to the datagram.
void add_string(const std::string &str)
Adds a variable-length string to the datagram.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
TypeHandle is the identifier used to differentiate C++ class types.
Base class for objects that can be written to and read from Bam files.
void reserve(size_type_0 n)
Informs the vector of a planned change in size; ensures that the capacity of the vector is greater th...
iterator_0 begin()
Returns the iterator that marks the first element in the ordered vector.
void push_back(const value_type_0 &key)
Adds the new element to the end of the vector without regard for proper sorting.
size_type_0 size() const
Returns the number of elements in the ordered vector.
iterator_0 end()
Returns the iterator that marks the end of the ordered vector.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.