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

panda/src/pgraph/lightAttrib.I

Go to the documentation of this file.
00001 // Filename: lightAttrib.I
00002 // Created by:  drose (26Mar02)
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 
00020 ////////////////////////////////////////////////////////////////////
00021 //     Function: LightAttrib::Constructor
00022 //       Access: Private
00023 //  Description: Use LightAttrib::make() to construct a new
00024 //               LightAttrib object.
00025 ////////////////////////////////////////////////////////////////////
00026 INLINE LightAttrib::
00027 LightAttrib() {
00028   _operation = O_set;
00029 }
00030 
00031 ////////////////////////////////////////////////////////////////////
00032 //     Function: LightAttrib::get_operation
00033 //       Access: Published
00034 //  Description: Returns the basic operation type of the LightAttrib.
00035 //               If this is O_set, the lights listed here completely
00036 //               replace any lights that were already on.  If this is
00037 //               O_add, the lights here are added to the set of of
00038 //               lights that were already on, and if O_remove, the
00039 //               lights here are removed from the set of lights that
00040 //               were on.
00041 ////////////////////////////////////////////////////////////////////
00042 INLINE LightAttrib::Operation LightAttrib::
00043 get_operation() const {
00044   return _operation;
00045 }
00046 
00047 ////////////////////////////////////////////////////////////////////
00048 //     Function: LightAttrib::get_num_lights
00049 //       Access: Published
00050 //  Description: Returns the number of lights listed in the attribute.
00051 ////////////////////////////////////////////////////////////////////
00052 INLINE int LightAttrib::
00053 get_num_lights() const {
00054   return _lights.size();
00055 }
00056 
00057 ////////////////////////////////////////////////////////////////////
00058 //     Function: LightAttrib::get_light
00059 //       Access: Published
00060 //  Description: Returns the nth lights listed in the attribute.
00061 ////////////////////////////////////////////////////////////////////
00062 INLINE Light *LightAttrib::
00063 get_light(int n) const {
00064   nassertr(n >= 0 && n < (int)_lights.size(), (Light *)NULL);
00065   return _lights[n];
00066 }
00067 
00068 ////////////////////////////////////////////////////////////////////
00069 //     Function: LightAttrib::add_light
00070 //       Access: Published
00071 //  Description: Returns a new LightAttrib, just like this one, but
00072 //               with the indicated light added to the list of lights.
00073 ////////////////////////////////////////////////////////////////////
00074 INLINE CPT(RenderAttrib) LightAttrib::
00075 add_light(Light *light) const {
00076   if (_operation == O_remove) {  
00077     return compose(make(O_remove, light));
00078   } else {
00079     return compose(make(O_add, light));
00080   }
00081 }
00082 
00083 ////////////////////////////////////////////////////////////////////
00084 //     Function: LightAttrib::remove_light
00085 //       Access: Published
00086 //  Description: Returns a new LightAttrib, just like this one, but
00087 //               with the indicated light removed from the list of
00088 //               lights.
00089 ////////////////////////////////////////////////////////////////////
00090 INLINE CPT(RenderAttrib) LightAttrib::
00091 remove_light(Light *light) const {
00092   if (_operation == O_remove) {  
00093     return compose(make(O_add, light));
00094   } else {
00095     return compose(make(O_remove, light));
00096   }
00097 }
00098 
00099 ////////////////////////////////////////////////////////////////////
00100 //     Function: LightAttrib::is_identity
00101 //       Access: Published
00102 //  Description: Returns true if this is an identity attrib: it does
00103 //               not change the set of lights in use.
00104 ////////////////////////////////////////////////////////////////////
00105 INLINE bool LightAttrib::
00106 is_identity() const {
00107   return _operation != O_set && _lights.empty();
00108 }
00109 
00110 ////////////////////////////////////////////////////////////////////
00111 //     Function: LightAttrib::is_all_off
00112 //       Access: Published
00113 //  Description: Returns true if this attrib turns off all lights and
00114 //               turns none on.
00115 ////////////////////////////////////////////////////////////////////
00116 INLINE bool LightAttrib::
00117 is_all_off() const {
00118   return _operation == O_set && _lights.empty();
00119 }

Generated on Fri May 2 00:41:45 2003 for Panda by doxygen1.3