Panda3D

light.cxx

00001 // Filename: light.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 "light.h"
00016 #include "bamWriter.h"
00017 #include "bamReader.h"
00018 #include "datagram.h"
00019 #include "datagramIterator.h"
00020 
00021 UpdateSeq Light::_sort_seq;
00022 
00023 TypeHandle Light::_type_handle;
00024 
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //     Function: Light::CData::make_copy
00028 //       Access: Public, Virtual
00029 //  Description:
00030 ////////////////////////////////////////////////////////////////////
00031 CycleData *Light::CData::
00032 make_copy() const {
00033   return new CData(*this);
00034 }
00035 
00036 ////////////////////////////////////////////////////////////////////
00037 //     Function: Light::CData::write_datagram
00038 //       Access: Public, Virtual
00039 //  Description: Writes the contents of this object to the datagram
00040 //               for shipping out to a Bam file.
00041 ////////////////////////////////////////////////////////////////////
00042 void Light::CData::
00043 write_datagram(BamWriter *, Datagram &dg) const {
00044   _color.write_datagram(dg);
00045 }
00046 
00047 ////////////////////////////////////////////////////////////////////
00048 //     Function: Light::CData::fillin
00049 //       Access: Public, Virtual
00050 //  Description: This internal function is called by make_from_bam to
00051 //               read in all of the relevant data from the BamFile for
00052 //               the new Light.
00053 ////////////////////////////////////////////////////////////////////
00054 void Light::CData::
00055 fillin(DatagramIterator &scan, BamReader *) {
00056   _color.read_datagram(scan);
00057 }
00058 
00059 ////////////////////////////////////////////////////////////////////
00060 //     Function: Light::Destructor
00061 //       Access: Published, Virtual
00062 //  Description: 
00063 ////////////////////////////////////////////////////////////////////
00064 Light::
00065 ~Light() {
00066 }
00067 
00068 ////////////////////////////////////////////////////////////////////
00069 //     Function: Light::is_ambient_light
00070 //       Access: Published, Virtual
00071 //  Description: Returns true if this is an AmbientLight, false if it
00072 //               is some other kind of light.
00073 ////////////////////////////////////////////////////////////////////
00074 bool Light::
00075 is_ambient_light() const {
00076   return false;
00077 }
00078 
00079 ////////////////////////////////////////////////////////////////////
00080 //     Function: Light::get_vector_to_light
00081 //       Access: Public, Virtual
00082 //  Description: Computes the vector from a particular vertex to this
00083 //               light.  The exact vector depends on the type of light
00084 //               (e.g. point lights return a different result than
00085 //               directional lights).
00086 //
00087 //               The input parameters are the vertex position in
00088 //               question, expressed in object space, and the matrix
00089 //               which converts from light space to object space.  The
00090 //               result is expressed in object space.
00091 //
00092 //               The return value is true if the result is successful,
00093 //               or false if it cannot be computed (e.g. for an
00094 //               ambient light).
00095 ////////////////////////////////////////////////////////////////////
00096 bool Light::
00097 get_vector_to_light(LVector3 &, const LPoint3 &, const LMatrix4 &) {
00098   return false;
00099 }
00100 
00101 ////////////////////////////////////////////////////////////////////
00102 //     Function: Light::get_viz
00103 //       Access: Public
00104 //  Description: Returns a GeomNode that may be rendered to visualize
00105 //               the Light.  This is used during the cull traversal to
00106 //               render the Lights that have been made visible.
00107 ////////////////////////////////////////////////////////////////////
00108 GeomNode *Light::
00109 get_viz() {
00110   CDLockedReader cdata(_cycler);
00111   if (cdata->_viz_geom_stale) {
00112     CDWriter cdata_w(_cycler, cdata);
00113 
00114     cdata_w->_viz_geom = new GeomNode("viz");
00115     fill_viz_geom(cdata_w->_viz_geom);
00116     cdata_w->_viz_geom_stale = false;
00117   }
00118   return cdata->_viz_geom;
00119 }
00120 
00121 ////////////////////////////////////////////////////////////////////
00122 //     Function: Light::fill_viz_geom
00123 //       Access: Protected, Virtual
00124 //  Description: Fills the indicated GeomNode up with Geoms suitable
00125 //               for rendering this light.
00126 ////////////////////////////////////////////////////////////////////
00127 void Light::
00128 fill_viz_geom(GeomNode *) {
00129 }
00130 
00131 ////////////////////////////////////////////////////////////////////
00132 //     Function: Light::write_datagram
00133 //       Access: Protected
00134 //  Description: Writes the contents of this object to the datagram
00135 //               for shipping out to a Bam file.
00136 ////////////////////////////////////////////////////////////////////
00137 void Light::
00138 write_datagram(BamWriter *manager, Datagram &dg) {
00139   manager->write_cdata(dg, _cycler);
00140   dg.add_int32(_priority);
00141 }
00142 
00143 ////////////////////////////////////////////////////////////////////
00144 //     Function: Light::fillin
00145 //       Access: Protected
00146 //  Description: This internal function is called by make_from_bam to
00147 //               read in all of the relevant data from the BamFile for
00148 //               the new Light.
00149 ////////////////////////////////////////////////////////////////////
00150 void Light::
00151 fillin(DatagramIterator &scan, BamReader *manager) {
00152   manager->read_cdata(scan, _cycler);
00153   _priority = scan.get_int32();
00154 }
 All Classes Functions Variables Enumerations