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