opennurbs_light.h
Go to the documentation of this file.
00001 /* $NoKeywords: $ */
00002 /*
00003 //
00004 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
00005 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
00006 // McNeel & Associates.
00007 //
00008 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
00009 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
00010 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
00011 //                              
00012 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
00013 //
00015 */
00016 
00017 #if !defined(OPENNURBS_LIGHT_INC_)
00018 #define OPENNURBS_LIGHT_INC_
00019 
00020 class ON_CLASS ON_Light : public ON_Geometry
00021 {
00022   ON_OBJECT_DECLARE(ON_Light);
00023 
00024 public:
00025   ON_Light();
00026   ~ON_Light();
00027   // C++ defaults work fine
00028   //ON_Light& operator=(const ON_Light&);
00029   //ON_Light(const ON_Light&);
00030 
00032   //
00033   // ON_Object virtual functions 
00034   //
00035 
00036   /*
00037   Description:
00038     Tests an object to see if its data members are correctly
00039     initialized.
00040   Parameters:
00041     text_log - [in] if the object is not valid and text_log
00042         is not NULL, then a brief englis description of the
00043         reason the object is not valid is appened to the log.
00044         The information appended to text_log is suitable for 
00045         low-level debugging purposes by programmers and is 
00046         not intended to be useful as a high level user 
00047         interface tool.
00048   Returns:
00049     @untitled table
00050     true     object is valid
00051     false    object is invalid, uninitialized, etc.
00052   Remarks:
00053     Overrides virtual ON_Object::IsValid
00054   */
00055   ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
00056 
00057   void Dump( ON_TextLog& ) const; // for debugging
00058 
00059   // Use ON_BinaryArchive::WriteObject() and ON_BinaryArchive::ReadObject()
00060   // for top level serialization.  These Read()/Write() members should just
00061   // write/read specific definitions.  In particular, they should not write/
00062   // read any chunk typecode or length information.  The default 
00063   // implementations return false and do nothing.
00064   ON_BOOL32 Write(
00065          ON_BinaryArchive&  // serialize definition to binary archive
00066        ) const;
00067 
00068   ON_BOOL32 Read(
00069          ON_BinaryArchive&  // restore definition from binary archive
00070        );
00071 
00072   ON::object_type ObjectType() const;
00073 
00074   // virtual
00075   ON_UUID ModelObjectId() const;
00076 
00077 
00079   //
00080   // ON_Geometry virtual functions 
00081   //
00082   int Dimension() const;
00083 
00084   ON_BOOL32 GetBBox( // returns true if successful
00085          double*,    // boxmin[dim]
00086          double*,    // boxmax[dim]
00087          ON_BOOL32 = false  // true means grow box
00088          ) const;
00089 
00090   ON_BOOL32 Transform( 
00091          const ON_Xform&
00092          );
00093  
00095   //
00096   // Interface
00097   //
00098 
00099   void Default(); // make default light
00100 
00102   //
00103   // turn light on/off
00104   //
00105   ON_BOOL32 Enable( ON_BOOL32 = true ); // returns previous state
00106   ON_BOOL32 IsEnabled() const;
00107   
00109   //
00110   // style, location, and direction
00111   //   direction is ignored for "point" and "ambient" lights
00112   //   location is ignored for "directional" and "ambient" lights
00113   void SetStyle(ON::light_style);
00114   ON::light_style Style() const;
00115 
00116   const ON_BOOL32 IsPointLight() const;
00117   const ON_BOOL32 IsDirectionalLight() const;
00118   const ON_BOOL32 IsSpotLight() const;
00119   const ON_BOOL32 IsLinearLight() const;
00120   const ON_BOOL32 IsRectangularLight() const;
00121 
00122   ON::coordinate_system CoordinateSystem() const; // determined by style
00123 
00124   /*
00125   Description:
00126     A light's location and direction can be defined with respect
00127     to world, camera, or view coordinates.  GetLightXform gets
00128     the transformation from the light's intrinsic coordinate
00129     system to the destination coordinate system specified
00130     by dest_cs.
00131   Parameters:
00132     vp - [in] viewport where light is being used
00133     dest_cs - [in] destination coordinate system
00134     xform - [out] transformation from the light's intrinsic
00135                   coordinate system to cs.
00136   Returns:
00137     true if successful.
00138   */
00139   ON_BOOL32 GetLightXform( 
00140            const ON_Viewport& vp,
00141            ON::coordinate_system dest_cs, 
00142            ON_Xform& xform 
00143            ) const;
00144 
00145   void SetLocation( const ON_3dPoint& );
00146   void SetDirection( const ON_3dVector& );
00147 
00148   ON_3dPoint Location() const;
00149   ON_3dVector Direction() const;
00150   ON_3dVector PerpindicularDirection() const;
00151 
00152   double Intensity() const; // 0.0 = 0%  1.0 = 100%
00153   void SetIntensity(double);
00154 
00155   double PowerWatts() const;
00156   double PowerLumens() const;
00157   double PowerCandela() const;
00158   
00159   void SetPowerWatts( double );
00160   void SetPowerLumens( double );
00161   void SetPowerCandela( double );
00162 
00164   //
00165   // colors
00166   //
00167   void SetAmbient(  ON_Color );
00168   void SetDiffuse(  ON_Color );
00169   void SetSpecular( ON_Color );
00170   ON_Color Ambient() const;
00171   ON_Color Diffuse() const;
00172   ON_Color Specular() const;
00173 
00175   //
00176   // attenuation settings (ignored for "directional" and "ambient" lights)
00177   // attenuation = 1/(a[0] + d*a[1] + d^2*a[2]) where d = distance to light
00178   //
00179   void SetAttenuation(double,double,double);
00180   void SetAttenuation(const ON_3dVector&);
00181   ON_3dVector Attenuation() const;
00182   double Attenuation(double) const; // computes 1/(a[0] + d*a[1] + d^2*a[2]) where d = argument
00183                                     // returns 0 if a[0] + d*a[1] + d^2*a[2] <= 0
00184 
00186   //
00187   // spot light parameters (ignored for non-spot lights)
00188   //
00189   // angle = 0 to 90 degrees
00190   // exponent = 0 to 128 (0=uniform, 128=high focus)
00191   //
00192   void SetSpotAngleDegrees( double );
00193   double SpotAngleDegrees() const;
00194 
00195   void SetSpotAngleRadians( double );
00196   double SpotAngleRadians() const;
00197 
00199   // The spot exponent varies from 0.0 to 128.0 and provides
00200   // an exponential interface for controling the focus or 
00201   // concentration of a spotlight (like the 
00202   // OpenGL GL_SPOT_EXPONENT parameter).  The spot exponent
00203   // and hot spot parameters are linked; changing one will
00204   // change the other.
00205   // A hot spot setting of 0.0 corresponds to a spot exponent of 128.
00206   // A hot spot setting of 1.0 corresponds to a spot exponent of 0.0.
00207   void SetSpotExponent( double );
00208   double SpotExponent() const;
00209 
00211   // The hot spot setting runs from 0.0 to 1.0 and is used to
00212   // provides a linear interface for controling the focus or 
00213   // concentration of a spotlight.
00214   // A hot spot setting of 0.0 corresponds to a spot exponent of 128.
00215   // A hot spot setting of 1.0 corresponds to a spot exponent of 0.0.
00216   void SetHotSpot( double );
00217   double HotSpot() const;
00218 
00219   // The spotlight radii are useful for display UI.
00220   bool GetSpotLightRadii( double* inner_radius, double* outer_radius ) const;
00221 
00222 
00224   //
00225   // linear and rectangular light parameters
00226   // (ignored for non-linear/rectangular lights)
00227   //
00228   void SetLength( const ON_3dVector& );
00229   ON_3dVector Length() const;
00230 
00231   void SetWidth( const ON_3dVector& );
00232   ON_3dVector Width() const;
00233 
00235   //
00236   // shadow parameters (ignored for non-spot lights)
00237   //
00238   // shadow intensity 0.0 = does not cast any shadows
00239   //                  1.0 = casts black shadows
00240   //
00241   void SetShadowIntensity(double);
00242   double ShadowIntensity() const;
00243                                  
00244 
00246   //
00247   // light index
00248   //
00249   void SetLightIndex( int );
00250   int LightIndex() const;
00251 
00253   //
00254   // light name
00255   //
00256   void SetLightName( const char* );
00257   void SetLightName( const wchar_t* );
00258   const ON_wString& LightName() const;
00259 
00260 public:
00261   int           m_light_index;
00262   ON_UUID       m_light_id;
00263   ON_wString    m_light_name;
00264 
00265   ON_BOOL32                 m_bOn;   // true if light is on
00266   ON::light_style      m_style; // style of light
00267 
00268   ON_Color m_ambient;
00269   ON_Color m_diffuse;
00270   ON_Color m_specular;
00271   
00272   ON_3dVector m_direction; // ignored for "point" and "ambient" lights
00273   ON_3dPoint  m_location;  // ignored for "directional" and "ambient" lights
00274   ON_3dVector m_length;    // only for linear and rectangular lights
00275                            // ends of linear lights are m_location and m_location+m_length
00276   ON_3dVector m_width;     // only for rectangular lights
00277                            // corners of rectangular lights are m_location, m_location+m_length,
00278                            // m_location+m_width, m_location+m_width+m_length
00279 
00280   double      m_intensity; // Linear dimming/brightening factor: 0.0 = off, 1.0 = 100%.
00281                            // Values < 0.0 and values > 1.0 are permitted but are
00282                            // not consistently interpreted by various renderers.
00283                            // Renderers should clamp the range to [0.0, 1.0] if their
00284                            // lighting model does not support more exotic interpretations
00285                            // of m_intensity.
00286   double      m_watts;     // Used by lighting models that reference lighting fixtures.
00287                            // Values < 0.0 are invalid.  If m_watts is 0.0, the
00288                            // value is ignored.
00289 
00290   // spot settings - ignored for non-spot lights
00291   double       m_spot_angle;    // 0.0 to 90.0
00292   double       m_spot_exponent; // 0.0 to 128.0
00293                                 // 0.0 = uniform
00294                                 // 128.0 = high focus
00295   double       m_hotspot;       // 0.0 to 1.0 (See SetHotSpot() for details)
00296 
00297   // attenuation settings - ignored for "directional" and "ambient" lights
00298   ON_3dVector m_attenuation;    // each entry >= 0.0
00299                                 // att = 1/(a[0] + d*a[1] + d^2*a[2])
00300                                 // where d = distance to light
00301 
00302   // shawdow casting
00303   double       m_shadow_intensity; // 0.0 = no shadow casting, 1.0 = full shadow casting
00304 };
00305 
00306 
00307 
00308 #endif


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:27:01