Panda3D
vertexTransform.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 vertexTransform.h
10  * @author drose
11  * @date 2005-03-23
12  */
13 
14 #ifndef VERTEXTRANSFORM_H
15 #define VERTEXTRANSFORM_H
16 
17 #include "pandabase.h"
19 #include "updateSeq.h"
20 #include "luse.h"
21 #include "ordered_vector.h"
22 #include "cycleData.h"
23 #include "cycleDataReader.h"
24 #include "cycleDataWriter.h"
25 #include "pipelineCycler.h"
26 
27 class TransformTable;
28 
29 /**
30  * This is an abstract base class that holds a pointer to some transform,
31  * computed in some arbitrary way, that is to be applied to vertices during
32  * rendering. This is used to implement soft-skinned and animated vertices.
33  * Derived classes will define how the transform is actually computed.
34  */
35 class EXPCL_PANDA_GOBJ VertexTransform : public TypedWritableReferenceCount {
36 PUBLISHED:
38  virtual ~VertexTransform();
39 
40  virtual void get_matrix(LMatrix4 &matrix) const=0;
41  virtual void mult_matrix(LMatrix4 &result, const LMatrix4 &previous) const;
42  virtual void accumulate_matrix(LMatrix4 &accum, PN_stdfloat weight) const;
43 
44  INLINE UpdateSeq get_modified(Thread *current_thread = Thread::get_current_thread()) const;
45  MAKE_PROPERTY(modified, get_modified);
46 
47  virtual void output(std::ostream &out) const;
48  virtual void write(std::ostream &out, int indent_level) const;
49 
50  static UpdateSeq get_next_modified(Thread *current_thread);
51  INLINE static UpdateSeq get_global_modified(Thread *current_thread);
52 
53 protected:
54  void mark_modified(Thread *current_thread);
55 
56 private:
58  Palettes _tables;
59 
60  // This is the data that must be cycled between pipeline stages.
61  class EXPCL_PANDA_GOBJ CData : public CycleData {
62  public:
63  INLINE CData();
64  INLINE CData(const CData &copy);
65  virtual CycleData *make_copy() const;
66  virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
67  virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
68  virtual void fillin(DatagramIterator &scan, BamReader *manager);
69  virtual TypeHandle get_parent_type() const {
70  VertexTransform::init_type();
71  return VertexTransform::get_class_type();
72  }
73 
74  UpdateSeq _modified;
75  };
76 
77  PipelineCycler<CData> _cycler;
78  typedef CycleDataReader<CData> CDReader;
79  typedef CycleDataWriter<CData> CDWriter;
80 
81  static PipelineCycler<CData> _global_cycler;
82  static UpdateSeq _next_modified;
83 
84 public:
85  virtual void write_datagram(BamWriter *manager, Datagram &dg);
86 
87 protected:
88  void fillin(DatagramIterator &scan, BamReader *manager);
89 
90 public:
91  static TypeHandle get_class_type() {
92  return _type_handle;
93  }
94  static void init_type() {
95  TypedWritableReferenceCount::init_type();
96  register_type(_type_handle, "VertexTransform",
97  TypedWritableReferenceCount::get_class_type());
98  }
99  virtual TypeHandle get_type() const {
100  return get_class_type();
101  }
102  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
103 
104 private:
105  static TypeHandle _type_handle;
106 
107  friend class TransformTable;
108 };
109 
110 INLINE std::ostream &operator << (std::ostream &out, const VertexTransform &obj);
111 
112 #include "vertexTransform.I"
113 
114 #endif
UpdateSeq
This is a sequence number that increments monotonically.
Definition: updateSeq.h:37
CycleData
A single page of data maintained by a PipelineCycler.
Definition: cycleData.h:47
CycleData::get_parent_type
virtual TypeHandle get_parent_type() const
Returns the type of the container that owns the CycleData.
Definition: cycleData.cxx:76
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
DatagramIterator
A class to retrieve the individual data elements previously stored in a Datagram.
Definition: datagramIterator.h:27
TransformTable
Stores the total set of VertexTransforms that the vertices in a particular GeomVertexData object migh...
Definition: transformTable.h:38
register_type
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
BamReader
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
BamWriter
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
vertexTransform.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
typedWritableReferenceCount.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypedWritable
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
CycleData::write_datagram
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:32
Thread::get_current_thread
get_current_thread
Returns a pointer to the currently-executing Thread object.
Definition: thread.h:109
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
CycleDataWriter
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
Definition: cycleDataWriter.h:34
cycleData.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
luse.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
CycleDataReader
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
Definition: cycleDataReader.h:35
cycleDataReader.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
CycleData::fillin
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...
Definition: cycleData.cxx:58
plist
This is our own Panda specialization on the default STL list.
Definition: plist.h:35
ordered_vector.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pipelineCycler.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypedWritableReferenceCount
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
Definition: typedWritableReferenceCount.h:31
cycleDataWriter.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
ov_set< TransformTable * >
Thread
A thread; that is, a lightweight process.
Definition: thread.h:46
updateSeq.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
CycleData::complete_pointers
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:48
VertexTransform
This is an abstract base class that holds a pointer to some transform, computed in some arbitrary way...
Definition: vertexTransform.h:35
PipelineCycler< CData >