Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/pgraph/planeNode.cxx

Go to the documentation of this file.
00001 // Filename: planeNode.cxx
00002 // Created by:  drose (11Jul02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "planeNode.h"
00020 #include "geometricBoundingVolume.h"
00021 #include "bamWriter.h"
00022 #include "bamReader.h"
00023 #include "datagram.h"
00024 #include "datagramIterator.h"
00025 
00026 TypeHandle PlaneNode::_type_handle;
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //     Function: PlaneNode::CData::make_copy
00030 //       Access: Public, Virtual
00031 //  Description:
00032 ////////////////////////////////////////////////////////////////////
00033 CycleData *PlaneNode::CData::
00034 make_copy() const {
00035   return new CData(*this);
00036 }
00037 
00038 ////////////////////////////////////////////////////////////////////
00039 //     Function: PlaneNode::CData::write_datagram
00040 //       Access: Public, Virtual
00041 //  Description: Writes the contents of this object to the datagram
00042 //               for shipping out to a Bam file.
00043 ////////////////////////////////////////////////////////////////////
00044 void PlaneNode::CData::
00045 write_datagram(BamWriter *, Datagram &dg) const {
00046   _plane.write_datagram(dg);
00047 }
00048 
00049 ////////////////////////////////////////////////////////////////////
00050 //     Function: PlaneNode::CData::fillin
00051 //       Access: Public, Virtual
00052 //  Description: This internal function is called by make_from_bam to
00053 //               read in all of the relevant data from the BamFile for
00054 //               the new Light.
00055 ////////////////////////////////////////////////////////////////////
00056 void PlaneNode::CData::
00057 fillin(DatagramIterator &scan, BamReader *) {
00058   _plane.read_datagram(scan);
00059 }
00060 
00061 ////////////////////////////////////////////////////////////////////
00062 //     Function: PlaneNode::Constructor
00063 //       Access: Public
00064 //  Description:
00065 ////////////////////////////////////////////////////////////////////
00066 PlaneNode::
00067 PlaneNode(const string &name) :
00068   PandaNode(name)
00069 {
00070 }
00071 
00072 ////////////////////////////////////////////////////////////////////
00073 //     Function: PlaneNode::Copy Constructor
00074 //       Access: Protected
00075 //  Description:
00076 ////////////////////////////////////////////////////////////////////
00077 PlaneNode::
00078 PlaneNode(const PlaneNode &copy) :
00079   PandaNode(copy),
00080   _cycler(copy._cycler)
00081 {
00082 }
00083 
00084 ////////////////////////////////////////////////////////////////////
00085 //     Function: PlaneNode::make_copy
00086 //       Access: Public, Virtual
00087 //  Description: Returns a newly-allocated Node that is a shallow copy
00088 //               of this one.  It will be a different Node pointer,
00089 //               but its internal data may or may not be shared with
00090 //               that of the original Node.
00091 ////////////////////////////////////////////////////////////////////
00092 PandaNode *PlaneNode::
00093 make_copy() const {
00094   return new PlaneNode(*this);
00095 }
00096 
00097 ////////////////////////////////////////////////////////////////////
00098 //     Function: PlaneNode::xform
00099 //       Access: Public, Virtual
00100 //  Description: Transforms the contents of this PandaNode by the
00101 //               indicated matrix, if it means anything to do so.  For
00102 //               most kinds of PandaNodes, this does nothing.
00103 ////////////////////////////////////////////////////////////////////
00104 void PlaneNode::
00105 xform(const LMatrix4f &mat) {
00106   PandaNode::xform(mat);
00107   CDWriter cdata(_cycler);
00108   cdata->_plane = cdata->_plane * mat;
00109 }
00110 
00111 ////////////////////////////////////////////////////////////////////
00112 //     Function: PlaneNode::output
00113 //       Access: Public, Virtual
00114 //  Description: 
00115 ////////////////////////////////////////////////////////////////////
00116 void PlaneNode::
00117 output(ostream &out) const {
00118   PandaNode::output(out);
00119   out << " " << get_plane();
00120 }
00121 
00122 ////////////////////////////////////////////////////////////////////
00123 //     Function: PlaneNode::write
00124 //       Access: Public, Virtual
00125 //  Description: 
00126 ////////////////////////////////////////////////////////////////////
00127 void PlaneNode::
00128 write(ostream &out, int indent_level) const {
00129   PandaNode::write(out, indent_level);
00130   get_plane().write(out, indent_level + 2);
00131 }
00132 
00133 ////////////////////////////////////////////////////////////////////
00134 //     Function: PlaneNode::register_with_read_factory
00135 //       Access: Public, Static
00136 //  Description: Tells the BamReader how to create objects of type
00137 //               PlaneNode.
00138 ////////////////////////////////////////////////////////////////////
00139 void PlaneNode::
00140 register_with_read_factory() {
00141   BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
00142 }
00143 
00144 ////////////////////////////////////////////////////////////////////
00145 //     Function: PlaneNode::write_datagram
00146 //       Access: Public, Virtual
00147 //  Description: Writes the contents of this object to the datagram
00148 //               for shipping out to a Bam file.
00149 ////////////////////////////////////////////////////////////////////
00150 void PlaneNode::
00151 write_datagram(BamWriter *manager, Datagram &dg) {
00152   PandaNode::write_datagram(manager, dg);
00153   manager->write_cdata(dg, _cycler);
00154 }
00155 
00156 ////////////////////////////////////////////////////////////////////
00157 //     Function: PlaneNode::make_from_bam
00158 //       Access: Protected, Static
00159 //  Description: This function is called by the BamReader's factory
00160 //               when a new object of type PlaneNode is encountered
00161 //               in the Bam file.  It should create the PlaneNode
00162 //               and extract its information from the file.
00163 ////////////////////////////////////////////////////////////////////
00164 TypedWritable *PlaneNode::
00165 make_from_bam(const FactoryParams &params) {
00166   PlaneNode *node = new PlaneNode("");
00167   DatagramIterator scan;
00168   BamReader *manager;
00169 
00170   parse_params(params, scan, manager);
00171   node->fillin(scan, manager);
00172 
00173   return node;
00174 }
00175 
00176 ////////////////////////////////////////////////////////////////////
00177 //     Function: PlaneNode::fillin
00178 //       Access: Protected
00179 //  Description: This internal function is called by make_from_bam to
00180 //               read in all of the relevant data from the BamFile for
00181 //               the new PlaneNode.
00182 ////////////////////////////////////////////////////////////////////
00183 void PlaneNode::
00184 fillin(DatagramIterator &scan, BamReader *manager) {
00185   PandaNode::fillin(scan, manager);
00186   manager->read_cdata(scan, _cycler);
00187 }

Generated on Fri May 2 00:42:10 2003 for Panda by doxygen1.3