Panda3D
Loading...
Searching...
No Matches
animPreloadTable.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file animPreloadTable.h
10 * @author drose
11 * @date 2008-08-05
12 */
13
14#ifndef ANIMPRELOADTABLE_H
15#define ANIMPRELOADTABLE_H
16
17#include "pandabase.h"
19#include "ordered_vector.h"
20#include "copyOnWriteObject.h"
21
22class BamWriter;
23class BamReader;
24class Datagram;
26class FactoryParams;
27
28/**
29 * This table records data about a list of animations for a particular model,
30 * such as number of frames and frame rate. It's used for implementating
31 * asynchronous binding.
32 *
33 * This table is normally built by an offline tool, such as egg-optchar.
34 */
35class EXPCL_PANDA_CHAN AnimPreloadTable : public CopyOnWriteObject {
36public:
37 class AnimRecord {
38 public:
39 INLINE AnimRecord();
40 INLINE bool operator < (const AnimRecord &other) const;
41
42 std::string _basename;
43 PN_stdfloat _base_frame_rate;
44 int _num_frames;
45 };
46
47protected:
48 virtual PT(CopyOnWriteObject) make_cow_copy();
49
50PUBLISHED:
51 AnimPreloadTable();
52 virtual ~AnimPreloadTable();
53
54 int get_num_anims() const;
55 int find_anim(const std::string &basename) const;
56
57 INLINE std::string get_basename(int n) const;
58 INLINE PN_stdfloat get_base_frame_rate(int n) const;
59 INLINE int get_num_frames(int n) const;
60
61 void clear_anims();
62 void remove_anim(int n);
63 void add_anim(const std::string &basename, PN_stdfloat base_frame_rate, int num_frames);
64 void add_anims_from(const AnimPreloadTable *other);
65
66 virtual void output(std::ostream &out) const;
67 virtual void write(std::ostream &out, int indent_level) const;
68
69private:
70 INLINE void consider_sort() const;
71
72public:
73 static void register_with_read_factory();
74 virtual void write_datagram(BamWriter *manager, Datagram &dg);
75 static TypedWritable *make_from_bam(const FactoryParams &params);
76
77protected:
78 void fillin(DatagramIterator &scan, BamReader *manager);
79
80private:
81 typedef ov_set<AnimRecord> Anims;
82 Anims _anims;
83 bool _needs_sort;
84
85public:
86 virtual TypeHandle get_type() const {
87 return get_class_type();
88 }
89 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
90
91 static TypeHandle get_class_type() {
92 return _type_handle;
93 }
94 static void init_type() {
95 CopyOnWriteObject::init_type();
96 register_type(_type_handle, "AnimPreloadTable",
97 CopyOnWriteObject::get_class_type());
98 }
99
100private:
101 static TypeHandle _type_handle;
102};
103
104inline std::ostream &operator << (std::ostream &out, const AnimPreloadTable &anim) {
105 anim.output(out);
106 return out;
107}
108
109#include "animPreloadTable.I"
110
111#endif
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.
std::string get_basename(int n) const
Returns the basename stored for the nth animation record.
void clear_anims()
Removes all animation records from the table.
PN_stdfloat get_base_frame_rate(int n) const
Returns the frame rate stored for the nth animation record.
int get_num_frames(int n) const
Returns the number of frames stored for the nth animation record.
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,...
void remove_anim(int n)
Removes the nth animation records from the table.
static TypedWritable * make_from_bam(const FactoryParams &params)
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...
Definition bamReader.h:110
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition bamWriter.h:63
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
An instance of this class is passed to the Factory when requesting it to do its business and construc...
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
Base class for objects that can be written to and read from Bam files.
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class's make_from_bam() method to read in all...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
A specialization of ordered_vector that emulates a standard STL set: one copy of each element is allo...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.