Panda3D

userVertexTransform.h

00001 // Filename: userVertexTransform.h
00002 // Created by:  drose (24Mar05)
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 USERVERTEXTRANSFORM_H
00016 #define USERVERTEXTRANSFORM_H
00017 
00018 #include "pandabase.h"
00019 #include "vertexTransform.h"
00020 #include "cycleData.h"
00021 #include "cycleDataReader.h"
00022 #include "cycleDataWriter.h"
00023 #include "pipelineCycler.h"
00024 
00025 class FactoryParams;
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //       Class : UserVertexTransform
00029 // Description : This is a specialization on VertexTransform that
00030 //               allows the user to specify any arbitrary transform
00031 //               matrix he likes.  This is rarely used except for
00032 //               testing.
00033 ////////////////////////////////////////////////////////////////////
00034 class EXPCL_PANDA_GOBJ UserVertexTransform : public VertexTransform {
00035 PUBLISHED:
00036   UserVertexTransform(const string &name);
00037 
00038   INLINE const string &get_name() const;
00039 
00040   INLINE void set_matrix(const LMatrix4 &matrix);
00041   virtual void get_matrix(LMatrix4 &matrix) const;
00042 
00043   virtual void output(ostream &out) const;
00044 
00045 private:
00046   string _name;
00047 
00048   // This is the data that must be cycled between pipeline stages.
00049   class EXPCL_PANDA_GOBJ CData : public CycleData {
00050   public:
00051     INLINE CData();
00052     INLINE CData(const CData &copy);
00053     virtual CycleData *make_copy() const;
00054     virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
00055     virtual void fillin(DatagramIterator &scan, BamReader *manager);
00056     virtual TypeHandle get_parent_type() const {
00057       return UserVertexTransform::get_class_type();
00058     }
00059 
00060     LMatrix4 _matrix;
00061   };
00062 
00063   PipelineCycler<CData> _cycler;
00064   typedef CycleDataReader<CData> CDReader;
00065   typedef CycleDataWriter<CData> CDWriter;
00066 
00067 public:
00068   static void register_with_read_factory();
00069   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00070 
00071 protected:
00072   static TypedWritable *make_from_bam(const FactoryParams &params);
00073   void fillin(DatagramIterator &scan, BamReader *manager);
00074 
00075 public:
00076   static TypeHandle get_class_type() {
00077     return _type_handle;
00078   }
00079   static void init_type() {
00080     VertexTransform::init_type();
00081     register_type(_type_handle, "UserVertexTransform",
00082                   VertexTransform::get_class_type());
00083   }
00084   virtual TypeHandle get_type() const {
00085     return get_class_type();
00086   }
00087   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00088 
00089 private:
00090   static TypeHandle _type_handle;
00091 };
00092 
00093 #include "userVertexTransform.I"
00094 
00095 #endif
 All Classes Functions Variables Enumerations