QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_light.h
Go to the documentation of this file.
1/* $NoKeywords: $ */
2/*
3//
4// Copyright (c) 1993-2007 Robert McNeel & Associates. All rights reserved.
5// Rhinoceros is a registered trademark of Robert McNeel & Assoicates.
6//
7// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
8// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
9// MERCHANTABILITY ARE HEREBY DISCLAIMED.
10//
11// For complete openNURBS copyright information see <http://www.opennurbs.org>.
12//
14*/
15
16#if !defined(OPENNURBS_LIGHT_INC_)
17#define OPENNURBS_LIGHT_INC_
18
20{
22
23public:
24 ON_Light();
25 ~ON_Light();
26 // C++ defaults work fine
27 //ON_Light& operator=(const ON_Light&);
28 //ON_Light(const ON_Light&);
29
31 //
32 // ON_Object virtual functions
33 //
34
35 /*
36 Description:
37 Tests an object to see if its data members are correctly
38 initialized.
39 Parameters:
40 text_log - [in] if the object is not valid and text_log
41 is not NULL, then a brief englis description of the
42 reason the object is not valid is appened to the log.
43 The information appended to text_log is suitable for
44 low-level debugging purposes by programmers and is
45 not intended to be useful as a high level user
46 interface tool.
47 Returns:
48 @untitled table
49 true object is valid
50 false object is invalid, uninitialized, etc.
51 Remarks:
52 Overrides virtual ON_Object::IsValid
53 */
54 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
55
56 void Dump( ON_TextLog& ) const; // for debugging
57
58 // Use ON_BinaryArchive::WriteObject() and ON_BinaryArchive::ReadObject()
59 // for top level serialization. These Read()/Write() members should just
60 // write/read specific definitions. In particular, they should not write/
61 // read any chunk typecode or length information. The default
62 // implementations return false and do nothing.
64 ON_BinaryArchive& // serialize definition to binary archive
65 ) const;
66
68 ON_BinaryArchive& // restore definition from binary archive
69 );
70
71 ON::object_type ObjectType() const;
72
73 // virtual
74 ON_UUID ModelObjectId() const;
75
76
78 //
79 // ON_Geometry virtual functions
80 //
81 int Dimension() const;
82
83 ON_BOOL32 GetBBox( // returns true if successful
84 double*, // boxmin[dim]
85 double*, // boxmax[dim]
86 ON_BOOL32 = false // true means grow box
87 ) const;
88
90 const ON_Xform&
91 );
92
94 //
95 // Interface
96 //
97
98 void Default(); // make default light
99
101 //
102 // turn light on/off
103 //
104 ON_BOOL32 Enable( ON_BOOL32 = true ); // returns previous state
105 ON_BOOL32 IsEnabled() const;
106
108 //
109 // style, location, and direction
110 // direction is ignored for "point" and "ambient" lights
111 // location is ignored for "directional" and "ambient" lights
112 void SetStyle(ON::light_style);
113 ON::light_style Style() const;
114
115 const ON_BOOL32 IsPointLight() const;
116 const ON_BOOL32 IsDirectionalLight() const;
117 const ON_BOOL32 IsSpotLight() const;
118 const ON_BOOL32 IsLinearLight() const;
119 const ON_BOOL32 IsRectangularLight() const;
120
121 ON::coordinate_system CoordinateSystem() const; // determined by style
122
123 /*
124 Description:
125 A light's location and direction can be defined with respect
126 to world, camera, or view coordinates. GetLightXform gets
127 the transformation from the light's intrinsic coordinate
128 system to the destination coordinate system specified
129 by dest_cs.
130 Parameters:
131 vp - [in] viewport where light is being used
132 dest_cs - [in] destination coordinate system
133 xform - [out] transformation from the light's intrinsic
134 coordinate system to cs.
135 Returns:
136 true if successful.
137 */
138 ON_BOOL32 GetLightXform(
139 const ON_Viewport& vp,
140 ON::coordinate_system dest_cs,
141 ON_Xform& xform
142 ) const;
143
144 void SetLocation( const ON_3dPoint& );
145 void SetDirection( const ON_3dVector& );
146
147 ON_3dPoint Location() const;
148 ON_3dVector Direction() const;
149 ON_3dVector PerpindicularDirection() const;
150
151 double Intensity() const; // 0.0 = 0% 1.0 = 100%
152 void SetIntensity(double);
153
154 double PowerWatts() const;
155 double PowerLumens() const;
156 double PowerCandela() const;
157
158 void SetPowerWatts( double );
159 void SetPowerLumens( double );
160 void SetPowerCandela( double );
161
163 //
164 // colors
165 //
166 void SetAmbient( ON_Color );
167 void SetDiffuse( ON_Color );
168 void SetSpecular( ON_Color );
169 ON_Color Ambient() const;
170 ON_Color Diffuse() const;
171 ON_Color Specular() const;
172
174 //
175 // attenuation settings (ignored for "directional" and "ambient" lights)
176 // attenuation = 1/(a[0] + d*a[1] + d^2*a[2]) where d = distance to light
177 //
178 void SetAttenuation(double,double,double);
179 void SetAttenuation(const ON_3dVector&);
180 ON_3dVector Attenuation() const;
181 double Attenuation(double) const; // computes 1/(a[0] + d*a[1] + d^2*a[2]) where d = argument
182 // returns 0 if a[0] + d*a[1] + d^2*a[2] <= 0
183
185 //
186 // spot light parameters (ignored for non-spot lights)
187 //
188 // angle = 0 to 90 degrees
189 // exponent = 0 to 128 (0=uniform, 128=high focus)
190 //
191 void SetSpotAngleDegrees( double );
192 double SpotAngleDegrees() const;
193
194 void SetSpotAngleRadians( double );
195 double SpotAngleRadians() const;
196
198 // The spot exponent varies from 0.0 to 128.0 and provides
199 // an exponential interface for controling the focus or
200 // concentration of a spotlight (like the
201 // OpenGL GL_SPOT_EXPONENT parameter). The spot exponent
202 // and hot spot parameters are linked; changing one will
203 // change the other.
204 // A hot spot setting of 0.0 corresponds to a spot exponent of 128.
205 // A hot spot setting of 1.0 corresponds to a spot exponent of 0.0.
206 void SetSpotExponent( double );
207 double SpotExponent() const;
208
210 // The hot spot setting runs from 0.0 to 1.0 and is used to
211 // provides a linear interface for controling the focus or
212 // concentration of a spotlight.
213 // A hot spot setting of 0.0 corresponds to a spot exponent of 128.
214 // A hot spot setting of 1.0 corresponds to a spot exponent of 0.0.
215 void SetHotSpot( double );
216 double HotSpot() const;
217
218 // The spotlight radii are useful for display UI.
219 bool GetSpotLightRadii( double* inner_radius, double* outer_radius ) const;
220
221
223 //
224 // linear and rectangular light parameters
225 // (ignored for non-linear/rectangular lights)
226 //
227 void SetLength( const ON_3dVector& );
228 ON_3dVector Length() const;
229
230 void SetWidth( const ON_3dVector& );
231 ON_3dVector Width() const;
232
234 //
235 // shadow parameters (ignored for non-spot lights)
236 //
237 // shadow intensity 0.0 = does not cast any shadows
238 // 1.0 = casts black shadows
239 //
240 void SetShadowIntensity(double);
241 double ShadowIntensity() const;
242
243
245 //
246 // light index
247 //
248 void SetLightIndex( int );
249 int LightIndex() const;
250
251 // m_light_id is set and maintained by Rhino - if your
252 // plug-in is messing with this field, fix the plugin
253 //__declspec(deprecated) void SetLightUuid( const ON_UUID& );
254
255 // m_light_id is set and maintained by Rhino - if your
256 // plug-in is messing with this field, fix the plugin
257 //__declspec(deprecated) const ON_UUID& LightUuid() const;
258
260 //
261 // light name
262 //
263 void SetLightName( const char* );
264 void SetLightName( const wchar_t* );
265 const ON_wString& LightName() const;
266
267public:
271
272 ON_BOOL32 m_bOn; // true if light is on
273 ON::light_style m_style; // style of light
274
278
279 ON_3dVector m_direction; // ignored for "point" and "ambient" lights
280 ON_3dPoint m_location; // ignored for "directional" and "ambient" lights
281 ON_3dVector m_length; // only for linear and rectangular lights
282 // ends of linear lights are m_location and m_location+m_length
283 ON_3dVector m_width; // only for rectangular lights
284 // corners of rectangular lights are m_location, m_location+m_length,
285 // m_location+m_width, m_location+m_width+m_length
286
287 double m_intensity; // 0.0 = 0%, 1.0 = 100%
288 double m_watts; // ignored if 0
289
290 // spot settings - ignored for non-spot lights
291 double m_spot_angle; // 0.0 to 90.0
292 double m_spot_exponent; // 0.0 to 128.0
293 // 0.0 = uniform
294 // 128.0 = high focus
295 double m_hotspot; // 0.0 to 1.0 (See SetHotSpot() for details)
296
297 // attenuation settings - ignored for "directional" and "ambient" lights
298 ON_3dVector m_attenuation; // each entry >= 0.0
299 // att = 1/(a[0] + d*a[1] + d^2*a[2])
300 // where d = distance to light
301
302 // shawdow casting
303 double m_shadow_intensity; // 0.0 = no shadow casting, 1.0 = full shadow casting
304};
305
306
307
308#endif
@ Transform
Definition RSMetaType.h:67
Definition opennurbs_point.h:403
Definition opennurbs_point.h:931
Definition opennurbs_archive.h:152
Definition opennurbs_color.h:24
Definition opennurbs_geometry.h:36
virtual ON_BOOL32 GetBBox(double *boxmin, double *boxmax, int bGrowBox=false) const =0
virtual int Dimension() const =0
Definition opennurbs_light.h:20
ON::light_style m_style
Definition opennurbs_light.h:273
double m_spot_exponent
Definition opennurbs_light.h:292
ON_3dPoint m_location
Definition opennurbs_light.h:280
ON_Color m_specular
Definition opennurbs_light.h:277
double m_spot_angle
Definition opennurbs_light.h:291
ON_UUID m_light_id
Definition opennurbs_light.h:269
double m_watts
Definition opennurbs_light.h:288
ON_3dVector m_attenuation
Definition opennurbs_light.h:298
ON_3dVector m_direction
Definition opennurbs_light.h:279
double m_hotspot
Definition opennurbs_light.h:295
ON_3dVector m_length
Definition opennurbs_light.h:281
ON_OBJECT_DECLARE(ON_Light)
ON_Color m_ambient
Definition opennurbs_light.h:275
double m_shadow_intensity
Definition opennurbs_light.h:303
double m_intensity
Definition opennurbs_light.h:287
ON_Color m_diffuse
Definition opennurbs_light.h:276
ON_3dVector m_width
Definition opennurbs_light.h:283
ON_BOOL32 m_bOn
Definition opennurbs_light.h:272
ON_wString m_light_name
Definition opennurbs_light.h:270
int m_light_index
Definition opennurbs_light.h:268
virtual void Dump(ON_TextLog &) const
Definition opennurbs_object.cpp:1695
virtual ON_BOOL32 IsValid(ON_TextLog *text_log=NULL) const =0
virtual ON_BOOL32 Read(ON_BinaryArchive &binary_archive)
Definition opennurbs_object.cpp:1734
virtual ON_UUID ModelObjectId() const
Definition opennurbs_object.cpp:1622
virtual ON_BOOL32 Write(ON_BinaryArchive &binary_archive) const
Definition opennurbs_object.cpp:1714
virtual ON::object_type ObjectType() const
Definition opennurbs_object.cpp:1616
Definition opennurbs_textlog.h:20
Definition opennurbs_uuid.h:31
Definition opennurbs_viewport.h:31
Definition opennurbs_xform.h:28
Definition opennurbs_string.h:392
#define ON_CLASS
Definition opennurbs_defines.h:91
#define NULL
Definition opennurbs_system.h:256
int ON_BOOL32
Definition opennurbs_system.h:362