Panda3D
transformTable.h
1 // Filename: transformTable.h
2 // Created by: drose (23Mar05)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef TRANSFORMTABLE_H
16 #define TRANSFORMTABLE_H
17 
18 #include "pandabase.h"
19 #include "vertexTransform.h"
20 #include "typedWritableReferenceCount.h"
21 #include "pointerTo.h"
22 #include "luse.h"
23 #include "pvector.h"
24 #include "cycleData.h"
25 #include "cycleDataReader.h"
26 #include "cycleDataWriter.h"
27 #include "pipelineCycler.h"
28 
29 class FactoryParams;
30 
31 ////////////////////////////////////////////////////////////////////
32 // Class : TransformTable
33 // Description : Stores the total set of VertexTransforms that the
34 // vertices in a particular GeomVertexData object might
35 // depend on.
36 //
37 // This structure is used for a GeomVertexData set up to
38 // compute its dynamic vertices on the graphics card.
39 // See TransformBlendTable for one set up to compute
40 // its dynamic vertices on the CPU.
41 ////////////////////////////////////////////////////////////////////
42 class EXPCL_PANDA_GOBJ TransformTable : public TypedWritableReferenceCount {
43 PUBLISHED:
45  TransformTable(const TransformTable &copy);
46  void operator = (const TransformTable &copy);
47  virtual ~TransformTable();
48 
49  INLINE bool is_registered() const;
50  INLINE static CPT(TransformTable) register_table(const TransformTable *table);
51 
52  INLINE int get_num_transforms() const;
53  INLINE const VertexTransform *get_transform(int n) const;
54  MAKE_SEQ(get_transforms, get_num_transforms, get_transform);
55  INLINE UpdateSeq get_modified(Thread *current_thread) const;
56 
57  void set_transform(int n, const VertexTransform *transform);
58  void remove_transform(int n);
59  int add_transform(const VertexTransform *transform);
60 
61  void write(ostream &out) const;
62 
63 private:
64  void do_register();
65  void do_unregister();
66  INLINE void update_modified(UpdateSeq modified, Thread *current_thread);
67 
68 private:
69  bool _is_registered;
70 
72  Transforms _transforms;
73 
74  // This is the data that must be cycled between pipeline stages.
75  class EXPCL_PANDA_GOBJ CData : public CycleData {
76  public:
77  INLINE CData();
78  INLINE CData(const CData &copy);
79  virtual CycleData *make_copy() const;
80  virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
81  virtual void fillin(DatagramIterator &scan, BamReader *manager);
82  virtual TypeHandle get_parent_type() const {
83  return TransformTable::get_class_type();
84  }
85 
86  UpdateSeq _modified;
87  };
88 
89  PipelineCycler<CData> _cycler;
92 
93 public:
94  static void register_with_read_factory();
95  virtual void write_datagram(BamWriter *manager, Datagram &dg);
96  virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
97 
98 protected:
99  static TypedWritable *make_from_bam(const FactoryParams &params);
100  void fillin(DatagramIterator &scan, BamReader *manager);
101 
102 public:
103  static TypeHandle get_class_type() {
104  return _type_handle;
105  }
106  static void init_type() {
107  TypedWritableReferenceCount::init_type();
108  register_type(_type_handle, "TransformTable",
109  TypedWritableReferenceCount::get_class_type());
110  }
111  virtual TypeHandle get_type() const {
112  return get_class_type();
113  }
114  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
115 
116 private:
117  static TypeHandle _type_handle;
118 
119  friend class VertexTransform;
120 };
121 
122 INLINE ostream &operator << (ostream &out, const TransformTable &obj);
123 
124 #include "transformTable.I"
125 
126 #endif
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
A single page of data maintained by a PipelineCycler.
Definition: cycleData.h:50
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
virtual TypeHandle get_parent_type() const
Returns the type of the container that owns the CycleData.
Definition: cycleData.cxx:91
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
This is our own Panda specialization on the default STL list.
Definition: plist.h:38
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
virtual void write_datagram(BamWriter *, Datagram &) const
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition: cycleData.cxx:34
This is an abstract base class that holds a pointer to some transform, computed in some arbitrary way...
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin()...
Definition: cycleData.cxx:55
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class&#39;s make_from_bam() method to read in all...
Definition: cycleData.cxx:68
Stores the total set of VertexTransforms that the vertices in a particular GeomVertexData object migh...
A thread; that is, a lightweight process.
Definition: thread.h:51
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
This is a sequence number that increments monotonically.
Definition: updateSeq.h:43
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43