Panda3D
 All Classes Functions Variables Enumerations
light.I
00001 // Filename: light.I
00002 // Created by:  drose (26Mar02)
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 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: Light::CData::Constructor
00018 //       Access: Public
00019 //  Description:
00020 ////////////////////////////////////////////////////////////////////
00021 INLINE Light::CData::
00022 CData() :
00023   _color(1.0f, 1.0f, 1.0f, 1.0f),
00024   _viz_geom_stale(true)
00025 {
00026 }
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //     Function: Light::CData::Copy Constructor
00030 //       Access: Public
00031 //  Description:
00032 ////////////////////////////////////////////////////////////////////
00033 INLINE Light::CData::
00034 CData(const Light::CData &copy) :
00035   _color(copy._color),
00036   _viz_geom(copy._viz_geom),
00037   _viz_geom_stale(copy._viz_geom_stale)
00038 {
00039 }
00040 
00041 ////////////////////////////////////////////////////////////////////
00042 //     Function: Light::Constructor
00043 //       Access: Public
00044 //  Description: 
00045 ////////////////////////////////////////////////////////////////////
00046 INLINE Light::
00047 Light() :
00048   _priority(0)
00049 {
00050 }
00051 
00052 ////////////////////////////////////////////////////////////////////
00053 //     Function: Light::Copy Constructor
00054 //       Access: Public
00055 //  Description: 
00056 ////////////////////////////////////////////////////////////////////
00057 INLINE Light::
00058 Light(const Light &copy) :
00059   _priority(copy._priority),
00060   _cycler(copy._cycler)
00061 {
00062 }
00063 
00064 ////////////////////////////////////////////////////////////////////
00065 //     Function: Light::get_color
00066 //       Access: Published
00067 //  Description: Returns the basic color of the light.
00068 ////////////////////////////////////////////////////////////////////
00069 INLINE const LColor &Light::
00070 get_color() const {
00071   CDReader cdata(_cycler);
00072   return cdata->_color;
00073 }
00074 
00075 ////////////////////////////////////////////////////////////////////
00076 //     Function: Light::set_color
00077 //       Access: Published
00078 //  Description: Sets the basic color of the light.
00079 ////////////////////////////////////////////////////////////////////
00080 INLINE void Light::
00081 set_color(const LColor &color) {
00082   CDWriter cdata(_cycler);
00083   cdata->_color = color;
00084   mark_viz_stale();
00085 }
00086 
00087 ////////////////////////////////////////////////////////////////////
00088 //     Function: Light::set_priority
00089 //       Access: Published
00090 //  Description: Changes the relative importance of this light
00091 //               relative to the other lights that are applied
00092 //               simultaneously.
00093 //
00094 //               The priority number is used to decide which of the
00095 //               requested lights are to be selected for rendering
00096 //               when more lights are requested than the hardware will
00097 //               support.  The highest-priority n lights are selected
00098 //               for rendering.
00099 //
00100 //               This is similar to TextureStage::set_priority().
00101 ////////////////////////////////////////////////////////////////////
00102 INLINE void Light::
00103 set_priority(int priority) {
00104   _priority = priority;
00105 
00106   // Update the global flag to indicate that all LightAttribs in the
00107   // world must now re-sort their lists.
00108   _sort_seq++;
00109 }
00110 
00111 ////////////////////////////////////////////////////////////////////
00112 //     Function: Light::get_priority
00113 //       Access: Published
00114 //  Description: Returns the priority associated with this light.  See
00115 //               set_priority().
00116 ////////////////////////////////////////////////////////////////////
00117 INLINE int Light::
00118 get_priority() const {
00119   return _priority;
00120 }
00121 
00122 ////////////////////////////////////////////////////////////////////
00123 //     Function: Light::get_sort_seq
00124 //       Access: Public, Static
00125 //  Description: Returns a global sequence number that is incremented
00126 //               any time any Light in the world changes sort
00127 //               or priority.  This is used by LightAttrib to
00128 //               determine when it is necessary to re-sort its
00129 //               internal array of stages.
00130 ////////////////////////////////////////////////////////////////////
00131 INLINE UpdateSeq Light::
00132 get_sort_seq() {
00133   return _sort_seq;
00134 }
00135 
00136 ////////////////////////////////////////////////////////////////////
00137 //     Function: Light::mark_viz_stale
00138 //       Access: Protected
00139 //  Description: Indicates that the internal visualization object will
00140 //               need to be updated.
00141 ////////////////////////////////////////////////////////////////////
00142 INLINE void Light::
00143 mark_viz_stale() {
00144   CDWriter cdata(_cycler);
00145   cdata->_viz_geom_stale = true;
00146 }
 All Classes Functions Variables Enumerations