Panda3D

vertexTransform.h

00001 // Filename: vertexTransform.h
00002 // Created by:  drose (23Mar05)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef VERTEXTRANSFORM_H
00016 #define VERTEXTRANSFORM_H
00017 
00018 #include "pandabase.h"
00019 #include "typedWritableReferenceCount.h"
00020 #include "updateSeq.h"
00021 #include "luse.h"
00022 #include "ordered_vector.h"
00023 #include "cycleData.h"
00024 #include "cycleDataReader.h"
00025 #include "cycleDataWriter.h"
00026 #include "pipelineCycler.h"
00027 
00028 class TransformTable;
00029 
00030 ////////////////////////////////////////////////////////////////////
00031 //       Class : VertexTransform
00032 // Description : This is an abstract base class that holds a pointer
00033 //               to some transform, computed in some arbitrary way,
00034 //               that is to be applied to vertices during rendering.
00035 //               This is used to implement soft-skinned and animated
00036 //               vertices.  Derived classes will define how the
00037 //               transform is actually computed.
00038 ////////////////////////////////////////////////////////////////////
00039 class EXPCL_PANDA_GOBJ VertexTransform : public TypedWritableReferenceCount {
00040 PUBLISHED:
00041   VertexTransform();
00042   virtual ~VertexTransform();
00043 
00044   virtual void get_matrix(LMatrix4 &matrix) const=0;
00045   virtual void mult_matrix(LMatrix4 &result, const LMatrix4 &previous) const;
00046   virtual void accumulate_matrix(LMatrix4 &accum, PN_stdfloat weight) const;
00047 
00048   INLINE UpdateSeq get_modified(Thread *current_thread) const;
00049 
00050   virtual void output(ostream &out) const;
00051   virtual void write(ostream &out, int indent_level) const;
00052 
00053   static UpdateSeq get_next_modified(Thread *current_thread);
00054   INLINE static UpdateSeq get_global_modified(Thread *current_thread);
00055 
00056 protected:
00057   void mark_modified(Thread *current_thread);
00058 
00059 private:
00060   typedef ov_set<TransformTable *> Palettes;
00061   Palettes _tables;
00062 
00063   // This is the data that must be cycled between pipeline stages.
00064   class EXPCL_PANDA_GOBJ CData : public CycleData {
00065   public:
00066     INLINE CData();
00067     INLINE CData(const CData &copy);
00068     virtual CycleData *make_copy() const;
00069     virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
00070     virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
00071     virtual void fillin(DatagramIterator &scan, BamReader *manager);
00072     virtual TypeHandle get_parent_type() const {
00073       return VertexTransform::get_class_type();
00074     }
00075 
00076     UpdateSeq _modified;
00077   };
00078 
00079   PipelineCycler<CData> _cycler;
00080   typedef CycleDataReader<CData> CDReader;
00081   typedef CycleDataWriter<CData> CDWriter;
00082 
00083   static PipelineCycler<CData> _global_cycler;
00084   static UpdateSeq _next_modified;
00085 
00086 public:
00087   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00088 
00089 protected:
00090   void fillin(DatagramIterator &scan, BamReader *manager);
00091 
00092 public:
00093   static TypeHandle get_class_type() {
00094     return _type_handle;
00095   }
00096   static void init_type() {
00097     TypedWritableReferenceCount::init_type();
00098     register_type(_type_handle, "VertexTransform",
00099                   TypedWritableReferenceCount::get_class_type());
00100   }
00101   virtual TypeHandle get_type() const {
00102     return get_class_type();
00103   }
00104   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00105 
00106 private:
00107   static TypeHandle _type_handle;
00108 
00109   friend class TransformTable;
00110 };
00111 
00112 INLINE ostream &operator << (ostream &out, const VertexTransform &obj);
00113 
00114 #include "vertexTransform.I"
00115 
00116 #endif
 All Classes Functions Variables Enumerations