00001 // Filename: geomLine.cxx 00002 // Created by: charles (13Jul00) 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 <datagram.h> 00020 #include <datagramIterator.h> 00021 #include <bamReader.h> 00022 #include <bamWriter.h> 00023 #include <ioPtaDatagramShort.h> 00024 #include <ioPtaDatagramInt.h> 00025 #include <ioPtaDatagramLinMath.h> 00026 #include <graphicsStateGuardianBase.h> 00027 00028 #include "geomLine.h" 00029 00030 TypeHandle GeomLine::_type_handle; 00031 00032 //////////////////////////////////////////////////////////////////// 00033 // Function: GeomLine::make_copy 00034 // Access: Public, Virtual 00035 // Description: Returns a newly-allocated Geom that is a shallow copy 00036 // of this one. It will be a different Geom pointer, 00037 // but its internal data may or may not be shared with 00038 // that of the original Geom. 00039 //////////////////////////////////////////////////////////////////// 00040 Geom *GeomLine:: 00041 make_copy() const { 00042 return new GeomLine(*this); 00043 } 00044 00045 //////////////////////////////////////////////////////////////////// 00046 // Function: GeomLine::draw_immediate 00047 // Access: 00048 // Description: 00049 //////////////////////////////////////////////////////////////////// 00050 void GeomLine:: 00051 draw_immediate(GraphicsStateGuardianBase *gsg, GeomContext *gc) { 00052 gsg->draw_line(this, gc); 00053 } 00054 00055 //////////////////////////////////////////////////////////////////// 00056 // Function: GeomLine::write_datagram 00057 // Access: Public 00058 // Description: Function to write the important information in 00059 // the particular object to a Datagram 00060 //////////////////////////////////////////////////////////////////// 00061 void GeomLine:: 00062 write_datagram(BamWriter *manager, Datagram &me) 00063 { 00064 Geom::write_datagram(manager, me); 00065 // Changed from uint32 to float32 on 1/16/02; didn't bother to 00066 // update the bam version on the assumption that no actual bam files 00067 // contain GeomLine objects. 00068 me.add_float32(_width); 00069 } 00070 00071 //////////////////////////////////////////////////////////////////// 00072 // Function: GeomLine::make_GeomLine 00073 // Access: Protected 00074 // Description: Factory method to generate a GeomLine object 00075 //////////////////////////////////////////////////////////////////// 00076 TypedWritable* GeomLine:: 00077 make_GeomLine(const FactoryParams ¶ms) { 00078 GeomLine *me = new GeomLine; 00079 DatagramIterator scan; 00080 BamReader *manager; 00081 00082 parse_params(params, scan, manager); 00083 me->fillin(scan, manager); 00084 me->make_dirty(); 00085 me->config(); 00086 return me; 00087 } 00088 00089 //////////////////////////////////////////////////////////////////// 00090 // Function: GeomLine::fillin 00091 // Access: Protected 00092 // Description: Function that reads out of the datagram (or asks 00093 // manager to read) all of the data that is needed to 00094 // re-create this object and stores it in the appropiate 00095 // place 00096 //////////////////////////////////////////////////////////////////// 00097 void GeomLine:: 00098 fillin(DatagramIterator& scan, BamReader* manager) { 00099 Geom::fillin(scan, manager); 00100 _width = scan.get_float32(); 00101 } 00102 00103 //////////////////////////////////////////////////////////////////// 00104 // Function: GeomLine::register_with_factory 00105 // Access: Public, Static 00106 // Description: Factory method to generate a GeomLine object 00107 //////////////////////////////////////////////////////////////////// 00108 void GeomLine:: 00109 register_with_read_factory(void) { 00110 BamReader::get_factory()->register_factory(get_class_type(), make_GeomLine); 00111 }