#include <V3d_PositionLight.hxx>
#include <V3d_TypeOfOrientation.hxx>
-class V3d_Viewer;
-class V3d_SpotLight;
-DEFINE_STANDARD_HANDLE(V3d_SpotLight, V3d_PositionLight)
-
//! Creation and modification of a spot.
+//! The attenuation factor F determines the illumination of a surface:
+//! @code
+//! F = 1/(ConstAttenuation() + LinearAttenuation() * Distance)
+//! @endcode
+//! Where Distance is the distance from the source to the surface.
+//! The default values (1.0, 0.0) correspond to a minimum of attenuation.
+//! The concentration factor determines the dispersion of the light on the surface, the default value (1.0) corresponds to a minimum of dispersion.
class V3d_SpotLight : public V3d_PositionLight
{
+ DEFINE_STANDARD_RTTIEXT(V3d_SpotLight, V3d_PositionLight)
public:
- //! Creates a light source of the Spot type in the viewer.
- //! The attenuation factor F which determines
- //! the illumination of a surface depends on the following formula :
- //! F = 1/(theConstAttenuation + theLinearAttenuation*Length)
- //! Length is the distance from the source to the surface.
- //! The default values (1.0,0.0) correspond to a minimum
- //! of attenuation.
- //! The concentration factor determines the dispersion
- //! of the light on the surface, the default value
- //! (1.0) corresponds to a minimum of dispersion.
- //! Warning! raises BadValue from V3d -
- //! If one of the coefficients is not between 0 and 1.
- //! If the lighting angle is <= 0 or > PI.
+ //! Creates a light source of the Spot type in the viewer with default attenuation factors (1.0, 0.0),
+ //! concentration factor 1.0 and spot angle 30 degrees.
+ Standard_EXPORT V3d_SpotLight (const gp_Pnt& thePos,
+ const V3d_TypeOfOrientation theDirection = V3d_XnegYnegZpos,
+ const Quantity_Color& theColor = Quantity_NOC_WHITE);
+
+ //! Creates a light source of the Spot type in the viewer with default attenuation factors (1.0, 0.0),
+ //! concentration factor 1.0 and spot angle 30 degrees.
+ Standard_EXPORT V3d_SpotLight (const gp_Pnt& thePos,
+ const gp_Dir& theDirection,
+ const Quantity_Color& theColor = Quantity_NOC_WHITE);
+
+ //! Defines the direction of the light source
+ //! according to a predefined directional vector.
+ Standard_EXPORT void SetDirection (V3d_TypeOfOrientation theOrientation);
+ using Graphic3d_CLight::SetDirection;
+ using Graphic3d_CLight::Position;
+ using Graphic3d_CLight::SetPosition;
+
+public:
+
+ Standard_DEPRECATED("This constructor is deprecated - the light source should be added to V3d_Viewer explicitly by method V3d_Viewer::AddLight()")
Standard_EXPORT V3d_SpotLight (const Handle(V3d_Viewer)& theViewer,
const Standard_Real theX,
const Standard_Real theY,
const Standard_Real theConcentration = 1.0,
const Standard_Real theAngle = 0.523599);
- //! Creates a light source of the Spot type in the viewer.
//! theXt, theYt, theZt : Coordinate of light source Target.
//! theXp, theYp, theZp : Coordinate of light source Position.
- //! The others parameters describe before.
- //! Warning! raises BadValue from V3d -
- //! If one of the coefficients is not between 0 and 1.
- //! If the lighting angle is <= 0 or > PI.
+ Standard_DEPRECATED("This constructor is deprecated - the light source should be added to V3d_Viewer explicitly by method V3d_Viewer::AddLight()")
Standard_EXPORT V3d_SpotLight (const Handle(V3d_Viewer)& theViewer,
const Standard_Real theXt,
const Standard_Real theYt,
const Standard_Real theConcentration = 1.0,
const Standard_Real theAngle = 0.523599);
- //! Defines the position of the light source.
- virtual void SetPosition (Standard_Real theX,
- Standard_Real theY,
- Standard_Real theZ) Standard_OVERRIDE
- {
- myLight.Position.x() = theX;
- myLight.Position.y() = theY;
- myLight.Position.z() = theZ;
- }
-
- //! Defines the direction of the light source.
- //! If the normal vector is NULL.
- void SetDirection (Standard_Real theVx,
- Standard_Real theVy,
- Standard_Real theVz)
- {
- myLight.Direction.x() = static_cast<Standard_ShortReal> (theVx);
- myLight.Direction.y() = static_cast<Standard_ShortReal> (theVy);
- myLight.Direction.z() = static_cast<Standard_ShortReal> (theVz);
- }
-
- //! Defines the direction of the light source
- //! according to a predefined directional vector.
- Standard_EXPORT void SetDirection (V3d_TypeOfOrientation theOrientation);
-
- //! Defines the coefficients of attenuation.
- //! Warning! raises BadValue from V3d
- //! if one of the coefficient is < 0 or > 1.
- Standard_EXPORT void SetAttenuation (const Standard_Real theConstAttenuation,
- const Standard_Real theLinearAttenuation);
-
- //! Defines the coefficient of concentration.
- //! if the coefficient is < 0 or > 1.
- Standard_EXPORT void SetConcentration (const Standard_Real theConcentration);
-
- //! Defines the spot angle in RADIANS.
- //! Warning: raises BadValue from from V3d
- //! If the angle is <= 0 or > PI.
- Standard_EXPORT void SetAngle (const Standard_Real theAngle);
-
- //! Display the graphic structure of light source
- //! in the chosen view. We have three type of representation
- //! - SIMPLE : Only the light source is displayed.
- //! - PARTIAL : The light source and the light space are
- //! displayed.
- //! - COMPLETE : The light source, the light space and the
- //! radius of light space are displayed.
- //! We can choose the "SAMELAST" as parameter of representation
- //! In this case the graphic structure representation will be
- //! the last displayed.
- Standard_EXPORT void Display (const Handle(V3d_View)& theView,
- const V3d_TypeOfRepresentation theRepresentation) Standard_OVERRIDE;
-
- //! Returns the direction of the light source defined by theVx, theVy, theVz.
- void Direction (Standard_Real& theVx,
- Standard_Real& theVy,
- Standard_Real& theVz) const
- {
- theVx = myLight.Direction.x();
- theVy = myLight.Direction.y();
- theVz = myLight.Direction.z();
- }
-
- //! Returns the position of the light source.
- virtual void Position (Standard_Real& theX,
- Standard_Real& theY,
- Standard_Real& theZ) const Standard_OVERRIDE
- {
- theX = myLight.Position.x();
- theY = myLight.Position.y();
- theZ = myLight.Position.z();
- }
-
- //! Returns the attenuation factors A1,A2 of the light source.
- void Attenuation (Standard_Real& theConstAttentuation,
- Standard_Real& theLinearAttentuation) const
- {
- theConstAttentuation = myLight.ConstAttenuation();
- theLinearAttentuation = myLight.LinearAttenuation();
- }
-
- Standard_Real Concentration() const { return myLight.Concentration(); }
-
- //! Returns the spot angle.
- Standard_Real Angle() const { return myLight.Angle(); }
-
- DEFINE_STANDARD_RTTIEXT(V3d_SpotLight,V3d_PositionLight)
-
-private:
-
- //! Defines the representation of the spot light source.
- Standard_EXPORT void Symbol (const Handle(Graphic3d_Group)& theSymbol,
- const Handle(V3d_View)& theView) const Standard_OVERRIDE;
};
+DEFINE_STANDARD_HANDLE(V3d_SpotLight, V3d_PositionLight)
+
#endif // _V3d_SpotLight_HeaderFile