Panda3D
vertexTransform.h
1 // Filename: vertexTransform.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 VERTEXTRANSFORM_H
16 #define VERTEXTRANSFORM_H
17 
18 #include "pandabase.h"
19 #include "typedWritableReferenceCount.h"
20 #include "updateSeq.h"
21 #include "luse.h"
22 #include "ordered_vector.h"
23 #include "cycleData.h"
24 #include "cycleDataReader.h"
25 #include "cycleDataWriter.h"
26 #include "pipelineCycler.h"
27 
28 class TransformTable;
29 
30 ////////////////////////////////////////////////////////////////////
31 // Class : VertexTransform
32 // Description : This is an abstract base class that holds a pointer
33 // to some transform, computed in some arbitrary way,
34 // that is to be applied to vertices during rendering.
35 // This is used to implement soft-skinned and animated
36 // vertices. Derived classes will define how the
37 // transform is actually computed.
38 ////////////////////////////////////////////////////////////////////
39 class EXPCL_PANDA_GOBJ VertexTransform : public TypedWritableReferenceCount {
40 PUBLISHED:
42  virtual ~VertexTransform();
43 
44  virtual void get_matrix(LMatrix4 &matrix) const=0;
45  virtual void mult_matrix(LMatrix4 &result, const LMatrix4 &previous) const;
46  virtual void accumulate_matrix(LMatrix4 &accum, PN_stdfloat weight) const;
47 
48  INLINE UpdateSeq get_modified(Thread *current_thread) const;
49 
50  virtual void output(ostream &out) const;
51  virtual void write(ostream &out, int indent_level) const;
52 
53  static UpdateSeq get_next_modified(Thread *current_thread);
54  INLINE static UpdateSeq get_global_modified(Thread *current_thread);
55 
56 protected:
57  void mark_modified(Thread *current_thread);
58 
59 private:
61  Palettes _tables;
62 
63  // This is the data that must be cycled between pipeline stages.
64  class EXPCL_PANDA_GOBJ CData : public CycleData {
65  public:
66  INLINE CData();
67  INLINE CData(const CData &copy);
68  virtual CycleData *make_copy() const;
69  virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
70  virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
71  virtual void fillin(DatagramIterator &scan, BamReader *manager);
72  virtual TypeHandle get_parent_type() const {
73  return VertexTransform::get_class_type();
74  }
75 
76  UpdateSeq _modified;
77  };
78 
79  PipelineCycler<CData> _cycler;
82 
83  static PipelineCycler<CData> _global_cycler;
84  static UpdateSeq _next_modified;
85 
86 public:
87  virtual void write_datagram(BamWriter *manager, Datagram &dg);
88 
89 protected:
90  void fillin(DatagramIterator &scan, BamReader *manager);
91 
92 public:
93  static TypeHandle get_class_type() {
94  return _type_handle;
95  }
96  static void init_type() {
97  TypedWritableReferenceCount::init_type();
98  register_type(_type_handle, "VertexTransform",
99  TypedWritableReferenceCount::get_class_type());
100  }
101  virtual TypeHandle get_type() const {
102  return get_class_type();
103  }
104  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
105 
106 private:
107  static TypeHandle _type_handle;
108 
109  friend class TransformTable;
110 };
111 
112 INLINE ostream &operator << (ostream &out, const VertexTransform &obj);
113 
114 #include "vertexTransform.I"
115 
116 #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...
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
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