00001 // Filename: ambientLight.cxx 00002 // Created by: mike (09Jan97) 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 "ambientLight.h" 00020 #include "bamWriter.h" 00021 #include "bamReader.h" 00022 #include "datagram.h" 00023 #include "datagramIterator.h" 00024 00025 TypeHandle AmbientLight::_type_handle; 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Function: AmbientLight::Constructor 00029 // Access: Published 00030 // Description: 00031 //////////////////////////////////////////////////////////////////// 00032 AmbientLight:: 00033 AmbientLight(const string &name) : 00034 LightNode(name) 00035 { 00036 } 00037 00038 //////////////////////////////////////////////////////////////////// 00039 // Function: AmbientLight::Copy Constructor 00040 // Access: Protected 00041 // Description: Do not call the copy constructor directly; instead, 00042 // use make_copy() or copy_subgraph() to make a copy of 00043 // a node. 00044 //////////////////////////////////////////////////////////////////// 00045 AmbientLight:: 00046 AmbientLight(const AmbientLight ©) : 00047 LightNode(copy) 00048 { 00049 } 00050 00051 //////////////////////////////////////////////////////////////////// 00052 // Function: AmbientLight::make_copy 00053 // Access: Public, Virtual 00054 // Description: Returns a newly-allocated PandaNode that is a shallow 00055 // copy of this one. It will be a different pointer, 00056 // but its internal data may or may not be shared with 00057 // that of the original PandaNode. No children will be 00058 // copied. 00059 //////////////////////////////////////////////////////////////////// 00060 PandaNode *AmbientLight:: 00061 make_copy() const { 00062 return new AmbientLight(*this); 00063 } 00064 00065 //////////////////////////////////////////////////////////////////// 00066 // Function: AmbientLight::write 00067 // Access: Public, Virtual 00068 // Description: 00069 //////////////////////////////////////////////////////////////////// 00070 void AmbientLight:: 00071 write(ostream &out, int indent_level) const { 00072 indent(out, indent_level) << *this << ":\n"; 00073 indent(out, indent_level + 2) 00074 << "color " << get_color() << "\n"; 00075 } 00076 00077 //////////////////////////////////////////////////////////////////// 00078 // Function: AmbientLight::bind 00079 // Access: Public, Virtual 00080 // Description: 00081 //////////////////////////////////////////////////////////////////// 00082 void AmbientLight:: 00083 bind(GraphicsStateGuardianBase *, int) { 00084 // AmbientLights aren't bound to light id's; this function should 00085 // never be called. 00086 nassertv(false); 00087 } 00088 00089 //////////////////////////////////////////////////////////////////// 00090 // Function: AmbientLight::register_with_read_factory 00091 // Access: Public, Static 00092 // Description: Tells the BamReader how to create objects of type 00093 // AmbientLight. 00094 //////////////////////////////////////////////////////////////////// 00095 void AmbientLight:: 00096 register_with_read_factory() { 00097 BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); 00098 } 00099 00100 //////////////////////////////////////////////////////////////////// 00101 // Function: AmbientLight::write_datagram 00102 // Access: Public, Virtual 00103 // Description: Writes the contents of this object to the datagram 00104 // for shipping out to a Bam file. 00105 //////////////////////////////////////////////////////////////////// 00106 void AmbientLight:: 00107 write_datagram(BamWriter *manager, Datagram &dg) { 00108 LightNode::write_datagram(manager, dg); 00109 } 00110 00111 //////////////////////////////////////////////////////////////////// 00112 // Function: AmbientLight::make_from_bam 00113 // Access: Protected, Static 00114 // Description: This function is called by the BamReader's factory 00115 // when a new object of type AmbientLight is encountered 00116 // in the Bam file. It should create the AmbientLight 00117 // and extract its information from the file. 00118 //////////////////////////////////////////////////////////////////// 00119 TypedWritable *AmbientLight:: 00120 make_from_bam(const FactoryParams ¶ms) { 00121 AmbientLight *node = new AmbientLight(""); 00122 DatagramIterator scan; 00123 BamReader *manager; 00124 00125 parse_params(params, scan, manager); 00126 node->fillin(scan, manager); 00127 00128 return node; 00129 } 00130 00131 //////////////////////////////////////////////////////////////////// 00132 // Function: AmbientLight::fillin 00133 // Access: Protected 00134 // Description: This internal function is called by make_from_bam to 00135 // read in all of the relevant data from the BamFile for 00136 // the new AmbientLight. 00137 //////////////////////////////////////////////////////////////////// 00138 void AmbientLight:: 00139 fillin(DatagramIterator &scan, BamReader *manager) { 00140 LightNode::fillin(scan, manager); 00141 }